From owner-svn-src-all@FreeBSD.ORG Thu Dec 3 16:33:48 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 345381065670; Thu, 3 Dec 2009 16:33:48 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1917E8FC1C; Thu, 3 Dec 2009 16:33:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id nB3GXlZY019592; Thu, 3 Dec 2009 16:33:47 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id nB3GXlQu019588; Thu, 3 Dec 2009 16:33:47 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <200912031633.nB3GXlQu019588@svn.freebsd.org> From: Ed Schouten Date: Thu, 3 Dec 2009 16:33:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r200065 - head/lib/libulog X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Dec 2009 16:33:48 -0000 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); }