For a desktop setup, I should like to provide /all/ users with a menu
item to turn off the machine. In the default configuration of FreeBSD, however, only a privileged user (e.g. root) can invoke the necessary
command (`poweroff'). This user may be substited for the current user identity with the `su' command, but only if the current user is a member
of the `wheel' group, and even in that case he still needs to type the
target user's password, and `su' does not seem to accept the password
on standard input.
What is the correct method of providing any use with the right to turn
the machine off wihout having to type any password?
<your_username> ALL = (ALL) NOPASSWD:/usr/sbin/poweroff
On 2024-10-05, Anton Shepelev <ant@tilde.culb> wrote:
For a desktop setup, I should like to provide /all/ users with a menu
item to turn off the machine. In the default configuration of FreeBSD,
however, only a privileged user (e.g. root) can invoke the necessary
command (`poweroff'). This user may be substited for the current user
identity with the `su' command, but only if the current user is a member
of the `wheel' group, and even in that case he still needs to type the
target user's password, and `su' does not seem to accept the password
on standard input.
What is the correct method of providing any use with the right to turn
the machine off wihout having to type any password?
You could use 'sudo'. User can run poweroff without asking for passed.
After that set the alias 'alias poweroff='sudo poweroff' system wide.
This /etc/sudoers entry should work:
Run 'visudo' to access the file.
<your_username> ALL = (ALL) NOPASSWD:/usr/sbin/poweroff
Sysop: | deepend |
---|---|
Location: | Calgary, Alberta |
Users: | 255 |
Nodes: | 10 (0 / 10) |
Uptime: | 159:17:29 |
Calls: | 1,725 |
Calls today: | 5 |
Files: | 4,107 |
D/L today: |
12 files (9,998K bytes) |
Messages: | 393,011 |