]> granicus.if.org Git - shadow/commitdiff
* libmisc/shell.c: Removed invalid code that executed the user's
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Tue, 12 May 2009 20:01:41 +0000 (20:01 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Tue, 12 May 2009 20:01:41 +0000 (20:01 +0000)
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__.

ChangeLog
libmisc/shell.c

index 655681a16b56511efdc8f5cda7beb4f5571678c1..a356ad364f914773d8272915abf3faf318047525 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2009-05-12  Nicolas François  <nicolas.francois@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@centraliens.net>
 
        * man/userdel.8.xml: The USERGROUPS_ENAB group may not be removed
index 3d5e28ffb48d143953e6acb6922fd77ee23eb846..e3d8931e95fc3478ebfefcc7ccddb7387f7f184c 100644 (file)
@@ -46,11 +46,8 @@ extern size_t newenvc;
  *     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,32 +79,6 @@ int shell (const char *file, /*@null@*/const char *arg, char *const envp[])
        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
@@ -118,3 +89,4 @@ int shell (const char *file, /*@null@*/const char *arg, char *const envp[])
        perror (arg0);
        return err;
 }
+