diff options
author | Brian Somers <brian@FreeBSD.org> | 1998-03-10 03:06:07 +0000 |
---|---|---|
committer | Brian Somers <brian@FreeBSD.org> | 1998-03-10 03:06:07 +0000 |
commit | fc1141b27b9b5382fd4b7405faa4b81de561baf4 (patch) | |
tree | c4231d0dccf63fa535d25c1679e0aee06dc3fd2c | |
parent | ab886ad0f6404d3f8745d96f98bae5f81dbd43c3 (diff) | |
download | src-fc1141b27b9b5382fd4b7405faa4b81de561baf4.tar.gz src-fc1141b27b9b5382fd4b7405faa4b81de561baf4.zip |
Move `Utmp' into struct physical. We can be logged in
once for every -direct physical connection.
Notes
Notes:
svn path=/cvs2svn/branches/MP/; revision=34446
-rw-r--r-- | usr.sbin/ppp/chap.c | 20 | ||||
-rw-r--r-- | usr.sbin/ppp/modem.c | 10 | ||||
-rw-r--r-- | usr.sbin/ppp/pap.c | 20 | ||||
-rw-r--r-- | usr.sbin/ppp/physical.c | 33 | ||||
-rw-r--r-- | usr.sbin/ppp/physical.h | 9 | ||||
-rw-r--r-- | usr.sbin/ppp/vars.c | 5 | ||||
-rw-r--r-- | usr.sbin/ppp/vars.h | 3 |
7 files changed, 50 insertions, 50 deletions
diff --git a/usr.sbin/ppp/chap.c b/usr.sbin/ppp/chap.c index 2ddf2372247d..698c5981800b 100644 --- a/usr.sbin/ppp/chap.c +++ b/usr.sbin/ppp/chap.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: chap.c,v 1.28.2.11 1998/03/01 01:07:40 brian Exp $ + * $Id: chap.c,v 1.28.2.12 1998/03/06 00:34:41 brian Exp $ * * TODO: */ @@ -40,7 +40,6 @@ #else #include <libutil.h> #endif -#include <utmp.h> #include "command.h" #include "mbuf.h" @@ -62,7 +61,6 @@ #include "descriptor.h" #include "physical.h" #include "bundle.h" -#include "id.h" #include "ccp.h" #include "chat.h" #include "datalink.h" @@ -235,21 +233,7 @@ RecvChapTalk(struct bundle *bundle, struct fsmheader *chp, struct mbuf *bp, */ if (memcmp(cp, cdigest, 16) == 0) { ChapOutput(physical, CHAP_SUCCESS, chp->id, "Welcome!!", 10); - if ((mode & MODE_DIRECT) && Physical_IsATTY(physical) - && Enabled(ConfUtmp)) - if (Utmp) - /* XXX: one entry per line please ! */ - LogPrintf(LogERROR, "Oops, already logged in on %s\n", - physical->name.base); - else { - struct utmp ut; - memset(&ut, 0, sizeof ut); - time(&ut.ut_time); - strncpy(ut.ut_name, name, sizeof ut.ut_name); - strncpy(ut.ut_line, physical->name.base, sizeof ut.ut_line - 1); - ID0login(&ut); - Utmp = 1; - } + Physical_Login(physical, name); if (LcpInfo.auth_iwait == 0) /* diff --git a/usr.sbin/ppp/modem.c b/usr.sbin/ppp/modem.c index 8f68eb18f0aa..49e4c1e35c05 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.77.2.28 1998/03/06 00:34:44 brian Exp $ + * $Id: modem.c,v 1.77.2.29 1998/03/09 19:24:57 brian Exp $ * * TODO: */ @@ -36,7 +36,6 @@ #include <sys/ioctl.h> #include <sys/tty.h> #include <unistd.h> -#include <utmp.h> #ifdef __OpenBSD__ #include <util.h> #else @@ -127,6 +126,8 @@ modem_Create(const char *name) *p->name.full = '\0'; p->name.base = p->name.full; + p->Utmp = 0; + p->cfg.is_direct = 0; /* not yet used */ p->cfg.is_dedicated = 0; /* not yet used */ p->cfg.rts_cts = MODEM_CTSRTS; @@ -847,10 +848,7 @@ modem_LogicalClose(struct physical *modem) { LogPrintf(LogDEBUG, "modem_LogicalClose\n"); if (modem->fd >= 0) { - if (Utmp) { - ID0logout(modem->name.base); - Utmp = 0; - } + Physical_Logout(modem); modem_PhysicalClose(modem); modem_Unlock(modem); } diff --git a/usr.sbin/ppp/pap.c b/usr.sbin/ppp/pap.c index 131933b5fde2..ec5d459cc64d 100644 --- a/usr.sbin/ppp/pap.c +++ b/usr.sbin/ppp/pap.c @@ -18,7 +18,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: pap.c,v 1.20.2.12 1998/03/06 00:34:45 brian Exp $ + * $Id: pap.c,v 1.20.2.13 1998/03/09 19:25:34 brian Exp $ * * TODO: */ @@ -36,7 +36,6 @@ #else #include <libutil.h> #endif -#include <utmp.h> #include "command.h" #include "mbuf.h" @@ -57,7 +56,6 @@ #include "descriptor.h" #include "physical.h" #include "bundle.h" -#include "id.h" #include "chat.h" #include "ccp.h" #include "chap.h" @@ -159,21 +157,7 @@ PapInput(struct bundle *bundle, struct mbuf *bp, struct physical *physical) if (PapValidate(bundle, cp, cp + *cp + 1, physical)) { SendPapCode(php->id, PAP_ACK, "Greetings!!", physical); LcpInfo.auth_ineed = 0; - if ((mode & MODE_DIRECT) && Physical_IsATTY(physical) && - Enabled(ConfUtmp)) - if (Utmp) - /* XXX: one entry per line please ! */ - LogPrintf(LogERROR, "Oops, already logged in on %s\n", - physical->name.base); - else { - struct utmp ut; - memset(&ut, 0, sizeof ut); - time(&ut.ut_time); - strncpy(ut.ut_name, cp+1, sizeof ut.ut_name); - strncpy(ut.ut_line, physical->name.base, sizeof ut.ut_line - 1); - ID0login(&ut); - Utmp = 1; - } + Physical_Login(physical, cp + 1); if (LcpInfo.auth_iwait == 0) /* diff --git a/usr.sbin/ppp/physical.c b/usr.sbin/ppp/physical.c index e0da3d8e20e8..349bc10d7c20 100644 --- a/usr.sbin/ppp/physical.c +++ b/usr.sbin/ppp/physical.c @@ -16,7 +16,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: physical.c,v 1.1.2.12 1998/02/23 00:38:39 brian Exp $ + * $Id: physical.c,v 1.1.2.13 1998/03/06 00:34:46 brian Exp $ * */ @@ -27,12 +27,15 @@ #include <assert.h> #include <stdio.h> #include <string.h> +#include <time.h> #include <unistd.h> +#include <utmp.h> /* XXX Name space pollution from vars.h */ #include <netinet/in.h> #include <alias.h> + #include "defs.h" #include "command.h" #include "loadalias.h" @@ -55,6 +58,7 @@ #include "vars.h" #include "bundle.h" #include "log.h" +#include "id.h" /* External calls - should possibly be moved inline */ extern int IntToSpeed(int); @@ -225,3 +229,30 @@ Physical_DescriptorWrite(struct descriptor *d, struct bundle *bundle, LogPrintf(LogDEBUG, "descriptor2physical; %p -> %p\n", d, p); link_StartOutput(&p->link, bundle); } + +void +Physical_Login(struct physical *phys, const char *name) +{ + if ((mode & MODE_DIRECT) && Physical_IsATTY(phys) && Enabled(ConfUtmp)) + if (phys->Utmp) + LogPrintf(LogERROR, "Oops, already logged in on %s\n", phys->name.base); + else { + struct utmp ut; + + memset(&ut, 0, sizeof ut); + time(&ut.ut_time); + strncpy(ut.ut_name, name, sizeof ut.ut_name); + strncpy(ut.ut_line, phys->name.base, sizeof ut.ut_line - 1); + ID0login(&ut); + phys->Utmp = 1; + } +} + +void +Physical_Logout(struct physical *phys) +{ + if (phys->Utmp) { + ID0logout(phys->name.base); + phys->Utmp = 0; + } +} diff --git a/usr.sbin/ppp/physical.h b/usr.sbin/ppp/physical.h index cbc7b208170e..1346245ca858 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.12 1998/02/23 00:38:39 brian Exp $ + * $Id: physical.h,v 1.1.2.13 1998/03/06 00:34:46 brian Exp $ * */ @@ -33,7 +33,7 @@ struct physical { (Possibly this should be dev_is_not_tcp?) XXX-ML */ - struct mbuf *out; + struct mbuf *out; /* mbuf that suffered a short write */ int connect_count; struct { @@ -41,6 +41,8 @@ struct physical { char *base; } name; + unsigned Utmp : 1; /* Are we in utmp ? */ + /* XXX-ML Most of the below is device specific, and probably do not belong in the generic physical struct. It comes from modem.c. */ @@ -102,3 +104,6 @@ int Physical_UpdateSet(struct descriptor *, fd_set *, fd_set *, fd_set *, int Physical_IsSet(struct descriptor *, fd_set *); void Physical_DescriptorWrite(struct descriptor *, struct bundle *, const fd_set *); + +void Physical_Login(struct physical *, const char *); +void Physical_Logout(struct physical *); diff --git a/usr.sbin/ppp/vars.c b/usr.sbin/ppp/vars.c index 92404f34f922..4c8cff7c8baf 100644 --- a/usr.sbin/ppp/vars.c +++ b/usr.sbin/ppp/vars.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: vars.c,v 1.45.2.12 1998/03/06 00:34:46 brian Exp $ + * $Id: vars.c,v 1.45.2.13 1998/03/09 19:26:40 brian Exp $ * */ #include <sys/param.h> @@ -46,8 +46,7 @@ #include "prompt.h" char VarVersion[] = "PPP Version 2.0-beta"; -char VarLocalVersion[] = "$Date: 1998/03/06 00:34:46 $"; -int Utmp = 0; +char VarLocalVersion[] = "$Date: 1998/03/09 19:26:40 $"; int ipKeepAlive = 0; /* diff --git a/usr.sbin/ppp/vars.h b/usr.sbin/ppp/vars.h index 5dfe8256e043..cec21c7435fa 100644 --- a/usr.sbin/ppp/vars.h +++ b/usr.sbin/ppp/vars.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: vars.h,v 1.42.2.11 1998/03/09 19:24:58 brian Exp $ + * $Id: vars.h,v 1.42.2.12 1998/03/09 19:26:41 brian Exp $ * * TODO: */ @@ -117,7 +117,6 @@ extern struct pppvars pppVars; extern char VarVersion[]; extern char VarLocalVersion[]; -extern int Utmp; /* Are we in /etc/utmp ? */ extern int ipKeepAlive; extern int EnableCommand(struct cmdargs const *); |