summaryrefslogblamecommitdiff
path: root/system/procps/use-utmpx.patch
blob: 83047cf222fb9557d8812e86410f589c8eab57f9 (plain) (tree)


































































































































                                                                                                                                                                                                                                                     
diff --git a/configure.ac b/configure.ac
index bc84a0d..da2916e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -44,7 +44,7 @@ AC_PROG_MAKE_SET
 
 # Checks for header files.
 AC_HEADER_MAJOR
-AC_CHECK_HEADERS([arpa/inet.h fcntl.h float.h langinfo.h libintl.h limits.h locale.h netinet/in.h stdint.h stdio_ext.h stdlib.h string.h sys/file.h sys/ioctl.h sys/param.h sys/time.h termios.h unistd.h utmp.h values.h wchar.h wctype.h])
+AC_CHECK_HEADERS([arpa/inet.h fcntl.h float.h langinfo.h libintl.h limits.h locale.h netinet/in.h stdint.h stdio_ext.h stdlib.h string.h sys/file.h sys/ioctl.h sys/param.h sys/time.h termios.h unistd.h utmp.h utmpx.h values.h wchar.h wctype.h])
 
 # Checks for typedefs, structures, and compiler characteristics.
 AC_CHECK_HEADER_STDBOOL
diff --git a/proc/whattime.c b/proc/whattime.c
index c223cad..d55fd22 100644
--- a/proc/whattime.c
+++ b/proc/whattime.c
@@ -33,7 +33,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <time.h>
-#include <utmp.h>
+#include <utmpx.h>
 #include <sys/ioctl.h>
 #include "whattime.h"
 #include "sysinfo.h"
@@ -42,7 +42,7 @@ static char buf[256];
 static double av[3];
 
 char *sprint_uptime(int human_readable) {
-  struct utmp *utmpstruct;
+  struct utmpx *utmpstruct;
   int upminutes, uphours, updays, upweeks, upyears, updecades;
   int pos;
   int comma;
@@ -98,13 +98,13 @@ char *sprint_uptime(int human_readable) {
 /* count the number of users */
 
     numuser = 0;
-    setutent();
-    while ((utmpstruct = getutent())) {
+    setutxent();
+    while ((utmpstruct = getutxent())) {
       if ((utmpstruct->ut_type == USER_PROCESS) &&
          (utmpstruct->ut_name[0] != '\0'))
         numuser++;
     }
-    endutent();
+    endutxent();
 
     pos += sprintf(buf + pos, "%2d user%s, ", numuser, numuser == 1 ? "" : "s");
 
diff --git a/w.c b/w.c
index 35710a3..6caa8a6 100644
--- a/w.c
+++ b/w.c
@@ -23,6 +23,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#include "config.h"
 #include "c.h"
 #include "fileutils.h"
 #include "nls.h"
@@ -54,14 +55,22 @@
 #include <termios.h>
 #include <time.h>
 #include <unistd.h>
-#include <utmp.h>
+#ifdef HAVE_UTMPX_H
+#	include <utmpx.h>
+#else
+#	include <utmp.h>
+#endif
 #include <arpa/inet.h>
 
 static int ignoreuser = 0;	/* for '-u' */
 static int oldstyle = 0;	/* for '-o' */
 static proc_t **procs;		/* our snapshot of the process table */
 
+#ifdef HAVE_UTMPX_H
+typedef struct utmpx utmp_t;
+#else
 typedef struct utmp utmp_t;
+#endif
 
 #ifdef W_SHOWFROM
 # define FROM_STRING "on"
@@ -604,11 +613,19 @@ int main(int argc, char **argv)
 			printf(_("   IDLE WHAT\n"));
 	}
 
+#ifdef HAVE_UTMPX_H
+	setutxent();
+#else
 	utmpname(UTMP_FILE);
 	setutent();
+#endif
 	if (user) {
 		for (;;) {
+#ifdef HAVE_UTMPX_H
+			u = getutxent();
+#else
 			u = getutent();
+#endif
 			if (unlikely(!u))
 				break;
 			if (u->ut_type != USER_PROCESS)
@@ -619,7 +636,11 @@ int main(int argc, char **argv)
 		}
 	} else {
 		for (;;) {
+#ifdef HAVE_UTMPX_H
+			u = getutxent();
+#else
 			u = getutent();
+#endif
 			if (unlikely(!u))
 				break;
 			if (u->ut_type != USER_PROCESS)
@@ -629,7 +650,11 @@ int main(int argc, char **argv)
 					 fromlen, ip_addresses);
 		}
 	}
+#ifdef HAVE_UTMPX_H
+	endutxent();
+#else
 	endutent();
+#endif
 
 	return EXIT_SUCCESS;
 }