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 matt335672
parent 56eec32b7e
commit bacda80492
5 changed files with 37 additions and 19 deletions

View File

@ -514,6 +514,8 @@ AC_CHECK_HEADER([X11/extensions/Xrandr.h], [],
[AC_MSG_ERROR([please install libxrandr-dev or libXrandr-devel])],
[#include <X11/Xlib.h>])
AC_CHECK_HEADERS(utmp.h utmpx.h)
CFLAGS="$save_CFLAGS"
# perform unit tests if libcheck and libmocka found

View File

@ -25,8 +25,8 @@ xrdp_sesexec_SOURCES = \
env.h \
login_info.c \
login_info.h \
utmp.c \
utmp.h \
sessionrecord.c \
sessionrecord.h \
xauth.c \
xauth.h \
xwait.c \

View File

@ -47,8 +47,8 @@
#include "login_info.h"
#include "os_calls.h"
#include "sesexec.h"
#include "sessionrecord.h"
#include "string_calls.h"
#include "utmp.h"
#include "xauth.h"
#include "xwait.h"
#include "xrdp_sockets.h"

View File

@ -18,7 +18,7 @@
/**
*
* @file utmp.c
* @file sessionrecord.c
* @brief utmp/wtmp handling code
*
*/
@ -27,27 +27,26 @@
#include <config_ac.h>
#endif
#include <string.h>
#include <stdlib.h>
#include <paths.h>
#include <pwd.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "log.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
*/
int
add_xtmp_entry(int pid, const char *line, const char *user, const char *rhostname, short state)
{
struct utmpx ut;
_utmp ut;
struct timeval tv;
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);
endutxent ();
/* wtmp XXX hardcoded! */
updwtmpx("/var/log/wtmp", &ut);
/* wtmp XXX hardcoded! UTMPX_FILE pb def*/
#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;
}

View File

@ -18,13 +18,25 @@
/**
*
* @file utmp.h
* @file sessionrecord.h
* @brief utmp/wtmp handling code
*
*/
#ifndef UTMP_H
#define UTMP_H
#ifndef SESSIONRECORD_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"
/**