You are not logged in.

#1 2018-02-04 17:22:16

JohnnyTheSmith
Member
Registered: 2018-02-04
Posts: 6

[solved] UDEV not triggering my rule

Hi there,

I am new to this forum and to arch, so hello all. I have a weird thing with my udev rule and my yubikey. I am trying to get my screen locked, when removing my yubikey. But it doesn't work. So I am using i3-gaps with gnome-flashback, betterlockscreen as a script for pretty i3lock-color. And I am using my Yubikey with pam.d. I have GDM as loginmanager.

So that's about it. You can find debugging logs here: https://gist.github.com/patrickhener/2a … 305e20dce6

As you can see the udevadm test shows, that the script should be running when removing the yubikey. When manually running the script from terminal it actually locks the screen. But it doesn't when removing the yubikey. So the main question is, why? And how can I narrow down the error?
Hope you guys can help me.

Thanks in advance,
Patrick

Last edited by JohnnyTheSmith (2018-02-05 12:56:38)

Offline

#2 2018-02-05 06:35:15

ooo
Member
Registered: 2013-04-10
Posts: 1,638

Re: [solved] UDEV not triggering my rule

Welcome to forums.

Did you check systemd journal for errors? I think any output from udev running the ykgone script should appear there.

Did you make sure the script works when run manually as root, not as regular user?

Offline

#3 2018-02-05 08:11:03

JohnnyTheSmith
Member
Registered: 2018-02-04
Posts: 6

Re: [solved] UDEV not triggering my rule

I will check those two thanks. I will get back to you when I have more details.

Offline

#4 2018-02-05 08:38:09

JohnnyTheSmith
Member
Registered: 2018-02-04
Posts: 6

Re: [solved] UDEV not triggering my rule

Journal says the following when removing the Yubikey:

Feb 05 09:34:37 hummingbird kernel: usb 1-1: USB disconnect, device number 9
Feb 05 09:34:37 hummingbird /usr/lib/gdm/gdm-x-session[1044]: (II) config/udev: removing device Yubico Yubikey 4 OTP+U2F+CCID
Feb 05 09:34:37 hummingbird /usr/lib/gdm/gdm-x-session[1044]: (**) Option "fd" "83"
Feb 05 09:34:37 hummingbird /usr/lib/gdm/gdm-x-session[1044]: (II) event24 - (II) Yubico Yubikey 4 OTP+U2F+CCID: (II) device removed
Feb 05 09:34:37 hummingbird /usr/lib/gdm/gdm-x-session[1044]: (II) UnloadModule: "libinput"
Feb 05 09:34:37 hummingbird /usr/lib/gdm/gdm-x-session[1044]: (II) systemd-logind: releasing fd for 13:88
Feb 05 09:34:37 hummingbird upowerd[847]: unhandled action 'unbind' on /sys/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/0003:1050:0407.0013
Feb 05 09:34:37 hummingbird upowerd[847]: unhandled action 'unbind' on /sys/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0
Feb 05 09:34:37 hummingbird upowerd[847]: unhandled action 'unbind' on /sys/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.1/0003:1050:0407.0006
Feb 05 09:34:37 hummingbird colord[993]: /usr/lib/colord-sane: error while loading shared libraries: libsane.so.1: cannot open shared object file: No such file or directory
Feb 05 09:34:37 hummingbird upowerd[847]: unhandled action 'unbind' on /sys/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.1
Feb 05 09:34:37 hummingbird upowerd[847]: unhandled action 'unbind' on /sys/devices/pci0000:00/0000:00:14.0/usb1/1-1
Feb 05 09:34:37 hummingbird colord[993]: /usr/lib/colord-sane: error while loading shared libraries: libsane.so.1: cannot open shared object file: No such file or directory
Feb 05 09:34:37 hummingbird colord[993]: /usr/lib/colord-sane: error while loading shared libraries: libsane.so.1: cannot open shared object file: No such file or directory

Script works as desired, when run in root bash.

[root@hummingbird bin]# ./ykgone 
P:  Vendor=1050 ProdID=0407 Rev=04.37
Yubikey present
[root@hummingbird bin]# ./ykgone 
Yubikey not present, locking

Session is beeing locked the second time and can be unlocked with user password and yubikey present. So xautolock locks as my user.

Offline

#5 2018-02-05 12:56:02

JohnnyTheSmith
Member
Registered: 2018-02-04
Posts: 6

Re: [solved] UDEV not triggering my rule

I figured it out myself. UDEV rule was not matching at all. I don't know why exactly but worked around it like so:

SUBSYSTEM=="usb", ACTION=="remove", ENV{DEVTYPE}=="usb_device", RUN+="/home/username/bin/ykgone"

Every USB device will now match the rule when removed.
In the script I then check for the Vendor name of the removed device. If it matches Yubico then the screen will lock, otherwise nothing is happening.
That works perfectly for me.

Offline

Board footer

Powered by FluxBB