I am using Raspbian Buster on an Raspberry Pi 4. I would like to give permissions to a non-root user to be able to set the time with /bin/date -s
. The user is going to be used to run a python script using a systemd service. I have tried following the instructions here and here without success. Those posts were not for Raspbian but I checked and it seems Debian uses the same thing.
One thing I tried while troubleshooting was to set pam_cap.so to required instead of optional, but then when running the su
command it says su: Module is unknown
, which seems to indicate that it can't find pam_cap.so at all... I confirmed I have libcap2
and libcap2-bin
installed though so I am not sure what I am missing... EDIT: I did a search for pam_cap.so on the system and couldn't find it, so that part makes sense I suppose... Does anyone know how to install it?
The specific steps I have taken are:
sudo useradd tasks_user
sudo sed '/pam_rootok.so/i auth optional pam_cap.so' /etc/pam.d/su -i
sudo setcap CAP_SYS_TIME+ei /bin/date
sudo su - tasks_user
capsh --print
I've tried restarting at every point in the process but it doesn't help. I confirmed that running sudo setcap CAP_SYS_TIME+ep /bin/date
works, but this gives access to all users, which is not ideal...