I have a small Linux device that may choose to sync it's time with a handheld device when said device connects to it. My program's been running as root, and I've just been using date --set commands. But I'm trying to move said program to a less privileged user. Since I'm using systemd now, I think I should be using timedatectl to set the time rather than date directly. I've proven to myself how I can do this root. But I don't know how to drive it from non-root.I could use a specific sudo item, but I was hoping to not have my program running sudo. If that's the only way though, I know how to do that. If that's the only way, then just answer that :)I hoped that if I made my user a member of the systemd-timesync group, I might be able to, but with or without said group, I get the following error:> timedatectl set-time 2017-3-2 01:40:30Failed to set time: The name org.freedesktop.PolicyKit1 was not provided by any .service filesI have no idea what that means, or how to fix it, or if I should, or if it's possible.
Allow non-root user to use timedatectl
debian;permissions;systemd;date
I would use sudo. You express reluctance to that approach, but you would only be granting your user root access to run the single timedatectl command.This ought be able to be solved with PolicyKit as well, but it would effectively have the same result of allowing a user to run a single command as root. So the risks would be similar-- and you already understand how to solve the problem with sudo.