Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[openssh-portable] utmpx and ut_name

0 views
Skip to first unread message

Ed Schouten

unread,
Dec 25, 2009, 11:54:35 AM12/25/09
to
Hello OpenSSH hackers,

The last couple of weeks I've been figuring out how hard it is to
replace FreeBSD's <utmp.h> with <utmpx.h>. I don't think utmpx is
perfect, but at least it's better than what we have now and at least it
has gone through some form of standardisation. I noticed POSIX says the
following [1]:

| The <utmpx.h> header shall define the utmpx structure that shall
| include at least the following members:
|
| char ut_user[] User login name.
| ...

Now ut_user deviates a bit from <utmp.h>, where this field is normally
called ut_name. I've noticed most (all?) implementations just #define
ut_name to ut_user to keep things happy, but I'd rather not put this
obfuscation in any new implementation.

I've noticed OpenSSH also uses ut_name, even when using utmpx. I've come
up with the following patch:

%%%
--- loginrec.c
+++ loginrec.c
@@ -758,8 +758,8 @@
utx->ut_pid = li->pid;

/* strncpy(): Don't necessarily want null termination */
- strncpy(utx->ut_name, li->username,
- MIN_SIZEOF(utx->ut_name, li->username));
+ strncpy(utx->ut_user, li->username,
+ MIN_SIZEOF(utx->ut_user, li->username));

if (li->type == LTYPE_LOGOUT)
return;
@@ -1316,8 +1316,8 @@
static int
wtmpx_islogin(struct logininfo *li, struct utmpx *utx)
{
- if (strncmp(li->username, utx->ut_name,
- MIN_SIZEOF(li->username, utx->ut_name)) == 0 ) {
+ if (strncmp(li->username, utx->ut_user,
+ MIN_SIZEOF(li->username, utx->ut_user)) == 0 ) {
# ifdef HAVE_TYPE_IN_UTMPX
if (utx->ut_type == USER_PROCESS)
return (1);
%%%

It changes all uses of ut_name on utmpx structures to ut_user. Any
chance this can go into CVS?

Merry christmas,
--
Ed Schouten <e...@80386.nl>
WWW: http://80386.nl/

[1] http://www.opengroup.org/onlinepubs/9699919799/basedefs/utmpx.h.html

0 new messages