diff options
author | Ed Schouten <ed@80386.nl> | 2011-06-26 14:04:20 +0200 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-06-26 09:30:31 -0700 |
commit | 18d68ce74bd810bc09f99a476798b8e4a66ec494 (patch) | |
tree | c6defc3bc8077905ada0a235df8fc41ae9f92672 | |
parent | 9e93c5f65a22824f6b4af7ee68944f2226f7efa7 (diff) |
Make lastlog work on BSD systems without <lastlog.h>.
FreeBSD 8.x and lower have struct lastlog in <utmp.h>. Add a specific
Autoconf check for struct lastlog, where we include both <utmp.h> and
<lastlog.h>.
Also, change NO_LASTLOG to a definition for the opposite; USE_LASTLOG.
This is more consistent with USE_UTMP and USE_UTMPX.
Signed-off-by: Ed Schouten <ed@80386.nl>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r-- | configure.ac | 12 | ||||
-rw-r--r-- | sessreg.c | 12 | ||||
-rw-r--r-- | sessreg.h | 17 |
3 files changed, 22 insertions, 19 deletions
diff --git a/configure.ac b/configure.ac index 739abfa..98061b0 100644 --- a/configure.ac +++ b/configure.ac @@ -41,7 +41,7 @@ XORG_DEFAULT_OPTIONS XORG_WITH_LINT # Checks for header files. -AC_CHECK_HEADERS([lastlog.h utmp.h utmpx.h sys/param.h]) +AC_CHECK_HEADERS([lastlog.h pwd.h utmp.h utmpx.h sys/param.h]) # Checks for typedefs, structures, and compiler characteristics. AC_CHECK_MEMBERS([ @@ -53,6 +53,16 @@ AC_CHECK_MEMBERS([ #include <utmp.h> ]) AC_CHECK_MEMBERS([struct utmpx.ut_syslen], [], [], [#include <utmpx.h>]) +AC_CHECK_TYPES([ + struct lastlog], [], [],[ + #include <sys/types.h> + #ifdef HAVE_UTMP_H + #include <utmp.h> + #endif + #ifdef HAVE_LASTLOG_H + #include <lastlog.h> + #endif + ]) # Checks for library functions. AC_CHECK_FUNCS([pututline updwtmpx utmpxname]) @@ -61,7 +61,7 @@ * * usage: sessreg [ -w <wtmp-file> ] [ -u <utmp-file> ] * [ -l <line> ] - * [ -L <lastlog-file> ] / #ifndef NO_LASTLOG + * [ -L <lastlog-file> ] / #ifdef USE_LASTLOG * [ -h <host-name> ] / BSD only * [ -s <slot-number> ] [ -x Xservers-file ] / BSD only * [ -t <ttys-file> ] / BSD only @@ -112,7 +112,7 @@ static int slot_number; static char *xservers_file, *ttys_file; static char *user_name; static int aflag, dflag; -#ifndef NO_LASTLOG +#ifdef USE_LASTLOG static char *llog_file; static int llog_none, Lflag; #endif @@ -130,7 +130,7 @@ usage (int x) { if (x) { fprintf (stderr, "%s: usage %s {-a -d} [-w wtmp-file] [-u utmp-file]", program_name, program_name); -#ifndef NO_LASTLOG +#ifdef USE_LASTLOG fprintf (stderr, " [-L lastlog-file]"); #endif fprintf (stderr, "\n"); @@ -207,7 +207,7 @@ main (int argc, char **argv) if (!strcmp (utmp_file, "none")) utmp_none = 1; break; -#ifndef NO_LASTLOG +#ifdef USE_LASTLOG case 'L': llog_file = getstring (&argv, &Lflag); if (!strcmp (llog_file, "none")) @@ -266,7 +266,7 @@ main (int argc, char **argv) #else utmp_none = 1; #endif -#ifndef NO_LASTLOG +#ifdef USE_LASTLOG if (!Lflag) llog_file = LLOG_FILE; #endif @@ -348,7 +348,7 @@ main (int argc, char **argv) } #endif } -#ifndef NO_LASTLOG +#ifdef USE_LASTLOG if (aflag && !llog_none) { int llog; struct passwd *pwd = getpwnam(user_name); @@ -67,19 +67,12 @@ # include <sys/param.h> #endif -#ifndef HAVE_LASTLOG_H -# define NO_LASTLOG -#endif - -#ifndef NO_LASTLOG -# ifdef CSRG_BASED -# if (BSD < 199103) -# include <lastlog.h> -# endif -# else -# include <lastlog.h> +#if defined(HAVE_STRUCT_LASTLOG) && defined(HAVE_PWD_H) +# ifdef HAVE_LASTLOG_H +# include <lastlog.h> # endif -# include <pwd.h> +# include <pwd.h> +# define USE_LASTLOG #endif #ifdef CSRG_BASED |