Skip to content

Commit 278db70

Browse files
committed
Reversing 3ce7c82 to avoid the second pivot_root()
Signed-off-by: Dmitry Mikushin <[email protected]>
1 parent ad76c2d commit 278db70

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

bubblewrap.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3146,7 +3146,7 @@ main (int argc,
31463146

31473147
if (umount2 ("oldroot", MNT_DETACH))
31483148
die_with_error ("unmount old root");
3149-
3149+
#if 0
31503150
/* This is our second pivot. It's like we're a Silicon Valley startup flush
31513151
* with cash but short on ideas!
31523152
*
@@ -3177,7 +3177,7 @@ main (int argc,
31773177
if (chdir ("/") != 0)
31783178
die_with_error ("chdir /");
31793179
}
3180-
3180+
#endif
31813181
if (opt_userns2_fd > 0 && setns (opt_userns2_fd, CLONE_NEWUSER) != 0)
31823182
die_with_error ("Setting userns2 failed");
31833183

@@ -3229,7 +3229,15 @@ main (int argc,
32293229
if (res == 0)
32303230
die ("creation of new user namespaces was not disabled as requested");
32313231
}
3232-
3232+
#if 1
3233+
/* Now make /newroot the real root */
3234+
if (chdir ("/newroot") != 0)
3235+
die_with_error ("chdir newroot");
3236+
if (chroot ("/newroot") != 0)
3237+
die_with_error ("chroot /newroot");
3238+
if (chdir ("/") != 0)
3239+
die_with_error ("chdir /");
3240+
#endif
32333241
/* All privileged ops are done now, so drop caps we don't need */
32343242
drop_privs (!is_privileged, TRUE);
32353243

0 commit comments

Comments
 (0)