WIP utmp/wtmp

- renamed the two files, including the header was conflicting with official headers
- configure look for utmp/utmpx headers, wo we know which struct to use
- reworked the usage for linux, works mostly (last still showing 'gone' for loggued users)
This commit is contained in:
BLINDAUER Emmanuel 2017-09-26 21:06:44 +02:00 committed by Koichiro IWAO
parent ae31066bcd
commit 38786d46a9
No known key found for this signature in database
GPG Key ID: 9F72CDBC01BF10EB
5 changed files with 37 additions and 16 deletions

View File

@ -321,6 +321,8 @@ AC_CHECK_HEADER([X11/extensions/Xrandr.h], [],
[AC_MSG_ERROR([please install libxrandr-dev or libXrandr-devel])], [AC_MSG_ERROR([please install libxrandr-dev or libXrandr-devel])],
[#include <X11/Xlib.h>]) [#include <X11/Xlib.h>])
AC_CHECK_HEADERS(utmp.h utmpx.h)
CFLAGS="$save_CFLAGS" CFLAGS="$save_CFLAGS"
AC_SUBST([moduledir], '${libdir}/xrdp') AC_SUBST([moduledir], '${libdir}/xrdp')

View File

@ -61,6 +61,8 @@ xrdp_sesman_SOURCES = \
sesman.h \ sesman.h \
session.c \ session.c \
session.h \ session.h \
sessionrecord.c \
sessionrecord.h \
sig.c \ sig.c \
sig.h \ sig.h \
utmp.c \ utmp.c \

View File

@ -40,6 +40,7 @@
#include "sesman.h" #include "sesman.h"
#include "libscp_types.h" #include "libscp_types.h"
#include "xauth.h" #include "xauth.h"
#include "sessionrecord.h"
#include "xrdp_sockets.h" #include "xrdp_sockets.h"
#include "utmp.h" #include "utmp.h"

View File

@ -18,7 +18,7 @@
/** /**
* *
* @file utmp.c * @file sessionrecord.c
* @brief utmp/wtmp handling code * @brief utmp/wtmp handling code
* *
*/ */
@ -27,27 +27,26 @@
#include <config_ac.h> #include <config_ac.h>
#endif #endif
#include <string.h> #include <paths.h>
#include <stdlib.h>
#include <pwd.h> #include <pwd.h>
#include <unistd.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "log.h" #include "log.h"
#include "os_calls.h" #include "os_calls.h"
#include "sessionrecord.h"
#include <utmp.h>
#include <utmpx.h>
/* /*
* Prepare the utmpx struct and write it. * Prepare the utmp/ struct and write it.
* this can handle login and logout at once with the 'state' parameter * this can handle login and logout at once with the 'state' parameter
*/ */
int int
add_xtmp_entry(int pid, const char *line, const char *user, const char *rhostname, short state) add_xtmp_entry(int pid, const char *line, const char *user, const char *rhostname, short state)
{ {
struct utmpx ut; _utmp ut;
struct timeval tv; struct timeval tv;
memset (&ut, 0, sizeof (ut)); memset (&ut, 0, sizeof (ut));
@ -66,9 +65,14 @@ add_xtmp_entry(int pid, const char *line, const char *user, const char *rhostnam
pututxline(&ut); pututxline(&ut);
endutxent (); endutxent ();
/* wtmp XXX hardcoded! */ /* wtmp XXX hardcoded! UTMPX_FILE pb def*/
updwtmpx("/var/log/wtmp", &ut); #ifdef HAVE_UTMPX_H
log_message(LOG_LEVEL_DEBUG, "HAVE_UTMPX_H");
updwtmpx(_PATH_WTMP, &ut);
#elif defined(HAVE_UTMP_H)
log_message(LOG_LEVEL_DEBUG, "HAVE_UTMP_H");
updwtmp("/var/log/wtmp", &ut);
#endif
return 0; return 0;
} }

View File

@ -18,13 +18,25 @@
/** /**
* *
* @file utmp.h * @file sessionrecord.h
* @brief utmp/wtmp handling code * @brief utmp/wtmp handling code
* *
*/ */
#ifndef UTMP_H #ifndef SESSIONRECORD_H
#define UTMP_H #define SESSIONRECORD_H
#ifdef HAVE_UTMPX_H
#include <utmpx.h>
typedef struct utmpx _utmp;
#else
#include <utmpx.h>
typedef struct utmp _utmp;
#endif
#define XRDP_LINE_FORMAT "xrdp:%d" #define XRDP_LINE_FORMAT "xrdp:%d"
/** /**