-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathuserbindmount.1.html
193 lines (164 loc) · 5.52 KB
/
userbindmount.1.html
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
Content-type: text/html; charset=UTF-8
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of USERBINDMOUNT</TITLE>
</HEAD><BODY>
<H1>USERBINDMOUNT</H1>
Section: User Commands (1)<BR>Updated: August 22, 2017<BR><A HREF="#index">Index</A>
<A HREF="/#/man/index">Return to Main Contents</A><HR>
<A NAME="lbAB"> </A>
<H2>NAME</H2>
userbindmount - bind-mount utility for user-namespaces
<A NAME="lbAC"> </A>
<H2>SYNOPSIS</H2>
<B>userbindmount</B>
[options] [<I>source</I> <I>target</I> [<I>source</I> <I>target</I> [...]]] [ <I>--</I> [<I>cmd</I> [<I>args</I>]]]
<P>
<A NAME="lbAD"> </A>
<H2>DESCRIPTION</H2>
<P>
userbindmount is a utility command based on libuserbindmount.
<P>
It can be used to perform one or more bind-mount operation and to create a user-namespace where
bind-mount is allowed.
<P>
This command does not need root access or specific capabilities to run (provided user-namespaces are supported,
see NOTES).
<P>
The command line arguments are a list of <I>source</I>-<I>target</I> pairs (one for each
bind-mount operation).
A new namespace is created if requested by the specific option (-n or
--newns) or if there is -- as an option in the command line.
If <I>source</I> is a double quoted string, the value of the string will be the content
of the file mounted on <I>target</I>.
The trailing -- followed by a command and its argument define the command
to run in the new namespace. ($SHELL is launched if the command is omitted)
<P>
The contents of the file to be mounted on <I>target</I> is read from
the standard input if the correspondent <I>source</I> is the tag "-".
<P>
<A NAME="lbAE"> </A>
<H2>OPTIONS</H2>
<I>userbindmount</I>
accepts the following options.
<P>
<DL COMPACT>
<DT><B>-n <DD>
--newns
create a new user-namespace
<P>
<DT>-s <DD>
--sysadm
add the CAP_SYS_ADMIN ambient capability to the current of newly created userspace
<P>
<DT>-v <DD>
--verbose
verbose mode: print debugging information on the actions taken by the program.
<P>
</DL>
</B><A NAME="lbAF"> </A>
<H2>NOTES</H2>
User namespaces require a kernel that is configured with the CONFIG_USER_NS option.
In some distributions (e.g. Debian) user namespaces must be enabled by writing 1 to
/proc/sys/kernel/unprivileged_userns_clone.
<A NAME="lbAG"> </A>
<H2>EXAMPLES</H2>
The following example mounts the file /tmp/resolv.conf instead of /etc/resolv.conf: the purpose of
this example is to redefine the name servers for the name resolution.
<DL COMPACT><DT><DD>
<PRE>
$ cat /etc/resolv.conf
nameserver 127.0.0.1
$ echo "nameserver 9.9.9.9" > /tmp/resolv.conf
$ userbindmount -v /tmp/resolv.conf /etc/resolv.conf -- bash
creating a user_namespace
mounting /tmp/resolv.conf on /etc/resolv.conf
starting bash
$ cat /etc/resolv.conf
nameserver 9.9.9.9
$ exit
$
</PRE>
</DL>
<P>
<P>
The following example creates a namespace where bind-mount is allowed and then mounts /tmp/resolv.conf on
/etc/resolv.conf. (It uses busybox instead of <A HREF="/#/man/man8/mount.8.html">mount</A>(8) as the latter does not support the capabilities, yet).
<DL COMPACT><DT><DD>
<PRE>
$ userbindmount -s -- bash
$ cat /etc/resolv.conf
nameserver 127.0.0.1
$ echo "nameserver 9.9.9.9" > /tmp/resolv.conf
$ busybox mount --bind /tmp/resolv.conf /etc/resolv.conf
$ cat /etc/resolv.conf
nameserver 9.9.9.9
$ exit
$
</PRE>
</DL>
Alternative equivalent commands for "userbindmount -s -- bash" are "userbindmount -sn" or "userbindmount -s --".
<P>
<P>
Several bind-mounts can be done in a user-namespace started with the -s option.
No more namespaces are needed in this case.
The contents of the file to mount can be taken from stdin if source is "-".
<DL COMPACT><DT><DD>
<PRE>
$ userbindmount -sn
$ echo "nameserver 9.9.9.9" | userbindmount - /etc/resolv.conf
$ cat /etc/resolv.conf
nameserver 9.9.9.9
$ exit
</PRE>
</DL>
<P>
<P>
It is possible to set the contents of a mounted file directly in the command line:
<DL COMPACT><DT><DD>
<PRE>
$ userbindmount $'"nameserver 9.9.9.9\n"' /etc/resolv.conf -- bash
$ cat /etc/resolv.conf
nameserver 9.9.9.9
$ exit
</PRE>
</DL>
<P>
<P>
Please note that the following command:
<DL COMPACT><DT><DD>
<PRE>
$ echo "nameserver 9.9.9.9" | userbindmount - /etc/resolv.conf -- bash
</PRE>
</DL>
works but the bash running in the new namespace terminates immediately as it reads the end-of-file on its
standard input.
<A NAME="lbAH"> </A>
<H2>SEE ALSO</H2>
<B><A HREF="/#/man/man3/libuserbindmount.3.html">libuserbindmount</A>(3),</B> <A HREF="/#/man/man8/mount.8.html">mount</A>(8),<B> <A HREF="/#/man/man7/user_namespaces.7.html">user_namespaces</A>(7),</B> <A HREF="/#/man/man7/capabilities.7.html">capabilities</A>(7)
<A NAME="lbAI"> </A>
<H2>BUGS</H2>
Bug reports should be addressed to <<A HREF="mailto:[email protected]">[email protected]</A>>
<A NAME="lbAJ"> </A>
<H2>AUTHORS</H2>
Renzo Davoli <<A HREF="mailto:[email protected]">[email protected]</A>>
<P>
<HR>
<A NAME="index"> </A><H2>Index</H2>
<DL>
<DT><A HREF="#lbAB">NAME</A><DD>
<DT><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT><A HREF="#lbAE">OPTIONS</A><DD>
<DT><A HREF="#lbAF">NOTES</A><DD>
<DT><A HREF="#lbAG">EXAMPLES</A><DD>
<DT><A HREF="#lbAH">SEE ALSO</A><DD>
<DT><A HREF="#lbAI">BUGS</A><DD>
<DT><A HREF="#lbAJ">AUTHORS</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 15:22:07 GMT, November 27, 2023
</BODY>
</HTML>