Deleted Added
full compact
command.c (49434) command.c (49976)
1/*
2 * PPP User command processing module
3 *
4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp)
5 *
6 * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
7 *
8 * Redistribution and use in source and binary forms are permitted
9 * provided that the above copyright notice and this paragraph are
10 * duplicated in all such forms and that any documentation,
11 * advertising materials, and other materials related to such
12 * distribution and use acknowledge that the software was developed
13 * by the Internet Initiative Japan, Inc. The name of the
14 * IIJ may not be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 *
1/*
2 * PPP User command processing module
3 *
4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp)
5 *
6 * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
7 *
8 * Redistribution and use in source and binary forms are permitted
9 * provided that the above copyright notice and this paragraph are
10 * duplicated in all such forms and that any documentation,
11 * advertising materials, and other materials related to such
12 * distribution and use acknowledge that the software was developed
13 * by the Internet Initiative Japan, Inc. The name of the
14 * IIJ may not be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 *
20 * $Id: command.c,v 1.204 1999/08/02 21:45:35 brian Exp $
20 * $Id: command.c,v 1.205 1999/08/05 10:32:09 brian Exp $
21 *
22 */
23#include <sys/param.h>
24#include <netinet/in_systm.h>
25#include <netinet/in.h>
26#include <netinet/ip.h>
27#include <arpa/inet.h>
28#include <sys/socket.h>

--- 110 unchanged lines hidden (view full) ---

139#define NEG_PAP 48
140#define NEG_PPPDDEFLATE 49
141#define NEG_PRED1 50
142#define NEG_PROTOCOMP 51
143#define NEG_SHORTSEQ 52
144#define NEG_VJCOMP 53
145
146const char Version[] = "2.23";
21 *
22 */
23#include <sys/param.h>
24#include <netinet/in_systm.h>
25#include <netinet/in.h>
26#include <netinet/ip.h>
27#include <arpa/inet.h>
28#include <sys/socket.h>

--- 110 unchanged lines hidden (view full) ---

139#define NEG_PAP 48
140#define NEG_PPPDDEFLATE 49
141#define NEG_PRED1 50
142#define NEG_PROTOCOMP 51
143#define NEG_SHORTSEQ 52
144#define NEG_VJCOMP 53
145
146const char Version[] = "2.23";
147const char VersionDate[] = "$Date: 1999/08/02 21:45:35 $";
147const char VersionDate[] = "$Date: 1999/08/05 10:32:09 $";
148
149static int ShowCommand(struct cmdargs const *);
150static int TerminalCommand(struct cmdargs const *);
151static int QuitCommand(struct cmdargs const *);
152static int OpenCommand(struct cmdargs const *);
153static int CloseCommand(struct cmdargs const *);
154static int DownCommand(struct cmdargs const *);
155static int SetCommand(struct cmdargs const *);

--- 317 unchanged lines hidden (view full) ---

473
474 if (arg->prompt)
475 fd = arg->prompt->fd_out;
476 else if ((fd = open(_PATH_DEVNULL, O_RDWR)) == -1) {
477 log_Printf(LogALERT, "Failed to open %s: %s\n",
478 _PATH_DEVNULL, strerror(errno));
479 exit(1);
480 }
148
149static int ShowCommand(struct cmdargs const *);
150static int TerminalCommand(struct cmdargs const *);
151static int QuitCommand(struct cmdargs const *);
152static int OpenCommand(struct cmdargs const *);
153static int CloseCommand(struct cmdargs const *);
154static int DownCommand(struct cmdargs const *);
155static int SetCommand(struct cmdargs const *);

--- 317 unchanged lines hidden (view full) ---

473
474 if (arg->prompt)
475 fd = arg->prompt->fd_out;
476 else if ((fd = open(_PATH_DEVNULL, O_RDWR)) == -1) {
477 log_Printf(LogALERT, "Failed to open %s: %s\n",
478 _PATH_DEVNULL, strerror(errno));
479 exit(1);
480 }
481 for (i = 0; i < 3; i++)
482 dup2(fd, i);
481 dup2(fd, STDIN_FILENO);
482 dup2(fd, STDOUT_FILENO);
483 dup2(fd, STDERR_FILENO);
484 for (i = getdtablesize(); i > STDERR_FILENO; i--)
485 fcntl(i, F_SETFD, 1);
483
486
484 fcntl(3, F_SETFD, 1); /* Set close-on-exec flag */
485
486 setuid(geteuid());
487 if (arg->argc > arg->argn) {
488 /* substitute pseudo args */
489 char *argv[MAXARGS];
490 int argc = arg->argc - arg->argn;
491
492 if (argc >= sizeof argv / sizeof argv[0]) {
493 argc = sizeof argv / sizeof argv[0] - 1;

--- 16 unchanged lines hidden (view full) ---

510 printf("ppp: Pausing until %s finishes\n", shell);
511 prompt_TtyOldMode(arg->prompt);
512 execl(shell, shell, NULL);
513 }
514
515 log_Printf(LogWARN, "exec() of %s failed: %s\n",
516 arg->argc > arg->argn ? arg->argv[arg->argn] : shell,
517 strerror(errno));
487 setuid(geteuid());
488 if (arg->argc > arg->argn) {
489 /* substitute pseudo args */
490 char *argv[MAXARGS];
491 int argc = arg->argc - arg->argn;
492
493 if (argc >= sizeof argv / sizeof argv[0]) {
494 argc = sizeof argv / sizeof argv[0] - 1;

--- 16 unchanged lines hidden (view full) ---

511 printf("ppp: Pausing until %s finishes\n", shell);
512 prompt_TtyOldMode(arg->prompt);
513 execl(shell, shell, NULL);
514 }
515
516 log_Printf(LogWARN, "exec() of %s failed: %s\n",
517 arg->argc > arg->argn ? arg->argv[arg->argn] : shell,
518 strerror(errno));
518 exit(255);
519 _exit(255);
519 }
520
521 if (shpid == (pid_t) - 1)
522 log_Printf(LogERROR, "Fork failed: %s\n", strerror(errno));
523 else {
524 int status;
525 waitpid(shpid, &status, 0);
526 }

--- 2069 unchanged lines hidden ---
520 }
521
522 if (shpid == (pid_t) - 1)
523 log_Printf(LogERROR, "Fork failed: %s\n", strerror(errno));
524 else {
525 int status;
526 waitpid(shpid, &status, 0);
527 }

--- 2069 unchanged lines hidden ---