diff options
author | brian <brian@cvs.openbsd.org> | 1999-06-09 08:47:24 +0000 |
---|---|---|
committer | brian <brian@cvs.openbsd.org> | 1999-06-09 08:47:24 +0000 |
commit | 58ee5d71444da64ff4e0f546b189830b629bafcb (patch) | |
tree | 10f4fc7a1e41ce6e2de05c9f481e5dcbb09cf65f /usr.sbin/ppp | |
parent | 5b25504c910ae952393636884728bb911ccd8733 (diff) |
Use the correct pid when substituting PROCESSID.
Problem reported by: Amedeo Beck Peccoz <gea@gressoney.it>
Diffstat (limited to 'usr.sbin/ppp')
-rw-r--r-- | usr.sbin/ppp/ppp/chap.c | 6 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp/chat.c | 4 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp/command.c | 19 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp/command.h | 4 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp/exec.c | 7 |
5 files changed, 22 insertions, 18 deletions
diff --git a/usr.sbin/ppp/ppp/chap.c b/usr.sbin/ppp/ppp/chap.c index 7f5f509094d..090f3ad218c 100644 --- a/usr.sbin/ppp/ppp/chap.c +++ b/usr.sbin/ppp/ppp/chap.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: chap.c,v 1.13 1999/06/02 15:58:40 brian Exp $ + * $Id: chap.c,v 1.14 1999/06/09 08:47:23 brian Exp $ * * TODO: */ @@ -197,6 +197,7 @@ chap_StartChild(struct chap *chap, char *prog, const char *name) char *argv[MAXARGS], *nargv[MAXARGS]; int argc, fd; int in[2], out[2]; + pid_t pid; if (chap->child.fd != -1) { log_Printf(LogWARN, "Chap: %s: Program already running\n", prog); @@ -215,6 +216,7 @@ chap_StartChild(struct chap *chap, char *prog, const char *name) return; } + pid = getpid(); switch ((chap->child.pid = fork())) { case -1: log_Printf(LogERROR, "Chap: fork: %s\n", strerror(errno)); @@ -247,7 +249,7 @@ chap_StartChild(struct chap *chap, char *prog, const char *name) setuid(geteuid()); argc = command_Interpret(prog, strlen(prog), argv); command_Expand(nargv, argc, (char const *const *)argv, - chap->auth.physical->dl->bundle, 0); + chap->auth.physical->dl->bundle, 0, pid); execvp(nargv[0], nargv); log_Printf(LogWARN, "exec() of %s failed: %s\n", diff --git a/usr.sbin/ppp/ppp/chat.c b/usr.sbin/ppp/ppp/chat.c index feb51ba448a..f4a44c02333 100644 --- a/usr.sbin/ppp/ppp/chat.c +++ b/usr.sbin/ppp/ppp/chat.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: chat.c,v 1.6 1999/05/27 09:51:12 brian Exp $ + * $Id: chat.c,v 1.7 1999/06/09 08:47:23 brian Exp $ */ #include <sys/param.h> @@ -683,7 +683,7 @@ ExecStr(struct physical *physical, char *command, char *out, int olen) log_Printf(LogCHAT, "Exec: %s\n", command); argc = MakeArgs(command, vector, VECSIZE(vector)); command_Expand(argv, argc, (char const *const *)vector, - physical->dl->bundle, 0); + physical->dl->bundle, 0, getpid()); if (pipe(fids) < 0) { log_Printf(LogCHAT, "Unable to create pipe in ExecStr: %s\n", diff --git a/usr.sbin/ppp/ppp/command.c b/usr.sbin/ppp/ppp/command.c index 1799940a59a..0bdc184b734 100644 --- a/usr.sbin/ppp/ppp/command.c +++ b/usr.sbin/ppp/ppp/command.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: command.c,v 1.26 1999/06/08 20:12:28 brian Exp $ + * $Id: command.c,v 1.27 1999/06/09 08:47:23 brian Exp $ * */ #include <sys/param.h> @@ -143,7 +143,7 @@ #define NEG_DNS 52 const char Version[] = "2.22"; -const char VersionDate[] = "$Date: 1999/06/08 20:12:28 $"; +const char VersionDate[] = "$Date: 1999/06/09 08:47:23 $"; static int ShowCommand(struct cmdargs const *); static int TerminalCommand(struct cmdargs const *); @@ -395,10 +395,10 @@ subst(char *tgt, const char *oldstr, const char *newstr) void command_Expand(char **nargv, int argc, char const *const *oargv, - struct bundle *bundle, int inc0) + struct bundle *bundle, int inc0, pid_t pid) { int arg; - char pid[12]; + char pidstr[12]; if (inc0) arg = 0; /* Start at arg 0 */ @@ -406,7 +406,7 @@ command_Expand(char **nargv, int argc, char const *const *oargv, nargv[0] = strdup(oargv[0]); arg = 1; } - snprintf(pid, sizeof pid, "%d", getpid()); + snprintf(pidstr, sizeof pidstr, "%d", (int)pid); for (; arg < argc; arg++) { nargv[arg] = strdup(oargv[arg]); nargv[arg] = subst(nargv[arg], "HISADDR", @@ -423,7 +423,7 @@ command_Expand(char **nargv, int argc, char const *const *oargv, mp_Enddisc(bundle->ncp.mp.cfg.enddisc.class, bundle->ncp.mp.cfg.enddisc.address, bundle->ncp.mp.cfg.enddisc.len)); - nargv[arg] = subst(nargv[arg], "PROCESSID", pid); + nargv[arg] = subst(nargv[arg], "PROCESSID", pidstr); nargv[arg] = subst(nargv[arg], "LABEL", bundle_GetLabel(bundle)); } nargv[arg] = NULL; @@ -433,7 +433,7 @@ static int ShellCommand(struct cmdargs const *arg, int bg) { const char *shell; - pid_t shpid; + pid_t shpid, pid; #ifdef SHELL_ONLY_INTERACTIVELY /* we're only allowed to shell when we run ppp interactively */ @@ -459,6 +459,7 @@ ShellCommand(struct cmdargs const *arg, int bg) } } + pid = getpid(); if ((shpid = fork()) == 0) { int i, fd; @@ -489,7 +490,7 @@ ShellCommand(struct cmdargs const *arg, int bg) argc = sizeof argv / sizeof argv[0] - 1; log_Printf(LogWARN, "Truncating shell command to %d args\n", argc); } - command_Expand(argv, argc, arg->argv + arg->argn, arg->bundle, 0); + command_Expand(argv, argc, arg->argv + arg->argn, arg->bundle, 0, pid); if (bg) { pid_t p; @@ -2537,7 +2538,7 @@ SetProcTitle(struct cmdargs const *arg) argc = sizeof argv / sizeof argv[0] - 1; log_Printf(LogWARN, "Truncating proc title to %d args\n", argc); } - command_Expand(argv, argc, arg->argv + arg->argn, arg->bundle, 1); + command_Expand(argv, argc, arg->argv + arg->argn, arg->bundle, 1, getpid()); ptr = title; remaining = sizeof title - 1; diff --git a/usr.sbin/ppp/ppp/command.h b/usr.sbin/ppp/ppp/command.h index 32495e93a91..854fa6b093c 100644 --- a/usr.sbin/ppp/ppp/command.h +++ b/usr.sbin/ppp/ppp/command.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: command.h,v 1.3 1999/02/11 10:14:50 brian Exp $ + * $Id: command.h,v 1.4 1999/06/09 08:47:23 brian Exp $ * * TODO: */ @@ -55,7 +55,7 @@ extern const char Version[]; extern const char VersionDate[]; extern void command_Expand(char **, int, char const *const *, struct bundle *, - int); + int, pid_t); extern int command_Interpret(char *, int, char *vector[MAXARGS]); extern void command_Run(struct bundle *, int, char const *const *, struct prompt *, const char *, struct datalink *); diff --git a/usr.sbin/ppp/ppp/exec.c b/usr.sbin/ppp/ppp/exec.c index a2e4387bd99..daef54e7415 100644 --- a/usr.sbin/ppp/ppp/exec.c +++ b/usr.sbin/ppp/ppp/exec.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: exec.c,v 1.5 1999/06/05 21:35:59 brian Exp $ + * $Id: exec.c,v 1.6 1999/06/09 08:47:23 brian Exp $ */ #include <sys/param.h> @@ -118,7 +118,7 @@ exec_Create(struct physical *p) strerror(errno)); else { int stat, argc; - pid_t pid; + pid_t pid, realpid; char *argv[MAXARGS]; stat = fcntl(fids[0], F_GETFL, 0); @@ -126,6 +126,7 @@ exec_Create(struct physical *p) stat |= O_NONBLOCK; fcntl(fids[0], F_SETFL, stat); } + realpid = getpid(); switch ((pid = fork())) { case -1: log_Printf(LogPHASE, "Unable to create pipe for line exec: %s\n", @@ -156,7 +157,7 @@ exec_Create(struct physical *p) log_Printf(LogDEBUG, "Exec'ing ``%s''\n", p->name.base); argc = MakeArgs(p->name.base, argv, VECSIZE(argv)); command_Expand(argv, argc, (char const *const *)argv, - p->dl->bundle, 0); + p->dl->bundle, 0, realpid); execvp(*argv, argv); fprintf(stderr, "execvp failed: %s: %s\r\n", *argv, strerror(errno)); _exit(127); |