Applied, thanks!

ajrojas, le jeu. 26 nov. 2026 11:07:33 -0300, a ecrit:
> acpi_sleep is restricted to root, but the shutdown translator runs as
> root and makes that call for whoever sends it shutdown_shutdown.  So
> once /servers/shutdown is set up, as Debian's setup-translators does,
> any user can power the machine off at once, without stopping services
> or syncing file systems.  The mode of the node does not prevent it: a
> lookup with no open flags succeeds for anyone, and the RPC needs no
> more.
> 
> startup opens /servers/shutdown as root, so halt keeps working.
> ---
> This is the restriction asked for acpi_sleep in
> <20220905224758.5vdofcdrgrc7c5f4@begin>, applied one level up.
> 
> Tested on Guix System (i586, QEMU), Hurd 6290b4c plus this patch
> (shutdown/ is the same as in master), with /servers/shutdown set up as
> proposed for Guix in https://codeberg.org/guix/guix/issues/12805.  The
> node was root:root, mode 600.  Before: shutdown_shutdown sent by uid
> 1000 through a port looked up with no flags powered the VM off within
> 5 seconds.  After: the same user gets EPERM and the VM keeps running,
> and halt as root still powers it off.  Not tested on Debian.
> 
>  shutdown/shutdown.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/shutdown/shutdown.c b/shutdown/shutdown.c
> index 4a2b1a41..e69c9874 100644
> --- a/shutdown/shutdown.c
> +++ b/shutdown/shutdown.c
> @@ -81,6 +81,13 @@ S_shutdown_shutdown(trivfs_protid_t server)
>    kern_return_t err;
>    mach_port_t acpi;
>  
> +  if (!server)
> +    return EOPNOTSUPP;
> +
> +  /* Only root may power the machine off.  */
> +  if (!server->isroot)
> +    return EPERM;
> +
>    acpi = get_acpi();
>    if (acpi == MACH_PORT_NULL)
>      return EIO;
> -- 
> 2.56.0
> 
> 

-- 
Samuel
"...[Linux's] capacity to talk via any medium except smoke signals."
(By Dr. Greg Wettstein, Roger Maris Cancer Center)

Reply via email to