diff --git a/usr.sbin/ppp/bundle.c b/usr.sbin/ppp/bundle.c index 48f996ef5a9f..dfe29b07f1e8 100644 --- a/usr.sbin/ppp/bundle.c +++ b/usr.sbin/ppp/bundle.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: bundle.c,v 1.10 1998/05/28 23:17:31 brian Exp $ + * $Id: bundle.c,v 1.11 1998/05/29 18:32:09 brian Exp $ */ #include @@ -682,7 +682,7 @@ bundle_UnlockTun(struct bundle *bundle) } struct bundle * -bundle_Create(const char *prefix, int type) +bundle_Create(const char *prefix, int type, const char **argv) { int s, enoentcount, err; struct ifreq ifrq; @@ -718,6 +718,7 @@ bundle_Create(const char *prefix, int type) } log_SetTun(bundle.unit); + bundle.argv = argv; s = socket(AF_INET, SOCK_DGRAM, 0); if (s < 0) { @@ -1654,6 +1655,9 @@ bundle_setsid(struct bundle *bundle, int holdsession) * intermediate is, we don't want it to become defunct. */ waitpid(pid, &status, 0); + /* Tweak our process arguments.... */ + bundle->argv[0] = "session owner"; + bundle->argv[1] = NULL; /* * Hang around for a HUP. This should happen as soon as the * ppp that we passed our ctty descriptor to closes it. diff --git a/usr.sbin/ppp/bundle.h b/usr.sbin/ppp/bundle.h index a903fa2c48de..ab11f0edf986 100644 --- a/usr.sbin/ppp/bundle.h +++ b/usr.sbin/ppp/bundle.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: bundle.h,v 1.3 1998/05/23 22:24:30 brian Exp $ + * $Id: bundle.h,v 1.4 1998/05/28 23:17:33 brian Exp $ */ #define PHASE_DEAD 0 /* Link is dead */ @@ -55,6 +55,7 @@ struct prompt; struct bundle { struct descriptor desc; /* really all our datalinks */ int unit; /* The device/interface unit number */ + const char **argv; /* From main() */ struct { char Name[20]; /* The /dev/XXXX name */ @@ -126,7 +127,7 @@ struct bundle { #define descriptor2bundle(d) \ ((d)->type == BUNDLE_DESCRIPTOR ? (struct bundle *)(d) : NULL) -extern struct bundle *bundle_Create(const char *, int); +extern struct bundle *bundle_Create(const char *, int, const char **); extern void bundle_Destroy(struct bundle *); extern const char *bundle_PhaseName(struct bundle *); #define bundle_Phase(b) ((b)->phase) diff --git a/usr.sbin/ppp/id.c b/usr.sbin/ppp/id.c index 4ac474e54933..406c382e0057 100644 --- a/usr.sbin/ppp/id.c +++ b/usr.sbin/ppp/id.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: id.c,v 1.8 1998/05/21 21:45:32 brian Exp $ + * $Id: id.c,v 1.9 1998/05/28 23:15:36 brian Exp $ */ #include @@ -32,6 +32,7 @@ #include #include +#include #include #include #include @@ -252,3 +253,15 @@ ID0connect_un(int s, const struct sockaddr_un *name) ID0setuser(); return result; } + +int +ID0kill(pid_t pid, int sig) +{ + int result; + + ID0set0(); + result = kill(pid, sig); + log_Printf(LogID0, "%d = kill(%d, %d)\n", result, (int)pid, sig); + ID0setuser(); + return result; +} diff --git a/usr.sbin/ppp/id.h b/usr.sbin/ppp/id.h index ca747c034ab8..2fcf3c9c04de 100644 --- a/usr.sbin/ppp/id.h +++ b/usr.sbin/ppp/id.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: id.h,v 1.5 1998/05/21 21:45:34 brian Exp $ + * $Id: id.h,v 1.6 1998/05/28 23:15:37 brian Exp $ */ struct utmp; @@ -44,3 +44,4 @@ extern void ID0login(struct utmp *); extern void ID0logout(const char *); extern int ID0bind_un(int, const struct sockaddr_un *); extern int ID0connect_un(int, const struct sockaddr_un *); +extern int ID0kill(pid_t, int); diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c index f782a55d3f98..0b812c37cd98 100644 --- a/usr.sbin/ppp/main.c +++ b/usr.sbin/ppp/main.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: main.c,v 1.127 1998/05/28 23:17:48 brian Exp $ + * $Id: main.c,v 1.128 1998/05/29 18:32:11 brian Exp $ * * TODO: */ @@ -260,9 +260,7 @@ main(int argc, char **argv) name = strrchr(argv[0], '/'); log_Open(name ? name + 1 : argv[0]); - argc--; - argv++; - label = ProcessArgs(argc, argv, &mode); + label = ProcessArgs(argc - 1, argv + 1, &mode); #ifdef __FreeBSD__ /* @@ -316,7 +314,7 @@ main(int argc, char **argv) return 1; } - if ((bundle = bundle_Create(TUN_PREFIX, mode)) == NULL) { + if ((bundle = bundle_Create(TUN_PREFIX, mode, (const char **)argv)) == NULL) { log_Printf(LogWARN, "bundle_Create: %s\n", strerror(errno)); return EX_START; } diff --git a/usr.sbin/ppp/modem.c b/usr.sbin/ppp/modem.c index 8e3c705aecd2..9d93bcfb5f68 100644 --- a/usr.sbin/ppp/modem.c +++ b/usr.sbin/ppp/modem.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: modem.c,v 1.86 1998/05/28 23:15:38 brian Exp $ + * $Id: modem.c,v 1.87 1998/05/28 23:17:51 brian Exp $ * * TODO: */ @@ -124,6 +124,7 @@ modem_Create(struct datalink *dl, int type) p->name.base = p->name.full; p->Utmp = 0; + p->session_owner = (pid_t)-1; p->cfg.rts_cts = MODEM_CTSRTS; p->cfg.speed = MODEM_SPEED; @@ -760,6 +761,10 @@ modem_PhysicalClose(struct physical *modem) log_SetTtyCommandMode(modem->dl); throughput_stop(&modem->link.throughput); throughput_log(&modem->link.throughput, LogPHASE, modem->link.name); + if (modem->session_owner != (pid_t)-1) { + ID0kill(modem->session_owner, SIGHUP); + modem->session_owner = (pid_t)-1; + } if (newsid) bundle_setsid(modem->dl->bundle, 0); } @@ -874,11 +879,14 @@ modem_ShowStatus(struct cmdargs const *arg) prompt_Printf(arg->prompt, "open\n"); } else prompt_Printf(arg->prompt, "closed\n"); - prompt_Printf(arg->prompt, " Device: %s\n", + prompt_Printf(arg->prompt, " Device: %s", *modem->name.full ? modem->name.full : modem->type == PHYS_DIRECT ? "unknown" : "N/A"); + if (modem->session_owner != (pid_t)-1) + prompt_Printf(arg->prompt, " (session owner: %d)", + (int)modem->session_owner); - prompt_Printf(arg->prompt, " Link Type: %s\n", mode2Nam(modem->type)); + prompt_Printf(arg->prompt, "\n Link Type: %s\n", mode2Nam(modem->type)); prompt_Printf(arg->prompt, " Connect Count: %d\n", modem->connect_count); #ifdef TIOCOUTQ @@ -1053,8 +1061,9 @@ modem2iov(struct physical *p, struct iovec *iov, int *niov, int maxiov, timer_Stop(&p->link.ccp.fsm.StoppedTimer); if (p->Timer.state != TIMER_STOPPED) { timer_Stop(&p->Timer); + p->Timer.state = TIMER_RUNNING; /* Special - see iov2modem() */ if (tcgetpgrp(p->fd) == getpgrp()) - p->Timer.state = TIMER_RUNNING; /* Special - see iov2modem() */ + p->session_owner = getpid(); /* So I'll eventually get HUP'd */ } timer_Stop(&p->link.throughput.Timer); modem_ChangedPid(p, newpid); diff --git a/usr.sbin/ppp/physical.h b/usr.sbin/ppp/physical.h index c99fdea2a6fc..4e07d071c822 100644 --- a/usr.sbin/ppp/physical.h +++ b/usr.sbin/ppp/physical.h @@ -16,7 +16,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: physical.h,v 1.1.2.26 1998/05/15 23:58:26 brian Exp $ + * $Id: physical.h,v 1.2 1998/05/21 21:47:40 brian Exp $ * */ @@ -45,6 +45,7 @@ struct physical { } name; unsigned Utmp : 1; /* Are we in utmp ? */ + pid_t session_owner; /* HUP this when closing the link */ /* XXX-ML Most of the below is device specific, and probably do not belong in the generic physical struct. It comes from modem.c. */