From 49a99140768d41c93b7fc4c69f60940d42ec9e90 Mon Sep 17 00:00:00 2001 From: David Venhoek Date: Thu, 15 Feb 2024 14:15:30 +0100 Subject: [PATCH] Added udev rules and better permissions for statime. --- docs/examples/conf/41-statime.rules | 1 + docs/examples/conf/statime.service | 2 +- pkg/deb/postinst | 5 +++++ pkg/deb/postrm | 10 ++++++++++ pkg/rpm/scriptlets.toml | 7 +++++++ statime-linux/Cargo.toml | 2 ++ 6 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 docs/examples/conf/41-statime.rules diff --git a/docs/examples/conf/41-statime.rules b/docs/examples/conf/41-statime.rules new file mode 100644 index 000000000..52b2ee176 --- /dev/null +++ b/docs/examples/conf/41-statime.rules @@ -0,0 +1 @@ +KERNEL=="ptp[0-9]*", SUBSYSTEM=="ptp", GROUP="statime", MODE="0660" diff --git a/docs/examples/conf/statime.service b/docs/examples/conf/statime.service index 59c450c66..a36f9f896 100644 --- a/docs/examples/conf/statime.service +++ b/docs/examples/conf/statime.service @@ -13,7 +13,7 @@ Environment="RUST_LOG=info" RuntimeDirectory=statime User=statime Group=statime -AmbientCapabilities=CAP_SYS_TIME CAP_NET_BIND_SERVICE CAP_NET_RAW +AmbientCapabilities=CAP_SYS_TIME CAP_NET_BIND_SERVICE CAP_NET_RAW CAP_NET_ADMIN [Install] WantedBy=multi-user.target diff --git a/pkg/deb/postinst b/pkg/deb/postinst index 9733145e5..3b77d3b7a 100644 --- a/pkg/deb/postinst +++ b/pkg/deb/postinst @@ -43,6 +43,11 @@ if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-decon fi deb-systemd-invoke $_dh_action statime.service >/dev/null || true fi + + if [ -d /run/udev ]; then + udevadm control -R + udevadm trigger + fi fi #DEBHELPER# diff --git a/pkg/deb/postrm b/pkg/deb/postrm index 8c7c78dfb..9194cfd03 100644 --- a/pkg/deb/postrm +++ b/pkg/deb/postrm @@ -22,6 +22,11 @@ if [ "$1" = "remove" ]; then if [ -x "/usr/bin/deb-systemd-helper" ]; then deb-systemd-helper mask statime.service >/dev/null || true fi + + if [ -d /run/udev ]; then + udevadm control -R + udevadm trigger + fi fi if [ "$1" = "purge" ]; then @@ -29,6 +34,11 @@ if [ "$1" = "purge" ]; then deb-systemd-helper purge statime.service >/dev/null || true deb-systemd-helper unmask statime.service >/dev/null || true fi + + if [ -d /run/udev ]; then + udevadm control -R + udevadm trigger + fi fi #DEBHELPER# diff --git a/pkg/rpm/scriptlets.toml b/pkg/rpm/scriptlets.toml index eeaf3ef4a..25ed80c3c 100644 --- a/pkg/rpm/scriptlets.toml +++ b/pkg/rpm/scriptlets.toml @@ -40,6 +40,9 @@ if [ $1 -eq 1 ] ; then create_user link_man_page init_systemd_service + + udevadm control -R + udevadm trigger fi ''' @@ -64,4 +67,8 @@ if [ $1 -ge 1 ] ; then systemd_postun_with_restart statime.service systemd_triggers fi + +#trigger udev regardless of upgrade or removal +udevadm control -R +udevadm trigger ''' diff --git a/statime-linux/Cargo.toml b/statime-linux/Cargo.toml index 746ffb97c..8470f66cb 100644 --- a/statime-linux/Cargo.toml +++ b/statime-linux/Cargo.toml @@ -57,6 +57,7 @@ assets = [ ["docs/examples/conf/statime.toml.default", "/etc/statime/statime.toml", "644"], ["docs/examples/conf/statime.preset", "/lib/systemd/system-preset/50-statime.preset", "644"], ["docs/examples/conf/statime.service", "/lib/systemd/system/statime.service", "644"], + ["docs/examples/conf/41-statime.rules", "/etc/udev/41-statime.rules", "644"], ["../COPYRIGHT", "/usr/share/doc/statime/COPYRIGHT", "644"], ["../LICENSE-APACHE", "/usr/share/doc/statime/LICENSE-APACHE", "644"], ["../LICENSE-MIT", "/usr/share/doc/statime/LICENSE-MIT", "644"], @@ -79,6 +80,7 @@ assets = [ { source = "docs/examples/conf/statime.toml.default", dest = "/etc/statime/statime.toml", mode = "644", config = true }, { source = "docs/examples/conf/statime.preset", dest = "/lib/systemd/system-preset/50-statime.preset", mode = "644" }, { source = "docs/examples/conf/statime.service", dest = "/lib/systemd/system/statime.service", mode = "644" }, + { source = "docs/examples/conf/41-statime.rules", dest = "/etc/udev/41-statime.rules", mode = "644" }, { source = "../COPYRIGHT", dest = "/usr/share/doc/statime/COPYRIGHT", mode = "644", doc = true }, { source = "../LICENSE-APACHE", dest = "/usr/share/doc/statime/LICENSE-APACHE", mode = "644", doc = true }, { source = "../LICENSE-MIT", dest = "/usr/share/doc/statime/LICENSE-MIT", mode = "644", doc = true },