chmod / chownに対するNOPASSWD権限を自分に付与することはできません。 [重複]

chmod / chownに対するNOPASSWD権限を自分に付与することはできません。 [重複]

chmod通常のユーザーアカウントを使用してすべてのファイルを操作できるように、ローカルコンピュータ(Linux Mint 13 Mayaを含む)を設定しようとしています。chownmax

このページに続き、 https://askubuntu.com/questions/159007/how-do-i-run-特異的-sudo-commands-without-a-password

私は次のことをしました。

#edit the /etc/sudoers file via `visudo` 
sudo visudo

#in the file, added these lines:
Cmnd_Alias NOPASS_CMNDS = /bin/chmod, /bin/chown
max ALL=(ALL) NOPASSWD: NOPASS_CMNDS

それから保存されました。 (chmodとchownを使用して位置を取得しましたwhich

今私のvisudoファイルは次のようになります。

#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults        env_reset
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL

Cmnd_Alias NOPASS_CMNDS = /bin/chmod, /bin/chown
max ALL=(ALL) NOPASSWD: NOPASS_CMNDS

# 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

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d

これが出力ですsudo -l

$ sudo -l
Matching 'Defaults' entries for max on this host:
    env_reset, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin

User max may run the following commands on this host:
    (ALL) NOPASSWD: /bin/chmod, /bin/chown
    (ALL : ALL) ALL

その後、新しいシェルタブを開き、sudo chmod他のユーザーとグループが所有するファイルにアクセスしようとすると、パスワードの入力を求められます。

$ ls -l  tmp/0000000001
-rw------- 1 www-data www-data 19245781 Sep 10 16:59 tmp/0000000001

$ sudo chmod +w tmp/0000000001
[sudo] password for max:

ここで何か抜けましたか?私が何か間違っているのか、それとも私が本当に変えたいことを誤解しているのかわかりません。

変更を表示するには、再起動するか、再ロード/再起動する必要がありますか?

ベストアンサー1

ここでの問題は、このユーザーには2つの規則があることです。

(ALL) NOPASSWD: /bin/chmod, /bin/chown
(ALL : ALL) ALL

2番目は、行を読むsudoersから来ます。

%sudo   ALL=(ALL:ALL) ALL

Sudoはファイルの下部にある最初の一致規則を使用します。したがって、コマンドのサブセットに別のオプションを提供する必要がある場合は、そのオプションがリストされていることを確認する必要があります。次のようなより一般的なライン。

つまり、行が次のようになっていることを確認する必要があります。

max ALL=(ALL) NOPASSWD: NOPASS_CMNDS

配置される後ろにワイヤー

%sudo   ALL=(ALL:ALL) ALL

ファイルから。

おすすめ記事