xterm not updating utmp on exit

xterm not updating utmp on exit

Post by Bryan J. Phillipp » Sun, 21 Jan 1996 04:00:00



Hello,

        my xterm/color_xterm are SUID root.  When I leave X and run
`finger` or `who` or aything, I still see a crap-load of people "logged
in" on ttyp ports.  They're not there, of course.  What's causing this,
and how can I fix it?  Thanks,

BTW, here is the ls -la output...
-rwsr-xr-x   1 root     bin        145276 Jun 11  1995 /usr/X11/bin/color_xterm*
-rwsr-xr-x   1 root     root       134412 Jul 23  1995 /usr/X11/bin/xterm*


Kickin' it since 1.1.59  http://www.ecst.csuchico.edu/~bryanxms
/* Do not distribute this message across the Microsoft(tm) Network */

 
 
 

xterm not updating utmp on exit

Post by Danek Duva » Mon, 22 Jan 1996 04:00:00


BJP>         my xterm/color_xterm are SUID root.  When I leave X and run
BJP> `finger` or `who` or aything, I still see a crap-load of people "logged
BJP> in" on ttyp ports.  They're not there, of course.  What's causing this,
BJP> and how can I fix it?  Thanks,

To say the least, xterm's [uw]tmp handling is screwed up.  The
program, after all, was intended to be replaced at some point with
good code...

Anyway, here's a patch that works for me.

--- main.c.orig Tue Oct 31 14:35:21 1995

                    utptr->ut_time = time((Time_t *) 0);
 #endif
                    (void) pututline(utptr);
+                   /* Make sure that ut_user is cleared so that we don't
+                      get an extraneous login event!  -DD */
+                   strcpy(utptr->ut_user, "");
 #ifdef WTMP
 #ifdef SVR4
-                   updwtmpx(WTMPX_FILE, &utmp);
+                   if (term->misc.login_shell)
+                     updwtmpx(WTMPX_FILE, &utmp);
 #else
                    /* set wtmp entry if wtmp file exists */
-                   if ((fd = open(etc_wtmp, O_WRONLY | O_APPEND)) >= 0) {
+                   if (term->misc.login_shell &&
+                        (fd = open(etc_wtmp, O_WRONLY | O_APPEND)) >= 0) {
                      i = write(fd, utptr, sizeof(utmp));
                      i = close(fd);
                    }

--

Computer Science, Princeton University        subject "get pgp key" or look
http://lorien.princeton.edu/~duvall/          it up on the keyservers.

 
 
 

xterm not updating utmp on exit

Post by Joerg Kleuv » Sat, 10 Feb 1996 04:00:00


:
: To say the least, xterm's [uw]tmp handling is screwed up.  The
: program, after all, was intended to be replaced at some point with
: good code...
:
: Anyway, here's a patch that works for me.

Your patch fixes the wtmp handling in some way so it seems to work, but the
utmp handling is still screwed up.
Here's a patch i wrote that fixes both [uw]tmp handling so it works for me
on Linux as it should.

--- main.c.orig Sat Apr 22 18:24:49 1995

            && added_utmp_entry
 #endif /* USE_HANDSHAKE */
            ) {
+           bzero((char *)&utmp, sizeof(struct utmp));
+
+           (void) setutent();
+           /* set up entry to search for */
            ptyname = ttydev;
-           utmp.ut_type = USER_PROCESS;
            (void) strncpy(utmp.ut_id, ptyname + strlen(ptyname) - PTYCHARLEN,
                           sizeof(utmp.ut_id));
-           (void) setutent();
+           utmp.ut_type = USER_PROCESS;
+
+           /* position to entry in utmp file */
            utptr = getutid(&utmp);
+
            /* write it out only if it exists, and the pid's match */
            if (utptr && (utptr->ut_pid == screen->pid)) {
-                   utptr->ut_type = DEAD_PROCESS;
+                   utmp.ut_type = DEAD_PROCESS;
+#ifndef linux
+                   utmp.ut_exit.e_exit = 0;
+#endif
+                   (void) strncpy (utmp.ut_line,
+                                   ptyname + strlen("/dev/"), sizeof (utmp.ut_line));
 #ifdef SVR4
                    utmp.ut_session = getsid(0);
                    utmp.ut_xtime = time ((Time_t *) 0);
                    utmp.ut_tv.tv_usec = 0;
 #else
-                   utptr->ut_time = time((Time_t *) 0);
+                   utmp.ut_time = time((Time_t *) 0);
 #endif
-                   (void) pututline(utptr);
+                   (void) pututline(&utmp);
 #ifdef WTMP
 #ifdef SVR4
-                   updwtmpx(WTMPX_FILE, &utmp);
+                   if (term->misc.login_shell)
+                     updwtmpx(WTMPX_FILE, &utmp);
 #else
                    /* set wtmp entry if wtmp file exists */
-                   if ((fd = open(etc_wtmp, O_WRONLY | O_APPEND)) >= 0) {
-                     i = write(fd, utptr, sizeof(utmp));
+                   if (term->misc.login_shell &&
+                        (fd = open(etc_wtmp, O_WRONLY | O_APPEND)) >= 0) {
+                     i = write(fd, &utmp, sizeof(utmp));
                      i = close(fd);
                    }
 #endif

--
Faith is the quality that enables you to eat blackberry jam on a picnic
without looking to see whether the seeds move.

 
 
 

1. xterm doesn't update utmp when exiting

--
Ok, I've been chasing this problem for a while now...

I recently upgraded libc's, ld.so's gcc, etc.
When I did this I ran into problems with utmp not being updated when
someone logged out.  I read the libc.so.5.2.18 release notes, and
changed my system so that there was only /var/run/utmp and /var/log/wtmp as
real files, and that /etc/utmp, /var/adm/utmp pointed to /var/run/utmp and
/etc/wtmp and /var/adm/wtmp pointed to /var/log/wtmp.

Here's the current situation:
        If a user logs in remotely, utmp gets cleaned up properly when they exit.
        If a user uses rxvt (instead of xterm) utmp gets cleaned up properly
           when they exit.

        But, if a user uses xterm...utmp gets updated to add the new tty, but
           the new tty doesn't get deleted when they log out.

If anyone can explain this behaviour, I'm all ears.

Recently upgraded libs:
ld.so.1.7.14 (was slackware 3.0 default...maybe ld.so.1.7.3?)
libc.so.5.2.18 (was 5.0.9)
libg++-2.7.1.3
binutils-2.6.0.2
gcc-2.7.2
XFree86-3.1.2

utmp and wtmp files:
/etc/utmp -> /var/run/utmp
/var/adm/utmp -> /var/run/utmp
/var/run/utmp
/etc/wtmp -> /var/log/wtmp
/var/adm/wtmp -> /var/log/wtmp
/var/log/wtmp

----------
Eric Boyd
407 Memorial Dr
Cambridge Ma, 02139
617-494-6573


"It's easier to ask for forgiveness than for permission"
------------------------------------------------------------------------------
"640K ought to be enough for anybody." (Bill Gates, 1981)

2. Oops in 2.5 kernels - SCSI related issues

3. in.ttysnoopd not updating utmp on exit ?

4. help with daild

5. xterms not updating utmp

6. SB drivers

7. very weird NIS problem/delayed login

8. Problem with 2.2.6, xterm failing to update utmp properly

9. ?? using sessreg and xterm +ut to update /etc/utmp

10. Xterms not cleaning up utmp properly / Telnet woes

11. Why does xterm not put in a utmp entry?

12. Xterm not finding /etc/utmp