「rootアクセス権の取得」と「すべてのコマンドの実行」の違いはありますか?

「rootアクセス権の取得」と「すべてのコマンドの実行」の違いはありますか?

最近 sudoers ファイルを開き、次のことを確認しました。

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL

admin実際、グループの権限とグループのsudo権限の間に有効な区切りがありますか?それでは何ですか?

ベストアンサー1

このセクションは Sudo の Runas_Spec セクションを参照します。詳細は以下で確認できます。マニュアルページ

あなたの例では、管理グループのすべてのメンバーがすべてのユーザーに対してsudo権限を持つように昇格でき、sudoグループのメンバーはすべてのユーザーに対してsudo権限を持つように昇格できます。そしてグループ。

次の例では、2人のユーザーを作成し、あなたの質問のように異なる権限を与えました。

cat /etc/sudoers | grep ^test
test1   ALL=(ALL)   NOPASSWD: ALL
test2   ALL=(ALL:ALL)   NOPASSWD: ALL

次に、Apacheユーザーとグループでコマンドを実行してテストします。 Apacheグループとして実行しようとすると、ユーザーtest1のパスワードを求めるメッセージが表示されます。

[test1@heisenbug root]$ sudo -u apache ping google.com
PING google.com (74.125.230.233) 56(84) bytes of data.
64 bytes from par08s10-in-f9.1e100.net (74.125.230.233): icmp_seq=1 ttl=63 time=36.2 ms
--- google.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 36.245/36.245/36.245/0.000 ms

[test1@heisenbug root]$ sudo -g apache ping google.com
[sudo] password for test1: 

[test2@heisenbug root]$ sudo -u apache ping google.com
PING google.com (74.125.230.226) 56(84) bytes of data.
64 bytes from lhr08s06-in-f2.1e100.net (74.125.230.226): icmp_seq=1 ttl=63 time=34.4 ms
--- google.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 34.465/34.465/34.465/0.000 ms

[test2@heisenbug root]$ sudo -g apache ping google.com
PING google.com (74.125.230.233) 56(84) bytes of data.
64 bytes from lhr08s06-in-f9.1e100.net (74.125.230.233): icmp_seq=1 ttl=63 time=35.0 ms
64 bytes from lhr08s06-in-f9.1e100.net (74.125.230.233): icmp_seq=2 ttl=63 time=33.5 ms
--- google.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 33.575/34.308/35.042/0.756 ms

このタイプの使用法を適用できる非常に厳しい状況があると想像できます。

おすすめ記事