Skip to content

Commit

Permalink
i/builtin: allow accessing real-time clock device nodes via symlinks (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewphelpsj authored Oct 2, 2024
1 parent 0d7c868 commit e7a25a6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions interfaces/builtin/time_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ capability sys_time,
/sys/class/rtc/*/ rw,
/sys/class/rtc/*/** rw,
# Nodes in /sys/class/rtc could be symlinks under /sys/devices
/sys/devices/**/rtc/*/** rw,
# Allow access to pps
# https://www.kernel.org/doc/html/latest/driver-api/pps.html
/dev/pps[0-9]* rw,
Expand Down
3 changes: 3 additions & 0 deletions tests/lib/snaps/test-snapd-timedate-control-consumer/bin/sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
PS1='$ '
exec /bin/sh "$@"
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ apps:
date:
command: bin/date
plugs: [time-control]
sh:
command: bin/sh
plugs: [time-control]
5 changes: 5 additions & 0 deletions tests/main/interfaces-time-control/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ execute: |
exit 0
fi
# make sure that we can access the files in /sys/class/rtc
test-snapd-timedate-control-consumer.sh -c "cat /sys/class/rtc/rtc0/wakealarm"
echo "When the plug is disconnected"
snap disconnect test-snapd-timedate-control-consumer:time-control
Expand All @@ -81,3 +84,5 @@ execute: |
not test-snapd-timedate-control-consumer.date "$now" 2> call.error
# EPERM because date gets blocked by the seccomp profile
MATCH "cannot set date: Operation not permitted" < call.error
not test-snapd-timedate-control-consumer.sh -c "cat /sys/class/rtc/rtc0/wakealarm"

0 comments on commit e7a25a6

Please sign in to comment.