Path: utzoo!attcan!uunet!husc6!think!snorkelwacker!bloom-beacon!prg.oxford.ac.UK!Mark.Bush From: Mark.Bush@prg.oxford.ac.UK Newsgroups: comp.windows.x Subject: Re: How to get xdm to make wtmp and utmp file entries? Message-ID: <9006012031.AA00442@uk.ac.oxford.prg.boothp1> Date: 1 Jun 90 20:31:45 GMT Sender: daemon@athena.mit.edu (Mr Background) Organization: The Internet Lines: 72 > In article , > mjd@central.cis.upenn.edu (Mark-Jason Dominus) writes: > |> > |> Our xdm's don't seem to be logging logins and logouts in the > |> /etc/wtmp and /etc/utmp files. Is there a good way to get > |> them to do this, or is there a good reason why they > |> shouldn't? > > xdm doesn't make the entries in these files, but you can make the main > xterm do it with the +ut and -ls options. The +ut makes it write in the > /etc/utmp file and the -ls is required to make it write in the /etc/wtmp > file. The -ls also makes it read and execute your .login file. The utmp file is world writable on many systems, but the wtmp file usually isn't. Even so, all that the -ls flag means is that the shell that is started is a login shell. This is done by prepending a `-' to the name of the shell. The xterm will add an entry to the utmp file but not the wtmp file. Normally it is `login' that writes the entry to the wtmp file. This hassle with these files is a pain. I have written two programs to sort this stuff out. One (xlogin) is called from the Xstartup file (see xdm(1)) and sticks a fake console entry into the utmp file for the user logging in and adds an entry to wtmp. The other (xlogout) is called from the Xreset file and removes the console entry from utmp and adds a logout entry to wtmp. In Xstartup I have: ------------------------------------------------------------------------------- #! /bin/sh if [ -f /etc/xlogin ]; then /etc/xlogin $USER fi if [ -f /etc/motd ]; then (cat /etc/motd) > /dev/console fi if [ -f /usr/ucb/quota ]; then (/usr/ucb/quota $USER) > /dev/console fi if [ -s /usr/spool/mail/$USER ]; then (echo You have mail) > /dev/console fi if [ -f /etc/nologin ]; then (cat /etc/nologin) > /dev/console exit 1 fi exit 0 ------------------------------------------------------------------------------- and in Xreset I have: ------------------------------------------------------------------------------- #! /bin/sh if [ -f /etc/xlogout ]; then /etc/xlogout fi ------------------------------------------------------------------------------- This keeps logging info happy, but since the console is never used, the person's fake console entry has a looooonnnng idle time. Does anyone have a better way of doing this sort of thing? If anyone wants the source for my xlogin and xlogout then mail me. They are not exactly elegant, but they do their job. Mark