From 3151e4828a08586cdee65766c94a70488bdb0a86 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Tue, 28 Dec 2021 06:32:00 +0000 Subject: Allow normal users to run s6-l-i-hpr/s Instead of testing the euid, test writability to the shutdownd pipe. Signed-off-by: Laurent Bercot --- src/shutdown/s6-linux-init-hpr.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/shutdown/s6-linux-init-hpr.c') diff --git a/src/shutdown/s6-linux-init-hpr.c b/src/shutdown/s6-linux-init-hpr.c index fe8a77d..7f3d457 100644 --- a/src/shutdown/s6-linux-init-hpr.c +++ b/src/shutdown/s6-linux-init-hpr.c @@ -71,14 +71,7 @@ int main (int argc, char const *const *argv) if (!what) strerr_dief1x(100, "one of the -h, -p or -r options must be given") ; - if (geteuid()) - { - errno = EPERM ; - strerr_dief1sys(100, "nice try, peon") ; - } - if (doconfirm) hpr_confirm_hostname() ; - if (force) { if (dosync) sync() ; @@ -87,6 +80,11 @@ int main (int argc, char const *const *argv) } if (!tain_now_g()) strerr_warnw1sys("get current time") ; + if (!hpr_send("", 0)) + { + errno = EPERM ; + strerr_diefu1sys(100, "talk to shutdownd") ; + } if (dowtmp) { struct utmpx utx = -- cgit v1.2.3