summaryrefslogtreecommitdiffstats
path: root/contrib/opie/libopie/login.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/opie/libopie/login.c')
-rw-r--r--contrib/opie/libopie/login.c50
1 files changed, 16 insertions, 34 deletions
diff --git a/contrib/opie/libopie/login.c b/contrib/opie/libopie/login.c
index d70280f..f7082c9 100644
--- a/contrib/opie/libopie/login.c
+++ b/contrib/opie/libopie/login.c
@@ -1,13 +1,18 @@
/* login.c: The opielogin() library function.
-%%% copyright-cmetz
-This software is Copyright 1996 by Craig Metz, All Rights Reserved.
+%%% copyright-cmetz-96
+This software is Copyright 1996-1997 by Craig Metz, All Rights Reserved.
The Inner Net License Version 2 applies to this software.
You should have received a copy of the license with this software. If
you didn't get a copy, you may request one from <license@inner.net>.
History:
+ Modified by cmetz for OPIE 2.31. If the OS won't tell us where
+ _PATH_WTMP[X] is, try playing the SVID game, then use
+ Autoconf-discovered values. Fixed gettimeofday() call
+ and updwtmpx() call. Call endutxent for utmpx. Added
+ DISABLE_UTMP.
Created by cmetz for OPIE 2.3.
*/
@@ -19,6 +24,7 @@ you didn't get a copy, you may request one from <license@inner.net>.
#if DOUTMPX
#include <utmpx.h>
#define pututline(x) pututxline(x)
+#define endutent endutxent
#define utmp utmpx
#endif /* DOUTMPX */
@@ -37,6 +43,7 @@ int opielogin FUNCTION((line, name, host), char *line AND char *name AND char *h
struct utmp u;
int rval = 0;
+#if !DISABLE_UTMP
if (__opiegetutmpentry(line, &u)) {
#if DEBUG
syslog(LOG_DEBUG, "opielogin: __opiegetutmpentry(line=%s, &u) failed", line);
@@ -60,21 +67,21 @@ int opielogin FUNCTION((line, name, host), char *line AND char *name AND char *h
#if HAVE_UT_NAME
strncpy(u.ut_name, name, sizeof(u.ut_name));
- u.ut_name[sizeof(u.ut_name)] = 0;
+ u.ut_name[sizeof(u.ut_name)-1] = 0;
#else /* HAVE_UT_NAME */
#error No ut_name field in struct utmp? (Please send in a bug report)
#endif /* HAVE_UT_NAME */
#if HAVE_UT_HOST
strncpy(u.ut_host, host, sizeof(u.ut_host));
- u.ut_host[sizeof(u.ut_host)] = 0;
+ u.ut_host[sizeof(u.ut_host)-1] = 0;
#endif /* HAVE_UT_HOST */
#if DOUTMPX
#ifdef HAVE_ONE_ARG_GETTIMEOFDAY
- gettimeofday(&u->ut_tv);
+ gettimeofday(&u.ut_tv);
#else /* HAVE_ONE_ARG_GETTIMEOFDAY */
- gettimeofday(&u->ut_tv, NULL);
+ gettimeofday(&u.ut_tv, NULL);
#endif /* HAVE_ONE_ARG_GETTIMEOFDAY */
#else /* DOUTMPX */
time(&u.ut_time);
@@ -86,36 +93,11 @@ int opielogin FUNCTION((line, name, host), char *line AND char *name AND char *h
#if DEBUG
syslog(LOG_DEBUG, "opielogin: utmp suceeded");
#endif /* DEBUG */
+#endif /* !DISABLE_UTMP */
dowtmp:
- {
- FILE *f;
-
-#if DOUTMPX
- updutmpx(_PATH_WTMPX, &u);
-#else /* DOUTMPX */
- if (!(f = __opieopen(_PATH_WTMP, 2, 0664))) {
- rval = -1;
-#if DEBUG
- syslog(LOG_DEBUG, "opielogin: wtmp open failed: %s (%d)", strerror(errno), errno);
-#endif /* DEBUG */
- goto dosetlogin;
- }
-
- if (fwrite(&u, sizeof(struct utmp), 1, f) != sizeof(struct utmp)) {
-#if DEBUG
- syslog(LOG_DEBUG, "opielogin: wtmp write failed: %s (%d)", strerror(errno), errno);
-#endif /* DEBUG */
- rval = -1;
- }
-
- fclose(f);
-#endif /* DOUTMPX */
- }
-
-#if DEBUG
- syslog(LOG_DEBUG, "opielogin: wtmp suceeded");
-#endif /* DEBUG */
+ opielogwtmp(line, name, host);
+ opielogwtmp(NULL, NULL, NULL);
dosetlogin:
#if HAVE_SETLOGIN
OpenPOWER on IntegriCloud