Stupid questions I have always wanted to ask: Part Three

Why do reboot(8) and shutdown(8) have different ownership and mode? And ftm, why is reboot(8) world-executable?

Code:
# ls -l $(which reboot shutdown)
-r-xr-xr-x  5 root wheel    15168 Dec  9 13:23 /sbin/reboot*
-r-sr-xr--  2 root operator 16056 Dec  9 13:23 /sbin/shutdown*

I usually add my non-privileged user to the operator group, which allows me to do all sorts of things with shutdown(8) including shutdown -r, and yet I am not allowed to reboot(8).

The work-around is obvious. My question is literally, "Why?"
 
Because reboot and shutdown are different; they do not perform the same functions.
Which you would have known if you had bothered to actually read the manual pages that you put into your post.

Don't ask "stupid questions" just to post; read the available documentation and try to understand it first, then ask questions.
Just my 0.002 Eurocents.
 
Indeed. Perhaps most interesting is
Code:
reboot -r
to re-root.

What about the world-execute bit, though? Am I missing out on a use case for non-privileged users to invoke
Code:
reboot
 
They have different ownership because reboot(8) is a more low-level program so to speak, only root can run it, because it reboots/halts the machine, but does it not as nicely as shutdown(8) does:

Code:
Normally, the shutdown(8) utility is used when the system needs to be
halted or restarted, giving users advance warning of their impending
doom and cleanly terminating specific programs.

shutdown(8) has to have root privileges in order to actually shut the machine down (I believe it's obvious why), but at the same time it should also be callable by users in the operator group. In order to do that, its executable has a SUID bit.

I hope that helps to clarify things for you.

P.S. I can't actually believe it, but I just came into the forums in order to post 'Question I always wanted to ask' and ask very-very similar question: why people usually prefer to call shutdown -p now insteadof poweroff in order to shutdown the machine. I mean, usually (at least what I saw), when people are giving some instructions or explaining something to someone and they need to say that now we need to shutdown the machine, they almost always use the shutdown(8) variant, not the poweroff(8). I mean, isn't that easier to type one word instead of three every time? And these are the same thing:
Code:
Calling “poweroff” is equivalent to running:
    shutdown -p now

So why's that?
Thanks.
 
tembun Muscle memory? My *BSD systems I've always typed shutdown followed by appropriate -r -p as the situation needed. But Linux systems? I've always typed reboot or poweroff.

poweroff equivalent to shutdown -p now may not mean "the same as". Perhaps "poweroff" does something before shutdown -p (or does not do).

Now if one could point out a shell alias:
poweroff = shutdown -p now
reboot = shutdown -r now

we could have different discussions
 
Pardon the obvious, but shutdown and poweroff are the same program (not unlike grep and egrep):
Code:
$ ls -li $(which poweroff shutdown)
6731 -r-sr-xr--  2 root operator 16056 Dec  4 12:58 /sbin/poweroff*
6731 -r-sr-xr--  2 root operator 16056 Dec  4 12:58 /sbin/shutdown*
only root can run it
Not so. The execute bit is set for all users. Granted, the code may block non-root users, but that is my point: If the program is not meant to be run by unprivileged users, then why is it world-executable?

And ditto for any user "foo" in the wheel group. If wheel isn't meant to be able to reboot, why isn't the executable just chmod 700?

Code:
$ id
uid=1000(foo) gid=1000(cas) groups=0(wheel),1000(foo)
$ ls -l $(which reboot)
-r-xr-xr-x  5 root wheel 15168 Dec  4 12:58 /sbin/reboot*
$ reboot
reboot: Operation not permitted

Not a big deal, I just have never understood why.
 
It's possible to ignore the entire shutdown or reboot procedures (for which I think different execute permissions are needed) and make them behave like reset and hard shutdown. You have to comment out some lines in /usr/src/sys/kern/kern_shutdown.c
Not sure, but isn't a reboot signal just a shutdown instruction without the ACPI halt+shutdown at the end? All RAM content gone means a reboot automatically except when the PSU receives a shutdown on the mobo wire as final action, I think.
 
A big difference is that on a system that's been hardened with encryption, rebooting won't do anything for you in terms of accessing things that can't be changed other than in single user mode, whereas shutdown can by virtue of getting you to single user mode before rebooting, gets you access as root that you aren't necessarily going to get from reboot.
 
Does CURRENT roll into new versions automatically (16 -> 17)? If so, is running CURRENT like rolling-release bleeding-edge FreeBSD?
 
Does CURRENT roll into new versions automatically (16 -> 17)? If so, is running CURRENT like rolling-release bleeding-edge FreeBSD?
Which is why you have companies like Netflix using current, just on a bit of a delay. The delay allows them to avoid installs when there's an issue that was later discovered with current and by using current, it makes it a lot easier for them to write whatever the need on top of it without having to worry about the bit of drift between when the release they're using was branched and the next release is branched.
 
Back
Top