Due Date: Friday, November 18, 1999 at 11:59PM
xsu - run a command as another user
xsu [ -d ] [ -u user ] command
The command xsu executes the given command with the UID of the named user. If no user is named, the UID of root is used.
The command may be in quotes (one argument) or may be multiple arguments. The command is run in a pristine environment. Specifically, the PATH is set to search /usr/bin, /bin, /usr/sbin, /sbin, and /etc in that order; the HOME is set to the home of user (again, to that of root if no user is named on the command line); SHELL is set to the user's login shell; IFS is set to tab, newline, and blank; and TZ is set to PDT8PST. No other environment variables are set. All files except for standard input, output, and error are closed.All signals are reset to their default value.
|Ignore failure of the change to the requested UID (or root, if none). This flag is used for debugging, when the programmer is not running as root.
|The real and effective UIDs and GIDs are to be set to those of user rather than root. If user is an integer, it is handled as follows. If a user exists with that integer UID, the command acts as though the name of the user had been typed. If no user exists with that UID, and the user executing xsu has the real UID of root, the password requested is that of root and the given UID is used. If no user exists with that UID and the user executing xsu does not have the real UID of root, the command is refused.
If command cannot be executed, xsu exits with a code of -127. If command is executed, the program returns with the return code of command.
xsu -u bishop more /home/bishop/private
This executes the command "more /home/bishop/private" with bishop's privileges.
xsu -u nobody ed /tmp/plugh
This allows the user to edit the file "/tmp/plugh" with the privileges of the nobody user.
Department of Computer Science
University of California at Davis
Davis, CA 95616-8562