Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local config data is cleared when ~/.cache mounted on tempfs #5313

Closed
gripped opened this issue Aug 22, 2020 · 10 comments
Closed

Local config data is cleared when ~/.cache mounted on tempfs #5313

gripped opened this issue Aug 22, 2020 · 10 comments
Assignees
Milestone

Comments

@gripped
Copy link

gripped commented Aug 22, 2020

Overview

Since the big update (new gui) keepassXC very very rarely remembers the last database no matter whether I shutdown the desktop cleanly or with a three or four finger salute (KDE only ?). Before the update it remembered fine. It is enabled in the options. Remember and open on startup

As I only ever use one database my workaround has been , just now, to change it's user .desktop file to explicitly open the database

Steps to Reproduce

  1. Tell keepassXC to remember last database and open on start up.
  2. Restart the computer or X by any method
  3. Start KeepassXC

Expected Behavior

Ask me for the password for the last used database instead of having to navigate to it's location almost every time.

Actual Behavior

Have to navigate to it's location almost every time.

Context

It occasionally works but I fail to see a pattern. I've tried making sure KeepassXC is closed cleanly but that doesn't make a difference AFAICT.

KeePassXC - Version 2.6.1
Revision: 9a35bba

Qt 5.15.0
Debugging mode is disabled.

Operating system: Gentoo/Linux
CPU architecture: x86_64
Kernel: linux 5.8.3-gentoo-x86_64

Enabled extensions:

  • SSH Agent
  • Secret Service Integration

Cryptographic libraries:
libgcrypt 1.8.6

Operating System: Linux/
Desktop Env: KDE
Windowing System: X11

@gripped gripped added the bug label Aug 22, 2020
@droidmonkey
Copy link
Member

You are mounting ~/.cache to a tmpfs?

@gripped
Copy link
Author

gripped commented Aug 22, 2020

Well that explains it then. Yes I do. Seems like an odd place to store settings. Or at least a setting.
I have an aversion to having these cache files hanging about potentially forever.

I have my workaround so if you're of the belief that .cache is the place to store settings (it isn't) please feel free to close :)

Edited to add: Cool program. Thanks.

@droidmonkey
Copy link
Member

You are not alone, there are a couple others who have mounted it to tmpfs. But really you are totally defeating the purpose of cache which is to prevent recreation of compiled/processed data all the time. You are also unnecessarily taking up space in your RAM (not a big concern these days). Either way, its arguable that its the right/wrong place to store this but XDG defines it as:

$XDG_CACHE_HOME defines the base directory relative to which user specific non-essential data files should be stored. If $XDG_CACHE_HOME is either not set or empty, a default equal to $HOME/.cache should be used.

There is no "local" config storage option in Linux. ~/.local/share is for "data" and so is ~/.cache. There really should be a ~/.local/config standard directory.

@gripped
Copy link
Author

gripped commented Aug 22, 2020

My own opinion is that it is a setting. Not data. But then everything is data to one degree or another.
And it IS essential. That is if remembering the last database is going to work as intended for those of us who prefer their local cache to be regularly wiped.

My cache isn't recreated all the time, just at reboots. It's a trade off I'm happy to make and with 32gb of ram and a 8 core recent CPU the impact is almost non existent.

I think ~/.config/keepassxc/keepassxc.ini is where it should be stored. I guess it must have resided there prior to the update ? I've just had a look through my .cache and nothing else seems to be storing settings like last used and windows states etc.

However if you disagree I fully respect that.

I must have been wrong about keepassXC forgetting when I'd only restarted X. It's not something I've been focusing on. Just a tiny annoyance.

A bit of effort but maybe you could check if ~/.cache is mounted on a tmpfs and if so warn the user that remembering databases is not going to work.
However, once again, thanks.

@gripped
Copy link
Author

gripped commented Aug 22, 2020

Now I know what's going on, a better workaround for me and others affected possibly ?
mkdir ~/.cache/keepassxc
ln -s ~/.config/keepassxc/keepassxclocal.ini ~/.cache/keepassxc/keepassxc.ini

at the top of my .xinitrc. Now I keep my window states as well. :)
Anyone using a window manager will probably have to put this somewhere else ?
I'm old school. startx !

@droidmonkey droidmonkey changed the title keepassXC fails to open the last used database when started Local config data is cleared when ~/.cache mounted on tempfs Aug 22, 2020
@droidmonkey droidmonkey added this to the v2.6.2 milestone Aug 22, 2020
@droidmonkey droidmonkey self-assigned this Aug 22, 2020
@droidmonkey
Copy link
Member

We should just store the local config in ~/.local/share/keepassxc

droidmonkey added a commit that referenced this issue Sep 20, 2020
* Fix #5313, allow specifying local config path using environment variable and command line flag
* Add command line flag `--localconfig <path>` to specify a file path to use for the local configuration settings.
* Add environment variable support to set config files paths: `KPXC_CONFIG` and `KPXC_CONFIG_LOCAL` to override default locations.
* Reorder startup sequence to load specified config files earlier to allow for theme settings and other early options to be picked up.
* Removed old command line option `--pw`, no longer used.

* Attempt a fix of application not closing when last window is gone. Only set `QApplication::setQuitOnLastWindowClosed(true)` when tray icon is enabled instead of always.
droidmonkey added a commit that referenced this issue Sep 20, 2020
* Fix #5313, allow specifying local config path using environment variable and command line flag
* Add command line flag `--localconfig <path>` to specify a file path to use for the local configuration settings.
* Add environment variable support to set config files paths: `KPXC_CONFIG` and `KPXC_CONFIG_LOCAL` to override default locations.
* Reorder startup sequence to load specified config files earlier to allow for theme settings and other early options to be picked up.
* Removed old command line option `--pw`, no longer used.

* Attempt a fix of application not closing when last window is gone. Only set `QApplication::setQuitOnLastWindowClosed(true)` when tray icon is enabled instead of always.
@gitvalds
Copy link

gitvalds commented Jan 20, 2022

On Fedora 35 /tmp/ is a tmpfs.

The following procedure works for me on Fedora 35 with KDE, for replacing:
${HOME}/.cache
with:
/tmp/kde_cache/
but preserving the settings of keepassxc.

You can copy paste after replacing all the occurrencies of:
<user>
with the name of your user.

This procedure is based on the suggestions made by:
#4911 (comment)

Thank you so much to everybody who contributes to this amazing software 👍


As the user <user>, run the following commands:

mv /home/<user>/.cache /home/<user>/.cache.renamed
mkdir /tmp/kde_cache/
ln -s /tmp/kde_cache/ /home/<user>/.cache
mkdir /home/<user>/.local/share/keepassxc
cp /home/<user>/.cache.renamed/keepassxc/keepassxc.ini /home/<user>/.local/share/keepassxc/keepassxc.ini

As the user root, run the following commands:

vim /etc/profile.d/my.sh
### this block of lines is the whole content of the file;
### it does not need to be executable;
###
### to use tmpfs for /home/<user>/.cache/
if [[ ! -e /tmp/kde_cache/ ]]; then
  mkdir /tmp/kde_cache/
  ### the following two commands are because keepassxc currently stores settings under
  ###   /home/<user>/.cache/
  ### and we want to preserve them between reboots;
  mkdir /tmp/kde_cache/keepassxc/
  ln -s /home/<user>/.local/share/keepassxc/keepassxc.ini /tmp/kde_cache/keepassxc/keepassxc.ini
  chown --recursive <user>:<user> /tmp/kde_cache/
  chmod --recursive u=rwX,go= /tmp/kde_cache/
fi

systemctl reboot

@droidmonkey
Copy link
Member

With keepassxc 2.6.0 and above you can just add an environment variable or command line flag to point to a different folder for the local config.

https://keepassxc.org/docs/KeePassXC_UserGuide.html#_command_line_options

--localconfig or KPXC_CONFIG_LOCAL

@gitvalds
Copy link

Hi @droidmonkey.
That is great :)
I tested both options and they both work on Fedora 35.
Most certanly the man pages on Fedora are not maintained by you but, just for your information, the "--localconfig" option is not mentioned in "man keepassxc".
The "--config" option is, but it does not achieve this result.
Thank you very much.

@droidmonkey
Copy link
Member

Oops forgot to put that in the man page, but it is in the user guide 😇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants