File: setuid.1.in

package info (click to toggle)
super 3.11.6-1
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 660 kB
  • ctags: 592
  • sloc: ansic: 7,338; sh: 183; makefile: 175
file content (69 lines) | stat: -rw-r--r-- 1,868 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
.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