Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 16 Jan 2010 12:59:28 +0100
From:      Ed Schouten <ed@80386.nl>
To:        Rainer Hurling <rhurlin@gwdg.de>
Cc:        ports@FreeBSD.org, x11@FreeBSD.org
Subject:   Re: HEADS UP: <utmp.h> gone. All welcome <utmpx.h>.
Message-ID:  <20100116115928.GF64905@hoeg.nl>
In-Reply-To: <4B5179B5.9020902@gwdg.de>
References:  <4B5179B5.9020902@gwdg.de>

next in thread | previous in thread | raw e-mail | index | archive | help

--/OavacbEee8bSN9S
Content-Type: multipart/mixed; boundary="g3yBcqrdPMlHc0Ul"
Content-Disposition: inline


--g3yBcqrdPMlHc0Ul
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hello Rainer,

* Rainer Hurling <rhurlin@gwdg.de> wrote:
> After updating my system i tried to rebuild Xorg ports. All went
> fine until it has to compile x11/sessreg.
>=20
> It seems that the configure script does not find struct
> 'utmpx.ut_syslen' and so the build process falls back to utmp?
>=20
> Could you please take a look if this is an issue of the new interface.

I just looked at this problem and sent a patch to the Xorg folks. I
can't find my email in the xorg-devel archives yet, so I've attached a
patch to this email. Hopefully the respective port maintainer can turn
it into something useful.

--=20
 Ed Schouten <ed@80386.nl>
 WWW: http://80386.nl/

--g3yBcqrdPMlHc0Ul
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="sessreg.diff"
Content-Transfer-Encoding: quoted-printable

diff --git a/configure.ac b/configure.ac
index 6e2f470..be1b4b4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -39,13 +39,14 @@ AC_PROG_INSTALL
=20
 XORG_DEFAULT_OPTIONS
=20
-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=3D1,
 		HAVE_SYSLEN=3D0,
 		[#include <utmpx.h>])
 AC_DEFINE_UNQUOTED(HAVE_UTMPX_UT_SYSLEN,$HAVE_SYSLEN,
 		   [utmpx structure includes ut_syslen field])
+AC_CHECK_FUNCS([updwtmpx utmpxname])
=20
 AC_SYS_LARGEFILE
=20
diff --git a/sessreg.c b/sessreg.c
index c674450..992a213 100644
--- a/sessreg.c
+++ b/sessreg.c
@@ -75,7 +75,6 @@
 # include	<X11/Xfuncs.h>
 # include	<stdio.h>
 # include	<stdlib.h>
-# include	<utmp.h>
=20
 #if defined(__SVR4) || defined(SVR4) || defined(linux) || defined(__GLIBC_=
_)
 # define SYSV
@@ -84,7 +83,10 @@
 #include <time.h>
 #define Time_t time_t
=20
-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
=20
 #ifdef USE_UTMPX
 static void set_utmpx (struct utmpx *u, const char *line, const char *user,
@@ -94,7 +96,12 @@ static void set_utmpx (struct utmpx *u, const char *line=
, const char *user,
 static int wflag, uflag, lflag;
 static char *wtmp_file, *utmp_file, *line;
 #ifdef USE_UTMPX
-static char *wtmpx_file =3D NULL, *utmpx_file =3D NULL;
+#ifdef HAVE_UPDWTMPX
+static char *wtmpx_file =3D NULL;
+#endif
+#ifdef HAVE_UTMPXNAME
+static char *utmpx_file =3D NULL;
+#endif
 #endif
 static int utmp_none, wtmp_none;
 /*
@@ -103,7 +110,9 @@ static int utmp_none, wtmp_none;
  */
 static int hflag, sflag, xflag, tflag;
 static char *host_name =3D NULL;
+#ifdef USE_UTMP
 static int slot_number;
+#endif
 static char *xservers_file, *ttys_file;
 static char *user_name;
 static int aflag, dflag;
@@ -175,7 +184,7 @@ sysnerr (int x, const char *s)
 int
 main (int argc, char **argv)
 {
-#ifndef SYSV
+#if defined(USE_UTMP) && !defined(SYSV)
 	int		utmp;
 #endif
 	char		*line_tmp;
@@ -183,7 +192,9 @@ main (int argc, char **argv)
 	int		wtmp;
 #endif=09
 	Time_t		current_time;
+#ifdef USE_UTMP
 	struct utmp	utmp_entry;
+#endif
 #ifdef USE_UTMPX
 	struct utmpx	utmpx_entry;
 #endif
@@ -218,7 +229,9 @@ main (int argc, char **argv)
 			host_name =3D getstring (&argv, &hflag);
 			break;
 		case 's':
+#ifdef USE_UTMP
 			slot_number =3D atoi (getstring (&argv, &sflag));
+#endif
 			break;
 		case 'x':
 			xservers_file =3D getstring (&argv, &xflag);
@@ -244,14 +257,14 @@ main (int argc, char **argv)
 	/* set up default file names */
 	if (!wflag) {
 		wtmp_file =3D WTMP_FILE;
-#ifdef USE_UTMPX
+#if defined(USE_UTMPX) && defined(HAVE_UPDWTMPX)
 		wtmpx_file =3D WTMPX_FILE;
 #endif
 	}
 #ifndef NO_UTMP
 	if (!uflag) {
 		utmp_file =3D UTMP_FILE;
-#ifdef USE_UTMPX
+#if defined(USE_UTMPX) && defined(HAVE_UTMPXNAME)
 		utmpx_file =3D UTMPX_FILE;
 #endif
 	}
@@ -262,7 +275,7 @@ main (int argc, char **argv)
 	if (!Lflag)
 		llog_file =3D LLOG_FILE;
 #endif
-#if !defined(SYSV) && !defined(linux) && !defined(__QNX__)
+#if defined(USE_UTMP) && !defined(SYSV) && !defined(linux) && !defined(__Q=
NX__)
 	if (!tflag)
 		ttys_file =3D TTYS_FILE;
 	if (!sflag && !utmp_none) {
@@ -281,34 +294,42 @@ main (int argc, char **argv)
 			line =3D line_tmp;
 	}
 	time (&current_time);
+#ifdef USE_UTMP
 	set_utmp (&utmp_entry, line, user_name, host_name, current_time, aflag);
+#endif
=20
 #ifdef USE_UTMPX
 	/* need to set utmpxname() before calling set_utmpx() for
 	   UtmpxIdOpen to work */
+#ifdef HAVE_UTMPXNAME
 	if (utmpx_file !=3D NULL) {
 	        utmpxname (utmpx_file);
 	}
+#endif
 	set_utmpx (&utmpx_entry, line, user_name,
 		   host_name, current_time, aflag);
 #endif=09
=20
 	if (!utmp_none) {
 #ifdef USE_UTMPX
-	    if (utmpx_file !=3D NULL) {
+# ifdef HAVE_UTMPX_NAME
+	    if (utmpx_file !=3D 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 =3D open (utmp_file, O_RDWR);
 		if (utmp !=3D -1) {
 			syserr ((int) lseek (utmp, (long) slot_number * sizeof (struct utmp), 0=
), "lseek");
@@ -316,13 +337,16 @@ main (int argc, char **argv)
 				        =3D=3D 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 !=3D NULL) {
 			updwtmpx(wtmpx_file, &utmpx_entry);
 		}
+# endif
 #else
 		wtmp =3D open (wtmp_file, O_WRONLY|O_APPEND);
 		if (wtmp !=3D -1) {
@@ -365,6 +389,7 @@ main (int argc, char **argv)
  * fill in the appropriate records of the utmp entry
  */
=20
+#ifdef USE_UTMP
 static void
 set_utmp (struct utmp *u, char *line, char *user, char *host, Time_t date,=
 int addp)
 {
@@ -411,6 +436,7 @@ set_utmp (struct utmp *u, char *line, char *user, char =
*host, Time_t date, int a
 #endif
 	u->ut_time =3D date;
 }
+#endif /* USE_UTMP */
=20
 #ifdef USE_UTMPX
 static int
@@ -418,6 +444,8 @@ UtmpxIdOpen( char *utmpId )
 {
 	struct utmpx *u;	/* pointer to entry in utmp file           */
 	int    status =3D 1;	/* return code                             */
+
+	setutxent();
 =20
 	while ( (u =3D getutxent()) !=3D NULL ) {
 	=09
@@ -429,7 +457,7 @@ UtmpxIdOpen( char *utmpId )
 		}
 	}
 =20
-	endutent();
+	endutxent();
 	return (status);
 }
=20
@@ -448,14 +476,16 @@ set_utmpx (struct utmpx *u, const char *line, const c=
har *user,
                         (void) strncpy (u->ut_line, line, sizeof (u->ut_li=
ne));
=20
 		strncpy(u->ut_host, line, sizeof(u->ut_host));
+#if HAVE_UTMPX_UT_SYSLEN
 		u->ut_syslen =3D strlen(line);=20
+#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));
=20
         if (line) {
                 int     i;
@@ -514,7 +544,7 @@ set_utmpx (struct utmpx *u, const char *line, const cha=
r *user,
 }
 #endif /* USE_UTMPX */
=20
-#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
diff --git a/sessreg.h b/sessreg.h
index 6583d57..6b3edc2 100644
--- a/sessreg.h
+++ b/sessreg.h
@@ -51,13 +51,15 @@
=20
 #include <sys/types.h>
 #include <time.h>
-#include <utmp.h>
+
+#ifdef HAVE_UTMP_H
+# include <utmp.h>
+# define USE_UTMP
+#endif
=20
 #ifdef HAVE_UTMPX_H
-# if HAVE_UTMPX_UT_SYSLEN
-#  include <utmpx.h>
-#  define USE_UTMPX
-# endif
+# include <utmpx.h>
+# define USE_UTMPX
 #endif
=20
 #ifdef HAVE_SYS_PARAM_H

--g3yBcqrdPMlHc0Ul--

--/OavacbEee8bSN9S
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (FreeBSD)

iEYEARECAAYFAktRqiAACgkQ52SDGA2eCwUFvwCffwPmJ0p4AEdWl7ahXFyD7YO5
Ww4An31yn2v9FakwghrYkAP9j5JISTEP
=sBMX
-----END PGP SIGNATURE-----

--/OavacbEee8bSN9S--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100116115928.GF64905>