summaryrefslogtreecommitdiff
path: root/doc/s6-envuidgid.html
blob: 9753d687c8a3e7351a6867eb5d5829370a07e117 (plain)
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta http-equiv="Content-Language" content="en" />
    <title>s6: the s6-envuidgid program</title>
    <meta name="Description" content="s6: the s6-envuidgid program" />
    <meta name="Keywords" content="s6 command s6-envuidgid uid gid environment modification" />
    <!-- <link rel="stylesheet" type="text/css" href="//skarnet.org/default.css" /> -->
  </head>
<body>

<p>
<a href="index.html">s6</a><br />
<a href="//skarnet.org/software/">Software</a><br />
<a href="//skarnet.org/">skarnet.org</a>
</p>

<h1> The s6-envuidgid program </h1>

<p>
s6-envuidgid potentially sets the UID, GID and GIDLIST environment
variables according to the options and arguments it is given; then it
executes into another program.
</p>

<h2> Interface </h2>

<pre>
     s6-envuidgid [ -u | -g | -B ] [ -n ] [ -i | -D <em>uid</em>:<em>gid</em>:<em>gidlist</em> ] <em>account</em> <em>prog...</em>
</pre>

<ul>
 <li> s6-envuidgid looks <em>account</em> up by name in the account database. </li>
 <li> It sets the UID environment variable to <em>account</em>'s uid, and the GID
environment variable to <em>account</em>'s gid. </li>
 <li> It also sets the GIDLIST environment variable to a comma-separated list of
supplementary group ids <em>account</em> is a member of according to the
group database. (If <em>account</em> doesn't belong to any other group than its
primary group, GIDLIST is still set, but empty.) </li>
 <li> Then it executes into <em>prog...</em>. </li>
</ul>

<h2> Options </h2>

<ul>
 <li> <tt>-u</tt>&nbsp;: user. <em>account</em> will be interpreted as a
user name; the UID environment variable will be set to its numerical
value, and the GID and GIDLIST variables will not be touched. </li>
 <li> <tt>-g</tt>&nbsp;: group. <em>account</em> will be interpreted as a
group name instead of a user name; the GID environment variable will be set
to its numerical value, and the UID and GIDLIST variables will not be touched. </li>
 <li> <tt>-B</tt>&nbsp;: both user and group. <em>account</em> will be
interpreted as <em>user<tt>:</tt>group</em>. The GIDLIST variable will not be
touched. If <em>user</em> does not exist, the UID variable will be set to 0 unless
a better default is provided with the <tt>-D</tt> option.
if <em>group</em> does not exist, the GID variable will be set to 0 unless a
better default is provided with the <tt>-D</tt> option. </li>
 <li> <tt>-n</tt>&nbsp;: numerical fallback. If <em>account</em> cannot be
found in the user or group database, try to interpret the given values literally.
For instance, <tt>s6-envuidgid -B root:42</tt> will fail if there's no group
named <tt>42</tt> in the group database, but <tt>s6-envuidgid -nB root:42</tt>
will set UID to 0 and GID to 42. </li>
 <li> <tt>-i</tt>&nbsp;: insist. If <em>account</em> is unknown, exit 1 with
an error message. This is the default. </li>
 <li> <tt>-D&nbsp;<em>uid</em>:<em>gid</em>:<em>gidlist</em></tt>&nbsp;: if <em>account</em>
is unknown, use <em>uid</em>, <em>gid</em> and <em>gidlist</em> as the values for
UID and GID and GIDLIST. </li>
</ul>

<h2> Notes </h2>

<ul>
 <li> s6-envuidgid without options behaves like
<a href="http://cr.yp.to/daemontools/envuidgid.html">envuidgid</a>, except that
the exit code is 1 if <em>account</em> doesn't exist, and it also exports
supplementary groups. </li>
 <li> s6-envuidgid is useful when running a program that must start as root but can
drop its privileges later. Such a program can read its new uid/gid/groups info
from the UID, GID and GIDLIST environment variables. Superservers such as
<a href="//skarnet.org/software/s6-networking/s6-tcpserver4.html">s6-tcpserver4</a>
make use of this. </li>
</ul>

</body>
</html>