Forum
Strange issue: sudo: effective uid is not 0, is sudo installed setuid root? - Printable Version

+- Forum (http://forum.xbian.org)
+-- Forum: Software (/forum-6.html)
+--- Forum: Installation (/forum-16.html)
+--- Thread: Strange issue: sudo: effective uid is not 0, is sudo installed setuid root? (/thread-1835.html)

Pages: 1 2 3


Strange issue: sudo: effective uid is not 0, is sudo installed setuid root? - d4m4s74 - 2nd Dec, 2013 08:10 AM

After borking my installation by trying to update xbian to beta 2 I did a fresh install to my SD card. In the installation wizard I set updating to automatic, installed the download package, and kept the rest default.
Over the course of an hour or so I set up everything the way I want it, and logged in through SSH. When closing the default xbian-config it told me xbian needed to be rebooted. After doing that and booting again instead of the default notification I got
Code:
sudo: effective uid is not 0, is sudo installed setuid root?
Using sudo for other things wasn't possible either. Since I expected it would cost me more time to figure out the problem than to just start over I reinstalled beta 2. I used the exact same configuration, logged in through SSH and got the same notification. I restarted the pi through xbian-config, and the same problem returned.
I think it has something to do with enabling automatic updating, but I'm not completely sure.
After some searching around I figured out root lost uid0, effectively making it a normal user, as demonstrated by any LS command, for example ls /usr/bin/sudo gives me
Code:
-rwxr-xr-x 1 xbian root 98712 Mar  3  2013 sudo

Since reinstalling xbian won't work, does anyone know how to fix it somehow?

edit 1: In the passwd file root is still 0 (root:x:0:0:root:/root:/bin/bash)
edit 2: maybe it helps, the only difference I found that might mean something is that before the forced reboot /etc/fstab didn't have a line for /, but after it does. Unfortionally I've already reinstalled xbian so I am unable to check what removing that line does


RE: Strange issue: sudo: effective uid is not 0, is sudo installed setuid root? - d4m4s74 - 2nd Dec, 2013 07:25 PM

Yesterday I reinstalled xbian with automatic updates disabled and the problem isn't occuring again. When I get home tonight I'm going to test it with a different SD card (so I don't ruin my finally working setup) with updates enabled to see if the problem reoccurs, and if it can be fixed as I explained earlier


RE: Strange issue: sudo: effective uid is not 0, is sudo installed setuid root? - mk01 - 2nd Dec, 2013 08:12 PM

@d4m4s74

technically auto update process runs the same way as manually started with apt upgrade. hard to guess what was the ugly enemy causing this but definitely your file/folder owner ship was changed to xbian - binaries like su, sudo and other low level system utilities have suid bit set to 1 and are (normally owned by root) - so the process can become owned by root regardless of ID of owner of starting process.

and because xbian's ownership sudo complained about not having effective id 0. I will recheck package's scripts for any ugly stupid thing with using chown incorrectly. everything is possible. if you wan't help investigating maybe, those packages are -xbmc, -config-shell, -config-xbmc, -tvheadend. should be all.

if you hit on this again, let me know. can we exclude any stupid typo like this with chown on your side? (just asking, will check our debs for sure in any case).


RE: Strange issue: sudo: effective uid is not 0, is sudo installed setuid root? - d4m4s74 - 3rd Dec, 2013 12:31 AM

I haven't used chown at all, I only used a chmod on the nzbget ppscripts folder.


RE: Strange issue: sudo: effective uid is not 0, is sudo installed setuid root? - mk01 - 3rd Dec, 2013 01:27 AM

can imagine that on ext media but not rootfs, … still I have to admit i was patching some small issues around early boot, fstab mounting and / remount with noatime. barely noticable problems appearing at 1 from 20 reboots but none of it had such huge impact as wrong mounts.

also I found them first only after installing jessie (successor to wheezy still under development).

but something happened to you as well. would it be possible for you to put also staging repo to sources.list and upgrade available packages ?


RE: Strange issue: sudo: effective uid is not 0, is sudo installed setuid root? - d4m4s74 - 3rd Dec, 2013 01:42 AM

Once I get home I'll do a testinstall on a seperate SD, I'll see what I can do.


RE: Strange issue: sudo: effective uid is not 0, is sudo installed setuid root? - mk01 - 3rd Dec, 2013 01:59 AM

don't spend any unneeded time with this. really.

just use your RPI as you want to. if you don't mind accidental error on screen with not 100% stable package, install them and again just use RPI. if you mind, no problem we have this info now and will take closer look if needed.

maybe last question, do you use any external drives (or was any connected during the time when your system collapsed - so one possibility would be bug in usbmount helper tool which by accident would remount rootfs with nosuid option)?


RE: Strange issue: sudo: effective uid is not 0, is sudo installed setuid root? - d4m4s74 - 3rd Dec, 2013 07:29 AM

(3rd Dec, 2013 01:59 AM)mk01 Wrote:  don't spend any unneeded time with this. really.

just use your RPI as you want to. if you don't mind accidental error on screen with not 100% stable package, install them and again just use RPI. if you mind, no problem we have this info now and will take closer look if needed.

maybe last question, do you use any external drives (or was any connected during the time when your system collapsed - so one possibility would be bug in usbmount helper tool which by accident would remount rootfs with nosuid option)?

Yes, I had an external harddrive with an NTFS partition. Which could make sense because while I tried to duplicate the circumstances on a different sd card it didn't occur, and at that time I had my external HD connected to my laptop.


RE: Strange issue: sudo: effective uid is not 0, is sudo installed setuid root? - Xenon - 20th Dec, 2013 01:08 AM

(2nd Dec, 2013 08:12 PM)mk01 Wrote:  @d4m4s74

technically auto update process runs the same way as manually started with apt upgrade. hard to guess what was the ugly enemy causing this but definitely your file/folder owner ship was changed to xbian - binaries like su, sudo and other low level system utilities have suid bit set to 1 and are (normally owned by root) - so the process can become owned by root regardless of ID of owner of starting process.

and because xbian's ownership sudo complained about not having effective id 0. I will recheck package's scripts for any ugly stupid thing with using chown incorrectly. everything is possible. if you wan't help investigating maybe, those packages are -xbmc, -config-shell, -config-xbmc, -tvheadend. should be all.

if you hit on this again, let me know. can we exclude any stupid typo like this with chown on your side? (just asking, will check our debs for sure in any case).

Hi mk01,
I have the same issue explained in this topic at the moment
I have it twice in 2 weeks, this is the second time actually.
Last week I rebuild the system from fresh image, but I'm worried why it happens again in the same way.
I've connected USB media NTFS which I'm going to replace with new extFat, do you think it should solve this strange issue?
Honestly I'd like to solve the issue, do you think there is something should I do?

I don't know if can be useful but this is "mount" output:

Code:
/dev/mmcblk0p2 on / type btrfs (rw,noatime,compress=lzo,ssd,space_cache,autodefrag)
devtmpfs on /dev type devtmpfs (rw,relatime,size=191796k,nr_inodes=47949,mode=755)
none on /dev/pts type devpts (rw,nosuid,noexec,relatime,mode=600)
none on /proc type proc (rw,nosuid,nodev,noexec,relatime)
none on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
none on /run type tmpfs (rw,nosuid,nodev,noexec,noatime,size=38376k)
/dev/mmcblk0p1 on /boot type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,​errors=remount-ro)
/dev/mmcblk0p2 on /home type btrfs (rw,noatime,compress=lzo,ssd,space_cache,autodefrag)
/dev/mmcblk0p2 on /lib/modules type btrfs (rw,noatime,compress=lzo,ssd,space_cache,autodefrag)
/dev/mmcblk0p2 on /xbmc-backup type btrfs (rw,noatime,compress=lzo,ssd,space_cache,autodefrag)

Thank you for the help


Strange issue: sudo: effective uid is not 0, is sudo installed setuid root? - mk01 - 21st Dec, 2013 04:00 AM

what is output of:
Code:
stat $(which sudo)



RE: Strange issue: sudo: effective uid is not 0, is sudo installed setuid root? - Xenon - 21st Dec, 2013 06:11 AM

(21st Dec, 2013 04:00 AM)mk01 Wrote:  what is output of:
Code:
stat $(which sudo)

Code:
xbian@xbian ~ $ stat $(which sudo)
  File: `/usr/bin/sudo'
  Size: 98712           Blocks: 200        IO Block: 4096   regular file
Device: dh/13d  Inode: 2803        Links: 1
Access: (0755/-rwxr-xr-x)  Uid: ( 1001/   xbian)   Gid: (    0/    root)
Access: 2013-12-14 13:36:14.808275799 +0100
Modify: 2013-03-03 06:24:47.000000000 +0100
Change: 2013-12-20 21:08:28.637264471 +0100
Birth: -



RE: Strange issue: sudo: effective uid is not 0, is sudo installed setuid root? - mk01 - 21st Dec, 2013 06:17 AM

and

Code:
ls -la /
ls -la /usr/bin/

use pastebin please


RE: Strange issue: sudo: effective uid is not 0, is sudo installed setuid root? - Xenon - 21st Dec, 2013 06:45 AM

(21st Dec, 2013 06:17 AM)mk01 Wrote:  and

Code:
ls -la /
ls -la /usr/bin/

use pastebin please

ls -la / output
http://pastebin.com/9dAJghMW

ls -la /usr/bin/
http://pastebin.com/xaX2f0xX


RE: Strange issue: sudo: effective uid is not 0, is sudo installed setuid root? - mk01 - 21st Dec, 2013 07:11 AM

edit /boot/cmdline.txt and add "init=/bin/bash" at the end of line
reboot
xbian will boot directly into command prompt with root privileges
run commands:
Code:
for f in bin etc lib media mnt opt root sbin usr var xbmc-backup; do chown -R root $f; done
chown root:root /home
chown syslog /var/log/*
chown -R man /var/cache/man
chown -R xbian:xbian /usr/local/share/xbmc/addons/plugin.xbianconfig
chmod 4755 /usr/bin/sudo

then update cmdline.txt again - just revert to previous content (remove init=/bin/bash)
after restart

Code:
sudo dpkg-reconfigure -a



RE: Strange issue: sudo: effective uid is not 0, is sudo installed setuid root? - Xenon - 21st Dec, 2013 08:16 AM

(21st Dec, 2013 07:11 AM)mk01 Wrote:  edit /boot/cmdline.txt and add "init=/bin/bash" at the end of line
[...]

Unfortunately I can't edit /boot/cmdline.txt because it needs root privileges
Code:
-rwxr-xr-x 1 root  root     319 Dec 14 14:24 cmdline.txt
and I never set pw for root.