From owner-freebsd-current Fri Jun 28 2:17:51 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CED9A37B400 for ; Fri, 28 Jun 2002 02:17:40 -0700 (PDT) Received: from sleet.ispgateway.de (sleet.ispgateway.de [62.67.200.125]) by mx1.FreeBSD.org (Postfix) with SMTP id A2EFC43E0C for ; Fri, 28 Jun 2002 02:17:39 -0700 (PDT) (envelope-from robert@zoot.drehmel.com) Received: (qmail 20138 invoked from network); 28 Jun 2002 09:17:38 -0000 Received: from unknown (HELO bsd.develop.ferrari.local) (948464@[62.159.79.193]) (envelope-sender ) by sleet.ispgateway.de (qmail-ldap-1.03) with SMTP for ; 28 Jun 2002 09:17:38 -0000 Received: (from robert@localhost) by bsd.develop.ferrari.local (8.12.5/8.11.5) id g5S92iOd034639; Fri, 28 Jun 2002 11:02:44 +0200 (CEST) (envelope-from robert) Date: Fri, 28 Jun 2002 11:02:44 +0200 From: Robert Drehmel To: current@FreeBSD.org Cc: robert@FreeBSD.org Subject: changing 'struct utmp' Message-ID: <20020628110244.A34627@bsd.develop.ferrari.local> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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