.TH SETUID 1 local .\" .\" Copyright (c) 1995 by William Deich. .\" Written by William Deich. Not derived from licensed software. .\" .\" You may distribute under the terms of either the GNU General Public .\" License or the Artistic License, as specified in the README file. .\" .\" .SH NAME setuid \- run a command with a different uid. .SH SYNOPSIS .B setuid .BR username | uid .I \ \ command [ .I args ] .SH DESCRIPTION .I Setuid changes user id, then executes the specified .IR command . Unlike some versions of .IR su (1), this program doesn't ever ask for a password when executed with effective uid=root. This program doesn't change the environment; it only changes the uid and then uses .I execvp() to find the .I command in the path, and execute it. (If the .I command is a script, .I execvp() passes the command name to .B /bin/sh for processing.) .PP For example, .RS setuid \fIsome_user\fP $SHELL .RE can be used to start a shell running as another user. .PP .I Setuid is useful inside scripts that are being run by a setuid-root user \(em such as a script invoked with .IR super , so that the script can execute some commands using the uid of the original user, instead of root. This allows unsafe commands (such as editors and pagers) to be used in a non-root mode inside a super script. For example, an operator with permission to modify a certain .I protected_file could use a super command that simply does: .RS .nf cp protected_file temp_file setuid $ORIG_USER ${EDITOR:-/bin/vi} temp_file cp temp_file protected_file .fi .RE (Note: don't use this example directly. If the \fItemp_file\fP can somehow be replaced by another user, as might be the case if it's kept in a temporary directory, there will be a race condition in the time between editing the temporary file and copying it back to the protected file.) .SH AUTHOR Will Deich