1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-15 04:32:24 +00:00

dtlogin: use utmpx when PAM is enabled.

This commit is contained in:
Liang Chang 2021-01-31 08:31:43 +08:00 committed by Jon Trulson
parent 4f2d356d31
commit 1d287720ad
2 changed files with 11 additions and 11 deletions

View file

@ -51,7 +51,7 @@
#endif #endif
#include <fcntl.h> #include <fcntl.h>
#if defined(__FreeBSD__) && OSMAJORVERSION > 8 #if defined(__FreeBSD__) && OSMAJORVERSION > 8 || defined(HAS_PAM_LIBRARY)
#include <utmpx.h> #include <utmpx.h>
#else #else
#include <utmp.h> #include <utmp.h>
@ -138,7 +138,7 @@ Account( struct display *d, char *user, char *line, pid_t pid,
waitType exitcode ) waitType exitcode )
{ {
#if !defined(CSRG_BASED) || defined(HAS_PAM_LIBRARY) #if !defined(CSRG_BASED) || defined(HAS_PAM_LIBRARY)
#if defined(__FreeBSD__) && OSMAJORVERSION > 8 #ifdef HAS_PAM_LIBRARY
struct utmpx utmp; /* local struct for new entry */ struct utmpx utmp; /* local struct for new entry */
struct utmpx *u; /* pointer to entry in utmp file */ struct utmpx *u; /* pointer to entry in utmp file */
#else #else
@ -187,7 +187,7 @@ Account( struct display *d, char *user, char *line, pid_t pid,
#ifdef sun #ifdef sun
return; return;
#else #else
#if defined(__FreeBSD__) && OSMAJORVERSION > 8 #ifdef HAS_PAM_LIBRARY
bzero(&utmp, sizeof(struct utmpx)); bzero(&utmp, sizeof(struct utmpx));
#else #else
bzero(&utmp, sizeof(struct utmp)); bzero(&utmp, sizeof(struct utmp));
@ -196,7 +196,7 @@ Account( struct display *d, char *user, char *line, pid_t pid,
strncpy(utmp.ut_id, d->utmpId, sizeof(u->ut_id) - 1); strncpy(utmp.ut_id, d->utmpId, sizeof(u->ut_id) - 1);
utmp.ut_type = LOGIN_PROCESS; utmp.ut_type = LOGIN_PROCESS;
#if defined(__FreeBSD__) && OSMAJORVERSION > 8 #ifdef HAS_PAM_LIBRARY
setutxent(); setutxent();
if ( (u = getutxid(&utmp)) == NULL ) u = &utmp; if ( (u = getutxid(&utmp)) == NULL ) u = &utmp;
#else #else
@ -212,7 +212,7 @@ Account( struct display *d, char *user, char *line, pid_t pid,
if ((type == DEAD_PROCESS && pid != 0 && u->ut_pid != pid) || if ((type == DEAD_PROCESS && pid != 0 && u->ut_pid != pid) ||
(type == DEAD_PROCESS && u->ut_type == DEAD_PROCESS) ) { (type == DEAD_PROCESS && u->ut_type == DEAD_PROCESS) ) {
#if defined(__FreeBSD__) && OSMAJORVERSION > 8 #ifdef HAS_PAM_LIBRARY
endutxent(); endutxent();
#else #else
endutent(); endutent();
@ -268,7 +268,7 @@ Account( struct display *d, char *user, char *line, pid_t pid,
if (type) { if (type) {
u->ut_type = type; u->ut_type = type;
if (type == DEAD_PROCESS) { if (type == DEAD_PROCESS) {
#if !(defined(__FreeBSD__) && OSMAJORVERSION > 8) #ifndef HAS_PAM_LIBRARY
u->ut_exit.e_termination = waitSig(exitcode); u->ut_exit.e_termination = waitSig(exitcode);
u->ut_exit.e_exit = waitCode(exitcode); u->ut_exit.e_exit = waitCode(exitcode);
#endif #endif
@ -286,13 +286,13 @@ Account( struct display *d, char *user, char *line, pid_t pid,
#endif #endif
} }
#if !(defined(__FreeBSD__) && OSMAJORVERSION > 8) #ifndef HAS_PAM_LIBRARY
if (type == USER_PROCESS) if (type == USER_PROCESS)
u->ut_exit.e_exit = (d->displayType.location == Local ? 1 : 0 ); u->ut_exit.e_exit = (d->displayType.location == Local ? 1 : 0 );
#endif #endif
} }
#if defined(__FreeBSD__) && OSMAJORVERSION > 8 #ifdef HAS_PAM_LIBRARY
(void) time(&u->ut_tv); (void) time(&u->ut_tv);
#else #else
(void) time(&u->ut_time); (void) time(&u->ut_time);
@ -306,14 +306,14 @@ Account( struct display *d, char *user, char *line, pid_t pid,
* to wtmp!) * to wtmp!)
*/ */
#if defined(__FreeBSD__) && OSMAJORVERSION > 8 #ifdef HAS_PAM_LIBRARY
pututxline(u); pututxline(u);
#else #else
pututline(u); pututline(u);
#endif #endif
#if !(defined(__FreeBSD__) && OSMAJORVERSION > 8) #ifndef HAS_PAM_LIBRARY
/* /*
* write the same entry to wtmp... * write the same entry to wtmp...
*/ */

View file

@ -66,7 +66,7 @@
# include <signal.h> # include <signal.h>
# include <X11/Xatom.h> # include <X11/Xatom.h>
# include <setjmp.h> # include <setjmp.h>
#if defined(__FreeBSD__) && OSMAJORVERSION > 8 #if defined(__FreeBSD__) && OSMAJORVERSION > 8 || defined(HAS_PAM_LIBRARY)
# include <utmpx.h> # include <utmpx.h>
#else #else
# include <utmp.h> # include <utmp.h>