handle case where there's no wtmpx (such as HP-UX 10)
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@1744 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -16,7 +16,7 @@ utmpx_update(struct utmpx *ut, char *line, char *user, char *host)
|
|||||||
{
|
{
|
||||||
struct timeval tmp;
|
struct timeval tmp;
|
||||||
|
|
||||||
strncpy(ut->ut_line, line, sizeof(ut->ut_line));
|
strncpy(ut->ut_line, clean_ttyname(line), sizeof(ut->ut_line));
|
||||||
strncpy(ut->ut_user, user, sizeof(ut->ut_user));
|
strncpy(ut->ut_user, user, sizeof(ut->ut_user));
|
||||||
strncpy(ut->ut_host, host, sizeof(ut->ut_host));
|
strncpy(ut->ut_host, host, sizeof(ut->ut_host));
|
||||||
#ifdef HAVE_UT_SYSLEN
|
#ifdef HAVE_UT_SYSLEN
|
||||||
@@ -31,6 +31,17 @@ utmpx_update(struct utmpx *ut, char *line, char *user, char *host)
|
|||||||
pututxline(ut);
|
pututxline(ut);
|
||||||
#ifdef WTMPX_FILE
|
#ifdef WTMPX_FILE
|
||||||
updwtmpx(WTMPX_FILE, ut);
|
updwtmpx(WTMPX_FILE, ut);
|
||||||
|
#elif defined(WTMP_FILE)
|
||||||
|
{
|
||||||
|
struct utmp utmp;
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
prepare_utmp (&utmp, line, user, host);
|
||||||
|
if ((fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) >= 0) {
|
||||||
|
write(fd, &utmp, sizeof(struct utmp));
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,7 +76,6 @@ utmpx_login(char *line, char *user, char *host)
|
|||||||
struct utmpx newut;
|
struct utmpx newut;
|
||||||
memset(&newut, 0, sizeof(newut));
|
memset(&newut, 0, sizeof(newut));
|
||||||
newut.ut_pid = mypid;
|
newut.ut_pid = mypid;
|
||||||
snprintf(newut.ut_id, sizeof(newut.ut_id), "lo%04x", (unsigned)mypid);
|
|
||||||
utmpx_update(&newut, line, user, host);
|
utmpx_update(&newut, line, user, host);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user