Forum

Full Version: sudo: effective uid is not 0 - returns after fix
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Similar to @d4m4s74, My recent set of updates has caused a problem with sudo.

In the thread titled "Strange issue: sudo: effective uid is not 0, is sudo installed setuid root?" the solution was to run the following 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

I did that, ran
Code:
dpkg-reconfigure -a
after reboot.

Lo and behold, the problem is BACK! I've now done this several times, with and without the `dpkg-reconfigure -a`.

So then I try to roll back to one of my btrfs snapshots. No luck there:
Code:
root@lamassu ~ # apt-get install strace
Reading package lists... Done
Building dependency tree      
Reading state information... Done
The following packages were automatically installed and are no longer required:
  fbset gnutls-bin libass-dev libbluray-dev libenca-dev libfontconfig1-dev libfreetype6-dev libjasper-dev libpar2-0 libsigc++-dev libsigc++0c2
  python-cheetah
Use 'apt-get autoremove' to remove them.
The following NEW packages will be installed:
  strace
0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
Need to get 0 B/123 kB of archives.
After this operation, 296 kB of additional disk space will be used.
Error: another copy is running ... 0
Error: another copy is running ... 1
Error: another copy is running ... 2
Error: another copy is running ... 3
Error: another copy is running ... 4
Error: another copy is running ... 5
Error: another copy is running ... 6
Error: another copy is running ... 7
Error: another copy is running ... 8
Error: another copy is running ... 9
Error: another copy is running ... 10
Error: another copy is running ... 11
Error: another copy is running ... 12
E: Problem executing scripts DPkg::Pre-Invoke '[ ! -e /etc/default/xbian-snap ] || . /etc/default/xbian-snap; [ $ENABLEDAPT = yes ] || exit 0; z=$(findmnt -n | grep -m1 . | awk '{print $2}'); z=${z#*\[\/}; export z=${z%%\/*}; if [ -x /usr/sbin/btrfs-auto-snapshot ]; then btrfs-auto-snapshot snapshot -k 10 -l apt-run $z ;  fi ;'
E: Sub-process returned an error code

And yes, I tried to rollback AFTER I'd fixed up the permissions and before I rebooted again, so presumably the permissions should have allowed the rollback.

I'm downloading B2 right now and expect to try a fresh install. This isn't my ideal. Tongue

Thanks for the awesome project and keep up the good works!
another copy is running is maybe only orphan lock … it is directory /tmp/btrfs-snap … if this dir exists and is NOT mountpoint, you can safely rmdir it and. btrfs-auto-snapshot will then run again without "Error: another copy is running .."

btw: rollback or running btrfs user space tool does not need proper permissions or suid bits on executables.

btw2; can you with Xenon and d4m4s74 define what you have in common ? probably downloader package or transmission at least, ntfs (fuse) usb disk ?
Another, maybe helpful bit is that the PID I was trying to strace was responsible for a command:
Code:
chown xbian -R /tmp

I just couldn't figure out what the parent process was that executed that command, and was just beginning my troubleshooting.

I'll PM both @Xenon and @d4m4s74 to see if we can figure out some commonality.
ok, now it is clear …

the problem is that btrfs-snapshot tool is mounting whole btrfs structure under /tmp to access root of filesystem hierarchy. so being mounted under /tmp/btrfs-snap with all snapshots and subvolumes, it get's chowned.

what you can do is:

Code:
mv /bin/chown /bin/chown.bck
cat <<EOF >/bin/chown
#!/bin/sh

pstree -hp > /tmp/pstree.log

EOF
chmod +x /bin/chown
reboot

then check /tmp/pstree.log

later move /bin/chown.bck /bin/chown
but you would need root privileges. or use the trick with booting via "init=/bin/bash" .

our script should be then started instead of chown binary with only one task, print process tree with PIDs and storing it into /tmp/pstree.log
In case it matters, here's the perms as they stand right now (before the chown mod):
Code:
root@lamassu / # ls -alh
total 16K
drwxr-xr-x  1 xbian root  158 Oct 21 13:18 .
drwxr-xr-x  1 xbian root  158 Oct 21 13:18 ..
drwxr-xr-x  1 xbian root 1.9K Dec 21 09:57 bin
drwxr-xr-x  2 root  root  16K Dec 31  1969 boot
drwxr-xr-x  9 root  root 2.4K Dec 21 07:56 dev
drwxr-xr-x  1 xbian root 3.3K Dec 20 23:29 etc
drwxr-xr-x  1 xbian root   10 Jun 23 06:51 home
drwxr-xr-x  1 xbian root 1.1K Jul 11 20:19 lib
drwxr-xr-x  1 xbian root    0 Dec 20 15:25 media
drwxr-xr-x  1 xbian root    0 Sep  2  2012 mnt
drwxr-xr-x  1 xbian root    4 Nov 11  2012 opt
dr-xr-xr-x 87 root  root    0 Dec 31  1969 proc
drwx------  1 xbian root  142 Dec 21 09:15 root
drwxrwxrwt 15 root  root  640 Dec 21 08:24 run
drwxr-xr-x  1 xbian root 3.5K Dec 20 10:02 sbin
drwxr-xr-x  1 xbian root    0 Jun 20  2012 selinux
drwxr-xr-x  1 xbian root    0 Oct 28  2012 srv
dr-xr-xr-x 11 root  root    0 Dec 31  1969 sys
drwxrwxrwt  1 xbian root  114 Dec 21 09:58 tmp
drwxr-xr-x  1 xbian root   70 Oct 28  2012 usr
drwxr-xr-x  1 xbian root   90 Dec 20 23:03 var
drwxr-xr-x  1 xbian root   38 Oct 21 13:18 xbmc-backup

I'm rebooting with the chown script right now...
@rbellamy

for tmp fix edit /usr/sbin/btrfs-auto-snapshot line 25

Code:
tmp_dir='/tmp/btrfs-snap'

to

Code:
tmp_dir='/root/btrfs-snap'
And here it is:

Code:
root@lamassu ~ # cat /tmp/pstree.log
init(1)-+-avahi-daemon(508)---avahi-daemon(514)
        |-cron(807)
        |-dbus-daemon(431)
        |-getty(667)
        |-getty(679)
        |-inetd(707)
        |-lircd(587)
        |-nmbd(888)
        |-python(860)
        |-rc(1178)---S01headphones(1256)---chown(1294)---pstree(1295)
        |-rpcbind(430)
        |-sh(793)-+-btrfs-auto-snap(810)---btrfs(1201)
        |         `-grep(811)
        |-sh(1024)---ntpd(1074)
        |-transmission-da(915)-+-{transmission-da}(985)
        |                      `-{transmission-da}(990)
        |-udevd(202)-+-udevd(934)
        |            |-udevd(938)
        |            |-udevd(1053)
        |            |-udevd(1086)
        |            |-udevd(1087)
        |            |-udevd(1088)
        |            |-udevd(1090)
        |            |-udevd(1104)
        |            |-udevd(1108)
        |            |-udevd(1136)
        |            |-udevd(1138)
        |            |-udevd(1145)
        |            |-udevd(1197)
        |            |-udevd(1214)
        |            |-udevd(1226)
        |            `-udevd(1230)
        `-upstart-udev-br(196)

And from your pm request:

Code:
root@lamassu ~ # grep -inr chown /etc
/etc/init/dbus.conf:19:    chown messagebus:messagebus /var/run/dbus
/etc/init/zram-swap.conf:107:                chown -Rc xbian:xbian "/home/xbian/.xbmc/temp"
/etc/init/zram-swap.conf:132:            mkdir /home/xbian/.xbmc/temp.new; chown xbian:xbian /home/xbian/.xbmc/temp.new
/etc/dhcp/dhclient-exit-hooks.d/ntp:31:    chown --reference=$NTP_CONF $tmp
/etc/insserv/overrides/sysklogd:63:    chown ${USER}:adm /dev/xconsole
/etc/insserv/overrides/sysklogd:72:        chown ${USER}:adm $l
/etc/cron.weekly/man-db:20:    chown man:root /var/cache/man || true
/etc/init.d/screen-cleanup:29:        chown root:utmp $SCREENDIR
/etc/init.d/klogd:35:    chown klog:klog /var/run/klogd
/etc/init.d/klogd:37:    chown klog:klog $kmsgpipe
/etc/init.d/sysklogd:63:    chown ${USER}:adm /dev/xconsole
/etc/init.d/sysklogd:72:        chown ${USER}:adm $l
/etc/init.d/headphones:16:## sudo chown headphones:nogroup -R /opt/headphones
/etc/init.d/headphones:136:    [ -d $PID_PATH ] || mkdir -p $PID_PATH && chown -R $RUN_AS $PID_PATH > /dev/null || {
/etc/init.d/headphones:150:    [ -d $DATA_DIR ] || mkdir -p $DATA_DIR && chown -R $RUN_AS $DATA_DIR > /dev/null || {
/etc/init.d/headphones:156:    chown -R $RUN_AS $APP_PATH > /dev/null || {
/etc/init.d/iguanaIR:112:        chown iguanair:iguanair $LOGFILE
/etc/security/namespace.init:17:                chown -R "$user":"$gid" "$homedir"
/etc/cron.daily/man-db:20:    chown man:root /var/cache/man || true
/etc/cron.daily/man-db:28:    find /var/cache/man ! -user man -print0 | xargs -r0 chown man || true
/etc/init.d.save/screen-cleanup:29:        chown root:utmp $SCREENDIR
/etc/init.d.save/dbus:49:    chown $DAEMONUSER $PIDDIR
/etc/init.d.save/klogd:35:    chown klog:klog /var/run/klogd
/etc/init.d.save/klogd:37:    chown klog:klog $kmsgpipe
/etc/init.d.save/sysklogd:63:    chown ${USER}:adm /dev/xconsole
/etc/init.d.save/sysklogd:72:        chown ${USER}:adm $l
/etc/init.d.save/iguanaIR:112:        chown iguanair:iguanair $LOGFILE
/etc/init.d.save/headphones:16:## sudo chown headphones:nogroup -R /opt/headphones
/etc/init.d.save/headphones:136:    [ -d $PID_PATH ] || mkdir -p $PID_PATH && chown -R $RUN_AS $PID_PATH > /dev/null || {
/etc/init.d.save/headphones:150:    [ -d $DATA_DIR ] || mkdir -p $DATA_DIR && chown -R $RUN_AS $DATA_DIR > /dev/null || {
/etc/init.d.save/headphones:156:    chown -R $RUN_AS $APP_PATH > /dev/null || {
/etc/xbian-udhcpc/dhclient-script-xbian:55:        chown --reference=/etc/resolv.conf $new_resolv_conf
/etc/xbian-udhcpc/dhclient-script-xbian:80:        chown --reference=/etc/resolv.conf $new_resolv_conf
startup script for headphones

I updated the package, headphones ver 1.1.0-1 is on repo

apt-get upgrade to install
(22nd Dec, 2013 04:08 AM)mk01 Wrote: [ -> ]startup script for headphones

I updated the package, headphones ver 1.1.0-1 is on repo

apt-get upgrade to install

And what about fully resetting the perms? Any suggestions?
reinstalling each package installed

to be honest what I sent is 99% correct (the dirs and ownership is from fresh image extracted by filtering other owners than root). only problem is with special permissions like suid and guid and sticky.
but this should be solved by "dpkg-reconfigure -a" … what I proposed to run after general repair after reboot.
Reference URL's