[PATCH v2:xdm] Only pass -u & -w args to sessreg if --with-{u, w}tmp-file=path specified
Alan Coopersmith
alan.coopersmith at oracle.com
Tue Nov 4 21:46:42 PST 2014
If not specified, let sessreg use its builtin defaults instead of
replicating the logic here (and possibly getting it wrong), especially
since in sessreg-1.0.8 and earlier, using the -u & -w flags forces
the use of the utmp/wtmp code and not the newer utmpx/wtmpx code.
If --without-{u,w}tmp-file or --with-{u,w}tmp-file=none is specified,
pass "none" as arguments to sessreg to disable writing to that file.
v2: better handling of --with & --without arguments when not passing path,
add documentation of the 3 choices to README
Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
README | 14 ++++++++++++++
config/Makefile.am | 14 +++++++++++++-
config/Xreset.cpp | 2 +-
config/Xstartup.cpp | 2 +-
configure.ac | 44 ++++++++++++++++++++++----------------------
5 files changed, 51 insertions(+), 25 deletions(-)
diff --git a/README b/README
index b810197..750273c 100644
--- a/README
+++ b/README
@@ -22,6 +22,20 @@ For instance, some packagers/sites may prefer:
--with-xdmlibdir=$(prefix)/lib/xdm
--with-xdmscriptdir=/etc/X11/xdm
+The handling of --with-utmp-file & --with-wtmp-file have also changed
+slightly since previous versions of xdm:
+
+ --with-{u,w}tmp-file
+ [default] write records to utmp/wtmp files, but allow sessreg to
+ use its builtin default paths. Omits -u/-w flag entirely from
+ sessreg command in Xstartup & Xreset files.
+ --with-{u,w}tmp-file=<filename>
+ write records to utmp/wtmp files at specified filename.
+ Passes filename as argument to sessreg -u/-w flag in Xstartup/Xreset.
+ --without-{u,w}tmp-file or --with-{u,w}tmp-file=none
+ Do not write records to utmp/wtmp files at all.
+ Passes "none" as argument to sessreg -u/-w flag in Xstartup/Xreset.
+
----------------------------------------------------------------
All questions regarding this software should be directed at the
diff --git a/config/Makefile.am b/config/Makefile.am
index 30e22ea..e1484f1 100644
--- a/config/Makefile.am
+++ b/config/Makefile.am
@@ -49,8 +49,20 @@ XPMDEFINES = -DXPM -DBITMAPDIR=$(XDM_PIXMAPDIR) -DXDM_PIXMAP=$(XDM_PIXMAP) \
MKTEMP_DEFINES = -DMKTEMP_COMMAND=$(MKTEMP_COMMAND)
#endif
+if SET_UTMP_FILE
+UTMP_CPP_FLAGS = -DUTMP_FILE="$(UTMP_FILE)" -DUTMP_FLAG="-u $(UTMP_FILE)"
+else
+UTMP_CPP_FLAGS = -DUTMP_FILE="" -DUTMP_FLAG=""
+endif
+
+if SET_WTMP_FILE
+WTMP_CPP_FLAGS = -DWTMP_FILE="$(WTMP_FILE)" -DWTMP_FLAG="-w $(WTMP_FILE)"
+else
+WTMP_CPP_FLAGS = -DWTMP_FILE="" -DWTMP_FLAG=""
+endif
+
CPP_FILES_FLAGS = -DBINDIR="$(bindir)" -DDEFAULTVT="$(DEFAULTVT)" \
- -DUTMP_FILE="$(UTMP_FILE)" -DWTMP_FILE="$(WTMP_FILE)" \
+ $(UTMP_CPP_FLAGS) $(WTMP_CPP_FLAGS) \
-DXDMDIR="$(XDMLIBDIR)" -DXDMLOGDIR="$(XDMLOGDIR)" \
-DXDMXAUTHDIR="$(XDMXAUTHDIR)" \
-DXDMPIDDIR="$(XDMPIDDIR)" -DXDMCONFIGDIR="$(XDMCONFIGDIR)" \
diff --git a/config/Xreset.cpp b/config/Xreset.cpp
index 321cd89..5327402 100644
--- a/config/Xreset.cpp
+++ b/config/Xreset.cpp
@@ -1,5 +1,5 @@
XCOMM!/bin/sh
XCOMM Deregister a login. (Derived from TakeConsole as follows:)
XCOMM
-BINDIR/sessreg -d -w WTMP_FILE -u UTMP_FILE \
+BINDIR/sessreg -d WTMP_FLAG UTMP_FLAG \
-x XDMCONFIGDIR/Xservers -l $DISPLAY -h "" $USER
diff --git a/config/Xstartup.cpp b/config/Xstartup.cpp
index 001cef2..9329460 100644
--- a/config/Xstartup.cpp
+++ b/config/Xstartup.cpp
@@ -1,5 +1,5 @@
XCOMM!/bin/sh
XCOMM Register a login (derived from GiveConsole as follows:)
XCOMM
-exec BINDIR/sessreg -a -w WTMP_FILE -u UTMP_FILE \
+exec BINDIR/sessreg -a WTMP_FLAG UTMP_FLAG \
-x XDMCONFIGDIR/Xservers -l $DISPLAY -h "" $USER
diff --git a/configure.ac b/configure.ac
index 38b2a28..12ef51c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -279,44 +279,44 @@ AC_ARG_WITH(config-type,
[SERVERSTYPE="$withval"], [SERVERSTYPE="ws"])
AC_SUBST(SERVERSTYPE)
-# Ideally we'd just pull out UTMP_FILE & WTMP_FILE from <utmp.h>
-# but that's not easy to do in autoconf
AC_ARG_WITH(utmp_file,
AS_HELP_STRING([--with-utmp-file=<pathname>],
- [specify file to pass to sessreg -u for current logins]),
+ [specify file to pass to sessreg -u for current logins])
+AS_HELP_STRING([--without-utmp-file],
+ [specify passing "none" to sessreg -u to not record logins in utmp]),
[UTMP_FILE="$withval"])
if test "x$UTMP_FILE" = "xyes" ; then
- AC_MSG_ERROR([path was not specified to --with-utmp-file])
+ UTMP_FILE=""
+elif test "x$UTMP_FILE" = "xno" ; then
+ UTMP_FILE="none"
fi
+AC_MSG_CHECKING([for path to file listing current logins for sessreg])
if test "x$UTMP_FILE" = "x" ; then
- for UTMP_FILE in /var/adm/utmpx /var/run/utmp /var/log/utmp /var/adm/utmp /usr/adm/utmp /etc/utmp ; do
- AC_CHECK_FILE([$UTMP_FILE], [break], [UTMP_FILE=""])
- done
- if test "x$UTMP_FILE" = "x" ; then
- UTMP_FILE="/var/run/utmp"
- fi
+ AC_MSG_RESULT([use sessreg default])
+else
+ AC_MSG_RESULT([$UTMP_FILE])
fi
-AC_MSG_CHECKING([for path to file listing current logins for sessreg])
-AC_MSG_RESULT([$UTMP_FILE])
+AM_CONDITIONAL(SET_UTMP_FILE, test x$UTMP_FILE != x)
AC_SUBST(UTMP_FILE)
AC_ARG_WITH(wtmp_file,
AS_HELP_STRING([--with-wtmp-file=<pathname>],
- [specify file to pass to sessreg -w for login history]),
+ [specify file to pass to sessreg -w for login history])
+AS_HELP_STRING([--without-wtmp-file],
+ [specify passing "none" to sessreg -w to not record logins in wtmp]),
[WTMP_FILE="$withval"])
if test "x$WTMP_FILE" = "xyes" ; then
- AC_MSG_ERROR([path was not specified to --with-wtmp-file])
+ WTMP_FILE=""
+elif test "x$WTMP_FILE" = "xno" ; then
+ WTMP_FILE="none"
fi
+AC_MSG_CHECKING([for path to file listing login history for sessreg])
if test "x$WTMP_FILE" = "x" ; then
- for WTMP_FILE in /var/adm/wtmpx /var/log/wtmp /var/adm/wtmp /usr/adm/wtmp /etc/wtmp ; do
- AC_CHECK_FILE([$WTMP_FILE], [break], [WTMP_FILE=""])
- done
- if test "x$WTMP_FILE" = "x" ; then
- WTMP_FILE="/var/log/wtmp"
- fi
+ AC_MSG_RESULT([use sessreg default])
+else
+ AC_MSG_RESULT([$WTMP_FILE])
fi
-AC_MSG_CHECKING([for path to file listing login history for sessreg])
-AC_MSG_RESULT([$WTMP_FILE])
+AM_CONDITIONAL(SET_WTMP_FILE, test x$WTMP_FILE != x)
AC_SUBST(WTMP_FILE)
case $host_os in
--
1.7.9.2
More information about the xorg-devel
mailing list