Subject: lib/13242: execvp does not loop on ENOTDIR from execve
To: None <gnats-bugs@gnats.netbsd.org>
From: john heasley <heas@shrubbery.net>
List: netbsd-bugs
Date: 06/19/2001 00:12:13
>Number:         13242
>Category:       lib
>Synopsis:       execvp does not loop on ENOTDIR from execve
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jun 18 17:10:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     john heasley
>Release:        NetBSD-current ~5/25
>Organization:
>Environment:
NetBSD roome 1.5V NetBSD 1.5V (heas) #10: Fri May 25 19:38:02 UTC 2001     root@roome:/home/src/sys/arch/i386/compile/heas i386
Architecture: 386
Machine: 686
>Description:
	if an executable binary (or #!) is listed in PATH, execve returns
	ENOTDIR and execvp considers this an "unrecoverable" error instead
	of proceeding to the next PATH component.
>How-To-Repeat:
	tcsh% setenv PATH ~/bin:$PATH
	tcsh% cp /usr/bin/tail ~/bin
	tcsh% setenv SSH_RSH ssh
	tcsh% cvs -d user@host:/path co something
		[cvs works here, presumably because of it's cmd cache (rehash)]
	cvs [checkout aborted]: cannot exec ssh: Not a directory
	cvs [checkout aborted]: end of file from server (consult above messages if any)

	ktrace: exec of 'cvs' failed: Not a directory
	  1606 ktrace   EMUL  "netbsd"
	  1606 ktrace   CALL  execve(0xbfbfd270,0xbfbfd704,0xbfbfd71c)
	  1606 ktrace   NAMI  "/home/heas/bin/cvs"
	  1606 ktrace   RET   execve -1 errno 20 Not a directory

>Fix:
	ignore (loop) on ENOTDIR

	Index: execvp.c
	===================================================================
	RCS file: /cvsroot/basesrc/lib/libc/gen/execvp.c,v
	retrieving revision 1.16
	diff -c -r1.16 execvp.c
	*** execvp.c	2000/01/22 22:19:09	1.16
	--- execvp.c	2001/06/19 00:08:50
	***************
	*** 132,137 ****
	--- 132,138 ----
	  		case EACCES:
	  			eacces = 1;
	  			break;
	+ 		case ENOTDIR:
	  		case ENOENT:
	  			break;
	  		case ENOEXEC:
>Release-Note:
>Audit-Trail:
>Unformatted: