[Pkg-shadow-commits] r2918 - in upstream/trunk: . libmisc

Nicolas FRANÇOIS nekral-guest at alioth.debian.org
Tue May 12 20:01:42 UTC 2009


Author: nekral-guest
Date: 2009-05-12 20:01:41 +0000 (Tue, 12 May 2009)
New Revision: 2918

Modified:
   upstream/trunk/ChangeLog
   upstream/trunk/libmisc/shell.c
Log:
	* libmisc/shell.c: Removed invalid code that executed the user's
	shell as a shell script when the direct execution of the user's
	shell failed with ENOEXEC and the user's shell has a shebang. The
	interpreter might not be the right one.  Executing the user's
	shell with sh -c might be better, but I'm not sure we should try
	harder when there is a failure. Note: The removed code was only
	included #ifndef __linux__.


Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog	2009-05-12 19:25:26 UTC (rev 2917)
+++ upstream/trunk/ChangeLog	2009-05-12 20:01:41 UTC (rev 2918)
@@ -1,5 +1,15 @@
 2009-05-12  Nicolas François  <nicolas.francois at centraliens.net>
 
+	* libmisc/shell.c: Removed invalid code that executed the user's
+	shell as a shell script when the direct execution of the user's
+	shell failed with ENOEXEC and the user's shell has a shebang. The
+	interpreter might not be the right one.  Executing the user's
+	shell with sh -c might be better, but I'm not sure we should try
+	harder when there is a failure. Note: the removed code was only
+	included #ifndef __linux__.
+
+2009-05-12  Nicolas François  <nicolas.francois at centraliens.net>
+
 	* man/userdel.8.xml: The USERGROUPS_ENAB group may not be removed
 	when the group is used by other users, not the user.
 

Modified: upstream/trunk/libmisc/shell.c
===================================================================
--- upstream/trunk/libmisc/shell.c	2009-05-12 19:25:26 UTC (rev 2917)
+++ upstream/trunk/libmisc/shell.c	2009-05-12 20:01:41 UTC (rev 2918)
@@ -46,11 +46,8 @@
  *	shell begins by trying to figure out what argv[0] is going to
  *	be for the named process.  The user may pass in that argument,
  *	or it will be the last pathname component of the file with a
- *	'-' prepended.  The first attempt is to just execute the named
- *	file.  If the errno comes back "ENOEXEC", the file is assumed
- *	at first glance to be a shell script.  The first two characters
- *	must be "#!", in which case "/bin/sh" is executed to process
- *	the file.  If all that fails, give up in disgust ...
+ *	'-' prepended.
+ *	Then, it executes the named file.
  */
 
 int shell (const char *file, /*@null@*/const char *arg, char *const envp[])
@@ -82,33 +79,7 @@
 	execle (file, arg, (char *) 0, envp);
 	err = errno;
 
-	/* Linux handles #! in the kernel, and bash doesn't make
-	   sense of "#!" so it wouldn't work anyway...  --marekm */
-#ifndef __linux__
 	/*
-	 * It is perfectly OK to have a shell script for a login
-	 * shell, and this code attempts to support that.  It
-	 * relies on the standard shell being able to make sense
-	 * of the "#!" magic number.
-	 */
-	if (err == ENOEXEC) {
-		FILE *fp;
-
-		fp = fopen (file, "r");
-		if (NULL != fp) {
-			if (getc (fp) == '#' && getc (fp) == '!') {
-				(void) fclose (fp);
-				execle ("/bin/sh", "sh",
-				        file, (char *) 0, envp);
-				err = errno;
-			} else {
-				(void) fclose (fp);
-			}
-		}
-	}
-#endif
-
-	/*
 	 * Obviously something is really wrong - I can't figure out
 	 * how to execute this stupid shell, so I might as well give
 	 * up in disgust ...
@@ -118,3 +89,4 @@
 	perror (arg0);
 	return err;
 }
+




More information about the Pkg-shadow-commits mailing list