0

In Armbian, I've been able to make the GPIO sysfs available for users in the gpio group using the unstructions on this first post and this works. This worked successfully for my unprivileged user.

Now I'm trying to do the same for the RTC sysfs without luck.

What I've tried are most steps from this post up to where they're editing the rules.d file: there's no /sys/devices/soc.0 on my device. Instead I added under he gpio* command list, this line:

chown -R root:gpio /sys/class/rtc && chmod -R 770 /sys/class/rtc;\

This doesn't seem to work. Even if I execute these commands manually and confirm the rtc folder tree is of root:gpio with 770 permissions, it still doesn't work (permission denied from the unprivileged user).

$ cat /sys/class/rtc/rtc1/since_epoch # this works!
$ echo 10 > /sys/class/rtc/rtc1/since_epoch # permission denied

Excuse me, I just realized the sysfs of the RTC seems to be read-only. Now my question shifts to, how can I set the HW time via sysfs? (Alternatively, how can I set the HW time at all from userspace?)

Mark Jeronimus
  • 674
  • 2
  • 10
  • 19

1 Answers1

0

This is an answer to my last-resort question "how can I set the HW time at all from userspace?"

Recently I learned about sudoers, which seems to be the universal solution for everything related to defeating su rights.

Run visudo as root. This is a shortcut to editing sudoers. Don't worry, it won't start vi, but your default editor (unless that is vi). Using this instead of manually editing /etc/sudoers causes the changes to be applied upon closing, and it gives warnings and errors if necessary.

I'm not yet a sudoers wizard (the man page is like 50 pages long) but I ended up adding this to the end:

Cmnd_Alias TIMEDATE=/usr/bin/timedatectl
pi ALL=(ALL) NOPASSWD: TIMEDATE

The using an alias instead of directly specifying the command allows you to use random command line arguments.

Then user pi can execute sudo timedatectl without being asked for a password. (note: sudo is still required.)

Mark Jeronimus
  • 674
  • 2
  • 10
  • 19