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. SVN revision: 1547
This commit is contained in:
parent
b9864e98fe
commit
4af86536a7
|
@ -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.
|
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.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
|
|
@ -322,6 +322,7 @@
|
||||||
#undef FONT4
|
#undef FONT4
|
||||||
#undef DEF_FONT_IDX
|
#undef DEF_FONT_IDX
|
||||||
#undef IOTRACE
|
#undef IOTRACE
|
||||||
|
#undef HAVE_UTEMPTER
|
||||||
|
|
||||||
|
|
||||||
/* Leave that blank line there!! Autoheader needs it.
|
/* Leave that blank line there!! Autoheader needs it.
|
||||||
|
|
|
@ -272,12 +272,21 @@ AC_ARG_ENABLE(utmp,
|
||||||
[ --enable-utmp compile with utmp support],
|
[ --enable-utmp compile with utmp support],
|
||||||
if test "$enableval" != "no"; then
|
if test "$enableval" != "no"; then
|
||||||
AC_MSG_RESULT(yes)
|
AC_MSG_RESULT(yes)
|
||||||
|
UTMP=1
|
||||||
AC_DEFINE(UTMP_SUPPORT)
|
AC_DEFINE(UTMP_SUPPORT)
|
||||||
else
|
else
|
||||||
AC_MSG_RESULT(no)
|
AC_MSG_RESULT(no)
|
||||||
|
UTMP=0
|
||||||
fi, AC_MSG_RESULT(yes)
|
fi, AC_MSG_RESULT(yes)
|
||||||
AC_DEFINE(UTMP_SUPPORT)
|
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_MSG_CHECKING(for backspace key configuration)
|
||||||
AC_ARG_WITH(backspace,
|
AC_ARG_WITH(backspace,
|
||||||
[ --with-backspace=KEY force backspace to send KEY (KEY is either \"bs\" for ^H or \"del\" for ^?)],
|
[ --with-backspace=KEY force backspace to send KEY (KEY is either \"bs\" for ^H or \"del\" for ^?)],
|
||||||
|
|
|
@ -1060,7 +1060,7 @@ Exit_signal(int sig)
|
||||||
|
|
||||||
#ifdef UTMP_SUPPORT
|
#ifdef UTMP_SUPPORT
|
||||||
privileges(INVOKE);
|
privileges(INVOKE);
|
||||||
cleanutent();
|
remove_utmp_entry();
|
||||||
privileges(REVERT);
|
privileges(REVERT);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1113,7 +1113,7 @@ clean_exit(void)
|
||||||
#endif /* __CYGWIN32__ */
|
#endif /* __CYGWIN32__ */
|
||||||
|
|
||||||
#ifdef UTMP_SUPPORT
|
#ifdef UTMP_SUPPORT
|
||||||
cleanutent();
|
remove_utmp_entry();
|
||||||
#endif
|
#endif
|
||||||
privileges(REVERT);
|
privileges(REVERT);
|
||||||
PABLO_STOP_TRACING();
|
PABLO_STOP_TRACING();
|
||||||
|
@ -2200,8 +2200,9 @@ run_command(char *argv[])
|
||||||
}
|
}
|
||||||
#ifdef UTMP_SUPPORT
|
#ifdef UTMP_SUPPORT
|
||||||
privileges(RESTORE);
|
privileges(RESTORE);
|
||||||
if (Options & Opt_utmpLogging)
|
if (Options & Opt_utmpLogging) {
|
||||||
makeutent(ttydev, display_name); /* stamp /etc/utmp */
|
add_utmp_entry(ttydev, display_name, ptyfd);
|
||||||
|
}
|
||||||
privileges(IGNORE);
|
privileges(IGNORE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -23,64 +23,78 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if !defined(ETERM_UTMP_H_) && defined(UTMP_SUPPORT)
|
#ifndef ETERM_UTMP_H_
|
||||||
#define ETERM_UTMP_H_
|
#define ETERM_UTMP_H_
|
||||||
|
|
||||||
#include <X11/Xfuncproto.h>
|
#include <X11/Xfuncproto.h>
|
||||||
#include <X11/Intrinsic.h> /* Xlib, Xutil, Xresource, Xfuncproto */
|
#include <X11/Intrinsic.h> /* Xlib, Xutil, Xresource, Xfuncproto */
|
||||||
|
|
||||||
/************ Macros and Definitions ************/
|
#ifdef UTMP_SUPPORT
|
||||||
#ifndef UTMP_FILENAME
|
# ifdef HAVE_UTEMPTER
|
||||||
# ifdef UTMP_FILE
|
# include <utempter.h>
|
||||||
# define UTMP_FILENAME UTMP_FILE
|
# define add_utmp_entry(p, h, f) addToUtmp(p, h, f)
|
||||||
# elif defined(_PATH_UTMP)
|
# define remove_utmp_entry() removeFromUtmp()
|
||||||
# define UTMP_FILENAME _PATH_UTMP
|
|
||||||
# else
|
|
||||||
# define UTMP_FILENAME "/etc/utmp"
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef LASTLOG_FILENAME
|
|
||||||
# ifdef _PATH_LASTLOG
|
|
||||||
# define LASTLOG_FILENAME _PATH_LASTLOG
|
|
||||||
# else
|
|
||||||
# define LASTLOG_FILENAME "/usr/adm/lastlog" /* only on BSD systems */
|
|
||||||
# endif
|
# endif
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef WTMP_FILENAME
|
/************ Macros and Definitions ************/
|
||||||
# ifdef WTMP_FILE
|
# ifndef UTMP_FILENAME
|
||||||
# define WTMP_FILENAME WTMP_FILE
|
# ifdef UTMP_FILE
|
||||||
# elif defined(_PATH_WTMP)
|
# define UTMP_FILENAME UTMP_FILE
|
||||||
# define WTMP_FILENAME _PATH_WTMP
|
# elif defined(_PATH_UTMP)
|
||||||
# elif defined(SYSV)
|
# define UTMP_FILENAME _PATH_UTMP
|
||||||
# define WTMP_FILENAME "/etc/wtmp"
|
# else
|
||||||
|
# define UTMP_FILENAME "/etc/utmp"
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef LASTLOG_FILENAME
|
||||||
|
# ifdef _PATH_LASTLOG
|
||||||
|
# define LASTLOG_FILENAME _PATH_LASTLOG
|
||||||
# else
|
# else
|
||||||
# define WTMP_FILENAME "/usr/adm/wtmp"
|
# define LASTLOG_FILENAME "/usr/adm/lastlog" /* only on BSD systems */
|
||||||
# endif
|
# endif
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
#ifndef TTYTAB_FILENAME
|
# ifndef WTMP_FILENAME
|
||||||
# ifdef TTYTAB
|
# ifdef WTMP_FILE
|
||||||
# define TTYTAB_FILENAME TTYTAB_FILENAME
|
# define WTMP_FILENAME WTMP_FILE
|
||||||
# else
|
# elif defined(_PATH_WTMP)
|
||||||
# define TTYTAB_FILENAME "/etc/ttytab"
|
# define WTMP_FILENAME _PATH_WTMP
|
||||||
# endif
|
# elif defined(SYSV)
|
||||||
#endif
|
# define WTMP_FILENAME "/etc/wtmp"
|
||||||
|
# else
|
||||||
|
# define WTMP_FILENAME "/usr/adm/wtmp"
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
#ifndef USER_PROCESS
|
# ifndef TTYTAB_FILENAME
|
||||||
# define USER_PROCESS 7
|
# ifdef TTYTAB
|
||||||
#endif
|
# define TTYTAB_FILENAME TTYTAB_FILENAME
|
||||||
#ifndef DEAD_PROCESS
|
# else
|
||||||
# define DEAD_PROCESS 8
|
# define TTYTAB_FILENAME "/etc/ttytab"
|
||||||
#endif
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef USER_PROCESS
|
||||||
|
# define USER_PROCESS 7
|
||||||
|
# endif
|
||||||
|
# ifndef DEAD_PROCESS
|
||||||
|
# define DEAD_PROCESS 8
|
||||||
|
# endif
|
||||||
|
|
||||||
/************ Function Prototypes ************/
|
/************ Function Prototypes ************/
|
||||||
_XFUNCPROTOBEGIN
|
_XFUNCPROTOBEGIN
|
||||||
|
|
||||||
extern void makeutent(const char *, const char *);
|
# ifndef HAVE_UTEMPTER
|
||||||
extern void cleanutent(void);
|
extern void add_utmp_entry(const char *, const char *, int);
|
||||||
|
extern void remove_utmp_entry(void);
|
||||||
|
# endif
|
||||||
|
|
||||||
_XFUNCPROTOEND
|
_XFUNCPROTOEND
|
||||||
|
|
||||||
|
#else /* UTMP_SUPPORT */
|
||||||
|
# define add_utmp_entry(p, h, f) NOP
|
||||||
|
# define remove_utmp_entry() NOP
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* ETERM_UTMP_H_ */
|
#endif /* ETERM_UTMP_H_ */
|
||||||
|
|
186
src/utmp.c
186
src/utmp.c
|
@ -28,76 +28,79 @@ static const char cvs_ident[] = "$Id$";
|
||||||
|
|
||||||
#ifdef UTMP_SUPPORT
|
#ifdef UTMP_SUPPORT
|
||||||
|
|
||||||
#include <stdio.h>
|
# include <stdio.h>
|
||||||
#include <string.h>
|
# include <string.h>
|
||||||
/* For some systems (HP-UX in particular), sys/types.h must be included
|
/* For some systems (HP-UX in particular), sys/types.h must be included
|
||||||
before utmp*.h -- mej */
|
before utmp*.h -- mej */
|
||||||
#include <sys/types.h>
|
# include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
# include <sys/stat.h>
|
||||||
/* Unsupported/broken utmpx.h on HP-UX, AIX, and glibc 2.1 */
|
/* Unsupported/broken utmpx.h on HP-UX, AIX, and glibc 2.1 */
|
||||||
#if defined(_HPUX_SOURCE) || defined(_AIX) || ((__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1))
|
# if defined(_HPUX_SOURCE) || defined(_AIX) || ((__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1))
|
||||||
# undef HAVE_UTMPX_H
|
# undef HAVE_UTMPX_H
|
||||||
#endif
|
# endif
|
||||||
#ifdef HAVE_UTMPX_H
|
# ifdef HAVE_UTMPX_H
|
||||||
# include <utmpx.h>
|
# include <utmpx.h>
|
||||||
# define USE_SYSV_UTMP
|
|
||||||
#else
|
|
||||||
# include <utmp.h>
|
|
||||||
# ifdef HAVE_SETUTENT
|
|
||||||
# define USE_SYSV_UTMP
|
# define USE_SYSV_UTMP
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#ifdef TIME_WITH_SYS_TIME
|
|
||||||
# include <sys/time.h>
|
|
||||||
# include <time.h>
|
|
||||||
#else
|
|
||||||
# ifdef HAVE_SYS_TIME_H
|
|
||||||
# include <sys/time.h>
|
|
||||||
# else
|
# else
|
||||||
# include <time.h>
|
# include <utmp.h>
|
||||||
|
# ifdef HAVE_SETUTENT
|
||||||
|
# define USE_SYSV_UTMP
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
# ifdef TIME_WITH_SYS_TIME
|
||||||
|
# include <sys/time.h>
|
||||||
|
# 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
|
||||||
#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 "eterm_utmp.h"
|
||||||
#include "debug.h"
|
# include "debug.h"
|
||||||
#include "../libmej/debug.h"
|
# include "../libmej/debug.h"
|
||||||
#include "command.h"
|
# include "command.h"
|
||||||
#include "screen.h"
|
# include "screen.h"
|
||||||
|
|
||||||
/* screen.h includes config.h again, so re-fix these. Pointed out by Sung-Hyun Nam <namsh@lgic.co.kr> */
|
/* 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))
|
# if defined(_HPUX_SOURCE) || defined(_AIX) || ((__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1))
|
||||||
# undef HAVE_UTMPX_H
|
# undef HAVE_UTMPX_H
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
/* don't go off end of ut_id & remember if an entry has been made */
|
/* 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 */
|
static char ut_id[5]; /* remember if entry to utmp made */
|
||||||
#else
|
# else
|
||||||
static int utmp_pos; /* BSD position of utmp-stamp */
|
static int utmp_pos; /* BSD position of utmp-stamp */
|
||||||
#endif
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
#ifdef USE_SYSV_UTMP
|
# ifdef USE_SYSV_UTMP
|
||||||
|
|
||||||
# ifdef HAVE_UTMPX_H
|
# ifdef HAVE_UTMPX_H
|
||||||
# undef WTMP_FILENAME
|
# undef WTMP_FILENAME
|
||||||
# define WTMP_FILENAME WTMPX_FILE
|
# define WTMP_FILENAME WTMPX_FILE
|
||||||
# define update_wtmp updwtmpx
|
# define update_wtmp updwtmpx
|
||||||
# else /* HAVE_UTMPX_H */
|
# else /* HAVE_UTMPX_H */
|
||||||
|
|
||||||
|
# ifndef HAVE_UTEMPTER
|
||||||
static void
|
static void
|
||||||
update_wtmp(char *fname, struct utmp *putmp)
|
update_wtmp(char *fname, struct utmp *putmp)
|
||||||
{
|
{
|
||||||
|
@ -133,29 +136,29 @@ update_wtmp(char *fname, struct utmp *putmp)
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
# endif /* ifndef HAVE_UTEMPTER */
|
||||||
|
# endif /* HAVE_UTMPX_H */
|
||||||
|
|
||||||
# endif /* HAVE_UTMPX_H */
|
# ifndef HAVE_UTEMPTER
|
||||||
|
|
||||||
/* makeutent() - make a utmp entry */
|
|
||||||
void
|
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 passwd *pwent = getpwuid(my_ruid);
|
||||||
|
|
||||||
#ifdef HAVE_UTMPX_H
|
# ifdef HAVE_UTMPX_H
|
||||||
struct utmpx utmp;
|
struct utmpx utmp;
|
||||||
struct utmp utmp2;
|
struct utmp utmp2;
|
||||||
MEMSET(&utmp, 0, sizeof(struct utmpx));
|
MEMSET(&utmp, 0, sizeof(struct utmpx));
|
||||||
|
|
||||||
#else
|
# else
|
||||||
struct utmp utmp;
|
struct utmp utmp;
|
||||||
MEMSET(&utmp, 0, sizeof(struct utmp));
|
MEMSET(&utmp, 0, sizeof(struct utmp));
|
||||||
|
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
#ifdef WITH_DMALLOC
|
# ifdef WITH_DMALLOC
|
||||||
return;
|
return;
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
if (!strncmp(pty, "/dev/", 5))
|
if (!strncmp(pty, "/dev/", 5))
|
||||||
pty += 5; /* skip /dev/ prefix */
|
pty += 5; /* skip /dev/ prefix */
|
||||||
|
@ -176,12 +179,12 @@ makeutent(const char *pty, const char *hostname)
|
||||||
utmp.ut_type = DEAD_PROCESS;
|
utmp.ut_type = DEAD_PROCESS;
|
||||||
|
|
||||||
privileges(INVOKE);
|
privileges(INVOKE);
|
||||||
#ifdef HAVE_UTMPX_H
|
# ifdef HAVE_UTMPX_H
|
||||||
getutmp(&utmp, &utmp2);
|
getutmp(&utmp, &utmp2);
|
||||||
getutid(&utmp2); /* position to entry in utmp file */
|
getutid(&utmp2); /* position to entry in utmp file */
|
||||||
#else
|
# else
|
||||||
getutid(&utmp); /* position to entry in utmp file */
|
getutid(&utmp); /* position to entry in utmp file */
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
/* set up the new entry */
|
/* set up the new entry */
|
||||||
strncpy(utmp.ut_id, ut_id, sizeof(utmp.ut_id));
|
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));
|
strncpy(utmp.ut_host, hostname, sizeof(utmp.ut_host));
|
||||||
utmp.ut_type = USER_PROCESS;
|
utmp.ut_type = USER_PROCESS;
|
||||||
utmp.ut_pid = getpid();
|
utmp.ut_pid = getpid();
|
||||||
#ifdef HAVE_UTMPX_H
|
# ifdef HAVE_UTMPX_H
|
||||||
utmp.ut_session = getsid(0);
|
utmp.ut_session = getsid(0);
|
||||||
utmp.ut_xtime = time(NULL);
|
utmp.ut_xtime = time(NULL);
|
||||||
utmp.ut_tv.tv_usec = 0;
|
utmp.ut_tv.tv_usec = 0;
|
||||||
#else
|
# else
|
||||||
utmp.ut_time = time(NULL);
|
utmp.ut_time = time(NULL);
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* write a utmp entry to the utmp file
|
* write a utmp entry to the utmp file
|
||||||
*/
|
*/
|
||||||
utmpname(UTMP_FILENAME);
|
utmpname(UTMP_FILENAME);
|
||||||
#ifdef HAVE_UTMPX_H
|
# ifdef HAVE_UTMPX_H
|
||||||
getutmp(&utmp, &utmp2);
|
getutmp(&utmp, &utmp2);
|
||||||
pututline(&utmp2);
|
pututline(&utmp2);
|
||||||
pututxline(&utmp);
|
pututxline(&utmp);
|
||||||
#else
|
# else
|
||||||
pututline(&utmp);
|
pututline(&utmp);
|
||||||
#endif
|
# endif
|
||||||
update_wtmp(WTMP_FILENAME, &utmp);
|
update_wtmp(WTMP_FILENAME, &utmp);
|
||||||
endutent(); /* close the file */
|
endutent(); /* close the file */
|
||||||
privileges(REVERT);
|
privileges(REVERT);
|
||||||
|
return;
|
||||||
|
fd = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* cleanutent() - remove a utmp entry */
|
|
||||||
void
|
void
|
||||||
cleanutent(void)
|
remove_utmp_entry(void)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_UTMPX_H
|
# ifdef HAVE_UTMPX_H
|
||||||
struct utmp utmp;
|
struct utmp utmp;
|
||||||
struct utmpx utmpx;
|
struct utmpx utmpx;
|
||||||
|
|
||||||
|
@ -239,7 +243,7 @@ cleanutent(void)
|
||||||
endutent();
|
endutent();
|
||||||
privileges(REVERT);
|
privileges(REVERT);
|
||||||
|
|
||||||
#else /* HAVE_UTMPX_H */
|
# else /* HAVE_UTMPX_H */
|
||||||
struct utmp *putmp;
|
struct utmp *putmp;
|
||||||
pid_t pid = getpid();
|
pid_t pid = getpid();
|
||||||
|
|
||||||
|
@ -266,13 +270,14 @@ cleanutent(void)
|
||||||
}
|
}
|
||||||
endutent();
|
endutent();
|
||||||
privileges(REVERT);
|
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 */
|
/* 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 */
|
/* used to hold the line we are using */
|
||||||
static char ut_line[32];
|
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 */
|
static int utmp_pos = 0; /* position of utmp-stamp */
|
||||||
|
|
||||||
/*----------------------------------------------------------------------*
|
/*----------------------------------------------------------------------*
|
||||||
|
@ -378,13 +383,10 @@ write_utmp(struct utmp *putmp)
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* __FreeBSD__ || NetBSD || BSDI */
|
# endif /* __FreeBSD__ || NetBSD || BSDI */
|
||||||
|
|
||||||
/*
|
|
||||||
* make a utmp entry
|
|
||||||
*/
|
|
||||||
void
|
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 passwd *pwent = getpwuid(my_ruid);
|
||||||
struct utmp utmp;
|
struct utmp utmp;
|
||||||
|
@ -401,7 +403,7 @@ makeutent(const char *pty, const char *hostname)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__bsdi__)
|
# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__bsdi__)
|
||||||
strncpy(ut_line, pty, 31);
|
strncpy(ut_line, pty, 31);
|
||||||
|
|
||||||
strncpy(utmp.ut_line, pty, UT_LINESIZE);
|
strncpy(utmp.ut_line, pty, UT_LINESIZE);
|
||||||
|
@ -410,7 +412,7 @@ makeutent(const char *pty, const char *hostname)
|
||||||
utmp.ut_time = time(NULL);
|
utmp.ut_time = time(NULL);
|
||||||
|
|
||||||
b_login(&utmp);
|
b_login(&utmp);
|
||||||
#else /* __FreeBSD__ || NetBSD || BSDI */
|
# else /* __FreeBSD__ || NetBSD || BSDI */
|
||||||
strncpy(utmp.ut_line, ut_id, sizeof(utmp.ut_line));
|
strncpy(utmp.ut_line, ut_id, sizeof(utmp.ut_line));
|
||||||
strncpy(utmp.ut_name, pwent->pw_name, sizeof(utmp.ut_name));
|
strncpy(utmp.ut_name, pwent->pw_name, sizeof(utmp.ut_name));
|
||||||
strncpy(utmp.ut_host, hostname, sizeof(utmp.ut_host));
|
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)
|
if (write_utmp(&utmp) < 0)
|
||||||
ut_id[0] = '\0'; /* entry not made */
|
ut_id[0] = '\0'; /* entry not made */
|
||||||
#endif
|
# endif
|
||||||
|
return;
|
||||||
|
fd = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* remove a utmp entry
|
* remove a utmp entry
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
cleanutent(void)
|
remove_utmp_entry(void)
|
||||||
{
|
{
|
||||||
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__bsdi__)
|
# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__bsdi__)
|
||||||
logout(ut_line);
|
logout(ut_line);
|
||||||
logwtmp(ut_line, "", "");
|
logwtmp(ut_line, "", "");
|
||||||
#else /* __FreeBSD__ */
|
# else /* __FreeBSD__ */
|
||||||
FILE *fd;
|
FILE *fd;
|
||||||
|
|
||||||
privileges(INVOKE);
|
privileges(INVOKE);
|
||||||
|
@ -444,9 +448,9 @@ cleanutent(void)
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
}
|
}
|
||||||
privileges(REVERT);
|
privileges(REVERT);
|
||||||
#endif /* __FreeBSD__ || NetBSD || BSDI */
|
# endif /* __FreeBSD__ || NetBSD || BSDI */
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* USE_SYSV_UTMP */
|
# endif /* USE_SYSV_UTMP */
|
||||||
|
|
||||||
#endif /* UTMP_SUPPORT */
|
#endif /* UTMP_SUPPORT */
|
||||||
|
|
|
@ -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 \
|
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
|
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 \
|
-@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' \
|
$(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 ; \
|
$(srcdir)/$$i/theme.cfg.in > $(srcdir)/$$i/theme.cfg ; \
|
||||||
done
|
done
|
||||||
|
|
||||||
|
install-data-hook:
|
||||||
$(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/themes
|
$(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/themes
|
||||||
-@for i in $(THEMES) ; do \
|
-@for i in $(THEMES) ; do \
|
||||||
if test ! -d $(DESTDIR)$(pkgdatadir)/themes/$$i ; then \
|
if test ! -d $(DESTDIR)$(pkgdatadir)/themes/$$i ; then \
|
||||||
|
|
Loading…
Reference in New Issue