boltgolt / howdy

🛡️ Windows Hello™ style facial authentication for Linux
MIT License
5.75k stars 299 forks source link

Enable/disable howdy with systemd service fails to execute with "run with sudo" #880

Open spxak1 opened 8 months ago

spxak1 commented 8 months ago

This is not a bug, but a problem enabling or disabling howdy with a systemd service.

Howdy works perfectly fine otherwise. No issue whatsoever.

I have written a little script that enables/disables howdy based on if the lid of my laptop is open (dockd) or closed (undocked).

Here's the little script testlid:

#!/bin/bash
# Basic if statement
state=`cat /proc/acpi/button/lid/LID/state | cut -d ":" -f 2` 
if [ $state == closed ]
then
echo Lid is $state
howdy disable 1
nmcli radio wifi off
systemctl stop tp-auto-kbbl.service
authselect disable-feature with-fingerprint
else
echo Lid is $state
howdy disable 0
nmcli radio wifi on
systemctl start tp-auto-kbbl.service
authselect enable-feature with-fingerprint
fi

This script is called using a systemd service:

[Unit]
Description=Check the status of the lid (open/closed)
After=network.target
After=syslog.target

[Service]
Type=oneshot
User=root
Group=root
ExecStart=/usr/local/bin/testlid

[Install]
WantedBy=multi-user.target

The service starts fine, runs the script and all parts of the scripts work, except for howdy. The line is not executed, and in journalctl I see:

Jan 25 19:26:57 weywot testlid[1829]: Lid is open
Jan 25 19:26:58 weywot testlid[1836]: Please run this command as root:
Jan 25 19:26:58 weywot testlid[1836]:         sudo howdy disable 0

Running the script from a terminal (with sudo) works fine. However starting the service from the terminal (sudo systemctl start checklid.service), has the same result, howdy asks for sudo```.

So when run from within a systemd service howdy won't e executed as root. No idea why.

I'm stuck as as far as I understand, howdy, like all other commands in the script are executed as root.

What am I missing?

Thank you very much for any help, and for the work you've put into this project.

Edit: running the script from cron (root's cron) has the same effect. Everything else runs, howdy asks for sudo.


I've searched for similar issues already, and my issue has not been reported yet.

Linux distribution (if applicable): Fedora 39

Howdy version (sudo howdy version): Howdy 2.6.1