diff --git a/usr.sbin/ppp/bundle.c b/usr.sbin/ppp/bundle.c index a054b132fbfe..cf48743be3b6 100644 --- a/usr.sbin/ppp/bundle.c +++ b/usr.sbin/ppp/bundle.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: bundle.c,v 1.1.2.65 1998/04/30 23:53:21 brian Exp $ + * $Id: bundle.c,v 1.1.2.66 1998/05/01 19:19:54 brian Exp $ */ #include @@ -1196,6 +1196,7 @@ bundle_SendDatalink(struct datalink *dl, int ppp_fd) ppp_fd = fcntl(ppp_fd, F_DUPFD, 3); link_fd = fcntl(link_fd, F_DUPFD, 3); nfd = dup2(open(_PATH_DEVNULL, O_WRONLY), STDERR_FILENO); + fcntl(3, F_SETFD, 1); /* Set close-on-exec flag */ setsid(); setuid(geteuid()); diff --git a/usr.sbin/ppp/chat.c b/usr.sbin/ppp/chat.c index 49698b2cfb2a..6ade25499075 100644 --- a/usr.sbin/ppp/chat.c +++ b/usr.sbin/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.44.2.26 1998/04/28 01:25:09 brian Exp $ + * $Id: chat.c,v 1.44.2.27 1998/04/30 23:53:26 brian Exp $ */ #include @@ -34,6 +34,7 @@ #include #include +#include #include #include #include @@ -728,25 +729,16 @@ ExecStr(struct physical *physical, char *command, char *out, int olen) } if ((pid = fork()) == 0) { TermTimerService(); - signal(SIGINT, SIG_DFL); - signal(SIGQUIT, SIG_DFL); - signal(SIGTERM, SIG_DFL); - signal(SIGHUP, SIG_DFL); - signal(SIGALRM, SIG_DFL); - /* XXX-ML This looks like it might need more encapsulation. */ - if (Physical_GetFD(physical) == 2) { - Physical_DupAndClose(physical); - } - close(fids[0]); - dup2(fids[1], 2); - close(fids[1]); - dup2(Physical_GetFD(physical), 0); - dup2(Physical_GetFD(physical), 1); - if ((nb = open("/dev/tty", O_RDWR)) > 3) { - dup2(nb, 3); - close(nb); + + fids[1] = fcntl(fids[1], F_DUPFD, 4); + dup2(Physical_GetFD(physical), STDIN_FILENO); + dup2(STDIN_FILENO, STDOUT_FILENO); + dup2(fids[1], STDERR_FILENO); + close(3); + if (open(_PATH_TTY, O_RDWR) == 3) fcntl(3, F_SETFD, 0); /* Clear close-on-exec flag */ - } + else + fcntl(3, F_SETFD, 1); /* Set close-on-exec flag */ setuid(geteuid()); execvp(vector[0], vector); fprintf(stderr, "execvp failed: %s: %s\n", vector[0], strerror(errno)); diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c index 7a8c0b13e24d..8cdea4e27a44 100644 --- a/usr.sbin/ppp/command.c +++ b/usr.sbin/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.131.2.74 1998/04/30 23:53:29 brian Exp $ + * $Id: command.c,v 1.131.2.75 1998/05/01 19:19:58 brian Exp $ * */ #include @@ -123,7 +123,7 @@ #define NEG_DNS 50 const char Version[] = "2.0-beta"; -const char VersionDate[] = "$Date: 1998/04/30 23:53:29 $"; +const char VersionDate[] = "$Date: 1998/05/01 19:19:58 $"; static int ShowCommand(struct cmdargs const *); static int TerminalCommand(struct cmdargs const *); @@ -317,11 +317,6 @@ ShellCommand(struct cmdargs const *arg, int bg) shell = _PATH_BSHELL; TermTimerService(); - signal(SIGINT, SIG_DFL); - signal(SIGQUIT, SIG_DFL); - signal(SIGTERM, SIG_DFL); - signal(SIGHUP, SIG_DFL); - signal(SIGALRM, SIG_DFL); if (arg->prompt) fd = arg->prompt->fd_out; @@ -333,6 +328,8 @@ ShellCommand(struct cmdargs const *arg, int bg) for (i = 0; i < 3; i++) dup2(fd, i); + fcntl(3, F_SETFD, 1); /* Set close-on-exec flag */ + setuid(geteuid()); if (arg->argc > arg->argn) { /* substitute pseudo args */ diff --git a/usr.sbin/ppp/modem.c b/usr.sbin/ppp/modem.c index 00b716882347..6aace52470b7 100644 --- a/usr.sbin/ppp/modem.c +++ b/usr.sbin/ppp/modem.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: modem.c,v 1.77.2.60 1998/04/30 23:53:49 brian Exp $ + * $Id: modem.c,v 1.77.2.61 1998/05/01 19:20:09 brian Exp $ * * TODO: */ @@ -251,10 +251,12 @@ IntToSpeed(int nspeed) static void modem_SetDevice(struct physical *physical, const char *name) { + int len = strlen(_PATH_DEV); + strncpy(physical->name.full, name, sizeof physical->name.full - 1); physical->name.full[sizeof physical->name.full - 1] = '\0'; - physical->name.base = strncmp(physical->name.full, "/dev/", 5) ? - physical->name.full : physical->name.full + 5; + physical->name.base = strncmp(physical->name.full, _PATH_DEV, len) ? + physical->name.full : physical->name.full + len; } /* diff --git a/usr.sbin/ppp/physical.c b/usr.sbin/ppp/physical.c index 7910a19cb049..decb7feebce5 100644 --- a/usr.sbin/ppp/physical.c +++ b/usr.sbin/ppp/physical.c @@ -16,13 +16,12 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: physical.c,v 1.1.2.27 1998/04/28 01:25:37 brian Exp $ + * $Id: physical.c,v 1.1.2.28 1998/04/30 23:53:53 brian Exp $ * */ #include -#include #include #include #include @@ -104,21 +103,10 @@ Physical_SetSync(struct physical *phys) { int Physical_SetRtsCts(struct physical *phys, int enable) { - assert(enable == 0 || enable == 1); - - phys->cfg.rts_cts = enable; + phys->cfg.rts_cts = enable ? 1 : 0; return 1; } -void -Physical_DupAndClose(struct physical *phys) { - int nmodem; - - nmodem = dup(phys->fd); - close(phys->fd); - phys->fd = nmodem; -} - /* Encapsulation for a read on the FD. Avoids some exposure, and concentrates control. */ ssize_t diff --git a/usr.sbin/ppp/physical.h b/usr.sbin/ppp/physical.h index c45b2f34a4c9..536c6ffa0da5 100644 --- a/usr.sbin/ppp/physical.h +++ b/usr.sbin/ppp/physical.h @@ -16,7 +16,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: physical.h,v 1.1.2.21 1998/04/10 23:51:33 brian Exp $ + * $Id: physical.h,v 1.1.2.22 1998/04/20 00:20:41 brian Exp $ * */ @@ -90,7 +90,6 @@ int /* Can this be set? (Might not be a relevant attribute for this device, for instance) */ Physical_SetRtsCts(struct physical *, int); -void Physical_DupAndClose(struct physical *); ssize_t Physical_Read(struct physical *, void *, size_t); ssize_t Physical_Write(struct physical *, const void *, size_t); int Physical_UpdateSet(struct descriptor *, fd_set *, fd_set *, fd_set *,