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

Lock database on SessionLock does not work with i3lock on arch linux #3339

Closed
kiprasmel opened this issue Jun 29, 2019 · 9 comments
Closed
Labels

Comments

@kiprasmel
Copy link

kiprasmel commented Jun 29, 2019

Expected Behavior

I'd expect the database to lock when my screen gets locked.

Current Behavior

The database is not locked on screen lock and after unlocking the screen - the database is still unlocked.

Possible Solution

Lock the database on lock screen (#545)

Steps to Reproduce

  1. Use arch linux
  2. Use i3 (i3gaps)
  3. Unlock your database
  4. Use i3lock to lock your screen
$ i3lock
  1. Unlock your screen
  2. Database is still unlocked.

Context

I'm running on arch linux, using i3 (i3gaps) as my window manager, and i3lock as my screen locker.
I expect my database to get locked once I lock my screen, but the database does NOT get locked.

Debug Info

KeePassXC - Version 2.4.3
Revision: 5d6ef0c

Qt 5.12.4
Debugging mode is disabled.

Operating system: Arch Linux
CPU architecture: x86_64
Kernel: linux 5.1.15-arch1-1-ARCH

Enabled extensions:
- Auto-Type
- Browser Integration
- SSH Agent
- KeeShare (signed and unsigned sharing)
- YubiKey

Cryptographic libraries:
 libgcrypt 1.8.4

Or is it expected behavior that on screen lock the database locks, but on screen unlock it unlocks itself?


Edit: I've created an issue for i3lock.

@droidmonkey
Copy link
Member

I just looked through the i3 documentation and i3lock source code and couldn't find anything regarding an event notification that is sent out when the screen is locked. I do not think this is even possible. Please bring this up with the i3 developers.

@chron-isch
Copy link

sway and swaylock have the same problem, but even when using 'loginctl lock-session' (which uses DBUS as far as I know) KeepassXC doesn't lock it's database.

@relaxeaza
Copy link

LightDM lock functionality dm-tool lock is not detected also.

@DuBistKomisch
Copy link

DuBistKomisch commented Jan 18, 2020

In the meantime, you can use the KeePassXC D-Bus interface to lock the database as explained here: #2764 (comment).

Looking at ScreenLockListenerDBus, you should be able to lock the session in logind and have KeePassXC notice, but no matter how I do it the database doesn't lock (loginctl lock-session, various qdbus commands to org.freedesktop.login1).

Maybe the real problem is that we're not running a display manager, just startx? I know teamviewer has issues in similar cases for example.

@afflux
Copy link
Contributor

afflux commented Jan 21, 2020

I see this dbus signal when locking my session using xss-lock:

sender=:1.29 -> destination=(null destination) serial=211 path=/org/freedesktop/login1/session/_33; interface=org.freedesktop.login1.Session; member=Lock

ScreenLockListenerDBus builds the listening path using /org/freedesktop/login1/session/$XDG_SESSION_ID, but my XDG_SESSION_ID is 3, while the signal appears on a path ending with /_33

@afflux
Copy link
Contributor

afflux commented Jan 21, 2020

Turns out, there are ways to get the current session object:

$ gdbus  call --system --dest org.freedesktop.login1 -o /org/freedesktop/login1 -m org.freedesktop.login1.Manager.GetSession "$XDG_SESSION_ID"
(objectpath '/org/freedesktop/login1/session/_33',)

(introduced in systemd/systemd@bef422a, systemd v30)

note that you could also use the self session /org/freedesktop/login1/session/self that will always resolve to the session of the caller, but I couldn't get the signal connection to work here, so I'm not sure if that helps. It was introduced in systemd/systemd@927b164, systemd v209.

@DuBistKomisch
Copy link

DuBistKomisch commented Jan 27, 2020

switching from raw i3lock ... to xss-lock -- i3lock -n ... is working for me with #4214 👍 thanks @afflux

@mkre
Copy link

mkre commented Mar 11, 2022

For sway(lock), the following setting in my sway config is working fine for me:

set $lock qdbus org.keepassxc.KeePassXC.MainWindow /keepassxc org.keepassxc.MainWindow.lockAllDatabases && swaylock -f -c 000000

@RensOliemans
Copy link

RensOliemans commented Dec 16, 2022

For sway(lock), the following setting in my sway config is working fine for me:

set $lock qdbus org.keepassxc.KeePassXC.MainWindow /keepassxc org.keepassxc.MainWindow.lockAllDatabases && swaylock -f -c 000000

This works nearly perfectly, it seems the methodName changed from org.keepassxc.MainWindow.lockAllDatabases to org.keepassxc.KeePassXC.MainWindow.lockAllDatabases. Concretely, the following command should lock your database and start swaylock:

 qdbus org.keepassxc.KeePassXC.MainWindow /keepassxc org.keepassxc.KeePassXC.MainWindow.lockAllDatabases && swaylock -f -c 000000

Edit - loginctl

loginctl lock-session is a much cleaner way to lock/close KeePassXC windows and other windows. The setting above has to be extended for each application that we want to close. Additionally, it fails to lock when KeePassXC is not running!

For completeness:

loginctl lock-session && swaylock -f -c 000000

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

No branches or pull requests

8 participants