execve changes break execlp with 2.1.122

David Dyck (dcd@tc.fluke.com)
Sun, 20 Sep 1998 21:46:30 -0700


Linux dd 2.1.122 #2 SMP Sat Sep 19 20:30:23 PDT 1998 i686

strace'ing the following program demonstrates that execve
changed its return code when a non-existant directory
was in the path. One may argue that this is a library problem
but was it necessary to change the system call?

older versions including 2.1.121 set errno to ENOENT from execve
but 2.1.122 with pre-patch-2.1.123-1.gz applied sets errno to ENOTDIR.

This breaks make and other programs that use execlp or execvp
when there are non-existant directories earlier in the PATH.

The program assumes that /bin/echo exists.

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main()
{
if (putenv("PATH=/non_existant_directory:/bin") == -1) {
perror("putenv");
return 2;
}
if (execlp("echo", "echo", "execlp of echo ok", 0) == -1) {
perror("bug in execlp or execve");
return 1;
}
return 0;
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/