5

I wanted to use strace to see what was happening when I do `hadoop fs -ls ', so I ran the command:

strace -f -e trace=execve hadoop fs -ls /stg which resulted in a lot of output like this:

[pid 187050] execve("/opt/sas/app/platform/lsf/8.0/linux2.6-glibc2.3-x86_64/etc/setsid", ["setsid", "bash", "-c", "echo $$"], [/* 78 vars */]) = -1 ENOENT (No such file or directory)
[pid 187050] execve("/opt/sas/app/platform/lsf/8.0/linux2.6-glibc2.3-x86_64/bin/setsid", ["setsid", "bash", "-c", "echo $$"], [/* 78 vars */]) = -1 ENOENT (No such file or directory)
[pid 187050] execve("/opt/dca/bin/setsid", ["setsid", "bash", "-c", "echo $$"], [/* 78 vars */]) = -1 ENOENT (No such file or directory)
[pid 187050] execve("/usr/local/greenplum-cc-web/./bin/setsid", ["setsid", "bash", "-c", "echo $$"], [/* 78 vars */]) = -1 ENOENT (No such file or directory)
[pid 187050] execve("/usr/lib64/qt-3.3/bin/setsid", ["setsid", "bash", "-c", "echo $$"], [/* 78 vars */]) = -1 ENOENT (No such file or directory)
[pid 187050] execve("/usr/local/bin/setsid", ["setsid", "bash", "-c", "echo $$"], [/* 78 vars */]) = -1 ENOENT (No such file or directory)
[pid 187050] execve("/bin/setsid", ["setsid", "bash", "-c", "echo $$"], [/* 78 vars */]) = -1 ENOENT (No such file or directory)
[pid 187050] execve("/usr/bin/setsid", ["setsid", "bash", "-c", "echo $$"], [/* 78 vars */]) = 0

Why would there be so many -1 ENOENT (No such file or directory) results?

1 Answer 1

9

It's trying to run the program by calling every potential location in $PATH-order without foreknowledge of where the program is. This is completely normal because doing something like stat() then execve() is considered a race condition by security best practices in a lot of software shops.

5
  • 1
    The libc functions execlp() and execvp() implement this PATH searching. The type of race condition is known as "TOCTOU", time-of-check time-of-use: CWE-367 Mar 12, 2015 at 10:25
  • 1
    Also, there is no point in doing checks first. You would just generate one extra system call. Mar 12, 2015 at 12:39
  • If I recall correctly, execlp and execvp both call a shell to do the path search for you (in the same way). Mar 12, 2015 at 12:50
  • @AndrewDomaszek None of the exec functions call a shell. They are all C library functions wrapping around the execve system call. The execve library call is a very thin wrapper, the other five exec functions need more logic and are likely implemented on top of the execve library call. The system library function does however call a shell.
    – kasperd
    Apr 13, 2015 at 8:39
  • IEEE Std 1003.1-2008 "In the cases where the other members of the exec family of functions would fail and set errno to [ENOEXEC], the execlp() and execvp() functions shall execute a command interpreter and the environment of the executed command shall be as if the process invoked the sh utility using execl() as follows [..]" Spec suggests otherwise... Apr 13, 2015 at 16:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .