1 /* login.c: The opielogin() library function.
4 This software is Copyright 1996-2001 by Craig Metz, All Rights Reserved.
5 The Inner Net License Version 3 applies to this software.
6 You should have received a copy of the license with this software. If
7 you didn't get a copy, you may request one from <license@inner.net>.
11 Modified by cmetz for OPIE 2.4. Add support for ut_id and
12 ut_syslen. Don't zero-terminate ut_name and ut_host.
13 Modified by cmetz for OPIE 2.31. If the OS won't tell us where
14 _PATH_WTMP[X] is, try playing the SVID game, then use
15 Autoconf-discovered values. Fixed gettimeofday() call
16 and updwtmpx() call. Call endutxent for utmpx. Added
18 Created by cmetz for OPIE 2.3.
23 #include <sys/types.h>
27 #define pututline(x) pututxline(x)
28 #define endutent endutxent
36 #endif /* HAVE_STRING_H */
46 int opielogin FUNCTION((line, name, host), char *line AND char *name AND char *host)
51 char id[IDLEN + 1] = "";
53 if (__opiegetutmpentry(line, &u)) {
55 syslog(LOG_DEBUG, "opielogin: __opiegetutmpentry(line=%s, &u) failed", line);
57 memset(&u, 0, sizeof(struct utmp));
58 if (!strncmp(line, "/dev/", 5))
59 strncpy(u.ut_line, line + 5, sizeof(u.ut_line));
61 strncpy(u.ut_line, line, sizeof(u.ut_line));
63 syslog(LOG_DEBUG, "opielogin: continuing with ut_line=%s", u.ut_line);
67 #if DOUTMPX || HAVE_UT_ID
68 strncpy(id, u.ut_id, sizeof(u.ut_id));
70 #endif /* DOUTMPX || HAVE_UT_ID */
72 #if HAVE_UT_TYPE && defined(USER_PROCESS)
73 u.ut_type = USER_PROCESS;
74 #endif /* HAVE_UT_TYPE && defined(USER_PROCESS) */
77 #endif /* HAVE_UT_PID */
80 strncpy(u.ut_name, name, sizeof(u.ut_name));
81 #else /* HAVE_UT_NAME */
82 #error No ut_name field in struct utmp? (Please send in a bug report)
83 #endif /* HAVE_UT_NAME */
86 strncpy(u.ut_host, host, sizeof(u.ut_host));
87 #endif /* HAVE_UT_HOST */
88 #if DOUTMPX && HAVE_UTX_SYSLEN
89 u.ut_syslen = strlen(host) + 1;
90 #endif /* DOUTMPX && HAVE_UT_SYSLEN */
93 #ifdef HAVE_ONE_ARG_GETTIMEOFDAY
94 gettimeofday(&u.ut_tv);
95 #else /* HAVE_ONE_ARG_GETTIMEOFDAY */
96 gettimeofday(&u.ut_tv, NULL);
97 #endif /* HAVE_ONE_ARG_GETTIMEOFDAY */
106 syslog(LOG_DEBUG, "opielogin: utmp suceeded");
108 #endif /* !DISABLE_UTMP */
111 opielogwtmp(line, name, host, id);
112 opielogwtmp(NULL, NULL, NULL);
117 #endif /* HAVE_SETLOGIN */
120 syslog(LOG_DEBUG, "opielogin: rval=%d", rval);