RealMabuse schrieb:
Ich finde die Antwort irgendwie unbefriedigend, denn in dem oben genannten Beispiel würde das doch bedeuten, dass der Benutzer die generelle Erlaubnis bekommen würde "chown" als sudo auszuführen?
Das kommt darauf an, wie du es konfigurierst - das ist ein Thema, bei dem man in die (zugegebenermaßen aufgrund der EBNF-Syntax mitunter etwas kryptische) Dokumentation schauen sollte: https://www.sudo.ws/man/sudoers.man.html (da findet man unter anderem auch eine Einführung in EBNF)
Cmnd_List ::= Cmnd |
Cmnd ',' Cmnd_List
command name ::= file name |
file name args |
file name '""'
Cmnd ::= Digest_Spec? '!'* command name |
'!'* directory |
'!'* "sudoedit" |
'!'* Cmnd_Alias
A Cmnd_List is a list of one or more command names, directories, and other aliases. A command name is a fully qualified file name which may include shell-style wildcards (see the Wildcards section below). A simple file name allows the user to run the command with any arguments he/she wishes. However, you may also specify command line arguments (including wildcards). Alternately, you can specify "" to indicate that the command may only be run without command line arguments. A directory is a fully qualified path name ending in a ‘/’. When you specify a directory in a Cmnd_List, the user will be able to run any file within that directory (but not in any sub-directories therein).
If a Cmnd has associated command line arguments, then the arguments in the Cmnd must match exactly those given by the user on the command line (or match the wildcards if there are any). Note that the following characters must be escaped with a ‘\’ if they are used in command arguments: ‘,’, ‘:’, ‘=’, ‘\’.
Wollte man also die passwortlose Ausführung von chown mit sudo nur mit einem definierten Set an Argumenten erlauben, ginge das z.B. so:
user ALL = NOPASSWD:/bin/chown root /tmp/tmp.txt
pstree schrieb:
(Und ich nicht jedes Mal sudo vor die Ausführung meines Scripts packen muss 😉)
Wenn man als in der Shell nicht jedes mal sudo davor schreiben will, kann man sich auch einen alias dafür anlegen.