Search code examples
linuxsudo

Cannot strace sudo; reports that effective uid is nonzero


command:

bigxu@bigxu-ThinkPad-T410 ~/work/lean $ sudo ls
content_shell.pak  leanote  libgcrypt.so.11  libnotify.so.4  __MACOSX      resources
icudtl.dat     leanote.png  libnode.so   locales     natives_blob.bin  snapshot_blob.bin

most time it is right.but sometimes it is very slow. so i strace it.

command:

bigxu@bigxu-ThinkPad-T410 ~/work/lean $ strace sudo ls
execve("/usr/bin/sudo", ["sudo", "ls"], [/* 66 vars */]) = 0
brk(0)                                  = 0x7f2b3c423000
fcntl(0, F_GETFD)                       = 0
fcntl(1, F_GETFD)                       = 0
fcntl(2, F_GETFD)                       = 0
......
......
......
write(2, "sudo: effective uid is not 0, is"..., 140sudo: effective uid is not 0, is /usr/bin/sudo on a file system with the 'nosuid' option set or an NFS file system without root privileges?
) = 140
exit_group(1)                           = ?
+++ exited with 1 +++

other information:

bigxu-ThinkPad-T410 lean # ls /etc/sudoers -alht
-r--r----- 1 root root 745  2月 11  2014 /etc/sudoers
bigxu-ThinkPad-T410 lean # ls /usr/bin/sudo -alht
-rwsr-xr-x 1 root root 152K 12月 14 21:13 /usr/bin/sudo
bigxu-ThinkPad-T410 lean # df `which sudo`
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/sdb1       67153528 7502092  56217148  12% 

Solution

  • For security reasons, the setuid bit and ptrace (used to run binaries under a debugger) cannot both be honored at the same time. Failure to enforce this restriction in the past led to CVE-2001-1384.

    Consequently, any operating system designed with an eye to security will either stop honoring ptrace on exec of a setuid binary, or fail to honor the setuid bit when ptrace is in use.

    On Linux, consider using Sysdig instead -- which, being able to only view but not modify behavior, does not run the same risks.