Keepassxc: KeePassXC cannot save files correctly to GVFS mount point

Created on 13 Jun 2020  路  24Comments  路  Source: keepassxreboot/keepassxc

Overview

Ubuntu 20.04
KeePassXC umounts Google Drive folder while trying to save converted database file on it.
Then opens read-only the database file stored on Google Drive folder.

I'm trying to move to keepassxc from keepass 1
My database is stored on Google Drive. I access it using the Ubuntu standard tool which utilizes Nautilus file manager. Thus Google Drive is seen as a mounted network disk.

Steps to Reproduce

  1. Database file produced by Keepasdroid on Google Drive
  2. Google Drive mounted by Ubuntu 20.04 Nautilus file manager as a network disk
  3. KeePassXC opens database file as a version 1 file to import
  4. When saving database on the same Google Drive folder the network disk is unmounted
  5. The database file remains with temporary extension and is unusable
  6. Re-mount Google Drive
  7. Open database file, convert and save it on a local folder
  8. Move the .kdbx file to the Google Drive folder
  9. Open it, do some mods and close
  10. Re-open it, the mods are lost.

Expected Behavior

Having the database file stored on a local folder or on a mounted network disk should not be different for KeePassXC

Actual Behavior

The Google Drive network disk is not properly managed

Context

KeePassXC - Version 2.4.3
Revision: 5d6ef0c

Operating System: Linux Ubuntu 20.04
Desktop Env: Gnome
Windowing System: X11

PRE-RELEASE BUG Linux Ubuntu Unity

All 24 comments

We are not mounting or unmounting anything.

Well maybe Nautilus unmounts Google Drive as a result of improper action by keepassxc

I realized version 2.4.3 from the ubuntu repository is not the latest. I installed version 2.5.4 from ppa:phoerious
The behaviour remains exactly the same :-(

The opening of a file as read only is fixed in 2.6.0. Try our beta build.

Well now the database file is saved on google drive but the original file name is lost. It is stored with something that looks like a temporary name: 1BdtRu8yCTCMjJW1O4knX74O0L0mUMeek

Ummm that's unique!

I tried that:
1- open the "strange name" file
2- save database as "new file name" on a local folder
3- open "new file name"
4- save database as same "new file name" on google drive
Saving fails and google drive is unmounted :-(

Do you have safe file saves enabled? We don't do much outside of standard Qt file calls. Does any other app have trouble with the Google drive mount?

With "safe file saves" enabled I get the unmount problem when saving a new file. Without it I get files saved with the strange temporary name.
I don't have troubles with other apps. I.e. I noticed that when libreoffice edits a google drive file a temporary file name is shown on its window top (that does not happen with a local file). Nonetheless then the file is saved correctly with its name on google drive.

So I just tried replicating this on Ubuntu 20.04, using standard Google account features in Gnome. When I tried saving a database to the GVFS mount, GVFS crashed. This is probably why you are seeing it unmount/mount again. It crashed with a null pointer error. This is clearly a bug in GVFS when using QSaveFile type operations. QSaveFile works by writing to a temporary file next to the real file, deleting the real file, then renaming the temporary file as the real file name.

Here are the results of my testing:

Safe Saves ENABLED:

  • Temporary file is created and written to in the GVFS folder (Passwords.kdbx.XXXXX)
  • GVFS crashes
  • Temporary file remains indicating that QSaveFile::commit() could not complete
  • Edits to existing files fail to save

Safe Saves DISABLED:

  • Writing a new database to the GVFS folder worked flawlessly
  • Saving an existing database file fails with "Cannot find file or folder"
  • Re-opening the file and editing it works but the really long file name occurs

Thank you very much droidmonkey! You pointed very well the problem. But I wouldn't be so sure about a bug in GVFS. Just because other apps that open and save files to GVFS mount point don't have the same problem. You can try and see.

Under no circumstances should it be possible to crash GVFS. That is a bug.

Well, I see your point, I will try to open a bug under gitlab.gnome.org
But the "saving an existing database" problems still stands

The problem is that Qt receives the file name as something like /run/user/1000/gvfs/google-drive:host=.../1BdtRu8yCTCMjJW1O4knX74O0L0mUMeek instead of google-drive://passwords.kdbx. So when the database is saved that is the file path that is used. Which is why that crazy long name is used, btw.

That crazy long name is just the temporary file name. KeePassXC should not use that name but save the file with its original file name. I guess for example Libreoffice does it that way since it shows the crazy long name while editing but uses the original name when saving. You can test and see

I have no idea how to get the original file name, it does not appear when choosing the file at all. Regardless, that shouldn't be our responsibility, we are technically saving to the temporary file and GVFS needs to do the translation for us. Perhaps because of the manner in which we save files it is getting confused. We do not save directly to the existing file, we write a temporary file, delete the original, and move a new file to where the original file was.

Can't you try to avoid deleting the original file? And close by saving the temporary file onto the original?

It looks like I have to give up using KeePassXC because of its incompatibility with Google Drive on Linux :-(

(Edited for formatting)
Hello,

I am having exactly the same issue as blasco51, using what appears to be the same setup (details below) of Ubuntu 20.04 and KPXC 2.6.0.

Using 2.4.3 under Ubuntu 19.04, this was never a problem, and safe saving worked, preserving the filename. Is the above thread an indication that this is purely a GVFS issue in Ubuntu 20.04?

Steps to reproduce:

  1. Open a password database on Google Drive
  2. Make any changes and save the database
  3. Fails to save
  4. Disable safe saves
  5. Save successfully, but with new random filename

Expected Behavior

Saving a database should preserve the original filename.

Actual Behavior

The filename is changed after every save.

Context

Fresh installation of Ubuntu 20.04
KeePassXC 2.6.0 installed from https://launchpad.net/~phoerious/+archive/ubuntu/keepassxc (repo was added to my sources to keep updating)
Syncing to Google Drive via native Ubuntu Online Accounts service, GVFS via Nautilus file manager

[NOTE]:

KeePassXC - Version 2.6.0
Revision: 0765954

Qt 5.12.8
Debugging mode is disabled.

Operating system: Ubuntu 20.04 LTS
CPU architecture: x86_64
Kernel: linux 5.4.0-40-generic

Enabled extensions:

  • Auto-Type
  • Browser Integration
  • SSH Agent
  • KeeShare (signed and unsigned sharing)
  • YubiKey
  • Secret Service Integration

Cryptographic libraries:
libgcrypt 1.8.5

[NOTE]:

Operating System: Linux/Ubuntu 20.04
Desktop Env: Gnome
Windowing System: Xorg

I'm surprised this worked for you at all in 2.4.3 because it should have opened the database read only.

This also is a huge problem for me and how I accidentally lost my main passwords file (now I use a crontab and "drive" for linux to pull them hourly). This is the only app I this issue with. Gnome + System 76 Pop!_OS.

For now, I am using grive instead (there are others of course at https://www.ubuntupit.com/top-12-best-google-drive-linux-client-software/) to sync files. Hope this gets fixed so I can use the built-in gvfs support in Gnome 3.

I'm surprised this worked for you at all in 2.4.3 because it should have opened the database read only.

I'm very sorry, my mistake - I think it might have been 2.4.1 that saved correctly. I neglected to make a note of the version I was using more successfully before I upgraded my OS and then installed 2.6.0.

Just adding +1, I also encounter this problem.

Was this page helpful?
0 / 5 - 0 ratings