X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=pppd%2Fmain.c;h=1c570eee7860338ae31139ef7f4ed6e06d46a4e2;hb=93b2bde457ac91bd4a395dfafd6bd5eed670c85a;hp=d92fdeb2142b18af6ef2c78e2b6351103d968bea;hpb=e5b7cafa28aeba66499fa26b286192529e5fde15;p=ppp.git diff --git a/pppd/main.c b/pppd/main.c index d92fdeb..1c570ee 100644 --- a/pppd/main.c +++ b/pppd/main.c @@ -40,7 +40,7 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#define RCSID "$Id: main.c,v 1.126 2003/04/07 00:01:45 paulus Exp $" +#define RCSID "$Id: main.c,v 1.131 2004/01/13 04:00:34 paulus Exp $" #include #include @@ -74,7 +74,7 @@ #include "ipv6cp.h" #endif #include "upap.h" -#include "chap.h" +#include "chap-new.h" #include "eap.h" #include "ccp.h" #include "ecp.h" @@ -438,8 +438,6 @@ main(argc, argv) waiting = 0; - create_linkpidfile(getpid()); - /* * If we're doing dial-on-demand, set up the interface now. */ @@ -459,6 +457,7 @@ main(argc, argv) * Configure the interface and mark it up, etc. */ demand_conf(); + create_linkpidfile(getpid()); } do_callback = 0; @@ -515,6 +514,9 @@ main(argc, argv) status = EXIT_FATAL_ERROR; goto disconnect; } + /* create the pid file, now that we've obtained a ppp interface */ + if (!demand) + create_linkpidfile(getpid()); if (!demand && ifunit >= 0) set_ifunit(1); @@ -587,7 +589,8 @@ main(argc, argv) */ disconnect: new_phase(PHASE_DISCONNECT); - the_channel->disconnect(); + if (the_channel->disconnect) + the_channel->disconnect(); fail: if (the_channel->cleanup) @@ -1335,8 +1338,8 @@ kill_my_pg(sig) act.sa_handler = SIG_IGN; act.sa_flags = 0; - kill(0, sig); sigaction(sig, &act, &oldact); + kill(0, sig); sigaction(sig, &oldact, NULL); } @@ -1501,6 +1504,7 @@ device_script(program, in, out, dont_wait) int pid; int status = -1; int errfd; + int fd; ++conn_running; pid = safe_fork(); @@ -1528,6 +1532,14 @@ device_script(program, in, out, dont_wait) /* here we are executing in the child */ + /* make sure fds 0, 1, 2 are occupied */ + while ((fd = dup(in)) >= 0) { + if (fd > 2) { + close(fd); + break; + } + } + /* dup in and out to fds > 2 */ { int fd1 = in, fd2 = out, fd3 = log_to_fd;