From owner-freebsd-arch@FreeBSD.ORG Sat Jan 9 12:04:45 2010 Return-Path: Delivered-To: arch@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 73560106566B for ; Sat, 9 Jan 2010 12:04:45 +0000 (UTC) (envelope-from ed@hoeg.nl) Received: from palm.hoeg.nl (mx0.hoeg.nl [IPv6:2001:7b8:613:100::211]) by mx1.freebsd.org (Postfix) with ESMTP id 1A30B8FC08 for ; Sat, 9 Jan 2010 12:04:45 +0000 (UTC) Received: by palm.hoeg.nl (Postfix, from userid 1000) id 338411CDBC; Sat, 9 Jan 2010 13:04:44 +0100 (CET) Date: Sat, 9 Jan 2010 13:04:44 +0100 From: Ed Schouten To: arch@FreeBSD.org Message-ID: <20100109120444.GW64905@hoeg.nl> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="AvHEjN7DoAM1hYpY" Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Cc: Subject: Replacing with X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jan 2010 12:04:45 -0000 --AvHEjN7DoAM1hYpY Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi all, Some of you probably know that the last couple of weeks I've been slowly working on an implementation of for FreeBSD: http://www.opengroup.org/onlinepubs/9699919799/basedefs/utmpx.h.html This interface has the following differences when compared to our existing `API' described in : - It uses library functions to interact with the underlying storage, which means in theory one could use sockets, pigeons and what not to transmit the records, instead of being restricted to files on disk. - Instead of reserving various keywords to denote special messages (i.e. boot/shutdown time), it uses a field called ut_type, which is nice. - The role of ut_line is less important than it used to be. Instead of being used as an identifier of login sessions, this is now done using ut_id. This means you can perform user accounting of services that are not related to TTYs (e.g. FTP) by leaving ut_line blank. You can also store multiple records per TTY, which means using login(1) within a shell shouldn't clobber the existing accounting record. - Timestamps are represented as a struct timeval instead of an uint32_t, which means we gain microsecond precision. I'm not sure whether it's useful in practice, but it comes with the package. It also means we can make it work past 2038. My file format just stores the timestamps as an uint64_t holding the number of microseconds since 01-01-1970, which means it can go up to the year 586524. I'm planning on committing my utmpx implementation within a couple of weeks from now, so I thought I'd better send a message about it first, highlighting some of my design decisions. It would be nice if I could get most of our requirements in there, because I'd rather not change the API/file format too often. First of all, one of the biggest changes I'm going to make, is that I'm going to remove entirely. Most operating systems try to implement both utmp and utmpx, but this is not possible in our case. Those operating systems already provide library functions to update utmp files, so they can internally convert it to utmpx. We don't, which means we'll get two databases with the same purpose, only leading to confusion for the programmer/user/system administrator. Second, the POSIX interface only standardizes the utmpx interface, but no functions to update wtmp or lastlog. After some thinking I came to the conclusion that this is not a problem for us. My implementation of pututxline() already updates all the log files properly, improving their consistency. I only added two non-standard functions which can be used by our own applications in the base system to perform lookups on the wtmp and lastlog databases, called setutxdb() and getutxuser(). I think Robert Watson made a remark about backward/forward compatibility of the file format. Even though my solution is not bullet-proof, I think it should be good enough in practice. The database holding the active sessions (originally called `utmp', now called `utx.active') is always discarded when rebooting the system. The entire log file (`wtmp' or `utx.log') includes a length for each entry, which means we can safely resize the records. The last login database (`lastlog' or `utx.lastlogin') provides no compatibility mechanisms, but this will not be an issue in practice, because of its low importance. The file format is equal on both big and little endian systems. Right now the utmpx records provide little additional information over the old format (user, line, host, pid, tv). I have incremented the size of the fields, which means we can store 32 byte usernames and TTY names. Hostnames are now 128 bytes. Various people mentioned they would like to see additional fields to be added, such as a local and remote IP address. Be sure to mention this to me as soon as possible, because then I can include it before committing it. Here are some links to useful files inside my SVN branch: - http://svn.freebsd.org/viewvc/base/user/ed/utmpx/include/utmpx.h?view=3Dm= arkup - http://svn.freebsd.org/viewvc/base/user/ed/utmpx/lib/libc/gen/getutxent.c= ?view=3Dmarkup - http://svn.freebsd.org/viewvc/base/user/ed/utmpx/lib/libc/gen/pututxline.= c?view=3Dmarkup - http://svn.freebsd.org/viewvc/base/user/ed/utmpx/lib/libc/gen/utxdb.c?vie= w=3Dmarkup - http://svn.freebsd.org/viewvc/base/user/ed/utmpx/lib/libc/gen/utxdb.h?vie= w=3Dmarkup I've also stored a copy of a formatted man page online: - http://80386.nl/pub/getutxent.txt I've requested a ports exp-run to see how big the impact is. Some initial testing shows the amount of ports that break is little, but does affect some high-profile ports. I'll see what I can do to make the transition as easy as possible. --=20 Ed Schouten WWW: http://80386.nl/ --AvHEjN7DoAM1hYpY Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (FreeBSD) iEYEARECAAYFAktIcNwACgkQ52SDGA2eCwWiEACff/N3Xma8NaP75vFeb8ovkOx5 M8EAnRE8+Q33s7MmwgRkmBLPPCHRT4I8 =pcL2 -----END PGP SIGNATURE----- --AvHEjN7DoAM1hYpY--