Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 Jun 2002 11:02:44 +0200
From:      Robert Drehmel <robert@zoot.drehmel.com>
To:        current@FreeBSD.org
Cc:        robert@FreeBSD.org
Subject:   changing 'struct utmp'
Message-ID:  <20020628110244.A34627@bsd.develop.ferrari.local>

next in thread | raw e-mail | index | archive | help
Hello.

While trying to fix the bug described in a problem report about
'w -n', and finding out that it is somewhat broken*, I came to
the conclusion that our 'struct utmp' is too limiting.

I would like to modernize it as follows:

#define	UT_USERSIZE		16
#define	UT_LINESIZE		8
#define	UT_HOSTSIZE		18	/* increase by two bytes */

struct utmp {
	char	ut_user[UT_USERSIZE];
	char	ut_line[UT_LINESIZE];
	char	ut_host[UT_HOSTSIZE];
	uint8_t	ut_type;		/* new field */
	uint8_t	ut_flags;		/* new field */
	uint32_t	ut_time;
	struct sockaddr	ut_saddr;	/* new field */
};

leaving us with a 64 byte structure.  I also have a patch for a
new function similiar to our login(3): utmp_login(), which takes
the user, line, host, type and sockaddr arguments, puts them into
a struct utmp and proceeds as in login(3).

With the addition of ut_saddr we could store the plain raw network
address in daemons like sshd or telnetd and use the same field in
programs that use the 'struct utmp' to do the Right Thing.

I know we have a pam_lastlog module that cares about utmp and
friends, but to my knowledge there is no simple way to transfer
the raw address data into the pam module; calling utmp_login()
in the daemons directly is straight forward.

Comments?


* As it is now, ut_host is the only place we store information
  about the remote host from which the user is logged in.
  The code is wrong in -STABLE and removed in -CURRENT.
  -STABLE attempts to get the IP address by looking up the
  host (succeeds when the complete name is less than UT_HOSTSIZE).
  -CURRENT does not even do that and works only when the
  code that filled the utmp entry spuriously filled in an IP
  address.  Not to mention problems with AF_INET6.


ciao,
-robert

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




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