From f1316a86432e8591f51cc454841600f77d8d3682 Mon Sep 17 00:00:00 2001 From: Brian Somers Date: Thu, 19 Feb 1998 02:08:53 +0000 Subject: [PATCH] Allow 8 character login names. Pointed out by: Forgotten Do the login()/logwtmp()/logout() as id 0. --- usr.sbin/ppp/chap.c | 9 ++++----- usr.sbin/ppp/id.c | 47 ++++++++++++++++++++++++++++++++++++++------ usr.sbin/ppp/id.h | 6 +++++- usr.sbin/ppp/modem.c | 13 +++--------- 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 28831b4f72c5..98c2304045eb 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.8 1998/02/09 19:20:34 brian Exp $ + * $Id: chap.c,v 1.28.2.9 1998/02/15 23:59:43 brian Exp $ * * TODO: */ @@ -62,6 +62,7 @@ #include "descriptor.h" #include "physical.h" #include "bundle.h" +#include "id.h" static const char *chapcodes[] = { "???", "CHALLENGE", "RESPONSE", "SUCCESS", "FAILURE" @@ -245,11 +246,9 @@ RecvChapTalk(struct bundle *bundle, 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; } diff --git a/usr.sbin/ppp/id.c b/usr.sbin/ppp/id.c index c030ccf6e2e6..27b506ab8706 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.6 1998/01/21 02:15:16 brian Exp $ + * $Id: id.c,v 1.6.4.1 1998/02/08 11:07:30 brian Exp $ */ #include @@ -32,18 +32,20 @@ #include #include #include +#include #include #include - -#include "command.h" -#include "mbuf.h" -#include "log.h" -#include "main.h" #ifdef __OpenBSD__ #include #else #include #endif +#include + +#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 121e8da331e3..6dba7b89d9bc 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.2 1997/12/21 12:11:05 brian Exp $ + * $Id: id.h,v 1.3 1997/12/27 19:23:13 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 30eb9f6035fd..33cf65535374 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.21 1998/02/17 19:28:49 brian Exp $ + * $Id: modem.c,v 1.77.2.22 1998/02/17 19:29:00 brian Exp $ * * TODO: */ @@ -840,18 +840,11 @@ modem_LogicalClose(struct physical *modem) { LogPrintf(LogDEBUG, "modem_LogicalClose\n"); if (modem->fd >= 0) { - modem_PhysicalClose(modem); 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, "modem_LogicalClose: No longer logged in on %s\n", - ut.ut_line); + ID0logout(VarBaseDevice); Utmp = 0; } + modem_PhysicalClose(modem); modem_Unlock(modem); } } diff --git a/usr.sbin/ppp/pap.c b/usr.sbin/ppp/pap.c index b9183da2bdd8..c1f4b4953a33 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.8 1998/02/09 19:21:05 brian Exp $ + * $Id: pap.c,v 1.20.2.9 1998/02/16 00:00:54 brian Exp $ * * TODO: */ @@ -57,6 +57,7 @@ #include "descriptor.h" #include "physical.h" #include "bundle.h" +#include "id.h" static const char *papcodes[] = { "???", "REQUEST", "ACK", "NAK" }; @@ -179,11 +180,9 @@ PapInput(struct bundle *bundle, struct mbuf *bp, struct physical *physical) 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; }