Use HAVE_UTMPX_H to check if the system does or does not use utmpx files.
Minor restructuring for maintainability. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@919 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -6,10 +6,13 @@ RCSID("$Id$");
|
|||||||
|
|
||||||
/* utmpx_login - update utmp and wtmp after login */
|
/* utmpx_login - update utmp and wtmp after login */
|
||||||
|
|
||||||
#ifdef HAVE_UTMPX
|
#ifndef HAVE_UTMPX_H
|
||||||
|
int utmpx_login(char *line, char *user, char *host) { return 0; }
|
||||||
|
#else
|
||||||
|
|
||||||
static
|
static
|
||||||
void
|
void
|
||||||
update(struct utmpx *ut, char *line, char *user, char *host)
|
utmpx_update(struct utmpx *ut, char *line, char *user, char *host)
|
||||||
{
|
{
|
||||||
strncpy(ut->ut_line, line, sizeof(ut->ut_line));
|
strncpy(ut->ut_line, line, sizeof(ut->ut_line));
|
||||||
strncpy(ut->ut_user, user, sizeof(ut->ut_user));
|
strncpy(ut->ut_user, user, sizeof(ut->ut_user));
|
||||||
@@ -26,14 +29,10 @@ update(struct utmpx *ut, char *line, char *user, char *host)
|
|||||||
updwtmpx(WTMPX_FILE, ut);
|
updwtmpx(WTMPX_FILE, ut);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
int
|
int
|
||||||
utmpx_login(char *line, char *user, char *host)
|
utmpx_login(char *line, char *user, char *host)
|
||||||
{
|
{
|
||||||
#ifndef HAVE_UTMPX
|
|
||||||
return 0;
|
|
||||||
#else
|
|
||||||
struct utmpx *ut;
|
struct utmpx *ut;
|
||||||
pid_t mypid = getpid();
|
pid_t mypid = getpid();
|
||||||
int ret = (-1);
|
int ret = (-1);
|
||||||
@@ -52,7 +51,7 @@ utmpx_login(char *line, char *user, char *host)
|
|||||||
&& ( ut->ut_type == INIT_PROCESS
|
&& ( ut->ut_type == INIT_PROCESS
|
||||||
|| ut->ut_type == LOGIN_PROCESS
|
|| ut->ut_type == LOGIN_PROCESS
|
||||||
|| ut->ut_type == USER_PROCESS)) {
|
|| ut->ut_type == USER_PROCESS)) {
|
||||||
update(ut, line, user, host);
|
utmpx_update(ut, line, user, host);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -62,10 +61,10 @@ 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;
|
||||||
update(&newut, line, user, host);
|
utmpx_update(&newut, line, user, host);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
endutxent();
|
endutxent();
|
||||||
return (ret);
|
return (ret);
|
||||||
#endif /* HAVE_UTMPX */
|
|
||||||
}
|
}
|
||||||
|
#endif /* HAVE_UTMPX_H */
|
||||||
|
Reference in New Issue
Block a user