Debian Codegraph @

po/es/man7/user_namespaces.7.po

raw
1 # Spanish translation of manpages
2 # This file is distributed under the same license as the manpages-l10n package.
3 # Copyright © of this file:
4 msgid ""
5 msgstr ""
6 "Project-Id-Version: manpages-l10n 4.11.0\n"
7 "POT-Creation-Date: 2026-06-05 06:50+0200\n"
8 "PO-Revision-Date: 2021-09-10 15:40+0200\n"
9 "Last-Translator: Automatically generated\n"
10 "Language-Team: Spanish <[email protected]>\n"
11 "Language: es\n"
12 "MIME-Version: 1.0\n"
13 "Content-Type: text/plain; charset=UTF-8\n"
14 "Content-Transfer-Encoding: 8bit\n"
15 "Plural-Forms: nplurals=2; plural=(n != 1);\n"
16
17 #. type: TH
18 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
19 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
20 #, no-wrap
21 msgid "user_namespaces"
22 msgstr ""
23
24 #. type: TH
25 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
26 #: opensuse-tumbleweed
27 #, no-wrap
28 msgid "2026-02-08"
29 msgstr "8 Febrero 2026"
30
31 #. type: TH
32 #: archlinux debian-unstable
33 #, fuzzy, no-wrap
34 #| msgid "Linux man-pages 6.17"
35 msgid "Linux man-pages 6.18"
36 msgstr "Páginas de Manual de Linux 6.17"
37
38 #. type: SH
39 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
40 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
41 #, no-wrap
42 msgid "NAME"
43 msgstr "NOMBRE"
44
45 #. type: Plain text
46 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
47 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
48 msgid "user_namespaces - overview of Linux user namespaces"
49 msgstr ""
50
51 #. type: SH
52 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
53 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
54 #, no-wrap
55 msgid "DESCRIPTION"
56 msgstr "DESCRIPCIÓN"
57
58 #. type: Plain text
59 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
60 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
61 msgid "For an overview of namespaces, see B<namespaces>(7)."
62 msgstr ""
63
64 #
65 #. #-#-#-#-# archlinux: user_namespaces.7.pot (PACKAGE VERSION) #-#-#-#-#
66 #. FIXME: This page says very little about the interaction
67 #. of user namespaces and keys. Add something on this topic.
68 #. ============================================================
69 #. type: Plain text
70 #. #-#-#-#-# debian-trixie: user_namespaces.7.pot (PACKAGE VERSION) #-#-#-#-#
71 #. FIXME: This page says very little about the interaction
72 #. of user namespaces and keys. Add something on this topic.
73 #. ============================================================
74 #. type: Plain text
75 #. #-#-#-#-# debian-unstable: user_namespaces.7.pot (PACKAGE VERSION) #-#-#-#-#
76 #. FIXME: This page says very little about the interaction
77 #. of user namespaces and keys. Add something on this topic.
78 #. ============================================================
79 #. type: Plain text
80 #. #-#-#-#-# fedora-44: user_namespaces.7.pot (PACKAGE VERSION) #-#-#-#-#
81 #. FIXME: This page says very little about the interaction
82 #. of user namespaces and keys. Add something on this topic.
83 #. ============================================================
84 #. type: Plain text
85 #. #-#-#-#-# fedora-rawhide: user_namespaces.7.pot (PACKAGE VERSION) #-#-#-#-#
86 #. FIXME: This page says very little about the interaction
87 #. of user namespaces and keys. Add something on this topic.
88 #. ============================================================
89 #. type: Plain text
90 #. #-#-#-#-# mageia-cauldron: user_namespaces.7.pot (PACKAGE VERSION) #-#-#-#-#
91 #. FIXME: This page says very little about the interaction
92 #. of user namespaces and keys. Add something on this topic.
93 #. ============================================================
94 #. type: Plain text
95 #. #-#-#-#-# opensuse-leap-16-1: user_namespaces.7.pot (PACKAGE VERSION) #-#-#-#-#
96 #. FIXME: This page says very little about the interaction
97 #. of user namespaces and keys. Add something on this topic.
98 #. ============================================================
99 #. type: Plain text
100 #. #-#-#-#-# opensuse-tumbleweed: user_namespaces.7.pot (PACKAGE VERSION) #-#-#-#-#
101 #. FIXME: This page says very little about the interaction
102 #. of user namespaces and keys. Add something on this topic.
103 #. ============================================================
104 #. type: Plain text
105 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
106 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
107 msgid ""
108 "User namespaces isolate security-related identifiers and attributes, in "
109 "particular, user IDs and group IDs (see B<credentials>(7)), the root "
110 "directory, keys (see B<keyrings>(7)), and capabilities (see "
111 "B<capabilities>(7)). A process's user and group IDs can be different inside "
112 "and outside a user namespace. In particular, a process can have a normal "
113 "unprivileged user ID outside a user namespace while at the same time having "
114 "a user ID of 0 inside the namespace; in other words, the process has full "
115 "privileges for operations inside the user namespace, but is unprivileged for "
116 "operations outside the namespace."
117 msgstr ""
118
119 #. type: SS
120 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
121 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
122 #, no-wrap
123 msgid "Nested namespaces, namespace membership"
124 msgstr ""
125
126 #. type: Plain text
127 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
128 #: opensuse-tumbleweed
129 msgid ""
130 "User namespaces can be nested; that is, each user namespace \\[em]except the "
131 "initial (\"root\") namespace\\[em] has a parent user namespace, and can have "
132 "zero or more child user namespaces. The parent user namespace is the user "
133 "namespace of the process that creates the user namespace via a call to "
134 "B<unshare>(2) or B<clone>(2) with the B<CLONE_NEWUSER> flag."
135 msgstr ""
136
137 #. commit 8742f229b635bf1c1c84a3dfe5e47c814c20b5c8
138 #. FIXME Explain the rationale for this limit. (What is the rationale?)
139 #. type: Plain text
140 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
141 #: opensuse-tumbleweed
142 msgid ""
143 "The kernel imposes (since Linux 3.11) a limit of 32 nested levels of user "
144 "namespaces. Calls to B<unshare>(2) or B<clone>(2) that would cause this "
145 "limit to be exceeded fail with the error B<EUSERS>."
146 msgstr ""
147
148 #. type: Plain text
149 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
150 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
151 msgid ""
152 "Each process is a member of exactly one user namespace. A process created "
153 "via B<fork>(2) or B<clone>(2) without the B<CLONE_NEWUSER> flag is a "
154 "member of the same user namespace as its parent. A single-threaded process "
155 "can join another user namespace with B<setns>(2) if it has the "
156 "B<CAP_SYS_ADMIN> in that namespace; upon doing so, it gains a full set of "
157 "capabilities in that namespace."
158 msgstr ""
159
160 #. type: Plain text
161 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
162 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
163 msgid ""
164 "A call to B<clone>(2) or B<unshare>(2) with the B<CLONE_NEWUSER> flag "
165 "makes the new child process (for B<clone>(2)) or the caller (for "
166 "B<unshare>(2)) a member of the new user namespace created by the call."
167 msgstr ""
168
169 #. type: Plain text
170 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
171 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
172 msgid ""
173 "The B<NS_GET_PARENT> B<ioctl>(2) operation can be used to discover the "
174 "parental relationship between user namespaces; see B<ioctl_nsfs>(2)."
175 msgstr ""
176
177 #
178 #. ============================================================
179 #. type: Plain text
180 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
181 #: opensuse-tumbleweed
182 msgid ""
183 "A task that changes one of its effective IDs will have its dumpability reset "
184 "to the value in I</proc/sys/fs/suid_dumpable>. This may affect the "
185 "ownership of proc files of child processes and may thus cause the parent to "
186 "lack the permissions to write to mapping files of child processes running in "
187 "a new user namespace. In such cases, making the parent process dumpable, "
188 "using B<PR_SET_DUMPABLE> in a call to B<prctl>(2), before creating a child "
189 "process in a new user namespace may rectify this problem. See B<prctl>(2) "
190 "and B<proc>(5) for details on how ownership is affected."
191 msgstr ""
192
193 #. type: SS
194 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
195 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
196 #, no-wrap
197 msgid "Capabilities"
198 msgstr ""
199
200 #. type: Plain text
201 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
202 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
203 msgid ""
204 "The child process created by B<clone>(2) with the B<CLONE_NEWUSER> flag "
205 "starts out with a complete set of capabilities in the new user namespace. "
206 "Likewise, a process that creates a new user namespace using B<unshare>(2) "
207 "or joins an existing user namespace using B<setns>(2) gains a full set of "
208 "capabilities in that namespace. On the other hand, that process has no "
209 "capabilities in the parent (in the case of B<clone>(2)) or previous (in the "
210 "case of B<unshare>(2) and B<setns>(2)) user namespace, even if the new "
211 "namespace is created or joined by the root user (i.e., a process with user "
212 "ID 0 in the root namespace)."
213 msgstr ""
214
215 #. type: Plain text
216 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
217 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
218 msgid ""
219 "Note that a call to B<execve>(2) will cause a process's capabilities to be "
220 "recalculated in the usual way (see B<capabilities>(7)). Consequently, "
221 "unless the process has a user ID of 0 within the namespace, or the "
222 "executable file has a nonempty inheritable capabilities mask, the process "
223 "will lose all capabilities. See the discussion of user and group ID "
224 "mappings, below."
225 msgstr ""
226
227 #. type: Plain text
228 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
229 #: opensuse-tumbleweed
230 msgid ""
231 "A call to B<clone>(2) or B<unshare>(2) using the B<CLONE_NEWUSER> flag or "
232 "a call to B<setns>(2) that moves the caller into another user namespace "
233 "sets the \"securebits\" flags (see B<capabilities>(7)) to their default "
234 "values (all flags disabled) in the child (for B<clone>(2)) or caller (for "
235 "B<unshare>(2) or B<setns>(2)). Note that because the caller no longer has "
236 "capabilities in its original user namespace after a call to B<setns>(2), it "
237 "is not possible for a process to reset its \"securebits\" flags while "
238 "retaining its user namespace membership by using a pair of B<setns>(2) "
239 "calls to move to another user namespace and then return to its original user "
240 "namespace."
241 msgstr ""
242
243 #. type: Plain text
244 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
245 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
246 msgid ""
247 "The rules for determining whether or not a process has a capability in a "
248 "particular user namespace are as follows:"
249 msgstr ""
250
251 #. type: IP
252 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
253 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
254 #, no-wrap
255 msgid "\\[bu]"
256 msgstr "\\[bu]"
257
258 #. In the 3.8 sources, see security/commoncap.c::cap_capable():
259 #. type: Plain text
260 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
261 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
262 msgid ""
263 "A process has a capability inside a user namespace if it is a member of that "
264 "namespace and it has the capability in its effective capability set. A "
265 "process can gain capabilities in its effective capability set in various "
266 "ways. For example, it may execute a set-user-ID program or an executable "
267 "with associated file capabilities. In addition, a process may gain "
268 "capabilities via the effect of B<clone>(2), B<unshare>(2), or B<setns>(2), "
269 "as already described."
270 msgstr ""
271
272 #. type: Plain text
273 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
274 #: opensuse-tumbleweed
275 msgid ""
276 "If a process has a capability in a user namespace, then it has that "
277 "capability in all child (and further removed descendant) namespaces as well."
278 msgstr ""
279
280 #
281 #. * The owner of the user namespace in the parent of the
282 #. * user namespace has all caps.
283 #. (and likewise associates the effective group ID of the creating process
284 #. with the namespace).
285 #. See kernel commit 520d9eabce18edfef76a60b7b839d54facafe1f9 for a fix
286 #. on this point
287 #. This includes the case where the process executes a set-user-ID
288 #. program that confers the effective UID of the creator of the namespace.
289 #. ============================================================
290 #. type: Plain text
291 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
292 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
293 msgid ""
294 "When a user namespace is created, the kernel records the effective user ID "
295 "of the creating process as being the \"owner\" of the namespace. A process "
296 "that resides in the parent of the user namespace and whose effective user ID "
297 "matches the owner of the namespace has all capabilities in the namespace. "
298 "By virtue of the previous rule, this means that the process has all "
299 "capabilities in all further removed descendant user namespaces as well. The "
300 "B<NS_GET_OWNER_UID> B<ioctl>(2) operation can be used to discover the user "
301 "ID of the owner of the namespace; see B<ioctl_nsfs>(2)."
302 msgstr ""
303
304 #. type: SS
305 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
306 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
307 #, no-wrap
308 msgid "Effect of capabilities within a user namespace"
309 msgstr ""
310
311 #. type: Plain text
312 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
313 #: opensuse-tumbleweed
314 msgid ""
315 "Having a capability inside a user namespace permits a process to perform "
316 "operations (that require privilege) only on resources governed by that "
317 "namespace. In other words, having a capability in a user namespace permits "
318 "a process to perform privileged operations on resources that are governed by "
319 "(nonuser) namespaces owned by (associated with) the user namespace (see the "
320 "next subsection)."
321 msgstr ""
322
323 #. type: Plain text
324 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
325 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
326 msgid ""
327 "On the other hand, there are many privileged operations that affect "
328 "resources that are not associated with any namespace type, for example, "
329 "changing the system (i.e., calendar) time (governed by B<CAP_SYS_TIME>), "
330 "loading a kernel module (governed by B<CAP_SYS_MODULE>), and creating a "
331 "device (governed by B<CAP_MKNOD>). Only a process with privileges in the "
332 "I<initial> user namespace can perform such operations."
333 msgstr ""
334
335 #. fs_flags = FS_USERNS_MOUNT in kernel sources
336 #. type: Plain text
337 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
338 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
339 msgid ""
340 "Holding B<CAP_SYS_ADMIN> within the user namespace that owns a process's "
341 "mount namespace allows that process to create bind mounts and mount the "
342 "following types of filesystems:"
343 msgstr ""
344
345 #. type: Plain text
346 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
347 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
348 msgid "I</proc> (since Linux 3.8)"
349 msgstr ""
350
351 #. type: Plain text
352 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
353 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
354 msgid "I</sys> (since Linux 3.8)"
355 msgstr ""
356
357 #. type: Plain text
358 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
359 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
360 msgid "I<devpts> (since Linux 3.9)"
361 msgstr ""
362
363 #. type: Plain text
364 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
365 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
366 msgid "B<tmpfs>(5) (since Linux 3.9)"
367 msgstr ""
368
369 #. type: Plain text
370 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
371 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
372 msgid "I<ramfs> (since Linux 3.9)"
373 msgstr ""
374
375 #. type: Plain text
376 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
377 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
378 msgid "I<mqueue> (since Linux 3.9)"
379 msgstr ""
380
381 #. commit b2197755b2633e164a439682fb05a9b5ea48f706
382 #. type: Plain text
383 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
384 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
385 msgid "I<bpf> (since Linux 4.4)"
386 msgstr ""
387
388 #. commit 92dbc9dedccb9759c7f9f2f0ae6242396376988f
389 #. commit 4cb2c00c43b3fe88b32f29df4f76da1b92c33224
390 #. type: Plain text
391 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
392 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
393 msgid "I<overlayfs> (since Linux 5.11)"
394 msgstr ""
395
396 #. type: Plain text
397 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
398 #: opensuse-leap-16-1 opensuse-tumbleweed
399 msgid ""
400 "Holding B<CAP_SYS_ADMIN> within the user namespace that owns a process's "
401 "cgroup namespace allows (since Linux 4.6) that process to mount the cgroup "
402 "version 2 filesystem and cgroup version 1 named hierarchies (i.e., cgroup "
403 "filesystems mounted with the I<\\[dq]none,name=\\[dq]> option)."
404 msgstr ""
405
406 #. type: Plain text
407 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
408 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
409 msgid ""
410 "Holding B<CAP_SYS_ADMIN> within the user namespace that owns a process's PID "
411 "namespace allows (since Linux 3.8) that process to mount I</proc> "
412 "filesystems."
413 msgstr ""
414
415 #
416 #. ============================================================
417 #. type: Plain text
418 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
419 #: opensuse-tumbleweed
420 msgid ""
421 "However, mounting block-based filesystems can be done only by a process that "
422 "holds B<CAP_SYS_ADMIN> in the initial user namespace."
423 msgstr ""
424
425 #. type: SS
426 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
427 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
428 #, no-wrap
429 msgid "Interaction of user namespaces and other types of namespaces"
430 msgstr ""
431
432 #. type: Plain text
433 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
434 #: opensuse-leap-16-1 opensuse-tumbleweed
435 msgid ""
436 "Since Linux 3.8, unprivileged processes can create user namespaces, and the "
437 "other types of namespaces can be created with just the B<CAP_SYS_ADMIN> "
438 "capability in the caller's user namespace."
439 msgstr ""
440
441 #. type: Plain text
442 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
443 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
444 msgid ""
445 "When a nonuser namespace is created, it is owned by the user namespace in "
446 "which the creating process was a member at the time of the creation of the "
447 "namespace. Privileged operations on resources governed by the nonuser "
448 "namespace require that the process has the necessary capabilities in the "
449 "user namespace that owns the nonuser namespace."
450 msgstr ""
451
452 #. type: Plain text
453 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
454 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
455 msgid ""
456 "If B<CLONE_NEWUSER> is specified along with other B<CLONE_NEW*> flags in a "
457 "single B<clone>(2) or B<unshare>(2) call, the user namespace is guaranteed "
458 "to be created first, giving the child (B<clone>(2)) or caller "
459 "(B<unshare>(2)) privileges over the remaining namespaces created by the "
460 "call. Thus, it is possible for an unprivileged caller to specify this "
461 "combination of flags."
462 msgstr ""
463
464 #. type: Plain text
465 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
466 #: opensuse-tumbleweed
467 msgid ""
468 "When a new namespace (other than a user namespace) is created via "
469 "B<clone>(2) or B<unshare>(2), the kernel records the user namespace of the "
470 "creating process as the owner of the new namespace. (This association can't "
471 "be changed.) When a process in the new namespace subsequently performs "
472 "privileged operations that operate on global resources isolated by the "
473 "namespace, the permission checks are performed according to the process's "
474 "capabilities in the user namespace that the kernel associated with the new "
475 "namespace. For example, suppose that a process attempts to change the "
476 "hostname (B<sethostname>(2)), a resource governed by the UTS namespace. In "
477 "this case, the kernel will determine which user namespace owns the process's "
478 "UTS namespace, and check whether the process has the required capability "
479 "(B<CAP_SYS_ADMIN>) in that user namespace."
480 msgstr ""
481
482 #
483 #. ============================================================
484 #. type: Plain text
485 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
486 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
487 msgid ""
488 "The B<NS_GET_USERNS> B<ioctl>(2) operation can be used to discover the user "
489 "namespace that owns a nonuser namespace; see B<ioctl_nsfs>(2)."
490 msgstr ""
491
492 #. type: SS
493 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
494 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
495 #, no-wrap
496 msgid "User and group ID mappings: uid_map and gid_map"
497 msgstr ""
498
499 #. commit 22d917d80e842829d0ca0a561967d728eb1d6303
500 #. type: Plain text
501 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
502 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
503 msgid ""
504 "When a user namespace is created, it starts out without a mapping of user "
505 "IDs (group IDs) to the parent user namespace. The I</proc/>pidI</uid_map> "
506 "and I</proc/>pidI</gid_map> files (available since Linux 3.5) expose the "
507 "mappings for user and group IDs inside the user namespace for the process "
508 "I<pid>. These files can be read to view the mappings in a user namespace "
509 "and written to (once) to define the mappings."
510 msgstr ""
511
512 #. type: Plain text
513 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
514 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
515 msgid ""
516 "The description in the following paragraphs explains the details for "
517 "I<uid_map>; I<gid_map> is exactly the same, but each instance of \"user ID\" "
518 "is replaced by \"group ID\"."
519 msgstr ""
520
521 #. type: Plain text
522 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
523 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
524 msgid ""
525 "The I<uid_map> file exposes the mapping of user IDs from the user namespace "
526 "of the process I<pid> to the user namespace of the process that opened "
527 "I<uid_map> (but see a qualification to this point below). In other words, "
528 "processes that are in different user namespaces will potentially see "
529 "different values when reading from a particular I<uid_map> file, depending "
530 "on the user ID mappings for the user namespaces of the reading processes."
531 msgstr ""
532
533 #. type: Plain text
534 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
535 #: opensuse-leap-16-1 opensuse-tumbleweed
536 msgid ""
537 "Each line in the I<uid_map> file specifies a 1-to-1 mapping of a range of "
538 "contiguous user IDs between two user namespaces. (When a user namespace is "
539 "first created, this file is empty.) The specification in each line takes "
540 "the form of three numbers delimited by white space. The first two numbers "
541 "specify the starting user ID in each of the two user namespaces. The third "
542 "number specifies the size of the mapped range. In detail, the fields are "
543 "interpreted as follows:"
544 msgstr ""
545
546 #. type: IP
547 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
548 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
549 #, no-wrap
550 msgid "(1)"
551 msgstr "(1)"
552
553 #. type: Plain text
554 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
555 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
556 msgid ""
557 "The start of the range of user IDs in the user namespace of the process "
558 "I<pid>."
559 msgstr ""
560
561 #. type: IP
562 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
563 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
564 #, no-wrap
565 msgid "(2)"
566 msgstr "(2)"
567
568 #. type: Plain text
569 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
570 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
571 msgid ""
572 "The start of the range of user IDs to which the user IDs specified by field "
573 "one map. How field two is interpreted depends on whether the process that "
574 "opened I<uid_map> and the process I<pid> are in the same user namespace, as "
575 "follows:"
576 msgstr ""
577
578 #. type: IP
579 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
580 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
581 #, no-wrap
582 msgid "(a)"
583 msgstr "(a)"
584
585 #. type: Plain text
586 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
587 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
588 msgid ""
589 "If the two processes are in different user namespaces: field two is the "
590 "start of a range of user IDs in the user namespace of the process that "
591 "opened I<uid_map>."
592 msgstr ""
593
594 #. type: IP
595 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
596 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
597 #, no-wrap
598 msgid "(b)"
599 msgstr "(b)"
600
601 #. type: Plain text
602 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
603 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
604 msgid ""
605 "If the two processes are in the same user namespace: field two is the start "
606 "of the range of user IDs in the parent user namespace of the process "
607 "I<pid>. This case enables the opener of I<uid_map> (the common case here is "
608 "opening I</proc/self/uid_map>) to see the mapping of user IDs into the user "
609 "namespace of the process that created this user namespace."
610 msgstr ""
611
612 #. type: IP
613 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
614 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
615 #, no-wrap
616 msgid "(3)"
617 msgstr "(3)"
618
619 #. type: Plain text
620 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
621 #: opensuse-leap-16-1 opensuse-tumbleweed
622 msgid ""
623 "The size of the range of user IDs that is mapped between the two user "
624 "namespaces."
625 msgstr ""
626
627 #. type: Plain text
628 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
629 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
630 msgid ""
631 "System calls that return user IDs (group IDs)\\[em]for example, "
632 "B<getuid>(2), B<getgid>(2), and the credential fields in the structure "
633 "returned by B<stat>(2)\\[em]return the user ID (group ID) mapped into the "
634 "caller's user namespace."
635 msgstr ""
636
637 #. type: Plain text
638 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
639 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
640 msgid ""
641 "When a process accesses a file, its user and group IDs are mapped into the "
642 "initial user namespace for the purpose of permission checking and assigning "
643 "IDs when creating a file. When a process retrieves file user and group IDs "
644 "via B<stat>(2), the IDs are mapped in the opposite direction, to produce "
645 "values relative to the process user and group ID mappings."
646 msgstr ""
647
648 #. type: Plain text
649 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
650 #: opensuse-tumbleweed
651 msgid ""
652 "The initial user namespace has no parent namespace, but, for consistency, "
653 "the kernel provides dummy user and group ID mapping files for this "
654 "namespace. Looking at the I<uid_map> file (I<gid_map> is the same) from a "
655 "shell in the initial namespace shows:"
656 msgstr ""
657
658 #. type: Plain text
659 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
660 #: opensuse-tumbleweed
661 #, no-wrap
662 msgid ""
663 "$B< cat /proc/$$/uid_map>;\n"
664 " 0 0 4294967295\n"
665 msgstr ""
666
667 #
668 #. ============================================================
669 #. type: Plain text
670 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
671 #: opensuse-leap-16-1 opensuse-tumbleweed
672 msgid ""
673 "This mapping tells us that the range starting at user ID 0 in this namespace "
674 "maps to a range starting at 0 in the (nonexistent) parent namespace, and the "
675 "size of the range is the largest 32-bit unsigned integer. This leaves "
676 "4294967295 (the 32-bit signed -1 value) unmapped. This is deliberate: "
677 "I<(uid_t)\\ -1> is used in several interfaces (e.g., B<setreuid>(2)) as a "
678 "way to specify \"no user ID\". Leaving I<(uid_t)\\ -1> unmapped and "
679 "unusable guarantees that there will be no confusion when using these "
680 "interfaces."
681 msgstr ""
682
683 #. type: SS
684 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
685 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
686 #, no-wrap
687 msgid "Defining user and group ID mappings: writing to uid_map and gid_map"
688 msgstr ""
689
690 #. type: Plain text
691 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
692 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
693 msgid ""
694 "After the creation of a new user namespace, the I<uid_map> file of I<one> of "
695 "the processes in the namespace may be written to I<once> to define the "
696 "mapping of user IDs in the new user namespace. An attempt to write more "
697 "than once to a I<uid_map> file in a user namespace fails with the error "
698 "B<EPERM>. Similar rules apply for I<gid_map> files."
699 msgstr ""
700
701 #. type: Plain text
702 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
703 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
704 msgid ""
705 "The lines written to I<uid_map> (I<gid_map>) must conform to the following "
706 "validity rules:"
707 msgstr ""
708
709 #. type: Plain text
710 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
711 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
712 msgid ""
713 "The three fields must be valid numbers, and the last field must be greater "
714 "than 0."
715 msgstr ""
716
717 #. type: Plain text
718 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
719 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
720 msgid "Lines are terminated by newline characters."
721 msgstr ""
722
723 #. 5*12-byte records could fit in a 64B cache line
724 #. commit 6397fac4915ab3002dc15aae751455da1a852f25
725 #. type: Plain text
726 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
727 #: opensuse-tumbleweed
728 msgid ""
729 "There is a limit on the number of lines in the file. Up to Linux 4.14, this "
730 "limit was (arbitrarily) set at 5 lines. Since Linux 4.16, the limit is 340 "
731 "lines. In addition, the number of bytes written to the file must be less "
732 "than the system page size, and the write must be performed at the start of "
733 "the file (i.e., B<lseek>(2) and B<pwrite>(2) can't be used to write to "
734 "nonzero offsets in the file)."
735 msgstr ""
736
737 #. commit 0bd14b4fd72afd5df41e9fd59f356740f22fceba
738 #. type: Plain text
739 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
740 #: opensuse-tumbleweed
741 msgid ""
742 "The range of user IDs (group IDs) specified in each line cannot overlap "
743 "with the ranges in any other lines. In the initial implementation (Linux "
744 "3.8), this requirement was satisfied by a simplistic implementation that "
745 "imposed the further requirement that the values in both field 1 and field 2 "
746 "of successive lines must be in ascending numerical order, which prevented "
747 "some otherwise valid maps from being created. Since Linux 3.9, this "
748 "limitation has been removed, allowing any valid set of nonoverlapping maps."
749 msgstr ""
750
751 #. type: Plain text
752 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
753 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
754 msgid "At least one line must be written to the file."
755 msgstr ""
756
757 #. type: Plain text
758 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
759 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
760 msgid "Writes that violate the above rules fail with the error B<EINVAL>."
761 msgstr ""
762
763 #. type: Plain text
764 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
765 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
766 msgid ""
767 "In order for a process to write to the I</proc/>pidI</uid_map> (I</proc/"
768 ">pidI</gid_map>) file, all of the following permission requirements must be "
769 "met:"
770 msgstr ""
771
772 #. type: Plain text
773 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
774 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
775 msgid ""
776 "The writing process must have the B<CAP_SETUID> (B<CAP_SETGID>) capability "
777 "in the user namespace of the process I<pid>."
778 msgstr ""
779
780 #. type: Plain text
781 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
782 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
783 msgid ""
784 "The writing process must either be in the user namespace of the process "
785 "I<pid> or be in the parent user namespace of the process I<pid>."
786 msgstr ""
787
788 #. type: Plain text
789 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
790 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
791 msgid ""
792 "The mapped user IDs (group IDs) must in turn have a mapping in the parent "
793 "user namespace."
794 msgstr ""
795
796 #. type: Plain text
797 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
798 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
799 msgid ""
800 "If updating I</proc/>pidI</uid_map> to create a mapping that maps UID 0 in "
801 "the parent namespace, then one of the following must be true:"
802 msgstr ""
803
804 #. type: Plain text
805 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
806 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
807 msgid ""
808 "if writing process is in the parent user namespace, then it must have the "
809 "B<CAP_SETFCAP> capability in that user namespace; or"
810 msgstr ""
811
812 #. type: Plain text
813 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
814 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
815 msgid ""
816 "if the writing process is in the child user namespace, then the process that "
817 "created the user namespace must have had the B<CAP_SETFCAP> capability when "
818 "the namespace was created."
819 msgstr ""
820
821 #. commit db2e718a47984b9d71ed890eb2ea36ecf150de18
822 #. type: Plain text
823 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
824 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
825 msgid ""
826 "This rule has been in place since Linux 5.12. It eliminates an earlier "
827 "security bug whereby a UID 0 process that lacks the B<CAP_SETFCAP> "
828 "capability, which is needed to create a binary with namespaced file "
829 "capabilities (as described in B<capabilities>(7)), could nevertheless create "
830 "such a binary, by the following steps:"
831 msgstr ""
832
833 #. type: Plain text
834 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
835 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
836 msgid ""
837 "Create a new user namespace with the identity mapping (i.e., UID 0 in the "
838 "new user namespace maps to UID 0 in the parent namespace), so that UID 0 in "
839 "both namespaces is equivalent to the same root user ID."
840 msgstr ""
841
842 #. type: Plain text
843 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
844 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
845 msgid ""
846 "Since the child process has the B<CAP_SETFCAP> capability, it could create a "
847 "binary with namespaced file capabilities that would then be effective in the "
848 "parent user namespace (because the root user IDs are the same in the two "
849 "namespaces)."
850 msgstr ""
851
852 #. type: Plain text
853 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
854 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
855 msgid "One of the following two cases applies:"
856 msgstr ""
857
858 #. type: Plain text
859 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
860 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
861 msgid ""
862 "I<Either> the writing process has the B<CAP_SETUID> (B<CAP_SETGID>) "
863 "capability in the I<parent> user namespace."
864 msgstr ""
865
866 #. type: Plain text
867 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
868 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
869 msgid ""
870 "No further restrictions apply: the process can make mappings to arbitrary "
871 "user IDs (group IDs) in the parent user namespace."
872 msgstr ""
873
874 #. type: Plain text
875 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
876 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
877 msgid "I<Or> otherwise all of the following restrictions apply:"
878 msgstr ""
879
880 #. type: Plain text
881 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
882 #: opensuse-tumbleweed
883 msgid ""
884 "The data written to I<uid_map> (I<gid_map>) must consist of a single line "
885 "that maps the writing process's effective user ID (group ID) in the parent "
886 "user namespace to a user ID (group ID) in the user namespace."
887 msgstr ""
888
889 #. type: Plain text
890 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
891 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
892 msgid ""
893 "The writing process must have the same effective user ID as the process that "
894 "created the user namespace."
895 msgstr ""
896
897 #. type: Plain text
898 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
899 #: opensuse-tumbleweed
900 msgid ""
901 "In the case of I<gid_map>, use of the B<setgroups>(2) system call must "
902 "first be denied by writing \\[dq]I<deny>\\[dq] to the I</proc/>pidI</"
903 "setgroups> file (see below) before writing to I<gid_map>."
904 msgstr ""
905
906 #
907 #. ============================================================
908 #. type: Plain text
909 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
910 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
911 msgid "Writes that violate the above rules fail with the error B<EPERM>."
912 msgstr ""
913
914 #. type: SS
915 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
916 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
917 #, no-wrap
918 msgid "Project ID mappings: projid_map"
919 msgstr ""
920
921 #. type: Plain text
922 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
923 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
924 msgid ""
925 "Similarly to user and group ID mappings, it is possible to create project ID "
926 "mappings for a user namespace. (Project IDs are used for disk quotas; see "
927 "B<setquota>(8) and B<quotactl>(2).)"
928 msgstr ""
929
930 #. commit f76d207a66c3a53defea67e7d36c3eb1b7d6d61d
931 #. type: Plain text
932 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
933 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
934 msgid ""
935 "Project ID mappings are defined by writing to the I</proc/>pidI</projid_map> "
936 "file (present since Linux 3.7)."
937 msgstr ""
938
939 #. type: Plain text
940 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
941 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
942 msgid ""
943 "The validity rules for writing to the I</proc/>pidI</projid_map> file are as "
944 "for writing to the I<uid_map> file; violation of these rules causes "
945 "B<write>(2) to fail with the error B<EINVAL>."
946 msgstr ""
947
948 #. type: Plain text
949 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
950 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
951 msgid ""
952 "The permission rules for writing to the I</proc/>pidI</projid_map> file are "
953 "as follows:"
954 msgstr ""
955
956 #. type: Plain text
957 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
958 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
959 msgid ""
960 "The mapped project IDs must in turn have a mapping in the parent user "
961 "namespace."
962 msgstr ""
963
964 #
965 #. ============================================================
966 #. type: Plain text
967 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
968 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
969 msgid ""
970 "Violation of these rules causes B<write>(2) to fail with the error B<EPERM>."
971 msgstr ""
972
973 #. type: SS
974 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
975 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
976 #, no-wrap
977 msgid "Interaction with system calls that change process UIDs or GIDs"
978 msgstr ""
979
980 #. type: Plain text
981 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
982 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
983 msgid ""
984 "In a user namespace where the I<uid_map> file has not been written, the "
985 "system calls that change user IDs will fail. Similarly, if the I<gid_map> "
986 "file has not been written, the system calls that change group IDs will "
987 "fail. After the I<uid_map> and I<gid_map> files have been written, only the "
988 "mapped values may be used in system calls that change user and group IDs."
989 msgstr ""
990
991 #. type: Plain text
992 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
993 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
994 msgid ""
995 "For user IDs, the relevant system calls include B<setuid>(2), "
996 "B<setfsuid>(2), B<setreuid>(2), and B<setresuid>(2). For group IDs, the "
997 "relevant system calls include B<setgid>(2), B<setfsgid>(2), B<setregid>(2), "
998 "B<setresgid>(2), and B<setgroups>(2)."
999 msgstr ""
1000
1001 #
1002 #. Things changed in Linux 3.19
1003 #. commit 9cc46516ddf497ea16e8d7cb986ae03a0f6b92f8
1004 #. commit 66d2f338ee4c449396b6f99f5e75cd18eb6df272
1005 #. http://lwn.net/Articles/626665/
1006 #. ============================================================
1007 #. type: Plain text
1008 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1009 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1010 msgid ""
1011 "Writing \\[dq]I<deny>\\[dq] to the I</proc/>pidI</setgroups> file before "
1012 "writing to I</proc/>pidI</gid_map> will permanently disable B<setgroups>(2) "
1013 "in a user namespace and allow writing to I</proc/>pidI</gid_map> without "
1014 "having the B<CAP_SETGID> capability in the parent user namespace."
1015 msgstr ""
1016
1017 #. type: SS
1018 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1019 #: opensuse-tumbleweed
1020 #, no-wrap
1021 msgid "The \\f[I]/proc/\\fBpid\\f[I]/setgroups\\fB file"
1022 msgstr ""
1023
1024 #
1025 #. commit 9cc46516ddf497ea16e8d7cb986ae03a0f6b92f8
1026 #. commit 66d2f338ee4c449396b6f99f5e75cd18eb6df272
1027 #. http://lwn.net/Articles/626665/
1028 #. http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2014-8989
1029 #. type: Plain text
1030 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1031 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1032 msgid ""
1033 "The I</proc/>pidI</setgroups> file displays the string \\[dq]I<allow>\\[dq] "
1034 "if processes in the user namespace that contains the process I<pid> are "
1035 "permitted to employ the B<setgroups>(2) system call; it displays \\"
1036 "[dq]I<deny>\\[dq] if B<setgroups>(2) is not permitted in that user "
1037 "namespace. Note that regardless of the value in the I</proc/>pidI</"
1038 "setgroups> file (and regardless of the process's capabilities), calls to "
1039 "B<setgroups>(2) are also not permitted if I</proc/>pidI</gid_map> has not "
1040 "yet been set."
1041 msgstr ""
1042
1043 #. type: Plain text
1044 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1045 #: opensuse-tumbleweed
1046 msgid ""
1047 "A privileged process (one with the B<CAP_SYS_ADMIN> capability in the "
1048 "namespace) may write either of the strings \\[dq]I<allow>\\[dq] or \\"
1049 "[dq]I<deny>\\[dq] to this file I<before> writing a group ID mapping for this "
1050 "user namespace to the file I</proc/>pidI</gid_map>. Writing the string \\"
1051 "[dq]I<deny>\\[dq] prevents any process in the user namespace from employing "
1052 "B<setgroups>(2)."
1053 msgstr ""
1054
1055 #. type: Plain text
1056 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1057 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1058 msgid ""
1059 "The essence of the restrictions described in the preceding paragraph is that "
1060 "it is permitted to write to I</proc/>pidI</setgroups> only so long as "
1061 "calling B<setgroups>(2) is disallowed because I</proc/>pidI</gid_map> has "
1062 "not been set. This ensures that a process cannot transition from a state "
1063 "where B<setgroups>(2) is allowed to a state where B<setgroups>(2) is "
1064 "denied; a process can transition only from B<setgroups>(2) being disallowed "
1065 "to B<setgroups>(2) being allowed."
1066 msgstr ""
1067
1068 #. type: Plain text
1069 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1070 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1071 msgid ""
1072 "The default value of this file in the initial user namespace is \\"
1073 "[dq]I<allow>\\[dq]."
1074 msgstr ""
1075
1076 #. type: Plain text
1077 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1078 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1079 msgid ""
1080 "Once I</proc/>pidI</gid_map> has been written to (which has the effect of "
1081 "enabling B<setgroups>(2) in the user namespace), it is no longer possible "
1082 "to disallow B<setgroups>(2) by writing \\[dq]I<deny>\\[dq] to I</proc/"
1083 ">pidI</setgroups> (the write fails with the error B<EPERM>)."
1084 msgstr ""
1085
1086 #. type: Plain text
1087 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1088 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1089 msgid ""
1090 "A child user namespace inherits the I</proc/>pidI</setgroups> setting from "
1091 "its parent."
1092 msgstr ""
1093
1094 #. type: Plain text
1095 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1096 #: opensuse-tumbleweed
1097 msgid ""
1098 "If the I<setgroups> file has the value \\[dq]I<deny>\\[dq], then the "
1099 "B<setgroups>(2) system call can't subsequently be reenabled (by writing \\"
1100 "[dq]I<allow>\\[dq] to the file) in this user namespace. (Attempts to do so "
1101 "fail with the error B<EPERM>.) This restriction also propagates down to all "
1102 "child user namespaces of this user namespace."
1103 msgstr ""
1104
1105 #
1106 #
1107 #
1108 #
1109 #. /proc/PID/setgroups
1110 #. [allow == setgroups() is allowed, "deny" == setgroups() is disallowed]
1111 #. * Can write if have CAP_SYS_ADMIN in NS
1112 #. * Must write BEFORE writing to /proc/PID/gid_map
1113 #. setgroups()
1114 #. * Must already have written to gid_map
1115 #. * /proc/PID/setgroups must be "allow"
1116 #. /proc/PID/gid_map -- writing
1117 #. * Must already have written "deny" to /proc/PID/setgroups
1118 #. ============================================================
1119 #. type: Plain text
1120 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1121 #: opensuse-tumbleweed
1122 msgid ""
1123 "The I</proc/>pidI</setgroups> file was added in Linux 3.19, but was "
1124 "backported to many earlier stable kernel series, because it addresses a "
1125 "security issue. The issue concerned files with permissions such as \"rwx---"
1126 "rwx\". Such files give fewer permissions to \"group\" than they do to "
1127 "\"other\". This means that dropping groups using B<setgroups>(2) might "
1128 "allow a process file access that it did not formerly have. Before the "
1129 "existence of user namespaces this was not a concern, since only a privileged "
1130 "process (one with the B<CAP_SETGID> capability) could call "
1131 "B<setgroups>(2). However, with the introduction of user namespaces, it "
1132 "became possible for an unprivileged process to create a new namespace in "
1133 "which the user had all privileges. This then allowed formerly unprivileged "
1134 "users to drop groups and thus gain file access that they did not previously "
1135 "have. The I</proc/>pidI</setgroups> file was added to address this security "
1136 "issue, by denying any pathway for an unprivileged process to drop groups "
1137 "with B<setgroups>(2)."
1138 msgstr ""
1139
1140 #. type: SS
1141 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1142 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1143 #, no-wrap
1144 msgid "Unmapped user and group IDs"
1145 msgstr ""
1146
1147 #. from_kuid_munged(), from_kgid_munged()
1148 #. type: Plain text
1149 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1150 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1151 msgid ""
1152 "There are various places where an unmapped user ID (group ID) may be "
1153 "exposed to user space. For example, the first process in a new user "
1154 "namespace may call B<getuid>(2) before a user ID mapping has been defined "
1155 "for the namespace. In most such cases, an unmapped user ID is converted to "
1156 "the overflow user ID (group ID); the default value for the overflow user ID "
1157 "(group ID) is 65534. See the descriptions of I</proc/sys/kernel/"
1158 "overflowuid> and I</proc/sys/kernel/overflowgid> in B<proc>(5)."
1159 msgstr ""
1160
1161 #. also SO_PEERCRED
1162 #. type: Plain text
1163 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1164 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1165 msgid ""
1166 "The cases where unmapped IDs are mapped in this fashion include system calls "
1167 "that return user IDs (B<getuid>(2), B<getgid>(2), and similar), credentials "
1168 "passed over a UNIX domain socket, credentials returned by B<stat>(2), "
1169 "B<waitid>(2), and the System V IPC \"ctl\" B<IPC_STAT> operations, "
1170 "credentials exposed by I</proc/>pidI</status> and the files in I</proc/"
1171 "sysvipc/*>, credentials returned via the I<si_uid> field in the I<siginfo_t> "
1172 "received with a signal (see B<sigaction>(2)), credentials written to the "
1173 "process accounting file (see B<acct>(5)), and credentials returned with "
1174 "POSIX message queue notifications (see B<mq_notify>(3))."
1175 msgstr ""
1176
1177 #
1178 #. from_kuid(), from_kgid()
1179 #. Also F_GETOWNER_UIDS is an exception
1180 #. ============================================================
1181 #. type: Plain text
1182 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1183 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1184 msgid ""
1185 "There is one notable case where unmapped user and group IDs are I<not> "
1186 "converted to the corresponding overflow ID value. When viewing a I<uid_map> "
1187 "or I<gid_map> file in which there is no mapping for the second field, that "
1188 "field is displayed as 4294967295 (-1 as an unsigned integer)."
1189 msgstr ""
1190
1191 #. type: SS
1192 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1193 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1194 #, no-wrap
1195 msgid "Accessing files"
1196 msgstr ""
1197
1198 #
1199 #. ============================================================
1200 #. type: Plain text
1201 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1202 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1203 msgid ""
1204 "In order to determine permissions when an unprivileged process accesses a "
1205 "file, the process credentials (UID, GID) and the file credentials are in "
1206 "effect mapped back to what they would be in the initial user namespace and "
1207 "then compared to determine the permissions that the process has on the "
1208 "file. The same is also true of other objects that employ the credentials "
1209 "plus permissions mask accessibility model, such as System V IPC objects."
1210 msgstr ""
1211
1212 #. type: SS
1213 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1214 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1215 #, no-wrap
1216 msgid "Operation of file-related capabilities"
1217 msgstr ""
1218
1219 #. type: Plain text
1220 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1221 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1222 msgid ""
1223 "Certain capabilities allow a process to bypass various kernel-enforced "
1224 "restrictions when performing operations on files owned by other users or "
1225 "groups. These capabilities are: B<CAP_CHOWN>, B<CAP_DAC_OVERRIDE>, "
1226 "B<CAP_DAC_READ_SEARCH>, B<CAP_FOWNER>, and B<CAP_FSETID>."
1227 msgstr ""
1228
1229 #. type: Plain text
1230 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1231 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1232 msgid ""
1233 "Within a user namespace, these capabilities allow a process to bypass the "
1234 "rules if the process has the relevant capability over the file, meaning that:"
1235 msgstr ""
1236
1237 #. type: Plain text
1238 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1239 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1240 msgid ""
1241 "the process has the relevant effective capability in its user namespace; and"
1242 msgstr ""
1243
1244 #. type: Plain text
1245 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1246 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1247 msgid ""
1248 "the file's user ID and group ID both have valid mappings in the user "
1249 "namespace."
1250 msgstr ""
1251
1252 #
1253 #. #-#-#-#-# archlinux: user_namespaces.7.pot (PACKAGE VERSION) #-#-#-#-#
1254 #. These are the checks performed by the kernel function
1255 #. inode_owner_or_capable(). There is one exception to the exception:
1256 #. overriding the directory sticky permission bit requires that
1257 #. the file has a valid mapping for both its UID and GID.
1258 #. ============================================================
1259 #. type: Plain text
1260 #. #-#-#-#-# debian-trixie: user_namespaces.7.pot (PACKAGE VERSION) #-#-#-#-#
1261 #. These are the checks performed by the kernel function
1262 #. inode_owner_or_capable(). There is one exception to the exception:
1263 #. overriding the directory sticky permission bit requires that
1264 #. the file has a valid mapping for both its UID and GID.
1265 #. ============================================================
1266 #. type: Plain text
1267 #. #-#-#-#-# debian-unstable: user_namespaces.7.pot (PACKAGE VERSION) #-#-#-#-#
1268 #. These are the checks performed by the kernel function
1269 #. inode_owner_or_capable(). There is one exception to the exception:
1270 #. overriding the directory sticky permission bit requires that
1271 #. the file has a valid mapping for both its UID and GID.
1272 #. ============================================================
1273 #. type: Plain text
1274 #. #-#-#-#-# fedora-44: user_namespaces.7.pot (PACKAGE VERSION) #-#-#-#-#
1275 #. These are the checks performed by the kernel function
1276 #. inode_owner_or_capable(). There is one exception to the exception:
1277 #. overriding the directory sticky permission bit requires that
1278 #. the file has a valid mapping for both its UID and GID.
1279 #. ============================================================
1280 #. type: Plain text
1281 #. #-#-#-#-# fedora-rawhide: user_namespaces.7.pot (PACKAGE VERSION) #-#-#-#-#
1282 #. These are the checks performed by the kernel function
1283 #. inode_owner_or_capable(). There is one exception to the exception:
1284 #. overriding the directory sticky permission bit requires that
1285 #. the file has a valid mapping for both its UID and GID.
1286 #. ============================================================
1287 #. type: Plain text
1288 #. #-#-#-#-# mageia-cauldron: user_namespaces.7.pot (PACKAGE VERSION) #-#-#-#-#
1289 #. These are the checks performed by the kernel function
1290 #. inode_owner_or_capable(). There is one exception to the exception:
1291 #. overriding the directory sticky permission bit requires that
1292 #. the file has a valid mapping for both its UID and GID.
1293 #. ============================================================
1294 #. type: Plain text
1295 #. #-#-#-#-# opensuse-leap-16-1: user_namespaces.7.pot (PACKAGE VERSION) #-#-#-#-#
1296 #. These are the checks performed by the kernel function
1297 #. inode_owner_or_capable(). There is one exception to the exception:
1298 #. overriding the directory sticky permission bit requires that
1299 #. the file has a valid mapping for both its UID and GID.
1300 #. ============================================================
1301 #. type: Plain text
1302 #. #-#-#-#-# opensuse-tumbleweed: user_namespaces.7.pot (PACKAGE VERSION) #-#-#-#-#
1303 #. These are the checks performed by the kernel function
1304 #. inode_owner_or_capable(). There is one exception to the exception:
1305 #. overriding the directory sticky permission bit requires that
1306 #. the file has a valid mapping for both its UID and GID.
1307 #. ============================================================
1308 #. type: Plain text
1309 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1310 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1311 msgid ""
1312 "The B<CAP_FOWNER> capability is treated somewhat exceptionally: it allows a "
1313 "process to bypass the corresponding rules so long as at least the file's "
1314 "user ID has a mapping in the user namespace (i.e., the file's group ID does "
1315 "not need to have a valid mapping)."
1316 msgstr ""
1317
1318 #. type: SS
1319 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1320 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1321 #, no-wrap
1322 msgid "Set-user-ID and set-group-ID programs"
1323 msgstr ""
1324
1325 #
1326 #. ============================================================
1327 #. type: Plain text
1328 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1329 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1330 msgid ""
1331 "When a process inside a user namespace executes a set-user-ID (set-group-ID) "
1332 "program, the process's effective user (group) ID inside the namespace is "
1333 "changed to whatever value is mapped for the user (group) ID of the file. "
1334 "However, if either the user I<or> the group ID of the file has no mapping "
1335 "inside the namespace, the set-user-ID (set-group-ID) bit is silently "
1336 "ignored: the new program is executed, but the process's effective user "
1337 "(group) ID is left unchanged. (This mirrors the semantics of executing a "
1338 "set-user-ID or set-group-ID program that resides on a filesystem that was "
1339 "mounted with the B<MS_NOSUID> flag, as described in B<mount>(2).)"
1340 msgstr ""
1341
1342 #. type: SS
1343 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1344 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1345 #, no-wrap
1346 msgid "Miscellaneous"
1347 msgstr "Varios"
1348
1349 #. type: Plain text
1350 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1351 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1352 msgid ""
1353 "When a process's user and group IDs are passed over a UNIX domain socket to "
1354 "a process in a different user namespace (see the description of "
1355 "B<SCM_CREDENTIALS> in B<unix>(7)), they are translated into the "
1356 "corresponding values as per the receiving process's user and group ID "
1357 "mappings."
1358 msgstr ""
1359
1360 #. type: SH
1361 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1362 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1363 #, no-wrap
1364 msgid "STANDARDS"
1365 msgstr "ESTÁNDARES"
1366
1367 #. type: Plain text
1368 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1369 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1370 msgid "Linux."
1371 msgstr "Linux."
1372
1373 #. type: SH
1374 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1375 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1376 #, no-wrap
1377 msgid "NOTES"
1378 msgstr "NOTAS"
1379
1380 #
1381 #. ============================================================
1382 #. type: Plain text
1383 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1384 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1385 msgid ""
1386 "Over the years, there have been a lot of features that have been added to "
1387 "the Linux kernel that have been made available only to privileged users "
1388 "because of their potential to confuse set-user-ID-root applications. In "
1389 "general, it becomes safe to allow the root user in a user namespace to use "
1390 "those features because it is impossible, while in a user namespace, to gain "
1391 "more privilege than the root user of a user namespace has."
1392 msgstr ""
1393
1394 #. type: SS
1395 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1396 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1397 #, no-wrap
1398 msgid "Global root"
1399 msgstr ""
1400
1401 #
1402 #. ============================================================
1403 #. type: Plain text
1404 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1405 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1406 msgid ""
1407 "The term \"global root\" is sometimes used as a shorthand for user ID 0 in "
1408 "the initial user namespace."
1409 msgstr ""
1410
1411 #. type: SS
1412 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1413 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1414 #, no-wrap
1415 msgid "Availability"
1416 msgstr ""
1417
1418 #. type: Plain text
1419 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1420 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1421 msgid ""
1422 "Use of user namespaces requires a kernel that is configured with the "
1423 "B<CONFIG_USER_NS> option. User namespaces require support in a range of "
1424 "subsystems across the kernel. When an unsupported subsystem is configured "
1425 "into the kernel, it is not possible to configure user namespaces support."
1426 msgstr ""
1427
1428 #. commit d6970d4b726cea6d7a9bc4120814f95c09571fc3
1429 #. type: Plain text
1430 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1431 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1432 msgid ""
1433 "As at Linux 3.8, most relevant subsystems supported user namespaces, but a "
1434 "number of filesystems did not have the infrastructure needed to map user and "
1435 "group IDs between user namespaces. Linux 3.9 added the required "
1436 "infrastructure support for many of the remaining unsupported filesystems "
1437 "(Plan 9 (9P), Andrew File System (AFS), Ceph, CIFS, CODA, NFS, and OCFS2). "
1438 "Linux 3.12 added support for the last of the unsupported major filesystems, "
1439 "XFS."
1440 msgstr ""
1441
1442 #. type: SH
1443 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1444 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1445 #, no-wrap
1446 msgid "EXAMPLES"
1447 msgstr "EJEMPLOS"
1448
1449 #. type: Plain text
1450 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1451 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1452 msgid ""
1453 "The program below is designed to allow experimenting with user namespaces, "
1454 "as well as other types of namespaces. It creates namespaces as specified by "
1455 "command-line options and then executes a command inside those namespaces. "
1456 "The comments and I<usage>() function inside the program provide a full "
1457 "explanation of the program. The following shell session demonstrates its "
1458 "use."
1459 msgstr ""
1460
1461 #. type: Plain text
1462 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1463 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1464 msgid "First, we look at the run-time environment:"
1465 msgstr ""
1466
1467 #. type: Plain text
1468 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1469 #: opensuse-tumbleweed
1470 #, no-wrap
1471 msgid ""
1472 "$B< uname -rs>; # Need Linux 3.8 or later\n"
1473 "Linux 3.8.0\n"
1474 "$B< id -u>; # Running as unprivileged user\n"
1475 "1000\n"
1476 "$B< id -g>;\n"
1477 "1000\n"
1478 msgstr ""
1479
1480 #. type: Plain text
1481 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1482 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1483 msgid ""
1484 "Now start a new shell in new user (I<-U>), mount (I<-m>), and PID (I<-p>) "
1485 "namespaces, with user ID (I<-M>) and group ID (I<-G>) 1000 mapped to 0 "
1486 "inside the user namespace:"
1487 msgstr ""
1488
1489 #. type: Plain text
1490 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1491 #: opensuse-tumbleweed
1492 #, no-wrap
1493 msgid "$B< ./userns_child_exec -p -m -U -M \\[aq]0 1000 1\\[aq] -G \\[aq]0 1000 1\\[aq] bash>;\n"
1494 msgstr ""
1495
1496 #. type: Plain text
1497 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1498 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1499 msgid ""
1500 "The shell has PID 1, because it is the first process in the new PID "
1501 "namespace:"
1502 msgstr ""
1503
1504 #. type: Plain text
1505 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1506 #: opensuse-tumbleweed
1507 #, no-wrap
1508 msgid ""
1509 "bash$B< echo $$>;\n"
1510 "1\n"
1511 msgstr ""
1512
1513 #. type: Plain text
1514 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1515 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1516 msgid ""
1517 "Mounting a new I</proc> filesystem and listing all of the processes visible "
1518 "in the new PID namespace shows that the shell can't see any processes "
1519 "outside the PID namespace:"
1520 msgstr ""
1521
1522 #. type: Plain text
1523 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1524 #: opensuse-tumbleweed
1525 #, no-wrap
1526 msgid ""
1527 "bash$B< mount -t proc proc /proc>;\n"
1528 "bash$B< ps ax>;\n"
1529 " PID TTY STAT TIME COMMAND\n"
1530 " 1 pts/3 S 0:00 bash\n"
1531 " 22 pts/3 R+ 0:00 ps ax\n"
1532 msgstr ""
1533
1534 #. type: Plain text
1535 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1536 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1537 msgid ""
1538 "Inside the user namespace, the shell has user and group ID 0, and a full set "
1539 "of permitted and effective capabilities:"
1540 msgstr ""
1541
1542 #. type: Plain text
1543 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1544 #: opensuse-tumbleweed
1545 #, no-wrap
1546 msgid ""
1547 "bash$B< cat /proc/$$/status | egrep \\[aq]\\[ha][UG]id\\[aq]>;\n"
1548 "Uid:\t0\t0\t0\t0\n"
1549 "Gid:\t0\t0\t0\t0\n"
1550 "bash$B< cat /proc/$$/status | egrep \\[aq]\\[ha]Cap(Prm|Inh|Eff)\\[aq]>;\n"
1551 "CapInh:\t0000000000000000\n"
1552 "CapPrm:\t0000001fffffffff\n"
1553 "CapEff:\t0000001fffffffff\n"
1554 msgstr ""
1555
1556 #. type: SS
1557 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1558 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1559 #, no-wrap
1560 msgid "Program source"
1561 msgstr "Código fuente"
1562
1563 #. type: Plain text
1564 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1565 #: opensuse-tumbleweed
1566 #, no-wrap
1567 msgid ""
1568 "/* userns_child_exec.c\n"
1569 "\\&\n"
1570 " Licensed under GNU General Public License v2 or later\n"
1571 "\\&\n"
1572 " Create a child process that executes a shell command in new\n"
1573 " namespace(s); allow UID and GID mappings to be specified when\n"
1574 " creating a user namespace.\n"
1575 "*/\n"
1576 "#define _GNU_SOURCE\n"
1577 "#include E<lt>err.hE<gt>\n"
1578 "#include E<lt>sched.hE<gt>\n"
1579 "#include E<lt>unistd.hE<gt>\n"
1580 "#include E<lt>stdint.hE<gt>\n"
1581 "#include E<lt>stdlib.hE<gt>\n"
1582 "#include E<lt>sys/wait.hE<gt>\n"
1583 "#include E<lt>signal.hE<gt>\n"
1584 "#include E<lt>fcntl.hE<gt>\n"
1585 "#include E<lt>stdio.hE<gt>\n"
1586 "#include E<lt>string.hE<gt>\n"
1587 "#include E<lt>limits.hE<gt>\n"
1588 "#include E<lt>errno.hE<gt>\n"
1589 "\\&\n"
1590 "struct child_args {\n"
1591 " char **argv; /* Command to be executed by child, with args */\n"
1592 " int pipe_fd[2]; /* Pipe used to synchronize parent and child */\n"
1593 "};\n"
1594 "\\&\n"
1595 "static int verbose;\n"
1596 "\\&\n"
1597 "static void\n"
1598 "usage(char *pname)\n"
1599 "{\n"
1600 " fprintf(stderr, \"Usage: %s [options] cmd [arg...]\\[rs]n\\[rs]n\", pname);\n"
1601 " fprintf(stderr, \"Create a child process that executes a shell \"\n"
1602 " \"command in a new user namespace,\\[rs]n\"\n"
1603 " \"and possibly also other new namespace(s).\\[rs]n\\[rs]n\");\n"
1604 " fprintf(stderr, \"Options can be:\\[rs]n\\[rs]n\");\n"
1605 "#define fpe(str) fprintf(stderr, \" %s\", str);\n"
1606 " fpe(\"-i New IPC namespace\\[rs]n\");\n"
1607 " fpe(\"-m New mount namespace\\[rs]n\");\n"
1608 " fpe(\"-n New network namespace\\[rs]n\");\n"
1609 " fpe(\"-p New PID namespace\\[rs]n\");\n"
1610 " fpe(\"-u New UTS namespace\\[rs]n\");\n"
1611 " fpe(\"-U New user namespace\\[rs]n\");\n"
1612 " fpe(\"-M uid_map Specify UID map for user namespace\\[rs]n\");\n"
1613 " fpe(\"-G gid_map Specify GID map for user namespace\\[rs]n\");\n"
1614 " fpe(\"-z Map user\\[aq]s UID and GID to 0 in user namespace\\[rs]n\");\n"
1615 " fpe(\" (equivalent to: -M \\[aq]0 E<lt>uidE<gt> 1\\[aq] -G \\[aq]0 E<lt>gidE<gt> 1\\[aq])\\[rs]n\");\n"
1616 " fpe(\"-v Display verbose messages\\[rs]n\");\n"
1617 " fpe(\"\\[rs]n\");\n"
1618 " fpe(\"If -z, -M, or -G is specified, -U is required.\\[rs]n\");\n"
1619 " fpe(\"It is not permitted to specify both -z and either -M or -G.\\[rs]n\");\n"
1620 " fpe(\"\\[rs]n\");\n"
1621 " fpe(\"Map strings for -M and -G consist of records of the form:\\[rs]n\");\n"
1622 " fpe(\"\\[rs]n\");\n"
1623 " fpe(\" ID-inside-ns ID-outside-ns size\\[rs]n\");\n"
1624 " fpe(\"\\[rs]n\");\n"
1625 " fpe(\"A map string can contain multiple records, separated\"\n"
1626 " \" by commas;\\[rs]n\");\n"
1627 " fpe(\"the commas are replaced by newlines before writing\"\n"
1628 " \" to map files.\\[rs]n\");\n"
1629 "\\&\n"
1630 " exit(EXIT_FAILURE);\n"
1631 "}\n"
1632 "\\&\n"
1633 "/* Update the mapping file \\[aq]map_file\\[aq], with the value provided in\n"
1634 " \\[aq]mapping\\[aq], a string that defines a UID or GID mapping. A UID or\n"
1635 " GID mapping consists of one or more newline-delimited records\n"
1636 " of the form:\n"
1637 "\\&\n"
1638 " ID_inside-ns ID-outside-ns size\n"
1639 "\\&\n"
1640 " Requiring the user to supply a string that contains newlines is\n"
1641 " of course inconvenient for command-line use. Thus, we permit the\n"
1642 " use of commas to delimit records in this string, and replace them\n"
1643 " with newlines before writing the string to the file. */\n"
1644 "\\&\n"
1645 "static void\n"
1646 "update_map(char *mapping, char *map_file)\n"
1647 "{\n"
1648 " int fd;\n"
1649 " size_t map_len; /* Length of \\[aq]mapping\\[aq] */\n"
1650 "\\&\n"
1651 " /* Replace commas in mapping string with newlines. */\n"
1652 "\\&\n"
1653 " map_len = strlen(mapping);\n"
1654 " for (size_t j = 0; j E<lt> map_len; j++)\n"
1655 " if (mapping[j] == \\[aq],\\[aq])\n"
1656 " mapping[j] = \\[aq]\\[rs]n\\[aq];\n"
1657 "\\&\n"
1658 " fd = open(map_file, O_RDWR);\n"
1659 " if (fd == -1) {\n"
1660 " fprintf(stderr, \"ERROR: open %s: %s\\[rs]n\", map_file,\n"
1661 " strerror(errno));\n"
1662 " exit(EXIT_FAILURE);\n"
1663 " }\n"
1664 "\\&\n"
1665 " if (write(fd, mapping, map_len) != map_len) {\n"
1666 " fprintf(stderr, \"ERROR: write %s: %s\\[rs]n\", map_file,\n"
1667 " strerror(errno));\n"
1668 " exit(EXIT_FAILURE);\n"
1669 " }\n"
1670 "\\&\n"
1671 " close(fd);\n"
1672 "}\n"
1673 "\\&\n"
1674 "/* Linux 3.19 made a change in the handling of setgroups(2) and\n"
1675 " the \\[aq]gid_map\\[aq] file to address a security issue. The issue\n"
1676 " allowed *unprivileged* users to employ user namespaces in\n"
1677 " order to drop groups. The upshot of the 3.19 changes is that\n"
1678 " in order to update the \\[aq]gid_maps\\[aq] file, use of the setgroups()\n"
1679 " system call in this user namespace must first be disabled by\n"
1680 " writing \"deny\" to one of the /proc/PID/setgroups files for\n"
1681 " this namespace. That is the purpose of the following function. */\n"
1682 "\\&\n"
1683 "static void\n"
1684 "proc_setgroups_write(pid_t child_pid, char *str)\n"
1685 "{\n"
1686 " char setgroups_path[PATH_MAX];\n"
1687 " int fd;\n"
1688 "\\&\n"
1689 " snprintf(setgroups_path, PATH_MAX, \"/proc/%jd/setgroups\",\n"
1690 " (intmax_t) child_pid);\n"
1691 "\\&\n"
1692 " fd = open(setgroups_path, O_RDWR);\n"
1693 " if (fd == -1) {\n"
1694 "\\&\n"
1695 " /* We may be on a system that doesn\\[aq]t support\n"
1696 " /proc/PID/setgroups. In that case, the file won\\[aq]t exist,\n"
1697 " and the system won\\[aq]t impose the restrictions that Linux 3.19\n"
1698 " added. That\\[aq]s fine: we don\\[aq]t need to do anything in order\n"
1699 " to permit \\[aq]gid_map\\[aq] to be updated.\n"
1700 "\\&\n"
1701 " However, if the error from open() was something other than\n"
1702 " the ENOENT error that is expected for that case, let the\n"
1703 " user know. */\n"
1704 "\\&\n"
1705 " if (errno != ENOENT)\n"
1706 " fprintf(stderr, \"ERROR: open %s: %s\\[rs]n\", setgroups_path,\n"
1707 " strerror(errno));\n"
1708 " return;\n"
1709 " }\n"
1710 "\\&\n"
1711 " if (write(fd, str, strlen(str)) == -1)\n"
1712 " fprintf(stderr, \"ERROR: write %s: %s\\[rs]n\", setgroups_path,\n"
1713 " strerror(errno));\n"
1714 "\\&\n"
1715 " close(fd);\n"
1716 "}\n"
1717 "\\&\n"
1718 "static int /* Start function for cloned child */\n"
1719 "childFunc(void *arg)\n"
1720 "{\n"
1721 " struct child_args *args = arg;\n"
1722 " char ch;\n"
1723 "\\&\n"
1724 " /* Wait until the parent has updated the UID and GID mappings.\n"
1725 " See the comment in main(). We wait for end of file on a\n"
1726 " pipe that will be closed by the parent process once it has\n"
1727 " updated the mappings. */\n"
1728 "\\&\n"
1729 " close(args-E<gt>pipe_fd[1]); /* Close our descriptor for the write\n"
1730 " end of the pipe so that we see EOF\n"
1731 " when parent closes its descriptor. */\n"
1732 " if (read(args-E<gt>pipe_fd[0], &ch, 1) != 0) {\n"
1733 " fprintf(stderr,\n"
1734 " \"Failure in child: read from pipe returned != 0\\[rs]n\");\n"
1735 " exit(EXIT_FAILURE);\n"
1736 " }\n"
1737 "\\&\n"
1738 " close(args-E<gt>pipe_fd[0]);\n"
1739 "\\&\n"
1740 " /* Execute a shell command. */\n"
1741 "\\&\n"
1742 " printf(\"About to exec %s\\[rs]n\", args-E<gt>argv[0]);\n"
1743 " execvp(args-E<gt>argv[0], args-E<gt>argv);\n"
1744 " err(EXIT_FAILURE, \"execvp\");\n"
1745 "}\n"
1746 "\\&\n"
1747 "#define STACK_SIZE (1024 * 1024)\n"
1748 "\\&\n"
1749 "static char child_stack[STACK_SIZE]; /* Space for child\\[aq]s stack */\n"
1750 "\\&\n"
1751 "int\n"
1752 "main(int argc, char *argv[])\n"
1753 "{\n"
1754 " int flags, opt, map_zero;\n"
1755 " pid_t child_pid;\n"
1756 " struct child_args args;\n"
1757 " char *uid_map, *gid_map;\n"
1758 " const int MAP_BUF_SIZE = 100;\n"
1759 " char map_buf[MAP_BUF_SIZE];\n"
1760 " char map_path[PATH_MAX];\n"
1761 "\\&\n"
1762 " /* Parse command-line options. The initial \\[aq]+\\[aq] character in\n"
1763 " the final getopt() argument prevents GNU-style permutation\n"
1764 " of command-line options. That\\[aq]s useful, since sometimes\n"
1765 " the \\[aq]command\\[aq] to be executed by this program itself\n"
1766 " has command-line options. We don\\[aq]t want getopt() to treat\n"
1767 " those as options to this program. */\n"
1768 "\\&\n"
1769 " flags = 0;\n"
1770 " verbose = 0;\n"
1771 " gid_map = NULL;\n"
1772 " uid_map = NULL;\n"
1773 " map_zero = 0;\n"
1774 " while ((opt = getopt(argc, argv, \"+imnpuUM:G:zv\")) != -1) {\n"
1775 " switch (opt) {\n"
1776 " case \\[aq]i\\[aq]: flags |= CLONE_NEWIPC; break;\n"
1777 " case \\[aq]m\\[aq]: flags |= CLONE_NEWNS; break;\n"
1778 " case \\[aq]n\\[aq]: flags |= CLONE_NEWNET; break;\n"
1779 " case \\[aq]p\\[aq]: flags |= CLONE_NEWPID; break;\n"
1780 " case \\[aq]u\\[aq]: flags |= CLONE_NEWUTS; break;\n"
1781 " case \\[aq]v\\[aq]: verbose = 1; break;\n"
1782 " case \\[aq]z\\[aq]: map_zero = 1; break;\n"
1783 " case \\[aq]M\\[aq]: uid_map = optarg; break;\n"
1784 " case \\[aq]G\\[aq]: gid_map = optarg; break;\n"
1785 " case \\[aq]U\\[aq]: flags |= CLONE_NEWUSER; break;\n"
1786 " default: usage(argv[0]);\n"
1787 " }\n"
1788 " }\n"
1789 "\\&\n"
1790 " /* -M or -G without -U is nonsensical */\n"
1791 "\\&\n"
1792 " if (((uid_map != NULL || gid_map != NULL || map_zero) &&\n"
1793 " !(flags & CLONE_NEWUSER)) ||\n"
1794 " (map_zero && (uid_map != NULL || gid_map != NULL)))\n"
1795 " usage(argv[0]);\n"
1796 "\\&\n"
1797 " args.argv = &argv[optind];\n"
1798 "\\&\n"
1799 " /* We use a pipe to synchronize the parent and child, in order to\n"
1800 " ensure that the parent sets the UID and GID maps before the child\n"
1801 " calls execve(). This ensures that the child maintains its\n"
1802 " capabilities during the execve() in the common case where we\n"
1803 " want to map the child\\[aq]s effective user ID to 0 in the new user\n"
1804 " namespace. Without this synchronization, the child would lose\n"
1805 " its capabilities if it performed an execve() with nonzero\n"
1806 " user IDs (see the capabilities(7) man page for details of the\n"
1807 " transformation of a process\\[aq]s capabilities during execve()). */\n"
1808 "\\&\n"
1809 " if (pipe(args.pipe_fd) == -1)\n"
1810 " err(EXIT_FAILURE, \"pipe\");\n"
1811 "\\&\n"
1812 " /* Create the child in new namespace(s). */\n"
1813 "\\&\n"
1814 " child_pid = clone(childFunc, child_stack + STACK_SIZE,\n"
1815 " flags | SIGCHLD, &args);\n"
1816 " if (child_pid == -1)\n"
1817 " err(EXIT_FAILURE, \"clone\");\n"
1818 "\\&\n"
1819 " /* Parent falls through to here. */\n"
1820 "\\&\n"
1821 " if (verbose)\n"
1822 " printf(\"%s: PID of child created by clone() is %jd\\[rs]n\",\n"
1823 " argv[0], (intmax_t) child_pid);\n"
1824 "\\&\n"
1825 " /* Update the UID and GID maps in the child. */\n"
1826 "\\&\n"
1827 " if (uid_map != NULL || map_zero) {\n"
1828 " snprintf(map_path, PATH_MAX, \"/proc/%jd/uid_map\",\n"
1829 " (intmax_t) child_pid);\n"
1830 " if (map_zero) {\n"
1831 " snprintf(map_buf, MAP_BUF_SIZE, \"0 %jd 1\",\n"
1832 " (intmax_t) getuid());\n"
1833 " uid_map = map_buf;\n"
1834 " }\n"
1835 " update_map(uid_map, map_path);\n"
1836 " }\n"
1837 "\\&\n"
1838 " if (gid_map != NULL || map_zero) {\n"
1839 " proc_setgroups_write(child_pid, \"deny\");\n"
1840 "\\&\n"
1841 " snprintf(map_path, PATH_MAX, \"/proc/%jd/gid_map\",\n"
1842 " (intmax_t) child_pid);\n"
1843 " if (map_zero) {\n"
1844 " snprintf(map_buf, MAP_BUF_SIZE, \"0 %ld 1\",\n"
1845 " (intmax_t) getgid());\n"
1846 " gid_map = map_buf;\n"
1847 " }\n"
1848 " update_map(gid_map, map_path);\n"
1849 " }\n"
1850 "\\&\n"
1851 " /* Close the write end of the pipe, to signal to the child that we\n"
1852 " have updated the UID and GID maps. */\n"
1853 "\\&\n"
1854 " close(args.pipe_fd[1]);\n"
1855 "\\&\n"
1856 " if (waitpid(child_pid, NULL, 0) == -1) /* Wait for child */\n"
1857 " err(EXIT_FAILURE, \"waitpid\");\n"
1858 "\\&\n"
1859 " if (verbose)\n"
1860 " printf(\"%s: terminating\\[rs]n\", argv[0]);\n"
1861 "\\&\n"
1862 " exit(EXIT_SUCCESS);\n"
1863 "}\n"
1864 msgstr ""
1865
1866 #. type: SH
1867 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1868 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1869 #, no-wrap
1870 msgid "SEE ALSO"
1871 msgstr "VÉASE TAMBIÉN"
1872
1873 #. From the shadow package
1874 #. From the shadow package
1875 #. From the shadow package
1876 #. From the shadow package
1877 #. type: Plain text
1878 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1879 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1880 msgid ""
1881 "B<newgidmap>(1), B<newuidmap>(1), B<clone>(2), B<ptrace>(2), B<setns>(2), "
1882 "B<unshare>(2), B<proc>(5), B<subgid>(5), B<subuid>(5), B<capabilities>(7), "
1883 "B<cgroup_namespaces>(7), B<credentials>(7), B<namespaces>(7), "
1884 "B<pid_namespaces>(7)"
1885 msgstr ""
1886
1887 #. type: Plain text
1888 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1889 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1890 msgid ""
1891 "The kernel source file I<Documentation/admin-guide/namespaces/resource-"
1892 "control.rst>."
1893 msgstr ""
1894
1895 #. type: TH
1896 #: debian-trixie
1897 #, no-wrap
1898 msgid "2024-06-15"
1899 msgstr "15 Junio 2024"
1900
1901 #. type: TH
1902 #: debian-trixie
1903 #, no-wrap
1904 msgid "Linux man-pages 6.9.1"
1905 msgstr "Páginas de Manual de Linux 6.9.1"
1906
1907 #. type: Plain text
1908 #: debian-trixie fedora-44 fedora-rawhide
1909 msgid ""
1910 "User namespaces can be nested; that is, each user namespace\\[em]except the "
1911 "initial (\"root\") namespace\\[em]has a parent user namespace, and can have "
1912 "zero or more child user namespaces. The parent user namespace is the user "
1913 "namespace of the process that creates the user namespace via a call to "
1914 "B<unshare>(2) or B<clone>(2) with the B<CLONE_NEWUSER> flag."
1915 msgstr ""
1916
1917 #. commit 8742f229b635bf1c1c84a3dfe5e47c814c20b5c8
1918 #. FIXME Explain the rationale for this limit. (What is the rationale?)
1919 #. type: Plain text
1920 #: debian-trixie fedora-44 fedora-rawhide
1921 msgid ""
1922 "The kernel imposes (since Linux 3.11) a limit of 32 nested levels of user "
1923 "namespaces. Calls to B<unshare>(2) or B<clone>(2) that would cause this "
1924 "limit to be exceeded fail with the error B<EUSERS>."
1925 msgstr ""
1926
1927 #
1928 #. ============================================================
1929 #. type: Plain text
1930 #: debian-trixie fedora-44 fedora-rawhide
1931 msgid ""
1932 "A task that changes one of its effective IDs will have its dumpability reset "
1933 "to the value in I</proc/sys/fs/suid_dumpable>. This may affect the "
1934 "ownership of proc files of child processes and may thus cause the parent to "
1935 "lack the permissions to write to mapping files of child processes running in "
1936 "a new user namespace. In such cases making the parent process dumpable, "
1937 "using B<PR_SET_DUMPABLE> in a call to B<prctl>(2), before creating a child "
1938 "process in a new user namespace may rectify this problem. See B<prctl>(2) "
1939 "and B<proc>(5) for details on how ownership is affected."
1940 msgstr ""
1941
1942 #. type: Plain text
1943 #: debian-trixie fedora-44 fedora-rawhide
1944 msgid ""
1945 "A call to B<clone>(2) or B<unshare>(2) using the B<CLONE_NEWUSER> flag or "
1946 "a call to B<setns>(2) that moves the caller into another user namespace "
1947 "sets the \"securebits\" flags (see B<capabilities>(7)) to their default "
1948 "values (all flags disabled) in the child (for B<clone>(2)) or caller (for "
1949 "B<unshare>(2) or B<setns>(2)). Note that because the caller no longer has "
1950 "capabilities in its original user namespace after a call to B<setns>(2), it "
1951 "is not possible for a process to reset its \"securebits\" flags while "
1952 "retaining its user namespace membership by using a pair of B<setns>(2) "
1953 "calls to move to another user namespace and then return to its original user "
1954 "namespace."
1955 msgstr ""
1956
1957 #. type: Plain text
1958 #: debian-trixie fedora-44 fedora-rawhide
1959 msgid ""
1960 "If a process has a capability in a user namespace, then it has that "
1961 "capability in all child (and further removed descendant) namespaces as well."
1962 msgstr ""
1963
1964 #. type: Plain text
1965 #: debian-trixie fedora-44 fedora-rawhide
1966 msgid ""
1967 "Having a capability inside a user namespace permits a process to perform "
1968 "operations (that require privilege) only on resources governed by that "
1969 "namespace. In other words, having a capability in a user namespace permits "
1970 "a process to perform privileged operations on resources that are governed by "
1971 "(nonuser) namespaces owned by (associated with) the user namespace (see the "
1972 "next subsection)."
1973 msgstr ""
1974
1975 #. type: Plain text
1976 #: debian-trixie
1977 msgid ""
1978 "Holding B<CAP_SYS_ADMIN> within the user namespace that owns a process's "
1979 "cgroup namespace allows (since Linux 4.6) that process to the mount the "
1980 "cgroup version 2 filesystem and cgroup version 1 named hierarchies (i.e., "
1981 "cgroup filesystems mounted with the I<\\[dq]none,name=\\[dq]> option)."
1982 msgstr ""
1983
1984 #
1985 #. ============================================================
1986 #. type: Plain text
1987 #: debian-trixie fedora-44 fedora-rawhide
1988 msgid ""
1989 "Note, however, that mounting block-based filesystems can be done only by a "
1990 "process that holds B<CAP_SYS_ADMIN> in the initial user namespace."
1991 msgstr ""
1992
1993 #. type: Plain text
1994 #: debian-trixie
1995 msgid ""
1996 "Starting in Linux 3.8, unprivileged processes can create user namespaces, "
1997 "and the other types of namespaces can be created with just the "
1998 "B<CAP_SYS_ADMIN> capability in the caller's user namespace."
1999 msgstr ""
2000
2001 #. type: Plain text
2002 #: debian-trixie fedora-44 fedora-rawhide
2003 msgid ""
2004 "When a new namespace (other than a user namespace) is created via "
2005 "B<clone>(2) or B<unshare>(2), the kernel records the user namespace of the "
2006 "creating process as the owner of the new namespace. (This association can't "
2007 "be changed.) When a process in the new namespace subsequently performs "
2008 "privileged operations that operate on global resources isolated by the "
2009 "namespace, the permission checks are performed according to the process's "
2010 "capabilities in the user namespace that the kernel associated with the new "
2011 "namespace. For example, suppose that a process attempts to change the "
2012 "hostname (B<sethostname>(2)), a resource governed by the UTS namespace. In "
2013 "this case, the kernel will determine which user namespace owns the process's "
2014 "UTS namespace, and check whether the process has the required capability "
2015 "(B<CAP_SYS_ADMIN>) in that user namespace."
2016 msgstr ""
2017
2018 #. type: Plain text
2019 #: debian-trixie
2020 msgid ""
2021 "Each line in the I<uid_map> file specifies a 1-to-1 mapping of a range of "
2022 "contiguous user IDs between two user namespaces. (When a user namespace is "
2023 "first created, this file is empty.) The specification in each line takes "
2024 "the form of three numbers delimited by white space. The first two numbers "
2025 "specify the starting user ID in each of the two user namespaces. The third "
2026 "number specifies the length of the mapped range. In detail, the fields are "
2027 "interpreted as follows:"
2028 msgstr ""
2029
2030 #. type: Plain text
2031 #: debian-trixie
2032 msgid ""
2033 "The length of the range of user IDs that is mapped between the two user "
2034 "namespaces."
2035 msgstr ""
2036
2037 #. type: Plain text
2038 #: debian-trixie fedora-44 fedora-rawhide
2039 msgid ""
2040 "The initial user namespace has no parent namespace, but, for consistency, "
2041 "the kernel provides dummy user and group ID mapping files for this "
2042 "namespace. Looking at the I<uid_map> file (I<gid_map> is the same) from a "
2043 "shell in the initial namespace shows:"
2044 msgstr ""
2045
2046 #. type: Plain text
2047 #: debian-trixie fedora-44 fedora-rawhide
2048 #, no-wrap
2049 msgid ""
2050 "$ B<cat /proc/$$/uid_map>\n"
2051 " 0 0 4294967295\n"
2052 msgstr ""
2053
2054 #
2055 #. ============================================================
2056 #. type: Plain text
2057 #: debian-trixie
2058 msgid ""
2059 "This mapping tells us that the range starting at user ID 0 in this namespace "
2060 "maps to a range starting at 0 in the (nonexistent) parent namespace, and the "
2061 "length of the range is the largest 32-bit unsigned integer. This leaves "
2062 "4294967295 (the 32-bit signed -1 value) unmapped. This is deliberate: "
2063 "I<(uid_t)\\ -1> is used in several interfaces (e.g., B<setreuid>(2)) as a "
2064 "way to specify \"no user ID\". Leaving I<(uid_t)\\ -1> unmapped and "
2065 "unusable guarantees that there will be no confusion when using these "
2066 "interfaces."
2067 msgstr ""
2068
2069 #. 5*12-byte records could fit in a 64B cache line
2070 #. commit 6397fac4915ab3002dc15aae751455da1a852f25
2071 #. type: Plain text
2072 #: debian-trixie fedora-44 fedora-rawhide
2073 msgid ""
2074 "There is a limit on the number of lines in the file. In Linux 4.14 and "
2075 "earlier, this limit was (arbitrarily) set at 5 lines. Since Linux 4.15, "
2076 "the limit is 340 lines. In addition, the number of bytes written to the "
2077 "file must be less than the system page size, and the write must be performed "
2078 "at the start of the file (i.e., B<lseek>(2) and B<pwrite>(2) can't be used "
2079 "to write to nonzero offsets in the file)."
2080 msgstr ""
2081
2082 #. commit 0bd14b4fd72afd5df41e9fd59f356740f22fceba
2083 #. type: Plain text
2084 #: debian-trixie fedora-44 fedora-rawhide
2085 msgid ""
2086 "The range of user IDs (group IDs) specified in each line cannot overlap "
2087 "with the ranges in any other lines. In the initial implementation (Linux "
2088 "3.8), this requirement was satisfied by a simplistic implementation that "
2089 "imposed the further requirement that the values in both field 1 and field 2 "
2090 "of successive lines must be in ascending numerical order, which prevented "
2091 "some otherwise valid maps from being created. Linux 3.9 and later fix this "
2092 "limitation, allowing any valid set of nonoverlapping maps."
2093 msgstr ""
2094
2095 #. type: Plain text
2096 #: debian-trixie fedora-44 fedora-rawhide
2097 msgid ""
2098 "The data written to I<uid_map> (I<gid_map>) must consist of a single line "
2099 "that maps the writing process's effective user ID (group ID) in the parent "
2100 "user namespace to a user ID (group ID) in the user namespace."
2101 msgstr ""
2102
2103 #. type: Plain text
2104 #: debian-trixie fedora-44 fedora-rawhide
2105 msgid ""
2106 "In the case of I<gid_map>, use of the B<setgroups>(2) system call must "
2107 "first be denied by writing \\[dq]I<deny>\\[dq] to the I</proc/>pidI</"
2108 "setgroups> file (see below) before writing to I<gid_map>."
2109 msgstr ""
2110
2111 #. type: SS
2112 #: debian-trixie fedora-44 fedora-rawhide
2113 #, no-wrap
2114 msgid "The I</proc/>pidI</setgroups> file"
2115 msgstr ""
2116
2117 #. type: Plain text
2118 #: debian-trixie fedora-44 fedora-rawhide
2119 msgid ""
2120 "A privileged process (one with the B<CAP_SYS_ADMIN> capability in the "
2121 "namespace) may write either of the strings \\[dq]I<allow>\\[dq] or \\"
2122 "[dq]I<deny>\\[dq] to this file I<before> writing a group ID mapping for this "
2123 "user namespace to the file I</proc/>pidI</gid_map>. Writing the string \\"
2124 "[dq]I<deny>\\[dq] prevents any process in the user namespace from employing "
2125 "B<setgroups>(2)."
2126 msgstr ""
2127
2128 #. type: Plain text
2129 #: debian-trixie fedora-44 fedora-rawhide
2130 msgid ""
2131 "If the I<setgroups> file has the value \\[dq]I<deny>\\[dq], then the "
2132 "B<setgroups>(2) system call can't subsequently be reenabled (by writing \\"
2133 "[dq]I<allow>\\[dq] to the file) in this user namespace. (Attempts to do so "
2134 "fail with the error B<EPERM>.) This restriction also propagates down to all "
2135 "child user namespaces of this user namespace."
2136 msgstr ""
2137
2138 #
2139 #
2140 #
2141 #
2142 #. /proc/PID/setgroups
2143 #. [allow == setgroups() is allowed, "deny" == setgroups() is disallowed]
2144 #. * Can write if have CAP_SYS_ADMIN in NS
2145 #. * Must write BEFORE writing to /proc/PID/gid_map
2146 #. setgroups()
2147 #. * Must already have written to gid_map
2148 #. * /proc/PID/setgroups must be "allow"
2149 #. /proc/PID/gid_map -- writing
2150 #. * Must already have written "deny" to /proc/PID/setgroups
2151 #. ============================================================
2152 #. type: Plain text
2153 #: debian-trixie fedora-44 fedora-rawhide
2154 msgid ""
2155 "The I</proc/>pidI</setgroups> file was added in Linux 3.19, but was "
2156 "backported to many earlier stable kernel series, because it addresses a "
2157 "security issue. The issue concerned files with permissions such as \"rwx---"
2158 "rwx\". Such files give fewer permissions to \"group\" than they do to "
2159 "\"other\". This means that dropping groups using B<setgroups>(2) might "
2160 "allow a process file access that it did not formerly have. Before the "
2161 "existence of user namespaces this was not a concern, since only a privileged "
2162 "process (one with the B<CAP_SETGID> capability) could call B<setgroups>(2). "
2163 "However, with the introduction of user namespaces, it became possible for an "
2164 "unprivileged process to create a new namespace in which the user had all "
2165 "privileges. This then allowed formerly unprivileged users to drop groups "
2166 "and thus gain file access that they did not previously have. The I</proc/"
2167 ">pidI</setgroups> file was added to address this security issue, by denying "
2168 "any pathway for an unprivileged process to drop groups with B<setgroups>(2)."
2169 msgstr ""
2170
2171 #. type: Plain text
2172 #: debian-trixie fedora-44 fedora-rawhide
2173 #, no-wrap
2174 msgid ""
2175 "$ B<uname -rs> # Need Linux 3.8 or later\n"
2176 "Linux 3.8.0\n"
2177 "$ B<id -u> # Running as unprivileged user\n"
2178 "1000\n"
2179 "$ B<id -g>\n"
2180 "1000\n"
2181 msgstr ""
2182
2183 #. type: Plain text
2184 #: debian-trixie fedora-44 fedora-rawhide
2185 #, no-wrap
2186 msgid "$ B<./userns_child_exec -p -m -U -M \\[aq]0 1000 1\\[aq] -G \\[aq]0 1000 1\\[aq] bash>\n"
2187 msgstr ""
2188
2189 #. type: Plain text
2190 #: debian-trixie fedora-44 fedora-rawhide
2191 #, no-wrap
2192 msgid ""
2193 "bash$ B<echo $$>\n"
2194 "1\n"
2195 msgstr ""
2196
2197 #. type: Plain text
2198 #: debian-trixie fedora-44 fedora-rawhide
2199 #, no-wrap
2200 msgid ""
2201 "bash$ B<mount -t proc proc /proc>\n"
2202 "bash$ B<ps ax>\n"
2203 " PID TTY STAT TIME COMMAND\n"
2204 " 1 pts/3 S 0:00 bash\n"
2205 " 22 pts/3 R+ 0:00 ps ax\n"
2206 msgstr ""
2207
2208 #. type: Plain text
2209 #: debian-trixie fedora-44 fedora-rawhide
2210 #, no-wrap
2211 msgid ""
2212 "bash$ B<cat /proc/$$/status | egrep \\[aq]\\[ha][UG]id\\[aq]>\n"
2213 "Uid:\t0\t0\t0\t0\n"
2214 "Gid:\t0\t0\t0\t0\n"
2215 "bash$ B<cat /proc/$$/status | egrep \\[aq]\\[ha]Cap(Prm|Inh|Eff)\\[aq]>\n"
2216 "CapInh:\t0000000000000000\n"
2217 "CapPrm:\t0000001fffffffff\n"
2218 "CapEff:\t0000001fffffffff\n"
2219 msgstr ""
2220
2221 #. type: Plain text
2222 #: debian-trixie
2223 #, no-wrap
2224 msgid ""
2225 "/* userns_child_exec.c\n"
2226 "\\&\n"
2227 " Licensed under GNU General Public License v2 or later\n"
2228 "\\&\n"
2229 " Create a child process that executes a shell command in new\n"
2230 " namespace(s); allow UID and GID mappings to be specified when\n"
2231 " creating a user namespace.\n"
2232 "*/\n"
2233 "#define _GNU_SOURCE\n"
2234 "#include E<lt>err.hE<gt>\n"
2235 "#include E<lt>sched.hE<gt>\n"
2236 "#include E<lt>unistd.hE<gt>\n"
2237 "#include E<lt>stdint.hE<gt>\n"
2238 "#include E<lt>stdlib.hE<gt>\n"
2239 "#include E<lt>sys/wait.hE<gt>\n"
2240 "#include E<lt>signal.hE<gt>\n"
2241 "#include E<lt>fcntl.hE<gt>\n"
2242 "#include E<lt>stdio.hE<gt>\n"
2243 "#include E<lt>string.hE<gt>\n"
2244 "#include E<lt>limits.hE<gt>\n"
2245 "#include E<lt>errno.hE<gt>\n"
2246 "\\&\n"
2247 "struct child_args {\n"
2248 " char **argv; /* Command to be executed by child, with args */\n"
2249 " int pipe_fd[2]; /* Pipe used to synchronize parent and child */\n"
2250 "};\n"
2251 "\\&\n"
2252 "static int verbose;\n"
2253 "\\&\n"
2254 "static void\n"
2255 "usage(char *pname)\n"
2256 "{\n"
2257 " fprintf(stderr, \"Usage: %s [options] cmd [arg...]\\[rs]n\\[rs]n\", pname);\n"
2258 " fprintf(stderr, \"Create a child process that executes a shell \"\n"
2259 " \"command in a new user namespace,\\[rs]n\"\n"
2260 " \"and possibly also other new namespace(s).\\[rs]n\\[rs]n\");\n"
2261 " fprintf(stderr, \"Options can be:\\[rs]n\\[rs]n\");\n"
2262 "#define fpe(str) fprintf(stderr, \" %s\", str);\n"
2263 " fpe(\"-i New IPC namespace\\[rs]n\");\n"
2264 " fpe(\"-m New mount namespace\\[rs]n\");\n"
2265 " fpe(\"-n New network namespace\\[rs]n\");\n"
2266 " fpe(\"-p New PID namespace\\[rs]n\");\n"
2267 " fpe(\"-u New UTS namespace\\[rs]n\");\n"
2268 " fpe(\"-U New user namespace\\[rs]n\");\n"
2269 " fpe(\"-M uid_map Specify UID map for user namespace\\[rs]n\");\n"
2270 " fpe(\"-G gid_map Specify GID map for user namespace\\[rs]n\");\n"
2271 " fpe(\"-z Map user\\[aq]s UID and GID to 0 in user namespace\\[rs]n\");\n"
2272 " fpe(\" (equivalent to: -M \\[aq]0 E<lt>uidE<gt> 1\\[aq] -G \\[aq]0 E<lt>gidE<gt> 1\\[aq])\\[rs]n\");\n"
2273 " fpe(\"-v Display verbose messages\\[rs]n\");\n"
2274 " fpe(\"\\[rs]n\");\n"
2275 " fpe(\"If -z, -M, or -G is specified, -U is required.\\[rs]n\");\n"
2276 " fpe(\"It is not permitted to specify both -z and either -M or -G.\\[rs]n\");\n"
2277 " fpe(\"\\[rs]n\");\n"
2278 " fpe(\"Map strings for -M and -G consist of records of the form:\\[rs]n\");\n"
2279 " fpe(\"\\[rs]n\");\n"
2280 " fpe(\" ID-inside-ns ID-outside-ns len\\[rs]n\");\n"
2281 " fpe(\"\\[rs]n\");\n"
2282 " fpe(\"A map string can contain multiple records, separated\"\n"
2283 " \" by commas;\\[rs]n\");\n"
2284 " fpe(\"the commas are replaced by newlines before writing\"\n"
2285 " \" to map files.\\[rs]n\");\n"
2286 "\\&\n"
2287 " exit(EXIT_FAILURE);\n"
2288 "}\n"
2289 "\\&\n"
2290 "/* Update the mapping file \\[aq]map_file\\[aq], with the value provided in\n"
2291 " \\[aq]mapping\\[aq], a string that defines a UID or GID mapping. A UID or\n"
2292 " GID mapping consists of one or more newline-delimited records\n"
2293 " of the form:\n"
2294 "\\&\n"
2295 " ID_inside-ns ID-outside-ns length\n"
2296 "\\&\n"
2297 " Requiring the user to supply a string that contains newlines is\n"
2298 " of course inconvenient for command-line use. Thus, we permit the\n"
2299 " use of commas to delimit records in this string, and replace them\n"
2300 " with newlines before writing the string to the file. */\n"
2301 "\\&\n"
2302 "static void\n"
2303 "update_map(char *mapping, char *map_file)\n"
2304 "{\n"
2305 " int fd;\n"
2306 " size_t map_len; /* Length of \\[aq]mapping\\[aq] */\n"
2307 "\\&\n"
2308 " /* Replace commas in mapping string with newlines. */\n"
2309 "\\&\n"
2310 " map_len = strlen(mapping);\n"
2311 " for (size_t j = 0; j E<lt> map_len; j++)\n"
2312 " if (mapping[j] == \\[aq],\\[aq])\n"
2313 " mapping[j] = \\[aq]\\[rs]n\\[aq];\n"
2314 "\\&\n"
2315 " fd = open(map_file, O_RDWR);\n"
2316 " if (fd == -1) {\n"
2317 " fprintf(stderr, \"ERROR: open %s: %s\\[rs]n\", map_file,\n"
2318 " strerror(errno));\n"
2319 " exit(EXIT_FAILURE);\n"
2320 " }\n"
2321 "\\&\n"
2322 " if (write(fd, mapping, map_len) != map_len) {\n"
2323 " fprintf(stderr, \"ERROR: write %s: %s\\[rs]n\", map_file,\n"
2324 " strerror(errno));\n"
2325 " exit(EXIT_FAILURE);\n"
2326 " }\n"
2327 "\\&\n"
2328 " close(fd);\n"
2329 "}\n"
2330 "\\&\n"
2331 "/* Linux 3.19 made a change in the handling of setgroups(2) and\n"
2332 " the \\[aq]gid_map\\[aq] file to address a security issue. The issue\n"
2333 " allowed *unprivileged* users to employ user namespaces in\n"
2334 " order to drop groups. The upshot of the 3.19 changes is that\n"
2335 " in order to update the \\[aq]gid_maps\\[aq] file, use of the setgroups()\n"
2336 " system call in this user namespace must first be disabled by\n"
2337 " writing \"deny\" to one of the /proc/PID/setgroups files for\n"
2338 " this namespace. That is the purpose of the following function. */\n"
2339 "\\&\n"
2340 "static void\n"
2341 "proc_setgroups_write(pid_t child_pid, char *str)\n"
2342 "{\n"
2343 " char setgroups_path[PATH_MAX];\n"
2344 " int fd;\n"
2345 "\\&\n"
2346 " snprintf(setgroups_path, PATH_MAX, \"/proc/%jd/setgroups\",\n"
2347 " (intmax_t) child_pid);\n"
2348 "\\&\n"
2349 " fd = open(setgroups_path, O_RDWR);\n"
2350 " if (fd == -1) {\n"
2351 "\\&\n"
2352 " /* We may be on a system that doesn\\[aq]t support\n"
2353 " /proc/PID/setgroups. In that case, the file won\\[aq]t exist,\n"
2354 " and the system won\\[aq]t impose the restrictions that Linux 3.19\n"
2355 " added. That\\[aq]s fine: we don\\[aq]t need to do anything in order\n"
2356 " to permit \\[aq]gid_map\\[aq] to be updated.\n"
2357 "\\&\n"
2358 " However, if the error from open() was something other than\n"
2359 " the ENOENT error that is expected for that case, let the\n"
2360 " user know. */\n"
2361 "\\&\n"
2362 " if (errno != ENOENT)\n"
2363 " fprintf(stderr, \"ERROR: open %s: %s\\[rs]n\", setgroups_path,\n"
2364 " strerror(errno));\n"
2365 " return;\n"
2366 " }\n"
2367 "\\&\n"
2368 " if (write(fd, str, strlen(str)) == -1)\n"
2369 " fprintf(stderr, \"ERROR: write %s: %s\\[rs]n\", setgroups_path,\n"
2370 " strerror(errno));\n"
2371 "\\&\n"
2372 " close(fd);\n"
2373 "}\n"
2374 "\\&\n"
2375 "static int /* Start function for cloned child */\n"
2376 "childFunc(void *arg)\n"
2377 "{\n"
2378 " struct child_args *args = arg;\n"
2379 " char ch;\n"
2380 "\\&\n"
2381 " /* Wait until the parent has updated the UID and GID mappings.\n"
2382 " See the comment in main(). We wait for end of file on a\n"
2383 " pipe that will be closed by the parent process once it has\n"
2384 " updated the mappings. */\n"
2385 "\\&\n"
2386 " close(args-E<gt>pipe_fd[1]); /* Close our descriptor for the write\n"
2387 " end of the pipe so that we see EOF\n"
2388 " when parent closes its descriptor. */\n"
2389 " if (read(args-E<gt>pipe_fd[0], &ch, 1) != 0) {\n"
2390 " fprintf(stderr,\n"
2391 " \"Failure in child: read from pipe returned != 0\\[rs]n\");\n"
2392 " exit(EXIT_FAILURE);\n"
2393 " }\n"
2394 "\\&\n"
2395 " close(args-E<gt>pipe_fd[0]);\n"
2396 "\\&\n"
2397 " /* Execute a shell command. */\n"
2398 "\\&\n"
2399 " printf(\"About to exec %s\\[rs]n\", args-E<gt>argv[0]);\n"
2400 " execvp(args-E<gt>argv[0], args-E<gt>argv);\n"
2401 " err(EXIT_FAILURE, \"execvp\");\n"
2402 "}\n"
2403 "\\&\n"
2404 "#define STACK_SIZE (1024 * 1024)\n"
2405 "\\&\n"
2406 "static char child_stack[STACK_SIZE]; /* Space for child\\[aq]s stack */\n"
2407 "\\&\n"
2408 "int\n"
2409 "main(int argc, char *argv[])\n"
2410 "{\n"
2411 " int flags, opt, map_zero;\n"
2412 " pid_t child_pid;\n"
2413 " struct child_args args;\n"
2414 " char *uid_map, *gid_map;\n"
2415 " const int MAP_BUF_SIZE = 100;\n"
2416 " char map_buf[MAP_BUF_SIZE];\n"
2417 " char map_path[PATH_MAX];\n"
2418 "\\&\n"
2419 " /* Parse command-line options. The initial \\[aq]+\\[aq] character in\n"
2420 " the final getopt() argument prevents GNU-style permutation\n"
2421 " of command-line options. That\\[aq]s useful, since sometimes\n"
2422 " the \\[aq]command\\[aq] to be executed by this program itself\n"
2423 " has command-line options. We don\\[aq]t want getopt() to treat\n"
2424 " those as options to this program. */\n"
2425 "\\&\n"
2426 " flags = 0;\n"
2427 " verbose = 0;\n"
2428 " gid_map = NULL;\n"
2429 " uid_map = NULL;\n"
2430 " map_zero = 0;\n"
2431 " while ((opt = getopt(argc, argv, \"+imnpuUM:G:zv\")) != -1) {\n"
2432 " switch (opt) {\n"
2433 " case \\[aq]i\\[aq]: flags |= CLONE_NEWIPC; break;\n"
2434 " case \\[aq]m\\[aq]: flags |= CLONE_NEWNS; break;\n"
2435 " case \\[aq]n\\[aq]: flags |= CLONE_NEWNET; break;\n"
2436 " case \\[aq]p\\[aq]: flags |= CLONE_NEWPID; break;\n"
2437 " case \\[aq]u\\[aq]: flags |= CLONE_NEWUTS; break;\n"
2438 " case \\[aq]v\\[aq]: verbose = 1; break;\n"
2439 " case \\[aq]z\\[aq]: map_zero = 1; break;\n"
2440 " case \\[aq]M\\[aq]: uid_map = optarg; break;\n"
2441 " case \\[aq]G\\[aq]: gid_map = optarg; break;\n"
2442 " case \\[aq]U\\[aq]: flags |= CLONE_NEWUSER; break;\n"
2443 " default: usage(argv[0]);\n"
2444 " }\n"
2445 " }\n"
2446 "\\&\n"
2447 " /* -M or -G without -U is nonsensical */\n"
2448 "\\&\n"
2449 " if (((uid_map != NULL || gid_map != NULL || map_zero) &&\n"
2450 " !(flags & CLONE_NEWUSER)) ||\n"
2451 " (map_zero && (uid_map != NULL || gid_map != NULL)))\n"
2452 " usage(argv[0]);\n"
2453 "\\&\n"
2454 " args.argv = &argv[optind];\n"
2455 "\\&\n"
2456 " /* We use a pipe to synchronize the parent and child, in order to\n"
2457 " ensure that the parent sets the UID and GID maps before the child\n"
2458 " calls execve(). This ensures that the child maintains its\n"
2459 " capabilities during the execve() in the common case where we\n"
2460 " want to map the child\\[aq]s effective user ID to 0 in the new user\n"
2461 " namespace. Without this synchronization, the child would lose\n"
2462 " its capabilities if it performed an execve() with nonzero\n"
2463 " user IDs (see the capabilities(7) man page for details of the\n"
2464 " transformation of a process\\[aq]s capabilities during execve()). */\n"
2465 "\\&\n"
2466 " if (pipe(args.pipe_fd) == -1)\n"
2467 " err(EXIT_FAILURE, \"pipe\");\n"
2468 "\\&\n"
2469 " /* Create the child in new namespace(s). */\n"
2470 "\\&\n"
2471 " child_pid = clone(childFunc, child_stack + STACK_SIZE,\n"
2472 " flags | SIGCHLD, &args);\n"
2473 " if (child_pid == -1)\n"
2474 " err(EXIT_FAILURE, \"clone\");\n"
2475 "\\&\n"
2476 " /* Parent falls through to here. */\n"
2477 "\\&\n"
2478 " if (verbose)\n"
2479 " printf(\"%s: PID of child created by clone() is %jd\\[rs]n\",\n"
2480 " argv[0], (intmax_t) child_pid);\n"
2481 "\\&\n"
2482 " /* Update the UID and GID maps in the child. */\n"
2483 "\\&\n"
2484 " if (uid_map != NULL || map_zero) {\n"
2485 " snprintf(map_path, PATH_MAX, \"/proc/%jd/uid_map\",\n"
2486 " (intmax_t) child_pid);\n"
2487 " if (map_zero) {\n"
2488 " snprintf(map_buf, MAP_BUF_SIZE, \"0 %jd 1\",\n"
2489 " (intmax_t) getuid());\n"
2490 " uid_map = map_buf;\n"
2491 " }\n"
2492 " update_map(uid_map, map_path);\n"
2493 " }\n"
2494 "\\&\n"
2495 " if (gid_map != NULL || map_zero) {\n"
2496 " proc_setgroups_write(child_pid, \"deny\");\n"
2497 "\\&\n"
2498 " snprintf(map_path, PATH_MAX, \"/proc/%jd/gid_map\",\n"
2499 " (intmax_t) child_pid);\n"
2500 " if (map_zero) {\n"
2501 " snprintf(map_buf, MAP_BUF_SIZE, \"0 %ld 1\",\n"
2502 " (intmax_t) getgid());\n"
2503 " gid_map = map_buf;\n"
2504 " }\n"
2505 " update_map(gid_map, map_path);\n"
2506 " }\n"
2507 "\\&\n"
2508 " /* Close the write end of the pipe, to signal to the child that we\n"
2509 " have updated the UID and GID maps. */\n"
2510 "\\&\n"
2511 " close(args.pipe_fd[1]);\n"
2512 "\\&\n"
2513 " if (waitpid(child_pid, NULL, 0) == -1) /* Wait for child */\n"
2514 " err(EXIT_FAILURE, \"waitpid\");\n"
2515 "\\&\n"
2516 " if (verbose)\n"
2517 " printf(\"%s: terminating\\[rs]n\", argv[0]);\n"
2518 "\\&\n"
2519 " exit(EXIT_SUCCESS);\n"
2520 "}\n"
2521 msgstr ""
2522
2523 #. type: TH
2524 #: fedora-44 fedora-rawhide
2525 #, no-wrap
2526 msgid "2025-01-11"
2527 msgstr "11 Enero 2025"
2528
2529 #. type: TH
2530 #: fedora-44 fedora-rawhide
2531 #, no-wrap
2532 msgid "Linux man-pages 6.13"
2533 msgstr "Páginas de Manual de Linux 6.13"
2534
2535 #. type: Plain text
2536 #: fedora-44 fedora-rawhide
2537 #, no-wrap
2538 msgid ""
2539 "/* userns_child_exec.c\n"
2540 "\\&\n"
2541 " Licensed under GNU General Public License v2 or later\n"
2542 "\\&\n"
2543 " Create a child process that executes a shell command in new\n"
2544 " namespace(s); allow UID and GID mappings to be specified when\n"
2545 " creating a user namespace.\n"
2546 "*/\n"
2547 "#define _GNU_SOURCE\n"
2548 "#include E<lt>err.hE<gt>\n"
2549 "#include E<lt>sched.hE<gt>\n"
2550 "#include E<lt>unistd.hE<gt>\n"
2551 "#include E<lt>stdint.hE<gt>\n"
2552 "#include E<lt>stdlib.hE<gt>\n"
2553 "#include E<lt>sys/wait.hE<gt>\n"
2554 "#include E<lt>signal.hE<gt>\n"
2555 "#include E<lt>fcntl.hE<gt>\n"
2556 "#include E<lt>stdio.hE<gt>\n"
2557 "#include E<lt>string.hE<gt>\n"
2558 "#include E<lt>limits.hE<gt>\n"
2559 "#include E<lt>errno.hE<gt>\n"
2560 "\\&\n"
2561 "struct child_args {\n"
2562 " char **argv; /* Command to be executed by child, with args */\n"
2563 " int pipe_fd[2]; /* Pipe used to synchronize parent and child */\n"
2564 "};\n"
2565 "\\&\n"
2566 "static int verbose;\n"
2567 "\\&\n"
2568 "static void\n"
2569 "usage(char *pname)\n"
2570 "{\n"
2571 " fprintf(stderr, \"Usage: %s [options] cmd [arg...]\\[rs]n\\[rs]n\", pname);\n"
2572 " fprintf(stderr, \"Create a child process that executes a shell \"\n"
2573 " \"command in a new user namespace,\\[rs]n\"\n"
2574 " \"and possibly also other new namespace(s).\\[rs]n\\[rs]n\");\n"
2575 " fprintf(stderr, \"Options can be:\\[rs]n\\[rs]n\");\n"
2576 "#define fpe(str) fprintf(stderr, \" %s\", str);\n"
2577 " fpe(\"-i New IPC namespace\\[rs]n\");\n"
2578 " fpe(\"-m New mount namespace\\[rs]n\");\n"
2579 " fpe(\"-n New network namespace\\[rs]n\");\n"
2580 " fpe(\"-p New PID namespace\\[rs]n\");\n"
2581 " fpe(\"-u New UTS namespace\\[rs]n\");\n"
2582 " fpe(\"-U New user namespace\\[rs]n\");\n"
2583 " fpe(\"-M uid_map Specify UID map for user namespace\\[rs]n\");\n"
2584 " fpe(\"-G gid_map Specify GID map for user namespace\\[rs]n\");\n"
2585 " fpe(\"-z Map user\\[aq]s UID and GID to 0 in user namespace\\[rs]n\");\n"
2586 " fpe(\" (equivalent to: -M \\[aq]0 E<lt>uidE<gt> 1\\[aq] -G \\[aq]0 E<lt>gidE<gt> 1\\[aq])\\[rs]n\");\n"
2587 " fpe(\"-v Display verbose messages\\[rs]n\");\n"
2588 " fpe(\"\\[rs]n\");\n"
2589 " fpe(\"If -z, -M, or -G is specified, -U is required.\\[rs]n\");\n"
2590 " fpe(\"It is not permitted to specify both -z and either -M or -G.\\[rs]n\");\n"
2591 " fpe(\"\\[rs]n\");\n"
2592 " fpe(\"Map strings for -M and -G consist of records of the form:\\[rs]n\");\n"
2593 " fpe(\"\\[rs]n\");\n"
2594 " fpe(\" ID-inside-ns ID-outside-ns size\\[rs]n\");\n"
2595 " fpe(\"\\[rs]n\");\n"
2596 " fpe(\"A map string can contain multiple records, separated\"\n"
2597 " \" by commas;\\[rs]n\");\n"
2598 " fpe(\"the commas are replaced by newlines before writing\"\n"
2599 " \" to map files.\\[rs]n\");\n"
2600 "\\&\n"
2601 " exit(EXIT_FAILURE);\n"
2602 "}\n"
2603 "\\&\n"
2604 "/* Update the mapping file \\[aq]map_file\\[aq], with the value provided in\n"
2605 " \\[aq]mapping\\[aq], a string that defines a UID or GID mapping. A UID or\n"
2606 " GID mapping consists of one or more newline-delimited records\n"
2607 " of the form:\n"
2608 "\\&\n"
2609 " ID_inside-ns ID-outside-ns size\n"
2610 "\\&\n"
2611 " Requiring the user to supply a string that contains newlines is\n"
2612 " of course inconvenient for command-line use. Thus, we permit the\n"
2613 " use of commas to delimit records in this string, and replace them\n"
2614 " with newlines before writing the string to the file. */\n"
2615 "\\&\n"
2616 "static void\n"
2617 "update_map(char *mapping, char *map_file)\n"
2618 "{\n"
2619 " int fd;\n"
2620 " size_t map_len; /* Length of \\[aq]mapping\\[aq] */\n"
2621 "\\&\n"
2622 " /* Replace commas in mapping string with newlines. */\n"
2623 "\\&\n"
2624 " map_len = strlen(mapping);\n"
2625 " for (size_t j = 0; j E<lt> map_len; j++)\n"
2626 " if (mapping[j] == \\[aq],\\[aq])\n"
2627 " mapping[j] = \\[aq]\\[rs]n\\[aq];\n"
2628 "\\&\n"
2629 " fd = open(map_file, O_RDWR);\n"
2630 " if (fd == -1) {\n"
2631 " fprintf(stderr, \"ERROR: open %s: %s\\[rs]n\", map_file,\n"
2632 " strerror(errno));\n"
2633 " exit(EXIT_FAILURE);\n"
2634 " }\n"
2635 "\\&\n"
2636 " if (write(fd, mapping, map_len) != map_len) {\n"
2637 " fprintf(stderr, \"ERROR: write %s: %s\\[rs]n\", map_file,\n"
2638 " strerror(errno));\n"
2639 " exit(EXIT_FAILURE);\n"
2640 " }\n"
2641 "\\&\n"
2642 " close(fd);\n"
2643 "}\n"
2644 "\\&\n"
2645 "/* Linux 3.19 made a change in the handling of setgroups(2) and\n"
2646 " the \\[aq]gid_map\\[aq] file to address a security issue. The issue\n"
2647 " allowed *unprivileged* users to employ user namespaces in\n"
2648 " order to drop groups. The upshot of the 3.19 changes is that\n"
2649 " in order to update the \\[aq]gid_maps\\[aq] file, use of the setgroups()\n"
2650 " system call in this user namespace must first be disabled by\n"
2651 " writing \"deny\" to one of the /proc/PID/setgroups files for\n"
2652 " this namespace. That is the purpose of the following function. */\n"
2653 "\\&\n"
2654 "static void\n"
2655 "proc_setgroups_write(pid_t child_pid, char *str)\n"
2656 "{\n"
2657 " char setgroups_path[PATH_MAX];\n"
2658 " int fd;\n"
2659 "\\&\n"
2660 " snprintf(setgroups_path, PATH_MAX, \"/proc/%jd/setgroups\",\n"
2661 " (intmax_t) child_pid);\n"
2662 "\\&\n"
2663 " fd = open(setgroups_path, O_RDWR);\n"
2664 " if (fd == -1) {\n"
2665 "\\&\n"
2666 " /* We may be on a system that doesn\\[aq]t support\n"
2667 " /proc/PID/setgroups. In that case, the file won\\[aq]t exist,\n"
2668 " and the system won\\[aq]t impose the restrictions that Linux 3.19\n"
2669 " added. That\\[aq]s fine: we don\\[aq]t need to do anything in order\n"
2670 " to permit \\[aq]gid_map\\[aq] to be updated.\n"
2671 "\\&\n"
2672 " However, if the error from open() was something other than\n"
2673 " the ENOENT error that is expected for that case, let the\n"
2674 " user know. */\n"
2675 "\\&\n"
2676 " if (errno != ENOENT)\n"
2677 " fprintf(stderr, \"ERROR: open %s: %s\\[rs]n\", setgroups_path,\n"
2678 " strerror(errno));\n"
2679 " return;\n"
2680 " }\n"
2681 "\\&\n"
2682 " if (write(fd, str, strlen(str)) == -1)\n"
2683 " fprintf(stderr, \"ERROR: write %s: %s\\[rs]n\", setgroups_path,\n"
2684 " strerror(errno));\n"
2685 "\\&\n"
2686 " close(fd);\n"
2687 "}\n"
2688 "\\&\n"
2689 "static int /* Start function for cloned child */\n"
2690 "childFunc(void *arg)\n"
2691 "{\n"
2692 " struct child_args *args = arg;\n"
2693 " char ch;\n"
2694 "\\&\n"
2695 " /* Wait until the parent has updated the UID and GID mappings.\n"
2696 " See the comment in main(). We wait for end of file on a\n"
2697 " pipe that will be closed by the parent process once it has\n"
2698 " updated the mappings. */\n"
2699 "\\&\n"
2700 " close(args-E<gt>pipe_fd[1]); /* Close our descriptor for the write\n"
2701 " end of the pipe so that we see EOF\n"
2702 " when parent closes its descriptor. */\n"
2703 " if (read(args-E<gt>pipe_fd[0], &ch, 1) != 0) {\n"
2704 " fprintf(stderr,\n"
2705 " \"Failure in child: read from pipe returned != 0\\[rs]n\");\n"
2706 " exit(EXIT_FAILURE);\n"
2707 " }\n"
2708 "\\&\n"
2709 " close(args-E<gt>pipe_fd[0]);\n"
2710 "\\&\n"
2711 " /* Execute a shell command. */\n"
2712 "\\&\n"
2713 " printf(\"About to exec %s\\[rs]n\", args-E<gt>argv[0]);\n"
2714 " execvp(args-E<gt>argv[0], args-E<gt>argv);\n"
2715 " err(EXIT_FAILURE, \"execvp\");\n"
2716 "}\n"
2717 "\\&\n"
2718 "#define STACK_SIZE (1024 * 1024)\n"
2719 "\\&\n"
2720 "static char child_stack[STACK_SIZE]; /* Space for child\\[aq]s stack */\n"
2721 "\\&\n"
2722 "int\n"
2723 "main(int argc, char *argv[])\n"
2724 "{\n"
2725 " int flags, opt, map_zero;\n"
2726 " pid_t child_pid;\n"
2727 " struct child_args args;\n"
2728 " char *uid_map, *gid_map;\n"
2729 " const int MAP_BUF_SIZE = 100;\n"
2730 " char map_buf[MAP_BUF_SIZE];\n"
2731 " char map_path[PATH_MAX];\n"
2732 "\\&\n"
2733 " /* Parse command-line options. The initial \\[aq]+\\[aq] character in\n"
2734 " the final getopt() argument prevents GNU-style permutation\n"
2735 " of command-line options. That\\[aq]s useful, since sometimes\n"
2736 " the \\[aq]command\\[aq] to be executed by this program itself\n"
2737 " has command-line options. We don\\[aq]t want getopt() to treat\n"
2738 " those as options to this program. */\n"
2739 "\\&\n"
2740 " flags = 0;\n"
2741 " verbose = 0;\n"
2742 " gid_map = NULL;\n"
2743 " uid_map = NULL;\n"
2744 " map_zero = 0;\n"
2745 " while ((opt = getopt(argc, argv, \"+imnpuUM:G:zv\")) != -1) {\n"
2746 " switch (opt) {\n"
2747 " case \\[aq]i\\[aq]: flags |= CLONE_NEWIPC; break;\n"
2748 " case \\[aq]m\\[aq]: flags |= CLONE_NEWNS; break;\n"
2749 " case \\[aq]n\\[aq]: flags |= CLONE_NEWNET; break;\n"
2750 " case \\[aq]p\\[aq]: flags |= CLONE_NEWPID; break;\n"
2751 " case \\[aq]u\\[aq]: flags |= CLONE_NEWUTS; break;\n"
2752 " case \\[aq]v\\[aq]: verbose = 1; break;\n"
2753 " case \\[aq]z\\[aq]: map_zero = 1; break;\n"
2754 " case \\[aq]M\\[aq]: uid_map = optarg; break;\n"
2755 " case \\[aq]G\\[aq]: gid_map = optarg; break;\n"
2756 " case \\[aq]U\\[aq]: flags |= CLONE_NEWUSER; break;\n"
2757 " default: usage(argv[0]);\n"
2758 " }\n"
2759 " }\n"
2760 "\\&\n"
2761 " /* -M or -G without -U is nonsensical */\n"
2762 "\\&\n"
2763 " if (((uid_map != NULL || gid_map != NULL || map_zero) &&\n"
2764 " !(flags & CLONE_NEWUSER)) ||\n"
2765 " (map_zero && (uid_map != NULL || gid_map != NULL)))\n"
2766 " usage(argv[0]);\n"
2767 "\\&\n"
2768 " args.argv = &argv[optind];\n"
2769 "\\&\n"
2770 " /* We use a pipe to synchronize the parent and child, in order to\n"
2771 " ensure that the parent sets the UID and GID maps before the child\n"
2772 " calls execve(). This ensures that the child maintains its\n"
2773 " capabilities during the execve() in the common case where we\n"
2774 " want to map the child\\[aq]s effective user ID to 0 in the new user\n"
2775 " namespace. Without this synchronization, the child would lose\n"
2776 " its capabilities if it performed an execve() with nonzero\n"
2777 " user IDs (see the capabilities(7) man page for details of the\n"
2778 " transformation of a process\\[aq]s capabilities during execve()). */\n"
2779 "\\&\n"
2780 " if (pipe(args.pipe_fd) == -1)\n"
2781 " err(EXIT_FAILURE, \"pipe\");\n"
2782 "\\&\n"
2783 " /* Create the child in new namespace(s). */\n"
2784 "\\&\n"
2785 " child_pid = clone(childFunc, child_stack + STACK_SIZE,\n"
2786 " flags | SIGCHLD, &args);\n"
2787 " if (child_pid == -1)\n"
2788 " err(EXIT_FAILURE, \"clone\");\n"
2789 "\\&\n"
2790 " /* Parent falls through to here. */\n"
2791 "\\&\n"
2792 " if (verbose)\n"
2793 " printf(\"%s: PID of child created by clone() is %jd\\[rs]n\",\n"
2794 " argv[0], (intmax_t) child_pid);\n"
2795 "\\&\n"
2796 " /* Update the UID and GID maps in the child. */\n"
2797 "\\&\n"
2798 " if (uid_map != NULL || map_zero) {\n"
2799 " snprintf(map_path, PATH_MAX, \"/proc/%jd/uid_map\",\n"
2800 " (intmax_t) child_pid);\n"
2801 " if (map_zero) {\n"
2802 " snprintf(map_buf, MAP_BUF_SIZE, \"0 %jd 1\",\n"
2803 " (intmax_t) getuid());\n"
2804 " uid_map = map_buf;\n"
2805 " }\n"
2806 " update_map(uid_map, map_path);\n"
2807 " }\n"
2808 "\\&\n"
2809 " if (gid_map != NULL || map_zero) {\n"
2810 " proc_setgroups_write(child_pid, \"deny\");\n"
2811 "\\&\n"
2812 " snprintf(map_path, PATH_MAX, \"/proc/%jd/gid_map\",\n"
2813 " (intmax_t) child_pid);\n"
2814 " if (map_zero) {\n"
2815 " snprintf(map_buf, MAP_BUF_SIZE, \"0 %ld 1\",\n"
2816 " (intmax_t) getgid());\n"
2817 " gid_map = map_buf;\n"
2818 " }\n"
2819 " update_map(gid_map, map_path);\n"
2820 " }\n"
2821 "\\&\n"
2822 " /* Close the write end of the pipe, to signal to the child that we\n"
2823 " have updated the UID and GID maps. */\n"
2824 "\\&\n"
2825 " close(args.pipe_fd[1]);\n"
2826 "\\&\n"
2827 " if (waitpid(child_pid, NULL, 0) == -1) /* Wait for child */\n"
2828 " err(EXIT_FAILURE, \"waitpid\");\n"
2829 "\\&\n"
2830 " if (verbose)\n"
2831 " printf(\"%s: terminating\\[rs]n\", argv[0]);\n"
2832 "\\&\n"
2833 " exit(EXIT_SUCCESS);\n"
2834 "}\n"
2835 msgstr ""
2836
2837 #. type: TH
2838 #: mageia-cauldron
2839 #, no-wrap
2840 msgid "Linux man-pages 6.17"
2841 msgstr "Páginas de Manual de Linux 6.17"
2842
2843 #. type: TH
2844 #: opensuse-leap-16-1 opensuse-tumbleweed
2845 #, no-wrap
2846 msgid "Linux man-pages (unreleased)"
2847 msgstr "Páginas de Manual de Linux (no publicadas)"