diff -ur ppp-2.3.11/pppd/demand.c ppp-2.3.11mnb1/pppd/demand.c --- ppp-2.3.11/pppd/demand.c Thu Aug 12 23:46:12 1999 +++ ppp-2.3.11mnb1/pppd/demand.c Tue Sep 6 16:08:35 1904 @@ -85,8 +85,8 @@ flush_flag = 0; fcs = PPP_INITFCS; - ppp_send_config(0, PPP_MRU, (u_int32_t) 0, 0, 0); - ppp_recv_config(0, PPP_MRU, (u_int32_t) 0, 0, 0); + send_config_hook(0, PPP_MRU, (u_int32_t) 0, 0, 0); + recv_config_hook(0, PPP_MRU, (u_int32_t) 0, 0, 0); #ifdef PPP_FILTER set_filters(&pass_filter, &active_filter); diff -ur ppp-2.3.11/pppd/lcp.c ppp-2.3.11mnb1/pppd/lcp.c --- ppp-2.3.11/pppd/lcp.c Wed Dec 22 17:27:28 1999 +++ ppp-2.3.11mnb1/pppd/lcp.c Tue Sep 6 16:07:59 1904 @@ -82,6 +82,8 @@ { "nopcomp", o_bool, &lcp_wantoptions[0].neg_pcompression, "Disable protocol field compression", OPT_A2COPY, &lcp_allowoptions[0].neg_pcompression }, + { "pcomp", o_bool, &lcp_wantoptions[0].neg_pcompression, + "Enable protocol field compression (default)", 1 }, { "-pc", o_bool, &lcp_wantoptions[0].neg_pcompression, "Disable protocol field compression", OPT_A2COPY, &lcp_allowoptions[0].neg_pcompression }, @@ -172,6 +174,13 @@ }; /* + * Hooks we use which can be overridden by protocol plugins + */ +void (*recv_config_hook) __P((int, int, u_int32_t, int, int)) = ppp_recv_config; +void (*send_config_hook) __P((int, int, u_int32_t, int, int)) = ppp_send_config; +void (*set_xaccm_hook) __P((int, ext_accm)) = ppp_set_xaccm; + +/* * Protocol entry points. * Some of these are called directly. */ @@ -366,9 +375,9 @@ * but accept A/C and protocol compressed packets * if we are going to ask for A/C and protocol compression. */ - ppp_set_xaccm(unit, xmit_accm[unit]); - ppp_send_config(unit, PPP_MRU, 0xffffffff, 0, 0); - ppp_recv_config(unit, PPP_MRU, (lax_recv? 0: 0xffffffff), + set_xaccm_hook(unit, xmit_accm[unit]); + send_config_hook(unit, PPP_MRU, 0xffffffff, 0, 0); + recv_config_hook(unit, PPP_MRU, (lax_recv? 0: 0xffffffff), wo->neg_pcompression, wo->neg_accompression); peer_mru[unit] = PPP_MRU; lcp_allowoptions[unit].asyncmap = xmit_accm[unit][0]; @@ -1557,10 +1566,10 @@ * set our MRU to the larger of value we wanted and * the value we got in the negotiation. */ - ppp_send_config(f->unit, MIN(ao->mru, (ho->neg_mru? ho->mru: PPP_MRU)), + send_config_hook(f->unit, MIN(ao->mru, (ho->neg_mru? ho->mru: PPP_MRU)), (ho->neg_asyncmap? ho->asyncmap: 0xffffffff), ho->neg_pcompression, ho->neg_accompression); - ppp_recv_config(f->unit, (go->neg_mru? MAX(wo->mru, go->mru): PPP_MRU), + recv_config_hook(f->unit, (go->neg_mru? MAX(wo->mru, go->mru): PPP_MRU), (lax_recv? 0: go->neg_asyncmap? go->asyncmap: 0xffffffff), go->neg_pcompression, go->neg_accompression); @@ -1588,8 +1597,8 @@ link_down(f->unit); - ppp_send_config(f->unit, PPP_MRU, 0xffffffff, 0, 0); - ppp_recv_config(f->unit, PPP_MRU, + send_config_hook(f->unit, PPP_MRU, 0xffffffff, 0, 0); + recv_config_hook(f->unit, PPP_MRU, (go->neg_asyncmap? go->asyncmap: 0xffffffff), go->neg_pcompression, go->neg_accompression); peer_mru[f->unit] = PPP_MRU; diff -ur ppp-2.3.11/pppd/main.c ppp-2.3.11mnb1/pppd/main.c --- ppp-2.3.11/pppd/main.c Wed Dec 22 18:12:31 1999 +++ ppp-2.3.11mnb1/pppd/main.c Wed Sep 7 14:33:36 1904 @@ -118,6 +118,10 @@ u_char outpacket_buf[PPP_MRU+PPP_HDRLEN]; /* buffer for outgoing packet */ u_char inpacket_buf[PPP_MRU+PPP_HDRLEN]; /* buffer for incoming packet */ +void (*set_line_discipline_hook) __P((int)) = NULL; /* TIOCSETD(N_PPP) */ +void (*reset_line_discipline_hook) __P((int)) = NULL; /* TIOCSETD(N_TTY) */ + + static int n_children; /* # child processes still running */ static int got_sigchld; /* set if we have received a SIGCHLD */ @@ -216,6 +220,86 @@ NULL }; +static int +open_device_async(void) +{ + return open(devnam, O_NONBLOCK | O_RDWR, 0); +} + +/* Open "devname", return an fd */ +int (*open_device_hook) __P((void)) = open_device_async; + +static char *connector; + +/* post-open tty setup */ +static void +post_open_setup_tty(fd) + int fd; +{ + struct stat statbuf; + int fdflags; + if ((fdflags = fcntl(ttyfd, F_GETFL)) == -1 || + fcntl(ttyfd, F_SETFL, fdflags & ~O_NONBLOCK) < 0) + warn("Couldn't reset non-blocking mode on device: %m"); + /* + * Do the equivalent of `mesg n' to stop broadcast messages. + */ + if (fstat(ttyfd, &statbuf) < 0 || + fchmod(ttyfd, statbuf.st_mode & ~(S_IWGRP | S_IWOTH)) < 0) { + warn("Couldn't restrict write permissions to %s: %m", devnam); + } else + tty_mode = statbuf.st_mode; + /* + * Set line speed, flow control, etc. + * If we have a non-null connection or initializer script, + * on most systems we set CLOCAL for now so that we can talk + * to the modem before carrier comes up. But this has the + * side effect that we might miss it if CD drops before we + * get to clear CLOCAL below. On systems where we can talk + * successfully to the modem with CLOCAL clear and CD down, + * we could clear CLOCAL at this point. + */ + set_up_tty(ttyfd, + ((connector != NULL && connector[0] != 0) || initializer != NULL)); +} + +void (*post_open_setup_hook) __P((int)) = post_open_setup_tty; + +static void +pre_close_restore_tty(fd) + int fd; +{ + restore_tty(fd); + + if (tty_mode != (mode_t) -1) { + if (fchmod(fd, tty_mode) != 0) { + /* XXX if devnam is a symlink, this will change the link */ + chmod(devnam, tty_mode); + } + } +} + +void (*pre_close_restore_hook) __P((int)) = pre_close_restore_tty; + +static void +no_device_given_async(void) +{ + char *p; + if (!isatty(0) || (p = ttyname(0)) == NULL) { + option_error("no device specified and stdin is not a tty"); + exit(EXIT_OPTION_ERROR); + } + strlcpy(devnam, p, sizeof(devnam)); + if (stat(devnam, &devstat) < 0) + fatal("Couldn't stat default device %s: %m", devnam); +} + +/* + * No device was specified in the options - open a default if + * available. Must fill in devnam and devstat + */ +void (*no_device_given_hook) __P((void)) = no_device_given_async; + int main(argc, argv) int argc; @@ -223,7 +307,7 @@ { int i, fdflags, t; struct sigaction sa; - char *p, *connector; + char *p; struct passwd *pw; struct timeval timo; sigset_t mask; @@ -296,16 +380,8 @@ * Work out the device name, if it hasn't already been specified. */ using_pty = notty || ptycommand != NULL; - if (!using_pty && default_device) { - char *p; - if (!isatty(0) || (p = ttyname(0)) == NULL) { - option_error("no device specified and stdin is not a tty"); - exit(EXIT_OPTION_ERROR); - } - strlcpy(devnam, p, sizeof(devnam)); - if (stat(devnam, &devstat) < 0) - fatal("Couldn't stat default device %s: %m", devnam); - } + if (!using_pty && default_device) + no_device_given_hook(); /* * Parse the tty options file and the command line. @@ -314,7 +390,7 @@ */ devnam_fixed = 1; if (!using_pty) { - if (!options_for_tty()) + if (!options_for_device_hook()) exit(EXIT_OPTION_ERROR); } @@ -375,8 +451,9 @@ * If the device is already open read/write on stdin, * we assume we don't need to lock it, and we can open it as root. */ - if (fstat(0, &statbuf) >= 0 && S_ISCHR(statbuf.st_mode) - && statbuf.st_rdev == devstat.st_rdev) { + if (S_ISCHR(devstat.st_mode) && + fstat(0, &statbuf) >= 0 && S_ISCHR(statbuf.st_mode) && + statbuf.st_rdev == devstat.st_rdev) { default_device = 1; fdflags = fcntl(0, F_GETFL); if (fdflags != -1 && (fdflags & O_ACCMODE) == O_RDWR) @@ -618,7 +695,7 @@ int err; if (!devnam_info.priv && !privopen) seteuid(uid); - ttyfd = open(devnam, O_NONBLOCK | O_RDWR, 0); + ttyfd = open_device_hook(); err = errno; if (!devnam_info.priv && !privopen) seteuid(0); @@ -632,31 +709,7 @@ if (!persist || err != EINTR) goto fail; } - if ((fdflags = fcntl(ttyfd, F_GETFL)) == -1 - || fcntl(ttyfd, F_SETFL, fdflags & ~O_NONBLOCK) < 0) - warn("Couldn't reset non-blocking mode on device: %m"); - - /* - * Do the equivalent of `mesg n' to stop broadcast messages. - */ - if (fstat(ttyfd, &statbuf) < 0 - || fchmod(ttyfd, statbuf.st_mode & ~(S_IWGRP | S_IWOTH)) < 0) { - warn("Couldn't restrict write permissions to %s: %m", devnam); - } else - tty_mode = statbuf.st_mode; - - /* - * Set line speed, flow control, etc. - * If we have a non-null connection or initializer script, - * on most systems we set CLOCAL for now so that we can talk - * to the modem before carrier comes up. But this has the - * side effect that we might miss it if CD drops before we - * get to clear CLOCAL below. On systems where we can talk - * successfully to the modem with CLOCAL clear and CD down, - * we could clear CLOCAL at this point. - */ - set_up_tty(ttyfd, ((connector != NULL && connector[0] != 0) - || initializer != NULL)); + post_open_setup_hook(ttyfd); real_ttyfd = ttyfd; } @@ -664,36 +717,38 @@ * If the notty and/or record option was specified, * start up the character shunt now. */ - status = EXIT_PTYCMD_FAILED; - if (ptycommand != NULL) { - if (record_file != NULL) { - int ipipe[2], opipe[2], ok; - - if (pipe(ipipe) < 0 || pipe(opipe) < 0) - fatal("Couldn't create pipes for record option: %m"); - ok = device_script(ptycommand, opipe[0], ipipe[1], 1) == 0 - && start_charshunt(ipipe[0], opipe[1]); - close(ipipe[0]); - close(ipipe[1]); - close(opipe[0]); - close(opipe[1]); - if (!ok) + if (S_ISCHR(devstat.st_mode)) { + status = EXIT_PTYCMD_FAILED; + if (ptycommand != NULL) { + if (record_file != NULL) { + int ipipe[2], opipe[2], ok; + + if (pipe(ipipe) < 0 || pipe(opipe) < 0) + fatal("Couldn't create pipes for record option: %m"); + ok = device_script(ptycommand, opipe[0], ipipe[1], 1) == 0 + && start_charshunt(ipipe[0], opipe[1]); + close(ipipe[0]); + close(ipipe[1]); + close(opipe[0]); + close(opipe[1]); + if (!ok) + goto fail; + } else { + if (device_script(ptycommand, pty_master, + pty_master, 1) < 0) + goto fail; + ttyfd = pty_slave; + close(pty_master); + pty_master = -1; + } + } else if (notty) { + if (!start_charshunt(0, 1)) goto fail; - } else { - if (device_script(ptycommand, pty_master, pty_master, 1) < 0) + } else if (record_file != NULL) { + if (!start_charshunt(ttyfd, ttyfd)) goto fail; - ttyfd = pty_slave; - close(pty_master); - pty_master = -1; } - } else if (notty) { - if (!start_charshunt(0, 1)) - goto fail; - } else if (record_file != NULL) { - if (!start_charshunt(ttyfd, ttyfd)) - goto fail; } - /* run connection script */ if ((connector && connector[0]) || initializer) { if (real_ttyfd != -1) { @@ -731,7 +786,7 @@ /* set line speed, flow control, etc.; clear CLOCAL if modem option */ - if (real_ttyfd != -1) + if (S_ISCHR(devstat.st_mode) && real_ttyfd != -1) set_up_tty(real_ttyfd, 0); if (doing_callback == CALLBACK_DIALIN) @@ -753,8 +808,12 @@ close(i); } - slprintf(numbuf, sizeof(numbuf), "%d", baud_rate); - script_setenv("SPEED", numbuf); + if (S_ISCHR(devstat.st_mode) && real_ttyfd != -1) { + slprintf(numbuf, sizeof(numbuf), "%d", baud_rate); + script_setenv("SPEED", numbuf); + } + else + script_setenv("SPEED","na"); /* run welcome script, if any */ if (welcomer && welcomer[0]) { @@ -864,7 +923,8 @@ * real serial device back to its normal mode of operation. */ remove_fd(fd_ppp); - clean_check(); + if (S_ISCHR(devstat.st_mode)) + clean_check(); if (demand) restore_loop(); disestablish_ppp(ttyfd); @@ -879,7 +939,7 @@ disconnect: if (disconnect_script && !hungup) { new_phase(PHASE_DISCONNECT); - if (real_ttyfd >= 0) + if (S_ISCHR(devstat.st_mode) && real_ttyfd >= 0) set_up_tty(real_ttyfd, 1); if (device_script(disconnect_script, ttyfd, ttyfd, 0) < 0) { warn("disconnect script failed"); @@ -1296,15 +1356,7 @@ sleep(1); } - restore_tty(real_ttyfd); - - if (tty_mode != (mode_t) -1) { - if (fchmod(real_ttyfd, tty_mode) != 0) { - /* XXX if devnam is a symlink, this will change the link */ - chmod(devnam, tty_mode); - } - } - + pre_close_restore_hook(real_ttyfd); close(real_ttyfd); real_ttyfd = -1; } diff -ur ppp-2.3.11/pppd/options.c ppp-2.3.11mnb1/pppd/options.c --- ppp-2.3.11/pppd/options.c Wed Dec 22 17:28:52 1999 +++ ppp-2.3.11mnb1/pppd/options.c Wed Sep 7 13:51:11 1904 @@ -127,9 +127,8 @@ /* * Prototypes */ -static int setdevname __P((char *)); +static int setdevname __P((const char *)); static int setipaddr __P((char *)); -static int setspeed __P((char *)); static int noopt __P((char **)); static int setdomain __P((char **)); static int setnetmask __P((char **)); @@ -272,7 +271,7 @@ "Maximum time (in ms) to wait after connect script finishes" }, #ifdef PLUGIN { "plugin", o_special, loadplugin, - "Load a plug-in module into pppd", OPT_PRIV }, + "Load a plug-in module into pppd", OPT_PRIV|OPT_PREPASS }, #endif #ifdef PPP_FILTER @@ -351,7 +350,7 @@ * Maybe a tty name, speed or IP address? */ if ((ret = setdevname(arg)) == 0 - && (ret = setspeed(arg)) == 0 + && (ret = setspeed_hook(arg)) == 0 && (ret = setipaddr(arg)) == 0 && !prepass) { option_error("unrecognized option '%s'", arg); @@ -472,7 +471,7 @@ * Maybe a tty name, speed or IP address? */ if ((i = setdevname(cmd)) == 0 - && (i = setspeed(cmd)) == 0 + && (i = setspeed_hook(cmd)) == 0 && (i = setipaddr(cmd)) == 0) { option_error("In file %s: unrecognized option '%s'", filename, cmd); @@ -517,28 +516,23 @@ } /* - * options_for_tty - See if an options file exists for the serial - * device, and if so, interpret options from it. + * options_from_devfile - Generic handler for getting options from + * device-specific file */ int -options_for_tty() +options_from_devfile(prefix, dev) +const char *prefix, *dev; { - char *dev, *path, *p; - int ret; size_t pl; - - dev = devnam; - if (strncmp(dev, "/dev/", 5) == 0) - dev += 5; - if (dev[0] == 0 || strcmp(dev, "tty") == 0) - return 1; /* don't look for /etc/ppp/options.tty */ - pl = strlen(_PATH_TTYOPT) + strlen(dev) + 1; + char *path, *p; + int ret; + pl = strlen(prefix) + strlen(dev) + 1; path = malloc(pl); if (path == NULL) - novm("tty init file name"); - slprintf(path, pl, "%s%s", _PATH_TTYOPT, dev); - /* Turn slashes into dots, for Solaris case (e.g. /dev/term/a) */ - for (p = path + strlen(_PATH_TTYOPT); *p != 0; ++p) + novm("per-device init file name"); + slprintf(path, pl, "%s%s", prefix, dev); + /* Turn slashes into dots */ + for (p = path + strlen(prefix); *p != 0; ++p) if (*p == '/') *p = '.'; ret = options_from_file(path, 0, 0, 1); @@ -547,6 +541,28 @@ } /* + * options_for_tty - See if an options file exists for the serial + * device, and if so, interpret options from it. + */ +static int +options_for_tty() +{ + char *dev = devnam; + + if (strncmp(dev, "/dev/", 5) == 0) + dev += 5; + if (dev[0] == 0 || strcmp(dev, "tty") == 0) + return 1; /* don't look for /etc/ppp/options.tty */ + return options_from_devfile(_PATH_TTYOPT, dev); +} + +/* + * options_for_device_hook - read the per-device options. This should + * usually just be a wrapper around options_from_devfile + */ +int (*options_for_device_hook) __P((void)) = options_for_tty; + +/* * options_from_list - process a string of options in a wordlist. */ int @@ -589,7 +605,7 @@ * Maybe a tty name, speed or IP address? */ if ((i = setdevname(w->word)) == 0 - && (i = setspeed(w->word)) == 0 + && (i = setspeed_hook(w->word)) == 0 && (i = setipaddr(w->word)) == 0) { option_error("In secrets file: unrecognized option '%s'", w->word); @@ -617,6 +633,8 @@ struct option_list *list; int i; + if (*name == '\0') + return NULL; for (list = extra_options; list != NULL; list = list->next) for (opt = list->options; opt->name != NULL; ++opt) if (strcmp(name, opt->name) == 0) @@ -636,6 +654,23 @@ } /* + * remove_option - permanently remove an option from consideration... + * for use by modules to remove choices which no longer make sense. + * returns true if found an option + */ +int +remove_option(name) + char *name; +{ + option_t *o; + o = find_option(name); + if (o == NULL) + return 0; + o->name = ""; + return 1; +} + +/* * process_option - process one new-style option. */ static int @@ -1319,8 +1354,8 @@ * setspeed - Set the speed. */ static int -setspeed(arg) - char *arg; +setspeed_async(arg) + const char *arg; { char *ptr; int spd; @@ -1334,13 +1369,34 @@ return 1; } +int (*setspeed_hook) __P((const char *)) = setspeed_async; + +/* + * dev_set_ok - Is it ok to specify new a device now? + */ +int +dev_set_ok(void) +{ + if (phase != PHASE_INITIALIZE) { + option_error("device name cannot be changed after initialization"); + return 0; + } else if (devnam_fixed) { + option_error("per-tty options file may not specify device name"); + return 0; + } + if (devnam_info.priv && !privileged_option) { + option_error("device name cannot be overridden"); + return 0; + } + return 1; +} /* - * setdevname - Set the device name. + * setdevname_async - Set the device name (for the default async behavior) */ static int -setdevname(cp) - char *cp; +setdevname_async(cp) + const char *cp; { struct stat statbuf; char dev[MAXPATHLEN]; @@ -1368,28 +1424,33 @@ return -1; } - if (phase != PHASE_INITIALIZE) { - option_error("device name cannot be changed after initialization"); - return -1; - } else if (devnam_fixed) { - option_error("per-tty options file may not specify device name"); - return -1; - } - - if (devnam_info.priv && !privileged_option) { - option_error("device name cannot be overridden"); - return -1; - } + if (!dev_set_ok()) + return -1; - strlcpy(devnam, cp, sizeof(devnam)); devstat = statbuf; - default_device = 0; - devnam_info.priv = privileged_option; - devnam_info.source = option_source; + strlcpy(devnam, cp, sizeof(devnam)); return 1; } +int (*setdevname_hook) __P((const char *cp)) = setdevname_async; + +/* + * setdevname - Set the device name + */ +static int +setdevname(cp) + const char *cp; +{ + int result; + result = setdevname_hook(cp); + if (result == 1) { + default_device = 0; + devnam_info.priv = privileged_option; + devnam_info.source = option_source; + } + return result; +} /* * setipaddr - Set the IP address @@ -1545,27 +1606,106 @@ } #ifdef PLUGIN + +static struct plugin_info { + char *name; + void *handle; + struct plugin_info *next; +} *plugin_registry = NULL; + +/* Odd semantics - returns NULL if plugin was already in the registry + * (i.e. we already loaded this module, probably in prepass), otherwise + * a pointer to a newly allocated plugin_info + */ +static struct plugin_info * +add_plugin_to_registry (name) + const char *name; +{ + struct plugin_info *a, *last = NULL; + for (a = plugin_registry; a != NULL; a = a->next) { + if (strcmp(name, a->name) == 0) { + if (a->handle != NULL && !prepass) { + void (*init_later) __P((void)); + init_later = dlsym(a->handle, "plugin_init_later"); + if (init_later != NULL) + (*init_later)(); + a->handle = NULL; /* Only init once */ + } + return NULL; + } + last = a; + a = a->next; + } + /* OK, it wasn't found, allocate a new one */ + a = (struct plugin_info *) malloc(sizeof *a); + if (a == NULL) + novm("plugin_info structure"); + a->name = strdup(name); + if (a->name == NULL) + novm("plugin_info name"); + a->next = NULL; + a->handle = NULL; + if (last != NULL) + last->next = a; + else + plugin_registry = a; + return a; +} + +/* dlopen a plugin. If name contains no '/' or '.'s its relative */ +static void * +openplugin(p) + const char *p; +{ + char *buf = NULL; + const char *q; + void *result; + if (*p == '\0') + return NULL; + q = p; + while (*q != '/' && *q != '.' && *q !='\0') + q++; + if (*q == '\0') { + /* _PATH_PLUGIN contains a %s for the plugin name */ + int len = strlen(p) + strlen(_PATH_PLUGIN); + buf = malloc(len); + if (buf == NULL) + novm("plugin file name"); + slprintf(buf, len, _PATH_PLUGIN, p); + p = buf; + } + result = dlopen(p, RTLD_GLOBAL | RTLD_NOW); + if (buf != NULL) + free(buf); + return result; +} + static int loadplugin(argv) char **argv; { char *arg = *argv; - void *handle; const char *err; void (*init) __P((void)); + struct plugin_info *pi; - handle = dlopen(arg, RTLD_GLOBAL | RTLD_NOW); - if (handle == 0) { + pi = add_plugin_to_registry (arg); + if (pi == NULL) + return 1; /* already done */ + if (!prepass) + return 0; + pi->handle = openplugin(arg); + if (pi->handle == 0) { err = dlerror(); if (err != 0) option_error("%s", err); option_error("Couldn't load plugin %s", arg); return 0; } - init = dlsym(handle, "plugin_init"); + init = dlsym(pi->handle, "plugin_init"); if (init == 0) { option_error("%s has no initialization entry point", arg); - dlclose(handle); + dlclose(pi->handle); return 0; } info("Plugin %s loaded.", arg); diff -ur ppp-2.3.11/pppd/pathnames.h ppp-2.3.11mnb1/pppd/pathnames.h --- ppp-2.3.11/pppd/pathnames.h Fri Nov 19 21:09:26 1999 +++ ppp-2.3.11mnb1/pppd/pathnames.h Wed Sep 7 12:08:06 1904 @@ -17,6 +17,9 @@ #ifndef _ROOT_PATH #define _ROOT_PATH #endif +#ifndef _LIB_DIR +#define _LIB_DIR "/usr/lib" +#endif #define _PATH_UPAPFILE _ROOT_PATH "/etc/ppp/pap-secrets" #define _PATH_CHAPFILE _ROOT_PATH "/etc/ppp/chap-secrets" @@ -26,6 +29,7 @@ #define _PATH_AUTHUP _ROOT_PATH "/etc/ppp/auth-up" #define _PATH_AUTHDOWN _ROOT_PATH "/etc/ppp/auth-down" #define _PATH_TTYOPT _ROOT_PATH "/etc/ppp/options." +#define _PATH_ATMOPT _ROOT_PATH "/etc/ppp/options-atm." #define _PATH_CONNERRS _ROOT_PATH "/etc/ppp/connect-errors" #define _PATH_PEERFILES _ROOT_PATH "/etc/ppp/peers/" #define _PATH_RESOLV _ROOT_PATH "/etc/ppp/resolv.conf" @@ -41,3 +45,7 @@ #define _PATH_IPXUP _ROOT_PATH "/etc/ppp/ipx-up" #define _PATH_IPXDOWN _ROOT_PATH "/etc/ppp/ipx-down" #endif /* IPX_CHANGE */ + +#ifdef PLUGIN +#define _PATH_PLUGIN _LIB_DIR "/pppd/plugins/%s.so" +#endif diff -ur ppp-2.3.11/pppd/plugins/Makefile.linux ppp-2.3.11mnb1/pppd/plugins/Makefile.linux --- ppp-2.3.11/pppd/plugins/Makefile.linux Sun Nov 14 20:08:24 1999 +++ ppp-2.3.11mnb1/pppd/plugins/Makefile.linux Wed Sep 7 13:28:44 1904 @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -g -O2 -I.. -I../../include +CFLAGS = -g -O2 -I.. -I../../include -D_linux_=1 LDFLAGS = -shared all: minconn.so passprompt.so diff -ur ppp-2.3.11/pppd/plugins/Makefile.sol2 ppp-2.3.11mnb1/pppd/plugins/Makefile.sol2 --- ppp-2.3.11/pppd/plugins/Makefile.sol2 Tue Nov 16 19:49:27 1999 +++ ppp-2.3.11mnb1/pppd/plugins/Makefile.sol2 Wed Sep 7 13:29:21 1904 @@ -6,7 +6,7 @@ include ../../svr4/Makedefs -CFLAGS = -c -O -I.. -I../../include $(COPTS) +CFLAGS = -c -O -I.. -I../../include -DSVR4 -DSOL2 $(COPTS) LDFLAGS = -G all: minconn.so diff -ur ppp-2.3.11/pppd/pppd.h ppp-2.3.11mnb1/pppd/pppd.h --- ppp-2.3.11/pppd/pppd.h Wed Dec 22 17:29:42 1999 +++ ppp-2.3.11mnb1/pppd/pppd.h Wed Sep 7 13:43:53 1904 @@ -448,7 +448,8 @@ int privileged)); /* Parse options from an options file */ int options_from_user __P((void)); /* Parse options from user's .ppprc */ -int options_for_tty __P((void)); /* Parse options from /etc/ppp/options.tty */ +int options_from_devfile __P((const char *, const char *)); + /* Parse options device-specific file */ int options_from_list __P((struct wordlist *, int privileged)); /* Parse options from a wordlist */ int getword __P((FILE *f, char *word, int *newlinep, char *filename)); @@ -458,6 +459,8 @@ int int_option __P((char *, int *)); /* Simplified number_option for decimal ints */ void add_options __P((option_t *)); /* Add extra options */ +int remove_option __P((char *)); /* Remove option */ +int dev_set_ok __P((void)); /* OK to specify a device */ /* * This structure is used to store information about certain @@ -478,7 +481,8 @@ extern struct option_info ptycommand_info; /* - * Hooks to enable plugins to change various things. + * Hooks to enable plugins to change various things. These are documented + * in the PLUGINS file */ extern int (*new_phase_hook) __P((int)); extern int (*idle_time_hook) __P((struct ppp_idle *)); @@ -491,6 +495,18 @@ extern int (*pap_passwd_hook) __P((char *user, char *passwd)); extern void (*ip_up_hook) __P((void)); extern void (*ip_down_hook) __P((void)); +extern int (*setspeed_hook) __P((const char *)); +extern int (*setdevname_hook) __P((const char *)); +extern int (*options_for_device_hook) __P((void)); +extern int (*open_device_hook) __P((void)); +extern void (*post_open_setup_hook) __P((int)); +extern void (*pre_close_restore_hook) __P((int)); +extern void (*no_device_given_hook) __P((void)); +extern void (*set_line_discipline_hook) __P((int)); +extern void (*reset_line_discipline_hook) __P((int)); +extern void (*send_config_hook) __P((int, int, u_int32_t, int, int)); +extern void (*recv_config_hook) __P((int, int, u_int32_t, int, int)); +extern void (*set_xaccm_hook) __P((int, ext_accm)); /* * Inline versions of get/put char/short/long. diff -ur ppp-2.3.11/pppd/sys-linux.c ppp-2.3.11mnb1/pppd/sys-linux.c --- ppp-2.3.11/pppd/sys-linux.c Wed Dec 22 15:51:31 1999 +++ ppp-2.3.11mnb1/pppd/sys-linux.c Wed Sep 7 14:43:23 1904 @@ -136,7 +136,7 @@ static int restore_term = 0; /* 1 => we've munged the terminal */ static struct termios inittermios; /* Initial TTY termios */ -static int new_style_driver = 0; +int new_style_driver = 0; static char loop_name[20]; static unsigned char inbuf[512]; /* buffer for chars read from loopback */ @@ -355,6 +355,7 @@ int establish_ppp (int tty_fd) { int x; + extern struct stat devstat; /* * The current PPP device will be the tty file. @@ -365,7 +366,7 @@ /* * Ensure that the tty device is in exclusive mode. */ - if (ioctl(tty_fd, TIOCEXCL, 0) < 0) { + if (isatty(tty_fd) && ioctl(tty_fd, TIOCEXCL, 0) < 0) { if ( ! ok_error ( errno )) warn("ioctl(TIOCEXCL): %m"); } @@ -385,9 +386,13 @@ if (new_style_driver) ppp_disc = sync_serial ? N_SYNC_PPP:N_PPP; - if (ioctl(tty_fd, TIOCSETD, &ppp_disc) < 0) { - if ( ! ok_error (errno) ) - fatal("ioctl(TIOCSETD): %m(%d)", errno); + if (set_line_discipline_hook != NULL) + set_line_discipline_hook(tty_fd); + else { + if (ioctl(tty_fd, TIOCSETD, &ppp_disc) < 0) { + if ( ! ok_error (errno) ) + fatal("ioctl(TIOCSETD): %m(%d)", errno); + } } /* * Find out which interface we were given. @@ -425,8 +430,9 @@ set_kdebugflag (kdebugflag); looped = 0; - set_flags(tty_fd, get_flags(tty_fd) & ~(SC_RCV_B7_0 | SC_RCV_B7_1 | - SC_RCV_EVNP | SC_RCV_ODDP)); + if (S_ISCHR(devstat.st_mode)) + set_flags(tty_fd, get_flags(tty_fd) & ~(SC_RCV_B7_0 | SC_RCV_B7_1 | + SC_RCV_EVNP | SC_RCV_ODDP)); SYSDEBUG ((LOG_NOTICE, "Using version %d.%d.%d of PPP driver", driver_version, driver_modification, driver_patch)); @@ -455,22 +461,26 @@ if (new_style_driver) remove_fd(tty_fd); if (!hungup) { + if (reset_line_discipline_hook != NULL) + reset_line_discipline_hook(tty_fd); + else { /* * Flush the tty output buffer so that the TIOCSETD doesn't hang. */ - if (tcflush(tty_fd, TCIOFLUSH) < 0) - warn("tcflush failed: %m"); + if (tcflush(tty_fd, TCIOFLUSH) < 0) + warn("tcflush failed: %m"); /* * Restore the previous line discipline */ - if (ioctl(tty_fd, TIOCSETD, &tty_disc) < 0) { - if ( ! ok_error (errno)) - error("ioctl(TIOCSETD, N_TTY): %m"); - } + if (ioctl(tty_fd, TIOCSETD, &tty_disc) < 0) { + if ( ! ok_error (errno)) + error("ioctl(TIOCSETD, N_TTY): %m"); + } - if (ioctl(tty_fd, TIOCNXCL, 0) < 0) { - if ( ! ok_error (errno)) - warn("ioctl(TIOCNXCL): %m(%d)", errno); + if (ioctl(tty_fd, TIOCNXCL, 0) < 0) { + if ( ! ok_error (errno)) + warn("ioctl(TIOCNXCL): %m(%d)", errno); + } } /* Reset non-blocking mode on fd. */