From f409b9f7b070fc7e0d1839f09d813503d7224df6 Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Wed, 24 Mar 1999 05:05:25 +0000 Subject: [PATCH 1/1] should read the tty options file now. --- pppd/main.c | 40 +++++++++++++++++++++++----------------- pppd/options.c | 8 ++++++-- pppd/pppd.h | 3 ++- 3 files changed, 31 insertions(+), 20 deletions(-) diff --git a/pppd/main.c b/pppd/main.c index c69d6c2..ba5e6ae 100644 --- a/pppd/main.c +++ b/pppd/main.c @@ -18,7 +18,7 @@ */ #ifndef lint -static char rcsid[] = "$Id: main.c,v 1.65 1999/03/23 01:23:46 paulus Exp $"; +static char rcsid[] = "$Id: main.c,v 1.66 1999/03/24 05:05:24 paulus Exp $"; #endif #include @@ -246,7 +246,25 @@ main(argc, argv) if (!options_from_file(_PATH_SYSOPTIONS, !privileged, 0, 1) || !options_from_user()) exit(1); + using_pty = notty || ptycommand != NULL; scan_args(argc-1, argv+1); /* look for tty name on command line */ + + /* + * Work out the device name, if it hasn't already been specified. + */ + if (!using_pty) { + p = isatty(0)? ttyname(0): NULL; + if (p != NULL) { + if (default_device) + strlcpy(devnam, p, sizeof(devnam)); + else if (strcmp(devnam, p) == 0) + default_device = 1; + } + } + + /* + * Parse the tty options file and the command line. + */ if (!options_for_tty() || !parse_args(argc-1, argv+1)) exit(1); @@ -279,7 +297,7 @@ main(argc, argv) exit(1); } - if (ptycommand != NULL || notty) { + if (using_pty) { if (!default_device) { option_error("%s option precludes specifying device name", notty? "notty": "pty"); @@ -293,21 +311,9 @@ main(argc, argv) lockflag = 0; modem = 0; } else { - /* - * If the user has specified the default device name explicitly, - * pretend they hadn't. - */ - p = isatty(0)? ttyname(0): NULL; - if (p == NULL) { - if (default_device) { - option_error("no device specified and stdin is not a tty"); - exit(1); - } - } else { - if (default_device) - strlcpy(devnam, p, sizeof(devnam)); - else if (strcmp(devnam, p) == 0) - default_device = 1; + if (devnam[0] == 0) { + option_error("no device specified and stdin is not a tty"); + exit(1); } } if (default_device) diff --git a/pppd/options.c b/pppd/options.c index 7d5c71a..3e28def 100644 --- a/pppd/options.c +++ b/pppd/options.c @@ -18,7 +18,7 @@ */ #ifndef lint -static char rcsid[] = "$Id: options.c,v 1.54 1999/03/22 05:55:33 paulus Exp $"; +static char rcsid[] = "$Id: options.c,v 1.55 1999/03/24 05:05:24 paulus Exp $"; #endif #include @@ -88,6 +88,7 @@ int idle_time_limit = 0; /* Disconnect if idle for this many seconds */ int holdoff = 30; /* # seconds to pause before reconnecting */ bool notty = 0; /* Stdin/out is not a tty */ char *record_file = NULL; /* File to record chars sent/received */ +int using_pty = 0; extern option_t auth_options[]; @@ -299,7 +300,7 @@ parse_args(argc, argv) /* * scan_args - scan the command line arguments to get the tty name, - * if specified. + * if specified. Also checks whether the notty or pty option was given. */ void scan_args(argc, argv) @@ -314,6 +315,9 @@ scan_args(argc, argv) arg = *argv++; --argc; + if (strcmp(arg, "notty") == 0 || strcmp(arg, "pty") == 0) + using_pty = 1; + /* Skip options and their arguments */ opt = find_option(arg); if (opt != NULL) { diff --git a/pppd/pppd.h b/pppd/pppd.h index dcd469b..04c3ff9 100644 --- a/pppd/pppd.h +++ b/pppd/pppd.h @@ -16,7 +16,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: pppd.h,v 1.34 1999/03/22 05:55:35 paulus Exp $ + * $Id: pppd.h,v 1.35 1999/03/24 05:05:25 paulus Exp $ */ /* @@ -144,6 +144,7 @@ extern GIDSET_TYPE groups[NGROUPS_MAX]; /* groups the user is in */ extern int ngroups; /* How many groups valid in groups */ extern struct pppd_stats link_stats; /* byte/packet counts etc. for link */ extern int link_stats_valid; /* set if link_stats is valid */ +extern int using_pty; /* using pty as device (notty or pty opt.) */ /* * Variables set by command-line options. -- 2.39.2