| | 42 | |
| | 43 | * [http://nixcraft.com/networking-firewalls-security/15132-sudo-exclude-commands-disable-sudo-su-bash-shell.html (Solved) Sudo Exclude Commands And Disable: sudo su -, Bash Shell] |
| | 44 | * 例えば、poweroff, reboot, shutdownコマンドをsudoからは扱えなくするには、以下の様に設定する |
| | 45 | * /etc/sudoers.d/adm |
| | 46 | {{{ |
| | 47 | Cmnd_Alias PWRCTL = /sbin/poweroff,/sbin/reboot,/sbin/shutdown |
| | 48 | %adm ALL=NOPASSWD: ALL, !PWRCTL |
| | 49 | }}} |
| | 50 | * mitty@test:~$ id mitty |
| | 51 | {{{ |
| | 52 | uid=1001(mitty) gid=1001(mitty) groups=1001(mitty),4(adm) |
| | 53 | }}} |
| | 54 | * mitty@test:~$ sudo shutdown |
| | 55 | {{{ |
| | 56 | Sorry, user mitty is not allowed to execute '/sbin/shutdown' as root on test. |
| | 57 | }}} |
| | 58 | * mitty@test:~$ sudo reboot |
| | 59 | {{{ |
| | 60 | Sorry, user mitty is not allowed to execute '/sbin/reboot' as root on test. |
| | 61 | }}} |
| | 62 | * mitty@test:~$ sudo poweroff |
| | 63 | {{{ |
| | 64 | Sorry, user mitty is not allowed to execute '/sbin/poweroff' as root on test. |
| | 65 | }}} |
| | 66 | * 禁止されているコマンドを実行する際は、{{{sudo su -}}}などして別のgroupになってから行う |