* 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__.
This commit is contained in:
parent
205e8b5137
commit
87bb724151
10
ChangeLog
10
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>
|
2009-05-12 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
* man/userdel.8.xml: The USERGROUPS_ENAB group may not be removed
|
* man/userdel.8.xml: The USERGROUPS_ENAB group may not be removed
|
||||||
|
@ -46,11 +46,8 @@ extern size_t newenvc;
|
|||||||
* shell begins by trying to figure out what argv[0] is going to
|
* 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,
|
* 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
|
* or it will be the last pathname component of the file with a
|
||||||
* '-' prepended. The first attempt is to just execute the named
|
* '-' prepended.
|
||||||
* file. If the errno comes back "ENOEXEC", the file is assumed
|
* Then, it executes the named file.
|
||||||
* 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 ...
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int shell (const char *file, /*@null@*/const char *arg, char *const envp[])
|
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);
|
execle (file, arg, (char *) 0, envp);
|
||||||
err = errno;
|
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
|
* Obviously something is really wrong - I can't figure out
|
||||||
* how to execute this stupid shell, so I might as well give
|
* 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);
|
perror (arg0);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user