Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 May 2011 22:50:03 +0200
From:      Ed Schouten <ed@80386.nl>
To:        Chris Rees <utisoft@gmail.com>
Cc:        freebsd-ports@freebsd.org
Subject:   Re: Utmpx usage
Message-ID:  <20110522205003.GH59496@hoeg.nl>
In-Reply-To: <BANLkTimVF_YgdJ_d6=-L5jmx_zVrbp0wBQ@mail.gmail.com>
References:  <BANLkTimVF_YgdJ_d6=-L5jmx_zVrbp0wBQ@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--fd5uyaI9j6xoeUBo
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hi Chris!

* Chris Rees <utisoft@gmail.com>, 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 <ed@80386.nl>
 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--



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