su or sudo in chroot: beware of nosuid mount
For su
or sudo
to work, the rootfs has to be mounted suid
-- which is obvious when you know how it work or think about it. sudo
is nice enough to hint us at it, but sud
isn't.
Either way, when chroot
ing you need to make sure the partition holding your new root is not mounter nosuid
. Any user-mounted partition usually is (for fairly obvious security reasons I guess), so if you're plugging in a drive, make sure you mount it manually or remount it mount -o remount,suid
.
Then, su
and sudo
should work fine in the chroot (at least if you mounted all the bits like /proc
, /sys
, /dev
, /dev/pts
and al.).
Beware of shady stuff though, obviously.
— Permalink