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