aboutsummaryrefslogtreecommitdiffstats
path: root/x11
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2010-01-18 17:01:26 +0800
committered <ed@FreeBSD.org>2010-01-18 17:01:26 +0800
commit5aa127f6d1254a63e5770602b979a3b186a9adcc (patch)
tree6bacbd4333d4435d8a920c697c546fc8b7a77706 /x11
parent5e3afc6ad447b6b0bde9a5c9425160407e59b1cb (diff)
downloadfreebsd-ports-gnome-5aa127f6d1254a63e5770602b979a3b186a9adcc.tar.gz
freebsd-ports-gnome-5aa127f6d1254a63e5770602b979a3b186a9adcc.tar.zst
freebsd-ports-gnome-5aa127f6d1254a63e5770602b979a3b186a9adcc.zip
Make x11/sessreg build with utmpx exclusively.
This patch has been backported from the Xorg git repository: http://cgit.freedesktop.org/xorg/app/sessreg/commit/?id=9792646873ac0e597cc65ef4a056444fd8f9a7fd Approved by: miwi (portmgr)
Diffstat (limited to 'x11')
-rw-r--r--x11/sessreg/Makefile5
-rw-r--r--x11/sessreg/files/patch-utmpx268
2 files changed, 273 insertions, 0 deletions
diff --git a/x11/sessreg/Makefile b/x11/sessreg/Makefile
index b82f9894233d..03de0618f141 100644
--- a/x11/sessreg/Makefile
+++ b/x11/sessreg/Makefile
@@ -12,9 +12,14 @@ CATEGORIES= x11
MAINTAINER= x11@FreeBSD.org
COMMENT= Manage utmp/wtmp entries for non-init X clients
+BUILD_DEPENDS+= ${LOCALBASE}/share/aclocal/xorg-macros.m4:${PORTSDIR}/devel/xorg-macros
+
XORG_CAT= app
USE_XORG= x11
+USE_AUTOTOOLS= aclocal:110 autoheader:262 automake:110 autoconf:262
+ACLOCAL_ARGS= -I${LOCALBASE}/share/aclocal
+
PLIST_FILES= bin/sessreg
MAN1= sessreg.1
diff --git a/x11/sessreg/files/patch-utmpx b/x11/sessreg/files/patch-utmpx
new file mode 100644
index 000000000000..67fdf2974975
--- /dev/null
+++ b/x11/sessreg/files/patch-utmpx
@@ -0,0 +1,268 @@
+--- configure.ac
++++ configure.ac
+@@ -39,13 +39,14 @@ AC_PROG_INSTALL
+
+ XORG_DEFAULT_OPTIONS
+
+-AC_CHECK_HEADERS([lastlog.h utmpx.h sys/param.h])
++AC_CHECK_HEADERS([lastlog.h utmp.h utmpx.h sys/param.h])
+ AC_CHECK_MEMBER([struct utmpx.ut_syslen],
+ HAVE_SYSLEN=1,
+ HAVE_SYSLEN=0,
+ [#include <utmpx.h>])
+ AC_DEFINE_UNQUOTED(HAVE_UTMPX_UT_SYSLEN,$HAVE_SYSLEN,
+ [utmpx structure includes ut_syslen field])
++AC_CHECK_FUNCS([updwtmpx utmpxname])
+
+ AC_SYS_LARGEFILE
+
+--- sessreg.c
++++ sessreg.c
+@@ -80,7 +80,6 @@
+ # include <X11/Xfuncs.h>
+ # include <stdio.h>
+ # include <stdlib.h>
+-# include <utmp.h>
+
+ #if defined(__SVR4) || defined(SVR4) || defined(linux) || defined(__GLIBC__)
+ # define SYSV
+@@ -89,7 +88,10 @@
+ #include <time.h>
+ #define Time_t time_t
+
+-static void set_utmp (struct utmp *u, char *line, char *user, char *host, Time_t date, int addp);
++#ifdef USE_UTMP
++static void set_utmp (struct utmp *u, char *line, char *user, char *host,
++ Time_t date, int addp);
++#endif
+
+ #ifdef USE_UTMPX
+ static void set_utmpx (struct utmpx *u, const char *line, const char *user,
+@@ -99,7 +101,12 @@
+ int wflag, uflag, lflag;
+ char *wtmp_file, *utmp_file, *line;
+ #ifdef USE_UTMPX
+-static char *wtmpx_file = NULL, *utmpx_file = NULL;
++#ifdef HAVE_UPDWTMPX
++static char *wtmpx_file = NULL;
++#endif
++#ifdef HAVE_UTMPXNAME
++static char *utmpx_file = NULL;
++#endif
+ #endif
+ int utmp_none, wtmp_none;
+ /*
+@@ -108,7 +115,9 @@
+ */
+ int hflag, sflag, xflag, tflag;
+ char *host_name = NULL;
++#ifdef USE_UTMP
+ int slot_number;
++#endif
+ char *xservers_file, *ttys_file;
+ char *user_name;
+ int aflag, dflag;
+@@ -180,7 +189,7 @@
+ int
+ main (int argc, char **argv)
+ {
+-#ifndef SYSV
++#if defined(USE_UTMP) && !defined(SYSV)
+ int utmp;
+ #endif
+ char *line_tmp;
+@@ -188,7 +197,9 @@
+ int wtmp;
+ #endif
+ Time_t current_time;
++#ifdef USE_UTMP
+ struct utmp utmp_entry;
++#endif
+ #ifdef USE_UTMPX
+ struct utmpx utmpx_entry;
+ #endif
+@@ -223,7 +234,9 @@
+ host_name = getstring (&argv, &hflag);
+ break;
+ case 's':
++#ifdef USE_UTMP
+ slot_number = atoi (getstring (&argv, &sflag));
++#endif
+ break;
+ case 'x':
+ xservers_file = getstring (&argv, &xflag);
+@@ -249,14 +262,14 @@
+ /* set up default file names */
+ if (!wflag) {
+ wtmp_file = WTMP_FILE;
+-#ifdef USE_UTMPX
++#if defined(USE_UTMPX) && defined(HAVE_UPDWTMPX)
+ wtmpx_file = WTMPX_FILE;
+ #endif
+ }
+ #ifndef NO_UTMP
+ if (!uflag) {
+ utmp_file = UTMP_FILE;
+-#ifdef USE_UTMPX
++#if defined(USE_UTMPX) && defined(HAVE_UTMPXNAME)
+ utmpx_file = UTMPX_FILE;
+ #endif
+ }
+@@ -267,7 +280,7 @@
+ if (!Lflag)
+ llog_file = LLOG_FILE;
+ #endif
+-#if !defined(SYSV) && !defined(linux) && !defined(__QNX__)
++#if defined(USE_UTMP) && !defined(SYSV) && !defined(linux) && !defined(__QNX__)
+ if (!tflag)
+ ttys_file = TTYS_FILE;
+ if (!sflag && !utmp_none) {
+@@ -286,34 +299,42 @@
+ line = line_tmp;
+ }
+ time (&current_time);
++#ifdef USE_UTMP
+ set_utmp (&utmp_entry, line, user_name, host_name, current_time, aflag);
++#endif
+
+ #ifdef USE_UTMPX
+ /* need to set utmpxname() before calling set_utmpx() for
+ UtmpxIdOpen to work */
++# ifdef HAVE_UTMPXNAME
+ if (utmpx_file != NULL) {
+ utmpxname (utmpx_file);
+ }
++# endif
+ set_utmpx (&utmpx_entry, line, user_name,
+ host_name, current_time, aflag);
+ #endif
+
+ if (!utmp_none) {
+ #ifdef USE_UTMPX
+- if (utmpx_file != NULL) {
++# ifdef HAVE_UTMPX_NAME
++ if (utmpx_file != NULL)
++# endif
++ {
+ setutxent ();
+ (void) getutxid (&utmpx_entry);
+ pututxline (&utmpx_entry);
+ endutxent ();
+ }
+ #endif
+-#ifdef SYSV
++#ifdef USE_UTMP
++# ifdef SYSV
+ utmpname (utmp_file);
+ setutent ();
+ (void) getutid (&utmp_entry);
+ pututline (&utmp_entry);
+ endutent ();
+-#else
++# else
+ utmp = open (utmp_file, O_RDWR);
+ if (utmp != -1) {
+ syserr ((int) lseek (utmp, (long) slot_number * sizeof (struct utmp), 0), "lseek");
+@@ -321,13 +342,16 @@
+ == sizeof (utmp_entry), "write utmp entry");
+ close (utmp);
+ }
+-#endif
++# endif
++#endif /* USE_UTMP */
+ }
+ if (!wtmp_none) {
+ #ifdef USE_UTMPX
++# ifdef HAVE_UPDWTMPX
+ if (wtmpx_file != NULL) {
+ updwtmpx(wtmpx_file, &utmpx_entry);
+ }
++# endif
+ #else
+ wtmp = open (wtmp_file, O_WRONLY|O_APPEND);
+ if (wtmp != -1) {
+@@ -370,6 +394,7 @@
+ * fill in the appropriate records of the utmp entry
+ */
+
++#ifdef USE_UTMP
+ static void
+ set_utmp (struct utmp *u, char *line, char *user, char *host, Time_t date, int addp)
+ {
+@@ -416,6 +441,7 @@
+ #endif
+ u->ut_time = date;
+ }
++#endif /* USE_UTMP */
+
+ #ifdef USE_UTMPX
+ static int
+@@ -423,6 +449,8 @@
+ {
+ struct utmpx *u; /* pointer to entry in utmp file */
+ int status = 1; /* return code */
++
++ setutxent();
+
+ while ( (u = getutxent()) != NULL ) {
+
+@@ -434,7 +462,7 @@
+ }
+ }
+
+- endutent();
++ endutxent();
+ return (status);
+ }
+
+@@ -453,14 +481,16 @@
+ (void) strncpy (u->ut_line, line, sizeof (u->ut_line));
+
+ strncpy(u->ut_host, line, sizeof(u->ut_host));
++#if HAVE_UTMPX_UT_SYSLEN
+ u->ut_syslen = strlen(line);
++#endif
+ }
+ else
+ bzero (u->ut_line, sizeof (u->ut_line));
+ if (addp && user)
+- (void) strncpy (u->ut_name, user, sizeof (u->ut_name));
++ (void) strncpy (u->ut_user, user, sizeof (u->ut_user));
+ else
+- bzero (u->ut_name, sizeof (u->ut_name));
++ bzero (u->ut_user, sizeof (u->ut_user));
+
+ if (line) {
+ int i;
+@@ -519,7 +549,7 @@
+ }
+ #endif /* USE_UTMPX */
+
+-#ifndef SYSV
++#if defined(USE_UTMP) && !defined(SYSV)
+ /*
+ * compute the slot-number for an X display. This is computed
+ * by counting the lines in /etc/ttys and adding the line-number
+--- sessreg.h
++++ sessreg.h
+@@ -51,13 +51,15 @@
+
+ #include <sys/types.h>
+ #include <time.h>
+-#include <utmp.h>
++
++#ifdef HAVE_UTMP_H
++# include <utmp.h>
++# define USE_UTMP
++#endif
+
+ #ifdef HAVE_UTMPX_H
+-# if HAVE_UTMPX_UT_SYSLEN
+-# include <utmpx.h>
+-# define USE_UTMPX
+-# endif
++# include <utmpx.h>
++# define USE_UTMPX
+ #endif
+
+ #ifdef HAVE_SYS_PARAM_H