Wierd problem with who and finger...

John F Haugh II jfh at rpp386.cactus.org
Fri Mar 29 02:43:53 AEST 1991


In article <1991Mar25.164317.9775 at rs6000.cmp.ilstu.edu> dbeedle at rs6000.cmp.ilstu.edu (Dave Beedle) writes:
>     Hi all.  I've got a strange problem going on with AIX 3003.  When I do
>a who or an Finger I see one user (not the same all the time) who appears
>to have been logged on for 26 (or more) days.  The user is not currently
>logged on and has no processes running.  What is going on?  We recently
>installed xwindows, pcsim, AIX access, and a compiler or two.

I've mentioned this several times, so here is the source code.  This code
is being provided without warrantee (or even a copyright notice).  Use it
at your own risk.

Compile this program with "cc -o /etc/utmpd utmpd.c" and run in the background
with "nohup /etc/utmpd < /dev/null > /dev/null 2>&1 &" from your /etc/rc file.
I use it on this system to clean up utmp file entries left over from various
programs that create sessions on pty devices.

DISCLAIMER: I speak for myself only.  My employers are not responsible for
what I post here and will not provide support for this code or anything it
may do to your system.  Use at your own risk.
--
---- begin utmpd.c ----
#include <sys/types.h>
#include <utmp.h>
#include <fcntl.h>

main ()
{
	int	fd;
	struct	utmp	utmp;

	while (1) {
		if ((fd = open ("/etc/utmp", O_RDWR)) < 0)
			exit (1);

		while (read (fd, &utmp, sizeof utmp) == sizeof utmp) {
			if (utmp.ut_type == USER_PROCESS &&
					kill (utmp.ut_pid, 0) != 0) {
				lseek (fd, - (long) sizeof utmp, 1);
				utmp.ut_type = DEAD_PROCESS;
				write (fd, &utmp, sizeof utmp);
			}
		}
		close (fd);
		sleep (60);
	}
}
---- end utmpd.c ----
-- 
John F. Haugh II        | Distribution to  | UUCP: ...!cs.utexas.edu!rpp386!jfh
Ma Bell: (512) 832-8832 | GEnie PROHIBITED :-) |  Domain: jfh at rpp386.cactus.org
"I want to be Robin to Bush's Batman."
                -- Vice President Dan Quayle



More information about the Comp.unix.aix mailing list