The commands allowable for a user can either be any command at all, a completely specified command with no possible variation, or else a prefix to a command where the user is allowed to add extra arguments to the end of the command.
It is up to the administrator to make sure that the commands allowed are secure (if that is required). For example, allowing users to run a shell or a program which can fork a shell lets the users do anything they want to the system.
The privilege file contains a list of directives, one per line, which are examined in sequence. These directives change the state of some internal variables (such as a log file path and a password). When a directive is seen which allows the user to execute his command, the state of the variables at that time are used. Since the state can change many times as the file is read, different states can apply for different commands.
Comment lines begin with hash marks, and are ignored. Continuation lines are indicated by a backslash at the end of a line. These join the line to the next one with a single space added at the location of the join. Multiple continuation lines are allowed.
The following is the list of directives, with their arguments. Words enclosed in angle brackets represent required values which can be varied. Words enclosed in square brackets represent optional values, and trailing dots indicate that multiple values can be specified.
The <type> argument can be one of "any", "exact", or "prefix". This specifies the amount by which the specified command can be modified. "Any" means that the user can execute any command (and so no command is specified in the directive). The user's command is executed using the normal search list defined by the user's PATH environment variable. "Exact" means that the user's command must match the specified command exactly. "Prefix" means that the user can execute any command which begins with the specified command by adding further arguments to the command.
In the "exact" and "prefix" cases, the command is usually executed using the search list specified in the most recent "paths" directive. However, the command can be an absolute path name, in which case it is run only from the specified path. If the command name matches a list name from a previous "define" directive, then the command name is an alias and is replaced by all of the words in the defined list. Extra arguments given on the "allow" directive or supplied by the user are added to the end of the replaced command.
The following is an example of a (not very useful) "/etc/su1.priv" file:
define GODS dbell nina define rmcore rm -f core paths /bin /usr/bin /etc ask never logfile /dev/null allow root any ask always logfile /etc/su1.log password WBg20dVsRLaqk allow GODS exact rmcore refuse fred exact ls -l allow * prefix ls password QWkree5fjIYam logfile /etc/su1.fsck-log allow sam prefix fsck
This file allows root to execute any command without passwords and without logging. It allows users dbell and nina to remove a core file anywhere when a password is given, and it is logged. It allows all users to execute ls when a password is given, and is logged (except that fred cannot execute ls -l). It allows sam to execute fsck with logging to a separate file, and with a different password than is required for the other commands.