diff --git a/src/netif/ppp/auth.c b/src/netif/ppp/auth.c index 79295c22..45801642 100644 --- a/src/netif/ppp/auth.c +++ b/src/netif/ppp/auth.c @@ -202,19 +202,6 @@ struct notifier *auth_up_notifier = NULL; /* A notifier for when the link goes down. */ struct notifier *link_down_notifier = NULL; -/* - * This is used to ensure that we don't start an auth-up/down - * script while one is already running. - */ -enum script_state { - s_down, - s_up -}; - -static enum script_state auth_state = s_down; -static enum script_state auth_script_state = s_down; -static pid_t auth_script_pid = 0; - /* * Option variables. */ @@ -259,8 +246,6 @@ static int scan_authfile __P((FILE *, char *, char *, char *, struct wordlist **, struct wordlist **, char *, int)); static void free_wordlist __P((struct wordlist *)); -static void auth_script __P((char *)); -static void auth_script_done __P((void *)); static void set_allowed_addrs __P((int, struct wordlist *, struct wordlist *)); static int some_ip_ok __P((struct wordlist *)); static int setupapfile __P((char **)); @@ -696,15 +681,6 @@ void link_down(unit) int unit; { - if (auth_state != s_down) { - notify(link_down_notifier, 0); - auth_state = s_down; - if (auth_script_state == s_up && auth_script_pid == 0) { - update_link_stats(unit); - auth_script_state = s_down; - auth_script(_PATH_AUTHDOWN); - } - } if (!doing_multilink) { upper_layers_down(unit); if (phase != PHASE_DEAD && phase != PHASE_MASTER) @@ -826,11 +802,6 @@ network_phase(unit) */ if (go->neg_chap || go->neg_upap || go->neg_eap) { notify(auth_up_notifier, 0); - auth_state = s_up; - if (auth_script_state == s_down && auth_script_pid == 0) { - auth_script_state = s_up; - auth_script(_PATH_AUTHUP); - } } #if CBCP_SUPPORT @@ -2356,61 +2327,3 @@ free_wordlist(wp) wp = next; } } - -/* - * auth_script_done - called when the auth-up or auth-down script - * has finished. - */ -static void -auth_script_done(arg) - void *arg; -{ - auth_script_pid = 0; - switch (auth_script_state) { - case s_up: - if (auth_state == s_down) { - auth_script_state = s_down; - auth_script(_PATH_AUTHDOWN); - } - break; - case s_down: - if (auth_state == s_up) { - auth_script_state = s_up; - auth_script(_PATH_AUTHUP); - } - break; - } -} - -/* - * auth_script - execute a script with arguments - * interface-name peer-name real-user tty speed - */ -static void -auth_script(script) - char *script; -{ - char strspeed[32]; - struct passwd *pw; - char struid[32]; - char *user_name; - char *argv[8]; - - if ((pw = getpwuid(getuid())) != NULL && pw->pw_name != NULL) - user_name = pw->pw_name; - else { - slprintf(struid, sizeof(struid), "%d", getuid()); - user_name = struid; - } - slprintf(strspeed, sizeof(strspeed), "%d", baud_rate); - - argv[0] = script; - argv[1] = ifname; - argv[2] = peer_authname; - argv[3] = user_name; - argv[4] = devnam; - argv[5] = strspeed; - argv[6] = NULL; - - auth_script_pid = run_program(script, argv, 0, auth_script_done, NULL, 0); -} diff --git a/src/netif/ppp/ipcp.c b/src/netif/ppp/ipcp.c index c29d5253..085c870c 100644 --- a/src/netif/ppp/ipcp.c +++ b/src/netif/ppp/ipcp.c @@ -282,8 +282,6 @@ struct protent ipcp_protent = { }; static void ipcp_clear_addrs __P((int, u_int32_t, u_int32_t, bool)); -static void ipcp_script __P((char *, int)); /* Run an up/down script */ -static void ipcp_script_done __P((void *)); /* * Lengths of configuration options. @@ -298,16 +296,6 @@ static void ipcp_script_done __P((void *)); #define CODENAME(x) ((x) == CONFACK ? "ACK" : \ (x) == CONFNAK ? "NAK" : "REJ") -/* - * This state variable is used to ensure that we don't - * run an ipcp-up/down script while one is already running. - */ -static enum script_state { - s_down, - s_up, -} ipcp_script_state; -static pid_t ipcp_script_pid; - /* * Make a string representation of a network IP address. */ @@ -1746,7 +1734,6 @@ ip_demand_conf(u) } if (!sifaddr(u, wo->ouraddr, wo->hisaddr, GetMask(wo->ouraddr))) return 0; - ipcp_script(_PATH_IPPREUP, 1); if (!sifup(u)) return 0; if (!sifnpmode(u, PPP_IP, NPMODE_QUEUE)) @@ -1898,9 +1885,6 @@ ipcp_up(f) } #endif - /* run the pre-up script, if any, and wait for it to finish */ - ipcp_script(_PATH_IPPREUP, 1); - /* bring the interface up for IP */ if (!sifup(f->unit)) { if (debug) @@ -1949,15 +1933,6 @@ ipcp_up(f) notify(ip_up_notifier, 0); if (ip_up_hook) ip_up_hook(); - - /* - * Execute the ip-up script, like this: - * /etc/ppp/ip-up interface tty speed local-IP remote-IP - */ - if (ipcp_script_state == s_down && ipcp_script_pid == 0) { - ipcp_script_state = s_up; - ipcp_script(_PATH_IPUP, 0); - } } @@ -2002,12 +1977,6 @@ ipcp_down(f) ipcp_clear_addrs(f->unit, ipcp_gotoptions[f->unit].ouraddr, ipcp_hisoptions[f->unit].hisaddr, 0); } - - /* Execute the ip-down script */ - if (ipcp_script_state == s_up && ipcp_script_pid == 0) { - ipcp_script_state = s_down; - ipcp_script(_PATH_IPDOWN, 0); - } } @@ -2056,63 +2025,6 @@ ipcp_finished(f) } -/* - * ipcp_script_done - called when the ip-up or ip-down script - * has finished. - */ -static void -ipcp_script_done(arg) - void *arg; -{ - ipcp_script_pid = 0; - switch (ipcp_script_state) { - case s_up: - if (ipcp_fsm[0].state != OPENED) { - ipcp_script_state = s_down; - ipcp_script(_PATH_IPDOWN, 0); - } - break; - case s_down: - if (ipcp_fsm[0].state == OPENED) { - ipcp_script_state = s_up; - ipcp_script(_PATH_IPUP, 0); - } - break; - } -} - - -/* - * ipcp_script - Execute a script with arguments - * interface-name tty-name speed local-IP remote-IP. - */ -static void -ipcp_script(script, wait) - char *script; - int wait; -{ - char strspeed[32], strlocal[32], strremote[32]; - char *argv[8]; - - slprintf(strspeed, sizeof(strspeed), "%d", baud_rate); - slprintf(strlocal, sizeof(strlocal), "%I", ipcp_gotoptions[0].ouraddr); - slprintf(strremote, sizeof(strremote), "%I", ipcp_hisoptions[0].hisaddr); - - argv[0] = script; - argv[1] = ifname; - argv[2] = devnam; - argv[3] = strspeed; - argv[4] = strlocal; - argv[5] = strremote; - argv[6] = ipparam; - argv[7] = NULL; - if (wait) - run_program(script, argv, 0, NULL, NULL, 1); - else - ipcp_script_pid = run_program(script, argv, 0, ipcp_script_done, - NULL, 0); -} - /* * create_resolv - create the replacement resolv.conf file */ @@ -2120,24 +2032,7 @@ static void create_resolv(peerdns1, peerdns2) u_int32_t peerdns1, peerdns2; { - FILE *f; - - f = fopen(_PATH_RESOLV, "w"); - if (f == NULL) { - error("Failed to create %s: %m", _PATH_RESOLV); - return; - } - - if (peerdns1) - fprintf(f, "nameserver %s\n", ip_ntoa(peerdns1)); - - if (peerdns2) - fprintf(f, "nameserver %s\n", ip_ntoa(peerdns2)); - - if (ferror(f)) - error("Write failed to %s: %m", _PATH_RESOLV); - - fclose(f); + /* FIXME: do we need to set here the DNS servers ? */ } /* diff --git a/src/netif/ppp/pathnames.h b/src/netif/ppp/pathnames.h index a33f0466..bc81a8ce 100644 --- a/src/netif/ppp/pathnames.h +++ b/src/netif/ppp/pathnames.h @@ -25,8 +25,6 @@ #define _PATH_IPUP _ROOT_PATH "/etc/ppp/ip-up" #define _PATH_IPDOWN _ROOT_PATH "/etc/ppp/ip-down" #define _PATH_IPPREUP _ROOT_PATH "/etc/ppp/ip-pre-up" -#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_CONNERRS _ROOT_PATH "/etc/ppp/connect-errors" #define _PATH_PEERFILES _ROOT_PATH "/etc/ppp/peers/" diff --git a/src/netif/ppp/ppp.c b/src/netif/ppp/ppp.c index d03f83f0..b78cdc85 100644 --- a/src/netif/ppp/ppp.c +++ b/src/netif/ppp/ppp.c @@ -1679,91 +1679,6 @@ device_script(program, in, out, dont_wait) } -/* - * run_program - execute a program with given arguments, - * but don't wait for it unless wait is non-zero. - * If the program can't be executed, logs an error unless - * must_exist is 0 and the program file doesn't exist. - * Returns -1 if it couldn't fork, 0 if the file doesn't exist - * or isn't an executable plain file, or the process ID of the child. - * If done != NULL, (*done)(arg) will be called later (within - * reap_kids) iff the return value is > 0. - */ -pid_t -run_program(prog, args, must_exist, done, arg, wait) - char *prog; - char **args; - int must_exist; - void (*done) __P((void *)); - void *arg; - int wait; -{ - int pid, status; - struct stat sbuf; - - printf("REMOVEME: run_program() called\n"); - return -1; - - /* - * First check if the file exists and is executable. - * We don't use access() because that would use the - * real user-id, which might not be root, and the script - * might be accessible only to root. - */ - errno = EINVAL; - if (stat(prog, &sbuf) < 0 || !S_ISREG(sbuf.st_mode) - || (sbuf.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH)) == 0) { - if (must_exist || errno != ENOENT) - warn("Can't execute %s: %m", prog); - return 0; - } - - pid = safe_fork(fd_devnull, fd_devnull, fd_devnull); - if (pid == -1) { - error("Failed to create child process for %s: %m", prog); - return -1; - } - if (pid != 0) { - if (debug) - dbglog("Script %s started (pid %d)", prog, pid); - record_child(pid, prog, done, arg, 0); - if (wait) { - while (waitpid(pid, &status, 0) < 0) { - if (errno == EINTR) - continue; - fatal("error waiting for script %s: %m", prog); - } - forget_child(pid, status); - } - return pid; - } - - /* Leave the current location */ - (void) setsid(); /* No controlling tty. */ - (void) umask (S_IRWXG|S_IRWXO); - (void) chdir ("/"); /* no current directory. */ - setuid(0); /* set real UID = root */ - setgid(getegid()); - -#ifdef BSD - /* Force the priority back to zero if pppd is running higher. */ - if (setpriority (PRIO_PROCESS, 0, 0) < 0) - warn("can't reset priority to 0: %m"); -#endif - - /* run the program */ - execve(prog, args, script_env); - if (must_exist || errno != ENOENT) { - /* have to reopen the log, there's nowhere else - for the message to go. */ - reopen_log(); - syslog(LOG_ERR, "Can't execute %s: %m", prog); - closelog(); - } - _exit(-1); -} - - /* * record_child - add a child process to the list for reap_kids * to use. diff --git a/src/netif/ppp/pppd.h b/src/netif/ppp/pppd.h index eaf954f6..da228b35 100644 --- a/src/netif/ppp/pppd.h +++ b/src/netif/ppp/pppd.h @@ -478,9 +478,6 @@ void record_child __P((int, char *, void (*) (void *), void *, int)); pid_t safe_fork __P((int, int, int)); /* Fork & close stuff in child */ int device_script __P((char *cmd, int in, int out, int dont_wait)); /* Run `cmd' with given stdin and stdout */ -pid_t run_program __P((char *prog, char **args, int must_exist, - void (*done)(void *), void *arg, int wait)); - /* Run program prog with args in child */ void reopen_log __P((void)); /* (re)open the connection to syslog */ void print_link_stats __P((void)); /* Print stats, if available */ void reset_link_stats __P((int)); /* Reset (init) stats when link goes up */