execvp regression in glibc 2.3.5?

Jakub Bogusz qboosh@pld-linux.org
Thu Apr 14 18:37:00 GMT 2005


Reducing stack usage in exec*() functions, particularly this change:

http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/posix/execvp.c.diff?cvsroot=glibc&r1=1.21&r2=1.22

and its backport to glibc-2_3-branch:

http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/posix/execvp.c.diff?cvsroot=glibc&only_with_tag=glibc-2_3-branch&r1=1.21&r2=1.21.2.1

changed execvp() behaviour on shell scripts without #!/bin/sh header:
when such script is found in $PATH and trying to execve() it returns
ENOEXEC, /bin/sh is run with only script name, not full path as first
argument (as it used to be in glibc <= 2.3.4).
bash still can execute such script (finding it in $PATH), but e.g. pdksh
displays:
"/bin/sh: script-name: No such file or directory".

As this change isn't mentioned in ChangeLog, I think it wasn't
intentional (and looks like "copy-pasto").
Attached patch restores previous (i.e. glibc <= 2.3.4) behaviour.


-- 
Jakub Bogusz    http://cyber.cs.net.pl/~qboosh/
-------------- next part --------------
Execute shell with full script path, not just base name.

--- glibc-2.3.5/posix/execvp.c.orig	2005-02-26 02:02:17.000000000 +0100
+++ glibc-2.3.5/posix/execvp.c	2005-04-14 17:42:22.000000000 +0200
@@ -140,7 +140,7 @@
 	    {
 	      if (script_argv == NULL)
 		{
-		  script_argv = allocate_scripts_argv (file, argv);
+		  script_argv = allocate_scripts_argv (startp, argv);
 		  if (script_argv == NULL)
 		    {
 		      /* A possible EACCES error is not as important as


More information about the Libc-alpha mailing list