Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I would like to be able to use the sudo command in a chroot environment.

I start the chroot as follows:

chroot /debian-squeeze /bin/bash

Now I'm logged in as root in the chroot. I can do su user to log in as a user named user. Now, sudo does not work:

user@HD:/$ sudo ls
sudo: must be setuid root

Some diagnostics:

user@HD:/$ which sudo
/usr/bin/sudo

user@HD:/$ ls -al /usr/bin/sudo
-rwsr-xr-x 2 root root 143884 May 23  2012 /usr/bin/sudo

user@HD:/$ ls -aln /usr/bin/sudo
-rwsr-xr-x 2 0 0 143884 May 23  2012 /usr/bin/sudo

root@HD:/# cat /etc/sudoers
Defaults    env_reset
root    ALL=(ALL) ALL
user ALL=(ALL) ALL
%sudo ALL=(ALL) ALL

As root, I can execute sudo without error.

Can anyone explain me why sudo (or setuid) does not work like this?

share|improve this question
    
This page might explain what you are after. –  Simplexion Dec 10 '12 at 2:41
    
@Simplexion I see nothing on that page that might answer this question. –  Michael Hampton Dec 10 '12 at 3:48
1  
Show output of mount –  warl0ck Dec 10 '12 at 3:52
add comment

1 Answer

up vote 4 down vote accepted

My guess is that /debian-squeeze is on a separate filesystem mounted without defaults or suid. The kernel will ignore the setuid bit on filesystems mounted without suid (defaults implies suid). To fix it:

mount -o remount,suid /debian-squeeze
share|improve this answer
    
If su works than this is not the case... –  David Kohen Dec 11 '12 at 15:06
    
Thanks, this was indeed the solution. (su worked because I was already root user when I executed su.) –  math1985 Dec 12 '12 at 10:19
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.