Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 3 Dec 2009 16:33:47 +0000 (UTC)
From:      Ed Schouten <ed@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r200065 - head/lib/libulog
Message-ID:  <200912031633.nB3GXlQu019588@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ed
Date: Thu Dec  3 16:33:47 2009
New Revision: 200065
URL: http://svn.freebsd.org/changeset/base/200065

Log:
  Also implement ut_type.
  
  I thought we couldn't emulate this field, but we can derive this field
  by looking at special values for ut_host, ut_line and ut_name.

Modified:
  head/lib/libulog/ulog.h
  head/lib/libulog/ulog_getutxent.3
  head/lib/libulog/ulog_getutxent.c

Modified: head/lib/libulog/ulog.h
==============================================================================
--- head/lib/libulog/ulog.h	Thu Dec  3 16:10:21 2009	(r200064)
+++ head/lib/libulog/ulog.h	Thu Dec  3 16:33:47 2009	(r200065)
@@ -63,8 +63,23 @@ struct ulog_utmpx {
 	char		*ut_host;
 #if 0
 	pid_t		 ut_pid;
+#endif
 	short		 ut_type;
+#define	EMPTY		0
+#if 0
+#define	BOOT_TIME	1
 #endif
+#define	OLD_TIME	2
+#define	NEW_TIME	3
+#if 0
+#define	USER_PROCESS	4
+#define	INIT_PROCESS	5
+#endif
+#define	LOGIN_PROCESS	6
+#define	DEAD_PROCESS	7
+
+#define	SHUTDOWN_TIME	8
+#define	REBOOT_TIME	9
 	struct timeval	 ut_tv;
 };
 

Modified: head/lib/libulog/ulog_getutxent.3
==============================================================================
--- head/lib/libulog/ulog_getutxent.3	Thu Dec  3 16:10:21 2009	(r200064)
+++ head/lib/libulog/ulog_getutxent.3	Thu Dec  3 16:33:47 2009	(r200065)
@@ -52,6 +52,7 @@ struct ulog_utmpx {
 	char	*ut_user;	/* Username. */
 	char	*ut_line;	/* TTY device. */
 	char	*ut_host;	/* Remote hostname. */
+	short	 ut_type;	/* Type of entry. */
 	struct timeval ut_tv;	/* Timestamp. */
 };
 .Ed
@@ -67,6 +68,27 @@ directory.
 .It Fa ut_host
 An optional hostname of a remote system, if the login session is
 provided through a networked login service.
+.It Fa ut_type
+The
+.Fa ut_type
+field contains the type of the message, which may have one of the
+following values:
+.Bl -tag -width LOGIN_PROCESS
+.It Dv EMPTY
+No valid user accounting information.
+.It Dv OLD_TIME
+Identifies time when system clock changed.
+.It Dv NEW_TIME
+Identifies time after system clock changed.
+.It Dv LOGIN_PROCESS
+Identifies the session leader of a logged in user.
+.It Dv DEAD_PROCESS
+Identifies a session leader who has exited.
+.It Dv SHUTDOWN_TIME
+Identifies time when system was shut down.
+.It Dv REBOOT_TIME
+Identifies time when system was rebooted.
+.El
 .It Fa ut_tv
 Timestamp indicating when the entry was last modified.
 .El

Modified: head/lib/libulog/ulog_getutxent.c
==============================================================================
--- head/lib/libulog/ulog_getutxent.c	Thu Dec  3 16:10:21 2009	(r200064)
+++ head/lib/libulog/ulog_getutxent.c	Thu Dec  3 16:33:47 2009	(r200065)
@@ -70,6 +70,21 @@ ulog_getutxent(void)
 	COPY_STRING(host);
 	utx.ut_tv.tv_sec = _time32_to_time(ut.ut_time);
 	utx.ut_tv.tv_usec = 0;
+#define	MATCH(field, value)	(strcmp(utx.ut_ ## field, (value)) == 0)
+	if (MATCH(user, "date") && MATCH(line, "|"))
+		utx.ut_type = OLD_TIME;
+	else if (MATCH(user, "date") && MATCH(line, "{"))
+		utx.ut_type = NEW_TIME;
+	else if (MATCH(user, "shutdown") && MATCH(line, "~"))
+		utx.ut_type = SHUTDOWN_TIME;
+	else if (MATCH(user, "reboot") && MATCH(line, "~"))
+		utx.ut_type = REBOOT_TIME;
+	else if (MATCH(user, "") && MATCH(host, ""))
+		utx.ut_type = DEAD_PROCESS;
+	else if (!MATCH(user, ""))
+		utx.ut_type = LOGIN_PROCESS;
+	else
+		utx.ut_type = EMPTY;
 	
 	return (&utx);
 }



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