Date: Sat, 6 Jul 2002 22:23:09 +0200 From: Robert Drehmel <robert@ferrari-electronic.de> To: freebsd-arch@FreeBSD.org Cc: brian@FreeBSD.org, des@FreeBSD.org, markm@FreeBSD.org Subject: utmpx in FreeBSD Message-ID: <20020706222309.A2816@alpha.develop.ferrari.net>
next in thread | raw e-mail | index | archive | help
[ CC'ed to the maintainers of the affected daemons ] This is a proposal to change the way FreeBSD collects and handles information associated with logins. My goal was to streamline the way ``login daemons'' use this information, in addition to adding the capability to keep any relevant login information for use by tools like 'w'. I think I found a way to combine the above with an implementation of the utmpx interface functions defined by XSI. One of the major difficulties was to make sure the utmpx structure contains every data possible, e.g. telnetd(8) can deliver the peer network address but it has no clue whether a user will log in over this connection and who it will be. Passing this information to login(8) is ugly. This was not a big problem before, as telnetd(8) resolved the hostname and passed it to login(8) as an argument, period. The network connection data was lost. Tools like 'w' are still struggling to display to correct information under certain conditions just because they are given way too less data to work on (limited through 'struct utmp'). The proposed system collects login information in the kernel, associating it with the current session, as rwatson suggested on current@FreeBSD.org. Using this technique, telnetd(8) passes the peer network information to the kernel to remember it, login(8) validates this in-kernel information by setting the login user name. Because the XSI interface functions are somewhat limiting, they are not used by the daemons, but they are provided for compliance. :-) One neat side effect is the possibility to have the kernel perform direct modifications of the terminal entries, like setting the ut_type member from LOGIN_PROCESS to DEAD_PROCESS when a session lost its last reference (i.e. the session is no longer existent - the user logged out) using a pointer member in 'struct session'. The new system calls are utmpx_init_slot(const char *); utmpx_set(int behav, int index, const struct utmpx *); utmpx_update(int index, int which, void *data); utmpx_get(int index, int behav, void *data, struct utmpx *); utmpx_init_slot is used only by init(8) to pass the names of the terminals registered in ttys(5) to the kernel whenever init(8) reconstructs its internal terminal tables. utmpx_set and utmpx_get store an utmpx structure in the in-kernel table. Their behaviour is controlled by the behav argument. utmpx_update is be used to update single structure members of one kernel tty table entry. The behav argument can be set to UTX_B_DIRECT, UTX_B_GETUTXENT, UTX_B_GETUTXID, or UTX_B_GETUTXLINE. UTX_B_DIRECT operates on the entry the index points to, the others implement the functionality of the respective functions defined by XSI. Eventually, there should be a function utmpx_login(), that gets called when all login data has been collected in the kernel and which inserts appropriate entries into the wtmp[x] and lastlog files. Comments and questions appeciated. I am especially interested what the PAM people have to say about this. ciao, -robert To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020706222309.A2816>