X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=pppd%2Ftty.c;h=c356483d1974ee9358010cc585049eddcc1de569;hb=bf69479845b0dc57e75423be4dd2491cadda1f89;hp=a911fde5c0f0b34f274a56763f8d075aa98f67f2;hpb=b1eca80e96acb988380b74d5a2f2afcb284d52fd;p=ppp.git diff --git a/pppd/tty.c b/pppd/tty.c index a911fde..c356483 100644 --- a/pppd/tty.c +++ b/pppd/tty.c @@ -68,7 +68,7 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#define RCSID "$Id: tty.c,v 1.22 2004/11/13 12:07:29 paulus Exp $" +#define RCSID "$Id: tty.c,v 1.25 2006/06/04 07:04:57 paulus Exp $" #include #include @@ -563,12 +563,16 @@ int connect_tty() int err, prio; prio = privopen? OPRIO_ROOT: tty_options[0].priority; - if (prio < OPRIO_ROOT) - seteuid(uid); + if (prio < OPRIO_ROOT && seteuid(uid) == -1) { + error("Unable to drop privileges before opening %s: %m\n", + devnam); + status = EXIT_OPEN_FAILED; + goto errret; + } real_ttyfd = open(devnam, O_NONBLOCK | O_RDWR, 0); err = errno; - if (prio < OPRIO_ROOT) - seteuid(0); + if (prio < OPRIO_ROOT && seteuid(0) == -1) + fatal("Unable to regain privileges"); if (real_ttyfd >= 0) break; errno = err; @@ -755,14 +759,6 @@ int connect_tty() close(pty_master); pty_master = -1; } - if (pty_slave >= 0) { - close(pty_slave); - pty_slave = -1; - } - if (real_ttyfd >= 0) { - close(real_ttyfd); - real_ttyfd = -1; - } ttyfd = -1; if (got_sigterm) asked_to_quit = 1; @@ -781,6 +777,7 @@ void disconnect_tty() } else { info("Serial link disconnected."); } + stop_charshunt(NULL, 0); } void tty_close_fds() @@ -944,7 +941,6 @@ start_charshunt(ifd, ofd) exit(0); } charshunt_pid = cpid; - add_notifier(&sigreceived, stop_charshunt, 0); record_child(cpid, "pppd (charshunt)", charshunt_done, NULL); return 1; }