Skip to content

Commit b71b977

Browse files
committed
Avoiding a call to pivot_root(), which does not succeed on some systems; it could be replaced by a mount bind and chroot(), additionally unsharing and uid/gid mapping is not available
Signed-off-by: Dmitry Mikushin <[email protected]>
1 parent 278db70 commit b71b977

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

bubblewrap.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3080,10 +3080,16 @@ main (int argc,
30803080

30813081
if (mkdir ("oldroot", 0755))
30823082
die_with_error ("Creating oldroot failed");
3083-
3083+
#if 0
30843084
if (pivot_root (base_path, "oldroot"))
30853085
die_with_error ("pivot_root");
3086+
#else
3087+
if (mount ("/", "oldroot", NULL, MS_SILENT | MS_MGC_VAL | MS_BIND | MS_REC, NULL) < 0)
3088+
die_with_error ("setting up newroot bind");
30863089

3090+
if (chroot (base_path))
3091+
die_with_error ("chroot");
3092+
#endif
30873093
if (chdir ("/") != 0)
30883094
die_with_error ("chdir / (base path)");
30893095

@@ -3209,16 +3215,17 @@ main (int argc,
32093215
if (write_to_fd (sysctl_fd, "1", 1) < 0)
32103216
die_with_error ("sysctl user.max_user_namespaces = 1");
32113217
}
3212-
3218+
#if 0
32133219
if (unshare (CLONE_NEWUSER))
32143220
die_with_error ("unshare user ns");
3215-
3221+
#endif
32163222
/* We're in a new user namespace, we got back the bounding set, clear it again */
32173223
drop_cap_bounding_set (FALSE);
3218-
3224+
#if 0
32193225
write_uid_gid_map (opt_sandbox_uid, ns_uid,
32203226
opt_sandbox_gid, ns_gid,
32213227
-1, FALSE, FALSE);
3228+
#endif
32223229
}
32233230

32243231
if (opt_disable_userns || opt_assert_userns_disabled)

0 commit comments

Comments
 (0)