From b4b6d4dfb97bdb948ea4c918134cf2e1a826f3c2 Mon Sep 17 00:00:00 2001 From: ru Date: Fri, 24 May 2002 15:51:27 +0000 Subject: [PATCH] Back out the ``run shell from $PATH'' change; this was an overkill and is insecure. Requested by: bde --- usr.bin/make/Makefile | 2 +- usr.bin/make/compat.c | 14 +++----------- usr.bin/make/job.c | 6 +----- usr.bin/make/main.c | 12 ++---------- usr.bin/make/pathnames.h | 2 -- 5 files changed, 7 insertions(+), 29 deletions(-) diff --git a/usr.bin/make/Makefile b/usr.bin/make/Makefile index 448940b0ee5b..208c2cc40c27 100644 --- a/usr.bin/make/Makefile +++ b/usr.bin/make/Makefile @@ -15,7 +15,7 @@ SRCS+= lstAppend.c lstAtEnd.c lstAtFront.c lstClose.c lstConcat.c \ NOSHARED?= YES -CFLAGS+=-DMAKE_VERSION=\"5200205221\" +CFLAGS+=-DMAKE_VERSION=\"5200205240\" main.o: ${MAKEFILE} diff --git a/usr.bin/make/compat.c b/usr.bin/make/compat.c index d50068bcf589..f0d08aae9728 100644 --- a/usr.bin/make/compat.c +++ b/usr.bin/make/compat.c @@ -281,11 +281,7 @@ CompatRunCommand (cmdp, gnp) * -e flag as well as -c if it's supposed to exit when it hits an * error. */ -#ifndef _PATH_DEFSHELLDIR - static char *shargv[4] = { "sh" }; -#else /* _PATH_DEFSHELLDIR */ - static char *shargv[4] = { _PATH_DEFSHELLDIR"/sh" }; -#endif /* _PATH_DEFSHELLDIR */ + static char *shargv[4] = { "/bin/sh" }; shargv[1] = (errCheck ? "-ec" : "-c"); shargv[2] = cmd; @@ -297,11 +293,7 @@ CompatRunCommand (cmdp, gnp) * This command must be passed by the shell for other reasons.. * or.. possibly not at all. */ -#ifndef _PATH_DEFSHELLDIR - static char *shargv[4] = { "sh" }; -#else /* _PATH_DEFSHELLDIR */ - static char *shargv[4] = { _PATH_DEFSHELLDIR"/sh" }; -#endif /* _PATH_DEFSHELLDIR */ + static char *shargv[4] = { "/bin/sh" }; if (internal == -1) { /* Command does not need to be executed */ @@ -341,7 +333,7 @@ CompatRunCommand (cmdp, gnp) (void) write (STDERR_FILENO, strerror(errno), strlen(strerror(errno))); (void) write (STDERR_FILENO, "\n", 1); } else { - (void)execvp(av[0], av); + (void)execv(av[0], av); } exit(1); } diff --git a/usr.bin/make/job.c b/usr.bin/make/job.c index 58ba738d0e2a..bf98c9195598 100644 --- a/usr.bin/make/job.c +++ b/usr.bin/make/job.c @@ -1283,7 +1283,7 @@ JobExec(job, argv) Rmt_Exec(shellPath, argv, FALSE); } else #endif /* REMOTE */ - (void) execvp(shellPath, argv); + (void) execv(shellPath, argv); (void) write(STDERR_FILENO, "Could not execute shell\n", sizeof("Could not execute shell")); @@ -2449,11 +2449,7 @@ Job_Init(maxproc, maxlocal) * All default shells are located in _PATH_DEFSHELLDIR. */ shellName = commandShell->name; -#ifndef _PATH_DEFSHELLDIR - shellPath = shellName; -#else /* _PATH_DEFSHELLDIR */ shellPath = str_concat(_PATH_DEFSHELLDIR, shellName, STR_ADDSLASH); -#endif /* _PATH_DEFSHELLDIR */ } if (commandShell->exit == NULL) { diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c index e0616aeb0301..6a035597e336 100644 --- a/usr.bin/make/main.c +++ b/usr.bin/make/main.c @@ -1021,17 +1021,9 @@ Cmd_Exec(cmd, err) (void) close(fds[1]); #if DEFSHELL == 1 -#ifndef _PATH_DEFSHELLDIR - (void) execvp("sh", args); -#else /* _PATH_DEFSHELLDIR */ - (void) execv(_PATH_DEFSHELLDIR"/sh", args); -#endif /* _PATH_DEFSHELLDIR */ + (void) execv("/bin/sh", args); #elif DEFSHELL == 2 -#ifndef _PATH_DEFSHELLDIR - (void) execvp("ksh", args); -#else /* _PATH_DEFSHELLDIR */ - (void) execv(_PATH_DEFSHELLDIR"/ksh", args); -#endif /* _PATH_DEFSHELLDIR */ + (void) execv("/bin/ksh", args); #else #error "DEFSHELL must be 1 or 2." #endif diff --git a/usr.bin/make/pathnames.h b/usr.bin/make/pathnames.h index 033901a5cf5e..d16167cc1f69 100644 --- a/usr.bin/make/pathnames.h +++ b/usr.bin/make/pathnames.h @@ -40,11 +40,9 @@ #ifndef _PATH_OBJDIRPREFIX #define _PATH_OBJDIRPREFIX "/usr/obj" #endif /* ! _PATH_OBJDIRPREFIX */ -#ifndef __FreeBSD__ #ifndef _PATH_DEFSHELLDIR #define _PATH_DEFSHELLDIR "/bin" #endif /* ! _PATH_DEFSHELLDIR */ -#endif /* not __FreeBSD__ */ #ifndef _PATH_DEFSYSMK #define _PATH_DEFSYSMK "sys.mk" #endif /* ! _PATH_DEFSYSMK */