summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2021-12-28 06:32:00 +0000
committerLaurent Bercot <ska@appnovation.com>2021-12-28 06:32:00 +0000
commit3151e4828a08586cdee65766c94a70488bdb0a86 (patch)
tree66f2fb9950ba0f6ddda60999c5c0ee48221ab34e /src
parent5e856d71400c617bb21e1dc61fd0eba3117ac51d (diff)
downloads6-linux-init-3151e4828a08586cdee65766c94a70488bdb0a86.tar.xz
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 <ska@appnovation.com>
Diffstat (limited to 'src')
-rw-r--r--src/shutdown/s6-linux-init-hpr.c12
-rw-r--r--src/shutdown/s6-linux-init-shutdown.c4
2 files changed, 7 insertions, 9 deletions
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 =
diff --git a/src/shutdown/s6-linux-init-shutdown.c b/src/shutdown/s6-linux-init-shutdown.c
index 2e81c3b..011abef 100644
--- a/src/shutdown/s6-linux-init-shutdown.c
+++ b/src/shutdown/s6-linux-init-shutdown.c
@@ -291,10 +291,10 @@ int main (int argc, char const *const *argv)
if (what == 1) what = subwhat ;
else strerr_dieusage(100, USAGE) ;
}
- if (geteuid())
+ if (!hpr_send("", 0))
{
errno = EPERM ;
- strerr_diefu1sys(111, "shutdown") ;
+ strerr_diefu1sys(111, "talk to shutdownd") ;
}
if (doactl) access_control() ;
if (doconfirm) hpr_confirm_hostname() ;