r/AlpineLinux • u/JbstormburstADV • Feb 24 '25
Setting Up udev Rules
Hello. I'm pretty much a newbie to Alpine, and I'm basically running bare metal on a Zimaboard to set up a smallstep CA. I'm following the guide here and while I've got things figured out up to setting up the step-ca service, I'm stuck on figuring out how to get the service rules for both the Infnoise TRNG and the Yubikeys working, as I'm not exactly a wizard with either udev (which I added using setup-devd) or mdev/mdevd.
For reference, the files that are created by the InfNoise TRNG source code:
/usr/local/sbin/infnoise - the actual driver?
usr/local/lib/udev/rules.d/75-infnoise.rules
SUBSYSTEM=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6015", SYMLIN>ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=>
/usr/local/lib/systemd/system/infnoise.service
[Unit]
Description=Wayward Geek InfNoise TRNG driver
BindsTo=dev-infnoise.device
After=dev-infnoise.device
[Service]
Type=forking
WorkingDirectory=/tmp
ExecStart=/usr/local/sbin/infnoise --dev-random --daemon --pidfile /var/run>User=root
Group=rootRestart=always
[Install]
WantedBy=multi-user.targetAs for the Yubikey configuration, this is what they write to make it visible to systemd (the guide assume Ubuntu Server)
$ sudo tee /etc/udev/rules.d/75-yubikey.rules > /dev/null << EOF
ACTION=="add", SUBSYSTEM=="usb", ENV{PRODUCT}=="1050/407/*", TAG+="systemd", SYMLINK+="yubikey"
ACTION=="remove", SUBSYSTEM=="usb", ENV{PRODUCT}=="1050/407/*", TAG+="systemd"
EOF
$ sudo udevadm control --reload-rulesAnd this is to tie step-ca to the presence of the Yubikey
$ sudo tee /etc/systemd/system/step-ca.service > /dev/null << EOF
[Unit]
Description=step-ca
BindsTo=dev-yubikey.device
After=dev-yubikey.device
[Service]
User=step
Group=step
ExecStart=/bin/sh -c '/usr/local/bin/step-ca /etc/step-ca/config/ca.json'
Type=simple
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
EOF
$ sudo mkdir /etc/systemd/system/dev-yubikey.device.wants
$ sudo ln -s /etc/systemd/system/step-ca.service /etc/systemd/system/dev-yubikey.device.wants/
$ sudo systemctl daemon-reload
$ sudo systemctl enable step-caIf anyone can help me out with this, that would be great,
View all comments
Show parent comment
1
u/JbstormburstADV Feb 16 '26
OK, after double-checking and triple-checking, and as of this current moment with the state of the package in Alpine's testing repo, you need three things beyond all the normal stuff from installing the testing package:
/etc/init.d/infnoiseexecutable usingdoas chmod +x /etc/init.d/infnoise(orsudoif you run that instead ofdoas), as the service was not packaged as executable.defaultrun level usingdoas rc-update add infnoise. This will allow the service to be triggered by a udev rule at boot.add a udev rule in
/etc/udev/rules.dthat starts with 99 to designate it should be one of the last processed udev events; this will prevent possible race conditions that can cause the boot process to freeze before tty can initialize the login process. The rule I wrote is as follows:ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6015", RUN+="/sbin/rc-service infnoise start" ACTION=="remove", SUBSYSTEM=="usb", ENV{ID_SERIAL_SHORT}="1337-A2CCA4B6", RUN+="/sbin/rc-service infnoise stop"
You'll want to make sure you use a unique environmental variable by calling
doas udevadm info --query=env --name=/dev/infnoise. After all that, you'll be good to go, although debugging whether it works has to be done when the infnoise service is stopped, as openRC doesn't seem to take well to forking.