diff options
-rw-r--r-- | usr.sbin/ppp/chap.c | 9 | ||||
-rw-r--r-- | usr.sbin/ppp/id.c | 47 | ||||
-rw-r--r-- | usr.sbin/ppp/id.h | 6 | ||||
-rw-r--r-- | usr.sbin/ppp/modem.c | 13 | ||||
-rw-r--r-- | usr.sbin/ppp/pap.c | 9 |
5 files changed, 57 insertions, 27 deletions
diff --git a/usr.sbin/ppp/chap.c b/usr.sbin/ppp/chap.c index 3187b66b37b..2e5c9c62df9 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.3 1997/12/24 09:30:24 brian Exp $ + * $Id: chap.c,v 1.4 1998/02/19 02:02:45 brian Exp $ * * TODO: */ @@ -56,6 +56,7 @@ #include "loadalias.h" #include "vars.h" #include "auth.h" +#include "id.h" static const char *chapcodes[] = { "???", "CHALLENGE", "RESPONSE", "SUCCESS", "FAILURE" @@ -232,11 +233,9 @@ RecvChapTalk(struct fsmheader *chp, struct mbuf *bp) struct utmp ut; memset(&ut, 0, sizeof ut); time(&ut.ut_time); - strncpy(ut.ut_name, name, sizeof ut.ut_name - 1); + strncpy(ut.ut_name, name, sizeof ut.ut_name); strncpy(ut.ut_line, VarBaseDevice, sizeof ut.ut_line - 1); - if (logout(ut.ut_line)) - logwtmp(ut.ut_line, "", ""); - login(&ut); + ID0login(&ut); Utmp = 1; } NewPhase(PHASE_NETWORK); diff --git a/usr.sbin/ppp/id.c b/usr.sbin/ppp/id.c index 34ad2e51f93..d455ea966f5 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.4 1998/01/21 02:13:33 brian Exp $ + * $Id: id.c,v 1.5 1998/02/19 02:02:46 brian Exp $ */ #include <sys/types.h> @@ -32,18 +32,20 @@ #include <sys/ioctl.h> #include <fcntl.h> #include <stdio.h> +#include <string.h> #include <sysexits.h> #include <unistd.h> - -#include "command.h" -#include "mbuf.h" -#include "log.h" -#include "main.h" #ifdef __OpenBSD__ #include <util.h> #else #include <libutil.h> #endif +#include <utmp.h> + +#include "command.h" +#include "mbuf.h" +#include "log.h" +#include "main.h" #include "id.h" static int uid; @@ -175,3 +177,36 @@ ID0uu_unlock(const char *basettyname) ID0setuser(); return ret; } + +void +ID0login(struct utmp *ut) +{ + ID0set0(); + if (logout(ut->ut_line)) { + LogPrintf(LogID0, "logout(\"%s\")\n", ut->ut_line); + logwtmp(ut->ut_line, "", ""); + LogPrintf(LogID0, "logwtmp(\"%s\", \"\", \"\")\n", ut->ut_line); + } + login(ut); + LogPrintf(LogID0, "login(\"%s\", \"%.*s\")\n", + ut->ut_line, sizeof ut->ut_name, ut->ut_name); + ID0setuser(); +} + +void +ID0logout(const char *device) +{ + struct utmp ut; + + strncpy(ut.ut_line, device, sizeof ut.ut_line - 1); + ut.ut_line[sizeof ut.ut_line - 1] = '\0'; + + ID0set0(); + if (logout(ut.ut_line)) { + LogPrintf(LogID0, "logout(\"%s\")\n", ut.ut_line); + logwtmp(ut.ut_line, "", ""); + LogPrintf(LogID0, "logwtmp(\"%s\", \"\", \"\")\n", ut.ut_line); + } else + LogPrintf(LogERROR, "ID0logout: No longer logged in on %s\n", ut.ut_line); + ID0setuser(); +} diff --git a/usr.sbin/ppp/id.h b/usr.sbin/ppp/id.h index 5d7b4b3aee6..f51893e1b5e 100644 --- a/usr.sbin/ppp/id.h +++ b/usr.sbin/ppp/id.h @@ -23,9 +23,11 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: id.h,v 1.3 1997/12/27 19:22:27 brian Exp $ + * $Id: id.h,v 1.4 1998/02/19 02:02:47 brian Exp $ */ +struct utmp; + extern void ID0init(void); extern uid_t ID0realuid(void); extern int ID0ioctl(int, unsigned long, void *); @@ -36,3 +38,5 @@ extern int ID0open(const char *, int); extern int ID0write(int, const void *, size_t); extern int ID0uu_lock(const char *); extern int ID0uu_unlock(const char *); +extern void ID0login(struct utmp *); +extern void ID0logout(const char *); diff --git a/usr.sbin/ppp/modem.c b/usr.sbin/ppp/modem.c index 428ab13cc87..62db126d5f5 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.11 1998/01/29 00:35:34 brian Exp $ + * $Id: modem.c,v 1.12 1998/02/19 02:02:47 brian Exp $ * * TODO: */ @@ -738,18 +738,11 @@ CloseLogicalModem(void) { LogPrintf(LogDEBUG, "CloseLogicalModem\n"); if (modem >= 0) { - ClosePhysicalModem(); if (Utmp) { - struct utmp ut; - strncpy(ut.ut_line, VarBaseDevice, sizeof ut.ut_line - 1); - ut.ut_line[sizeof ut.ut_line - 1] = '\0'; - if (logout(ut.ut_line)) - logwtmp(ut.ut_line, "", ""); - else - LogPrintf(LogERROR, "CloseLogicalModem: No longer logged in on %s\n", - ut.ut_line); + ID0logout(VarBaseDevice); Utmp = 0; } + ClosePhysicalModem(); UnlockModem(); } } diff --git a/usr.sbin/ppp/pap.c b/usr.sbin/ppp/pap.c index 101c720f173..e2e9c2f78b2 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.2 1997/12/24 09:30:45 brian Exp $ + * $Id: pap.c,v 1.3 1998/02/19 02:02:48 brian Exp $ * * TODO: */ @@ -51,6 +51,7 @@ #include "lcpproto.h" #include "phase.h" #include "auth.h" +#include "id.h" static const char *papcodes[] = { "???", "REQUEST", "ACK", "NAK" }; @@ -173,11 +174,9 @@ PapInput(struct mbuf * bp) struct utmp ut; memset(&ut, 0, sizeof ut); time(&ut.ut_time); - strncpy(ut.ut_name, cp+1, sizeof ut.ut_name - 1); + strncpy(ut.ut_name, cp+1, sizeof ut.ut_name); strncpy(ut.ut_line, VarBaseDevice, sizeof ut.ut_line - 1); - if (logout(ut.ut_line)) - logwtmp(ut.ut_line, "", ""); - login(&ut); + ID0login(&ut); Utmp = 1; } NewPhase(PHASE_NETWORK); |