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

Consider using XDG_STATE_HOME instead of cache folder for local config #9738

Closed
haarp opened this issue Aug 14, 2023 · 6 comments · Fixed by #9755
Closed

Consider using XDG_STATE_HOME instead of cache folder for local config #9738

haarp opened this issue Aug 14, 2023 · 6 comments · Fixed by #9755

Comments

@haarp
Copy link

haarp commented Aug 14, 2023

Overview

Transient data such as last active database, GUI size/settings are stored in ~/.cache/keepassxc/kepassxc.ini. This means this data is prone to being deleted (as cache directories might be cleared during logout/reboot or reside on volatile storage such as ramdisks to begin with. These settings are not caches, they should go into ~/.local/share/ or ~/.local/state/ (or rather XDG_DATA_HOME) instead.

Steps to Reproduce

  1. Start KXC
  2. Observe file created under ~/.cache/

Expected Behavior

Use ~/.local instead

Actual Behavior

Uses ~/.cache

Context

XDG_DATA_HOME is part of the Freedesktop basedir spec.

KeePassXC - Version 2.7.5
Revision: 9d0537b

Qt 5.15.10
Debugging mode is disabled.

Operating system: Gentoo Linux
CPU architecture: x86_64
Kernel: linux 6.1.41-gentoo-HH

Enabled extensions:

  • Browser Integration
  • SSH Agent
  • Secret Service Integration

Cryptographic libraries:

  • Botan 3.0.0

Operating System: Linux
Desktop Env: XFCE
Windowing System: X11

Thanks!

@haarp haarp added the bug label Aug 14, 2023
@phoerious
Copy link
Member

phoerious commented Aug 14, 2023

.local/share is explicitly not the location we want to store these things in. XDG_STATE_HOME is new and might be worth considering. At the time we implemented this, .local/cache was the closest to a semi-persistent location. XDG_CACHE_HOME is not a temporary folder, so IMHO any distribution that deletes it automatically on reboot or puts the contents in a tmpfs does it wrong.

@haarp
Copy link
Author

haarp commented Aug 14, 2023

You're right, XDG_CACHE_HOME is not explicitely described as being volatile, but it is considered "non-essential". There shouldn't be any detrimental effects to deleting it, other than increased delays during app startup and runtime ;) Doing so requires me to e.g. setup my KXC window again tho, which shouldn't be the case.

XDG_STATE_HOME is probably the better place for it tho.

@droidmonkey droidmonkey changed the title Transient data stored in cache directory Consider using XDG_STATE_HOME instead of cache folder for local config Aug 14, 2023
@jNullj
Copy link
Contributor

jNullj commented Aug 16, 2023

I gave the spec a quick look, i think XDG_STATE_HOME is a better fit then XDG_CACHE_HOME, if you read in the spec it seems to be similar to what you described:

The $XDG_STATE_HOME contains state data that should persist between (application) restarts, but that is not important or portable enough to the user that it should be stored in $XDG_DATA_HOME. It may contain:

actions history (logs, history, recently used files, …)

current state of the application that can be reused on a restart (view, layout, open files, undo history, …)

Should we consider XDG_CONFIG_HOME? as this looks much like a config file.

@haarp
Copy link
Author

haarp commented Aug 16, 2023

Should we consider XDG_CONFIG_HOME? as this looks much like a config file.

There is a separate keepassxc.ini already in XDG_CONFIG_HOME. I assumed there was a reason for this separation.

@phoerious
Copy link
Member

phoerious commented Aug 16, 2023

The INI under ~/.local/cache contains non-essential machine-specific state information, such as the window geometry. On Windows, this is under %LocalAppData%. Linux, so far, didn't have a location for it, but now apparently does.

jNullj added a commit to jNullj/keepassxc-fetures-n-fixes that referenced this issue Aug 18, 2023
Keepassxc saves application state at XDG_CACHE_HOME which can be cleared on some systems periodicly.
This is not desireable as app state like window size is not consistent when openning the app.
To avoid this this commit is switching the path to XDG_STATE_HOME which is more fitting based on the freedesktop basedir spec (https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html), this will allow to prevent state file deletion as well.

Solves keepassxreboot#9738
phoerious pushed a commit that referenced this issue Oct 23, 2023
Keepassxc saves application state at XDG_CACHE_HOME which can be cleared on some systems periodicly.
This is not desireable as app state like window size is not consistent when openning the app.
To avoid this this commit is switching the path to XDG_STATE_HOME which is more fitting based on the freedesktop basedir spec (https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html), this will allow to prevent state file deletion as well.

Resolves #9738
@haarp
Copy link
Author

haarp commented Oct 23, 2023

Excellent, thanks a lot!

pull bot pushed a commit to tigerwill90/keepassxc that referenced this issue Oct 23, 2023
Keepassxc saves application state at XDG_CACHE_HOME which can be cleared on some systems periodicly.
This is not desireable as app state like window size is not consistent when openning the app.
To avoid this this commit is switching the path to XDG_STATE_HOME which is more fitting based on the freedesktop basedir spec (https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html), this will allow to prevent state file deletion as well.

Resolves keepassxreboot#9738
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.

4 participants