From owner-freebsd-ports@FreeBSD.ORG Sun May 22 20:50:04 2011 Return-Path: Delivered-To: freebsd-ports@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A4C14106566C for ; Sun, 22 May 2011 20:50:04 +0000 (UTC) (envelope-from ed@hoeg.nl) Received: from mx0.hoeg.nl (mx0.hoeg.nl [IPv6:2a01:4f8:101:5343::aa]) by mx1.freebsd.org (Postfix) with ESMTP id 3F60B8FC0C for ; Sun, 22 May 2011 20:50:04 +0000 (UTC) Received: by mx0.hoeg.nl (Postfix, from userid 1000) id 24B4E2A29125; Sun, 22 May 2011 22:50:03 +0200 (CEST) Date: Sun, 22 May 2011 22:50:03 +0200 From: Ed Schouten To: Chris Rees Message-ID: <20110522205003.GH59496@hoeg.nl> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="fd5uyaI9j6xoeUBo" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Cc: freebsd-ports@freebsd.org Subject: Re: Utmpx usage X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 May 2011 20:50:04 -0000 --fd5uyaI9j6xoeUBo Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Chris! * Chris Rees , 20110522 09:29: > Hi all, >=20 > After removing all kittens from Ed's reach, I'm disclosing that > sysutils/runit tried to use utmpx to directly read() and write() the > utmpx files directly... >=20 > I've replaced the offending code with a patch to the port [1], but I > wonder if anyone would please review the patch? I don't have a CURRENT > machine to try it on... I may have also made some terrible mistakes -- > I'm not hugely familiar with utmpx. >=20 > Thanks! >=20 > Chris >=20 > [1] http://www.bayofrum.net/~crees/patches/runit-utmpx.patch As promised, I would look at your patch this evening. I've changed the cc to ports@, since it's likely a better place to discuss this. First of all, you can remove the getutxent()/endutxent() calls; at least on FreeBSD (but even on Solaris -- the first OS to implement utmpx) pututxline() is implemented separately from the read-functions. There is no need to open the database for reading. Secondly, please make sure you set the proper fields of the utmpx structure. Always zero it (e.g. with memset()) before calling pututxline() to prevent random junk from ending up in the log files. Also, for DEAD_PROCESS must we set ut_id, but not ut_line. ut_id must be set to one of the identifiers of an existing session. These identifiers can be set to arbitrary values by the application that added the entry. Some apps are lazy and just put the TTY name in there, but you cannot assume that that's the case. Run `getent utmpx active' to see what the identifiers look like. For example, pam_lastlog(8) uses random identifiers. You must also set ut_tv, even though our implementation does it for you. Finally, I'm not really sure what the code is trying to solve here. What's the use of implementing an utmp_logout(), to simulate logouts on the utmp database, without actually providing code to perform logins? Maybe we should just patch runit to leave utmp(x) alone. So far I don't have a feeling it's trying to do something useful with it. Any opinions, anyone? --=20 Ed Schouten WWW: http://80386.nl/ --fd5uyaI9j6xoeUBo Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (FreeBSD) iQIcBAEBAgAGBQJN2Xb7AAoJEG5e2P40kaK7oJUP/1Qk4zJzFlz39eZycEXeqrOJ 6/Jp1e2791gI+Z4UWMn8qF+zj5GBy65Zn7o1smPewt6v6OivzBLukTqKG1ibMDiN QeIwwGxGMvBaIUwQZO6Wb7aToum3ynH26LcR26Kmxk+CcRJjeRSgrUPfg8EMNRAw gzvNE4CXFKeBzDbUYt/q1q7SWMmTPzEP/L8wgAa8GtFZwTyBUK97qdEahxF4SBVu OlBbeaS8bp37Qe+5+Trl+w35Pgdro3snQKXBp1/YKGQiAK8npTbbSsWWc0P804kL DFXVn9oqMvHYjcKHmYAV7kzBfl6rTdmQGjQZa2xe9Dzx7zI4VMR+nD0kovfGQ3q2 4ORw5wWy3Mj5TSHr/+IQ7qicl+ZxNqlTCSijPmk5Gez6L0OuezMrwMQWb7O4pDNL l0V7RFT03lfFQs6CB+6LuY6AyBbxEzseQDBnqdWTmoMdbQQsOmELc7GzVV+Thau7 TdezpJ2GqyYltkkY3RIvW2pHz5qfjusWFHr9iYHcbkoo7pCNYQ0w5iExebbL210F W1QiXuMEwzJnXA74sM4bumGSNrmv7SmwlE3PcZR+a6xRtR3rzNcsqxLx9teTiHv6 JWXOdio4HIrCsZ9SKQY3d/INSk/t66btPghf60bBvkNl4GGkwzEBUacBZzEaFx4Y UoSYCEYK+TJSk2e79AON =SxPi -----END PGP SIGNATURE----- --fd5uyaI9j6xoeUBo--