summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@sun.com>2009-07-29 11:16:29 -0700
committerAlan Coopersmith <alan.coopersmith@sun.com>2009-07-29 11:16:29 -0700
commita9040b281062ddabcfb2cfdfc37e431b047531b2 (patch)
tree42fd4fb262ebf9f8da5912a4242a8842711fcd27
parentcafa4376f4761c2d565b2c1deeb7dbfb553d7045 (diff)
Set utmp/wtmp paths via configure instead of hardcoding them
Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
-rw-r--r--config/Makefile.am1
-rw-r--r--config/Xreset.cpp2
-rw-r--r--config/Xstartup.cpp2
-rw-r--r--configure.ac40
-rw-r--r--xdm.man.cpp6
5 files changed, 46 insertions, 5 deletions
diff --git a/config/Makefile.am b/config/Makefile.am
index 86eb0b3..7682725 100644
--- a/config/Makefile.am
+++ b/config/Makefile.am
@@ -50,6 +50,7 @@ MKTEMP_DEFINES = -DMKTEMP_COMMAND=$(MKTEMP_COMMAND)
#endif
CPP_FILES_FLAGS = -DBINDIR="$(bindir)" -DDEFAULTVT="$(DEFAULTVT)" \
+ -DUTMP_FILE="$(UTMP_FILE)" -DWTMP_FILE="$(WTMP_FILE)" \
-DXDMDIR="$(XDMLIBDIR)" -DXDMLOGDIR="$(XDMLOGDIR)" \
-DXDMXAUTHDIR="$(XDMXAUTHDIR)" \
-DXDMPIDDIR="$(XDMPIDDIR)" -DXDMCONFIGDIR="$(XDMCONFIGDIR)" \
diff --git a/config/Xreset.cpp b/config/Xreset.cpp
index d64df0d..321cd89 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 "/var/log/wtmp" -u "/var/run/utmp" \
+BINDIR/sessreg -d -w WTMP_FILE -u UTMP_FILE \
-x XDMCONFIGDIR/Xservers -l $DISPLAY -h "" $USER
diff --git a/config/Xstartup.cpp b/config/Xstartup.cpp
index 3d513f6..d837359 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
-BINDIR/sessreg -a -w "/var/log/wtmp" -u "/var/run/utmp" \
+BINDIR/sessreg -a -w WTMP_FILE -u UTMP_FILE \
-x XDMCONFIGDIR/Xservers -l $DISPLAY -h "" $USER
diff --git a/configure.ac b/configure.ac
index 19b3c26..fb46901 100644
--- a/configure.ac
+++ b/configure.ac
@@ -236,6 +236,46 @@ 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,
+ AC_HELP_STRING([--with-utmp-file=<pathname>],
+ [specify file to pass to sessreg -u for current logins]),
+ [UTMP_FILE="$withval"])
+if test "x$UTMP_FILE" = "xyes" ; then
+ AC_MSG_ERROR([path was not specified to --with-utmp-file])
+fi
+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
+fi
+AC_MSG_CHECKING([for path to file listing current logins for sessreg])
+AC_MSG_RESULT([$UTMP_FILE])
+AC_SUBST(UTMP_FILE)
+
+AC_ARG_WITH(wtmp_file,
+ AC_HELP_STRING([--with-wtmp-file=<pathname>],
+ [specify file to pass to sessreg -w for login history]),
+ [WTMP_FILE="$withval"])
+if test "x$WTMP_FILE" = "xyes" ; then
+ AC_MSG_ERROR([path was not specified to --with-wtmp-file])
+fi
+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
+fi
+AC_MSG_CHECKING([for path to file listing login history for sessreg])
+AC_MSG_RESULT([$WTMP_FILE])
+AC_SUBST(WTMP_FILE)
+
case $host_os in
*sco*|*solaris*)
SHELL_CMD="/bin/ksh" ;;
diff --git a/xdm.man.cpp b/xdm.man.cpp
index b0bd718..b947e5a 100644
--- a/xdm.man.cpp
+++ b/xdm.man.cpp
@@ -1137,7 +1137,7 @@ root when the user logs in.
It is typically a shell script.
Since it is run as root, \fIXstartup\fP should be
very careful about security. This is the place to put commands which add
-entries to \fI/etc/utmp\fP
+entries to \fIutmp\fP or \fIwtmp\fP files,
(the \fIsessreg\fP program may be useful here),
mount users' home directories from file servers,
or abort the session if logins are not
@@ -1286,8 +1286,8 @@ example. Don't forget that the file must have execute permission.
Symmetrical with \fIXstartup\fP,
the \fIXreset\fP script is run after the user session has
terminated. Run as root, it should contain commands that undo
-the effects of commands in \fIXstartup,\fP removing entries
-from \fI/etc/utmp\fP
+the effects of commands in \fIXstartup,\fP updating entries
+in \fIutmp\fP or \fIwtmp\fP files,
or unmounting directories from file servers. The environment
variables that were passed to \fIXstartup\fP are also
passed to \fIXreset\fP.