summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--acconfig.h1
-rw-r--r--configure.in9
-rw-r--r--src/command.c9
-rw-r--r--src/eterm_utmp.h96
-rw-r--r--src/utmp.c184
-rw-r--r--themes/Makefile.am5
7 files changed, 175 insertions, 136 deletions
diff --git a/ChangeLog b/ChangeLog
index 391016b..4fe7819 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2890,3 +2890,10 @@ Mon Dec 6 21:53:23 PST 1999 Michael Jennings <mej@eterm.org>
will supercede any config file settings you have; that's life.
-------------------------------------------------------------------------------
+Tue Dec 7 22:10:19 PST 1999 Michael Jennings <mej@eterm.org>
+
+ Support for RedHat's utempter library and some other fixes. Thanks to
+ Erik Troan <ewt@redhat.com> and Tim Powers <timp@redhat.com> for their
+ help with this.
+
+-------------------------------------------------------------------------------
diff --git a/acconfig.h b/acconfig.h
index 1d34046..1943763 100644
--- a/acconfig.h
+++ b/acconfig.h
@@ -322,6 +322,7 @@
#undef FONT4
#undef DEF_FONT_IDX
#undef IOTRACE
+#undef HAVE_UTEMPTER
/* Leave that blank line there!! Autoheader needs it.
diff --git a/configure.in b/configure.in
index 966ded6..01312c0 100644
--- a/configure.in
+++ b/configure.in
@@ -272,12 +272,21 @@ AC_ARG_ENABLE(utmp,
[ --enable-utmp compile with utmp support],
if test "$enableval" != "no"; then
AC_MSG_RESULT(yes)
+ UTMP=1
AC_DEFINE(UTMP_SUPPORT)
else
AC_MSG_RESULT(no)
+ UTMP=0
fi, AC_MSG_RESULT(yes)
AC_DEFINE(UTMP_SUPPORT)
+ UTMP=1
)
+if test $UTMP -eq 1; then
+ AC_CHECK_LIB(utempter, addToUtmp,
+ AC_DEFINE(HAVE_UTEMPTER)
+ LIBS="$LIBS -lutempter"
+ )
+fi
AC_MSG_CHECKING(for backspace key configuration)
AC_ARG_WITH(backspace,
[ --with-backspace=KEY force backspace to send KEY (KEY is either \"bs\" for ^H or \"del\" for ^?)],
diff --git a/src/command.c b/src/command.c
index 64ae87e..5d8d5fc 100644
--- a/src/command.c
+++ b/src/command.c
@@ -1060,7 +1060,7 @@ Exit_signal(int sig)
#ifdef UTMP_SUPPORT
privileges(INVOKE);
- cleanutent();
+ remove_utmp_entry();
privileges(REVERT);
#endif
@@ -1113,7 +1113,7 @@ clean_exit(void)
#endif /* __CYGWIN32__ */
#ifdef UTMP_SUPPORT
- cleanutent();
+ remove_utmp_entry();
#endif
privileges(REVERT);
PABLO_STOP_TRACING();
@@ -2200,8 +2200,9 @@ run_command(char *argv[])
}
#ifdef UTMP_SUPPORT
privileges(RESTORE);
- if (Options & Opt_utmpLogging)
- makeutent(ttydev, display_name); /* stamp /etc/utmp */
+ if (Options & Opt_utmpLogging) {
+ add_utmp_entry(ttydev, display_name, ptyfd);
+ }
privileges(IGNORE);
#endif
diff --git a/src/eterm_utmp.h b/src/eterm_utmp.h
index 9545560..305f39a 100644
--- a/src/eterm_utmp.h
+++ b/src/eterm_utmp.h
@@ -23,64 +23,78 @@
*
*/
-#if !defined(ETERM_UTMP_H_) && defined(UTMP_SUPPORT)
+#ifndef ETERM_UTMP_H_
#define ETERM_UTMP_H_
#include <X11/Xfuncproto.h>
#include <X11/Intrinsic.h> /* Xlib, Xutil, Xresource, Xfuncproto */
-/************ Macros and Definitions ************/
-#ifndef UTMP_FILENAME
-# ifdef UTMP_FILE
-# define UTMP_FILENAME UTMP_FILE
-# elif defined(_PATH_UTMP)
-# define UTMP_FILENAME _PATH_UTMP
-# else
-# define UTMP_FILENAME "/etc/utmp"
-# endif
-#endif
+#ifdef UTMP_SUPPORT
+# ifdef HAVE_UTEMPTER
+# include <utempter.h>
+# define add_utmp_entry(p, h, f) addToUtmp(p, h, f)
+# define remove_utmp_entry() removeFromUtmp()
+# endif
-#ifndef LASTLOG_FILENAME
-# ifdef _PATH_LASTLOG
-# define LASTLOG_FILENAME _PATH_LASTLOG
-# else
-# define LASTLOG_FILENAME "/usr/adm/lastlog" /* only on BSD systems */
+/************ Macros and Definitions ************/
+# ifndef UTMP_FILENAME
+# ifdef UTMP_FILE
+# define UTMP_FILENAME UTMP_FILE
+# elif defined(_PATH_UTMP)
+# define UTMP_FILENAME _PATH_UTMP
+# else
+# define UTMP_FILENAME "/etc/utmp"
+# endif
# endif
-#endif
-#ifndef WTMP_FILENAME
-# ifdef WTMP_FILE
-# define WTMP_FILENAME WTMP_FILE
-# elif defined(_PATH_WTMP)
-# define WTMP_FILENAME _PATH_WTMP
-# elif defined(SYSV)
-# define WTMP_FILENAME "/etc/wtmp"
+# ifndef LASTLOG_FILENAME
+# ifdef _PATH_LASTLOG
+# define LASTLOG_FILENAME _PATH_LASTLOG
# else
-# define WTMP_FILENAME "/usr/adm/wtmp"
+# define LASTLOG_FILENAME "/usr/adm/lastlog" /* only on BSD systems */
# endif
-#endif
+# endif
-#ifndef TTYTAB_FILENAME
-# ifdef TTYTAB
-# define TTYTAB_FILENAME TTYTAB_FILENAME
-# else
-# define TTYTAB_FILENAME "/etc/ttytab"
-# endif
-#endif
+# ifndef WTMP_FILENAME
+# ifdef WTMP_FILE
+# define WTMP_FILENAME WTMP_FILE
+# elif defined(_PATH_WTMP)
+# define WTMP_FILENAME _PATH_WTMP
+# elif defined(SYSV)
+# define WTMP_FILENAME "/etc/wtmp"
+# else
+# define WTMP_FILENAME "/usr/adm/wtmp"
+# endif
+# endif
-#ifndef USER_PROCESS
-# define USER_PROCESS 7
-#endif
-#ifndef DEAD_PROCESS
-# define DEAD_PROCESS 8
-#endif
+# ifndef TTYTAB_FILENAME
+# ifdef TTYTAB
+# define TTYTAB_FILENAME TTYTAB_FILENAME
+# else
+# define TTYTAB_FILENAME "/etc/ttytab"
+# endif
+# endif
+
+# ifndef USER_PROCESS
+# define USER_PROCESS 7
+# endif
+# ifndef DEAD_PROCESS
+# define DEAD_PROCESS 8
+# endif
/************ Function Prototypes ************/
_XFUNCPROTOBEGIN
-extern void makeutent(const char *, const char *);
-extern void cleanutent(void);
+# ifndef HAVE_UTEMPTER
+extern void add_utmp_entry(const char *, const char *, int);
+extern void remove_utmp_entry(void);
+# endif
_XFUNCPROTOEND
+#else /* UTMP_SUPPORT */
+# define add_utmp_entry(p, h, f) NOP
+# define remove_utmp_entry() NOP
+#endif
+
#endif /* ETERM_UTMP_H_ */
diff --git a/src/utmp.c b/src/utmp.c
index 2c001de..da5be94 100644
--- a/src/utmp.c
+++ b/src/utmp.c
@@ -28,76 +28,79 @@ static const char cvs_ident[] = "$Id$";
#ifdef UTMP_SUPPORT
-#include <stdio.h>
-#include <string.h>
+# include <stdio.h>
+# include <string.h>
/* For some systems (HP-UX in particular), sys/types.h must be included
before utmp*.h -- mej */
-#include <sys/types.h>
-#include <sys/stat.h>
+# include <sys/types.h>
+# include <sys/stat.h>
/* Unsupported/broken utmpx.h on HP-UX, AIX, and glibc 2.1 */
-#if defined(_HPUX_SOURCE) || defined(_AIX) || ((__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1))
-# undef HAVE_UTMPX_H
-#endif
-#ifdef HAVE_UTMPX_H
-# include <utmpx.h>
-# define USE_SYSV_UTMP
-#else
-# include <utmp.h>
-# ifdef HAVE_SETUTENT
+# if defined(_HPUX_SOURCE) || defined(_AIX) || ((__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1))
+# undef HAVE_UTMPX_H
+# endif
+# ifdef HAVE_UTMPX_H
+# include <utmpx.h>
# define USE_SYSV_UTMP
+# else
+# include <utmp.h>
+# ifdef HAVE_SETUTENT
+# define USE_SYSV_UTMP
+# endif
# endif
-#endif
-#ifdef TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# ifdef HAVE_SYS_TIME_H
+# ifdef TIME_WITH_SYS_TIME
# include <sys/time.h>
-# else
# include <time.h>
+# else
+# ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+# endif
+# ifdef HAVE_UNISTD_H
+# include <unistd.h>
+# endif
+# include <pwd.h>
+# include <errno.h>
+# ifdef HAVE_FCNTL_H
+# include <fcntl.h>
+# endif
+# ifdef HAVE_LASTLOG_H
+# include <lastlog.h>
+# endif
+# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__bsdi__)
+# include <ttyent.h>
# endif
-#endif
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-#include <pwd.h>
-#include <errno.h>
-#ifdef HAVE_FCNTL_H
-# include <fcntl.h>
-#endif
-#ifdef HAVE_LASTLOG_H
-# include <lastlog.h>
-#endif
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__bsdi__)
-# include <ttyent.h>
-#endif
-
-#include "eterm_utmp.h"
-#include "debug.h"
-#include "../libmej/debug.h"
-#include "command.h"
-#include "screen.h"
+
+# include "eterm_utmp.h"
+# include "debug.h"
+# include "../libmej/debug.h"
+# include "command.h"
+# include "screen.h"
/* screen.h includes config.h again, so re-fix these. Pointed out by Sung-Hyun Nam <namsh@lgic.co.kr> */
-#if defined(_HPUX_SOURCE) || defined(_AIX) || ((__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1))
-# undef HAVE_UTMPX_H
-#endif
+# if defined(_HPUX_SOURCE) || defined(_AIX) || ((__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1))
+# undef HAVE_UTMPX_H
+# endif
/* don't go off end of ut_id & remember if an entry has been made */
-#if defined(USE_SYSV_UTMP) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__)
+# ifndef HAVE_UTEMPTER
+# if defined(USE_SYSV_UTMP) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__)
static char ut_id[5]; /* remember if entry to utmp made */
-#else
+# else
static int utmp_pos; /* BSD position of utmp-stamp */
-#endif
+# endif
+# endif
-#ifdef USE_SYSV_UTMP
+# ifdef USE_SYSV_UTMP
# ifdef HAVE_UTMPX_H
-# undef WTMP_FILENAME
-# define WTMP_FILENAME WTMPX_FILE
-# define update_wtmp updwtmpx
+# undef WTMP_FILENAME
+# define WTMP_FILENAME WTMPX_FILE
+# define update_wtmp updwtmpx
# else /* HAVE_UTMPX_H */
+# ifndef HAVE_UTEMPTER
static void
update_wtmp(char *fname, struct utmp *putmp)
{
@@ -133,29 +136,29 @@ update_wtmp(char *fname, struct utmp *putmp)
close(fd);
}
+# endif /* ifndef HAVE_UTEMPTER */
+# endif /* HAVE_UTMPX_H */
-# endif /* HAVE_UTMPX_H */
-
-/* makeutent() - make a utmp entry */
+# ifndef HAVE_UTEMPTER
void
-makeutent(const char *pty, const char *hostname)
+add_utmp_entry(const char *pty, const char *hostname, int fd)
{
struct passwd *pwent = getpwuid(my_ruid);
-#ifdef HAVE_UTMPX_H
+# ifdef HAVE_UTMPX_H
struct utmpx utmp;
struct utmp utmp2;
MEMSET(&utmp, 0, sizeof(struct utmpx));
-#else
+# else
struct utmp utmp;
MEMSET(&utmp, 0, sizeof(struct utmp));
-#endif
+# endif
-#ifdef WITH_DMALLOC
+# ifdef WITH_DMALLOC
return;
-#endif
+# endif
if (!strncmp(pty, "/dev/", 5))
pty += 5; /* skip /dev/ prefix */
@@ -176,12 +179,12 @@ makeutent(const char *pty, const char *hostname)
utmp.ut_type = DEAD_PROCESS;
privileges(INVOKE);
-#ifdef HAVE_UTMPX_H
+# ifdef HAVE_UTMPX_H
getutmp(&utmp, &utmp2);
getutid(&utmp2); /* position to entry in utmp file */
-#else
+# else
getutid(&utmp); /* position to entry in utmp file */
-#endif
+# endif
/* set up the new entry */
strncpy(utmp.ut_id, ut_id, sizeof(utmp.ut_id));
@@ -191,35 +194,36 @@ makeutent(const char *pty, const char *hostname)
strncpy(utmp.ut_host, hostname, sizeof(utmp.ut_host));
utmp.ut_type = USER_PROCESS;
utmp.ut_pid = getpid();
-#ifdef HAVE_UTMPX_H
+# ifdef HAVE_UTMPX_H
utmp.ut_session = getsid(0);
utmp.ut_xtime = time(NULL);
utmp.ut_tv.tv_usec = 0;
-#else
+# else
utmp.ut_time = time(NULL);
-#endif
+# endif
/*
* write a utmp entry to the utmp file
*/
utmpname(UTMP_FILENAME);
-#ifdef HAVE_UTMPX_H
+# ifdef HAVE_UTMPX_H
getutmp(&utmp, &utmp2);
pututline(&utmp2);
pututxline(&utmp);
-#else
+# else
pututline(&utmp);
-#endif
+# endif
update_wtmp(WTMP_FILENAME, &utmp);
endutent(); /* close the file */
privileges(REVERT);
+ return;
+ fd = 0;
}
-/* cleanutent() - remove a utmp entry */
void
-cleanutent(void)
+remove_utmp_entry(void)
{
-#ifdef HAVE_UTMPX_H
+# ifdef HAVE_UTMPX_H
struct utmp utmp;
struct utmpx utmpx;
@@ -239,7 +243,7 @@ cleanutent(void)
endutent();
privileges(REVERT);
-#else /* HAVE_UTMPX_H */
+# else /* HAVE_UTMPX_H */
struct utmp *putmp;
pid_t pid = getpid();
@@ -266,13 +270,14 @@ cleanutent(void)
}
endutent();
privileges(REVERT);
-#endif /* HAVE_UTMPX_H */
+# endif /* HAVE_UTMPX_H */
}
+# endif /* ifndef HAVE_UTEMPTER */
-#else /* USE_SYSV_UTMP */
+# else /* USE_SYSV_UTMP */
/* BSD utmp support */
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__bsdi__)
+# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__bsdi__)
/* used to hold the line we are using */
static char ut_line[32];
@@ -320,7 +325,7 @@ b_login(struct utmp *ut)
}
}
-#else /* __FreeBSD__ || NetBSD || BSDI */
+# else /* __FreeBSD__ || NetBSD || BSDI */
static int utmp_pos = 0; /* position of utmp-stamp */
/*----------------------------------------------------------------------*
@@ -378,13 +383,10 @@ write_utmp(struct utmp *putmp)
return rval;
}
-#endif /* __FreeBSD__ || NetBSD || BSDI */
+# endif /* __FreeBSD__ || NetBSD || BSDI */
-/*
- * make a utmp entry
- */
void
-makeutent(const char *pty, const char *hostname)
+add_utmp_entry(const char *pty, const char *hostname, int fd)
{
struct passwd *pwent = getpwuid(my_ruid);
struct utmp utmp;
@@ -401,7 +403,7 @@ makeutent(const char *pty, const char *hostname)
return;
}
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__bsdi__)
+# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__bsdi__)
strncpy(ut_line, pty, 31);
strncpy(utmp.ut_line, pty, UT_LINESIZE);
@@ -410,7 +412,7 @@ makeutent(const char *pty, const char *hostname)
utmp.ut_time = time(NULL);
b_login(&utmp);
-#else /* __FreeBSD__ || NetBSD || BSDI */
+# else /* __FreeBSD__ || NetBSD || BSDI */
strncpy(utmp.ut_line, ut_id, sizeof(utmp.ut_line));
strncpy(utmp.ut_name, pwent->pw_name, sizeof(utmp.ut_name));
strncpy(utmp.ut_host, hostname, sizeof(utmp.ut_host));
@@ -418,19 +420,21 @@ makeutent(const char *pty, const char *hostname)
if (write_utmp(&utmp) < 0)
ut_id[0] = '\0'; /* entry not made */
-#endif
+# endif
+ return;
+ fd = 0;
}
/*
* remove a utmp entry
*/
void
-cleanutent(void)
+remove_utmp_entry(void)
{
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__bsdi__)
+# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__bsdi__)
logout(ut_line);
logwtmp(ut_line, "", "");
-#else /* __FreeBSD__ */
+# else /* __FreeBSD__ */
FILE *fd;
privileges(INVOKE);
@@ -444,9 +448,9 @@ cleanutent(void)
fclose(fd);
}
privileges(REVERT);
-#endif /* __FreeBSD__ || NetBSD || BSDI */
+# endif /* __FreeBSD__ || NetBSD || BSDI */
}
-#endif /* USE_SYSV_UTMP */
+# endif /* USE_SYSV_UTMP */
#endif /* UTMP_SUPPORT */
diff --git a/themes/Makefile.am b/themes/Makefile.am
index 68b09b3..c3d697c 100644
--- a/themes/Makefile.am
+++ b/themes/Makefile.am
@@ -6,11 +6,14 @@ EXTRA_DIST = Eterm/theme.cfg.in irc/theme.cfg.in chooser/theme.cfg.in emacs/them
Eterm/Eterm-menu.cfg irc/irc-menu.cfg chooser/chooser-menu.cfg emacs/emacs-menu.cfg mutt/mutt-menu.cfg trans/trans-menu.cfg \
cEterm/cEterm-menu.cfg cEterm/theme.cfg.in auto/auto-menu.cfg auto/theme.cfg.in
-install-data-hook:
+all: Makefile
-@for i in $(THEMES) ; do \
+ echo "Generating theme config file for the $$i theme." ; \
$(SED) -e 's%@''PREFIX''@%${prefix}%g' -e 's%@''PKGDATADIR''@%${DESTDIR}${pkgdatadir}%g' -e 's%@''THEME''@%'$$i'%g' \
$(srcdir)/$$i/theme.cfg.in > $(srcdir)/$$i/theme.cfg ; \
done
+
+install-data-hook:
$(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/themes
-@for i in $(THEMES) ; do \
if test ! -d $(DESTDIR)$(pkgdatadir)/themes/$$i ; then \