Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am facing a strange problem while using a chroot'd 12.04 Ubuntu. When I try to run anything with sudo I get the following error:

sudo: effective uid is not 0, is sudo installed setuid root?

If I boot on the same system I'm "chroot'ing" to sudo works as expected. What can be the cause of this? How can I fix it?

Additional info:

[user@host /]$ ls -la /usr/bin/sudo
-rwsr-xr-x 1 root root 116928 12.05.2013 08:14 /usr/bin/sudo*

To chroot I used this: http://ubuntuforums.org/showthread.php?t=1156240

share|improve this question
add comment

3 Answers

up vote 0 down vote accepted
+100

Having created a chroot from my current Ubuntu 12.04 installation by copying the necessary files I can confirm that the chroot + sudo actually works.

Now for your problem: there can be two solutions.

  1. You really don't have enough permissions on /usr/bin/sudo. This can be due to the actual permissions on the file or due to some filesystem mounting issues like nosetuid.

  2. Some kernel security module is blocking sudo / setuid bit within the chroot. This is less likely, but there are some security modules that can disable the setuid bit within a chroot.

If you want to debug this issue in detail, I suggest you get acquainted with strace, it will show you all the system calls the sudo command does and it'll help you debug what file or permission is causing the exact problem. I have written a tutorial on it, you might be interested in that.

share|improve this answer
    
It seems it is the 1st option: the Ubuntu I am trying to chroot is in a different partition and in the mount options I can see (rw,nosuid,nodev,uhelper=udisks2) (mounted by Nautilus). How can I change it, either using Nautilus or mount? –  Salem Jun 12 '13 at 10:25
    
Nevermind, plain mount does exactly what I need. –  Salem Jun 12 '13 at 11:27
add comment

Could you please try to see what all commands you may execute using sudo.

sudo -l -U YOUR_USERNAME

In case you have enough privileges try to execute.

chmod u+s /usr/bin/sudo

Hope it helps.

share|improve this answer
    
Nope. sudo has the same permissions as my main OS. –  Salem Jun 12 '13 at 10:19
add comment

Run the following command chmod 4755 /usr/bin/sudo. Aww my fault you already have the correct settings, anyway maybe the linked answer can help. It might be a PolicyKit related problem.

Also take a look at this answer: How to fix sudo after "chmod -R 777 /usr/bin"?

Good Luck!

share|improve this answer
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.