*BSD News Article 22962


Return to BSD News archive

Newsgroups: comp.os.386bsd.bugs
Path: sserve!newshost.anu.edu.au!munnari.oz.au!news.Hawaii.Edu!ames!elroy.jpl.nasa.gov!sdd.hp.com!spool.mu.edu!howland.reston.ans.net!ee.und.ac.za!hippo.ru.ac.za!kudu!g89r4222
From: g89r4222@kudu.ru.ac.za (Geoff Rehmet)
Subject: rxvt 1.45 -  fix for utmp support
Message-ID: <g89r4222.751752070@kudu>
Sender: news@hippo.ru.ac.za (Usenet News Admin)
Organization: Rhodes University, Grahamstown, South Africa
Date: Wed, 27 Oct 1993 20:01:10 GMT
Lines: 135


Hi,

The diff which follows fixes the utmp support for Robert Nation's
rxvt version 1.45.  Without the diff rxvt will hang if it is not
setuid root (and thus unable to write to /var/run/utmp).

rxvt-1.45 can be obtained from
spcot.sanders.com:/pub/rxvt/rxvt-1.45.tar.gz

Geoff.

-------------------------------------------------------------
diff -c rxvt/Makefile rxvt.freebsd/Makefile
*** rxvt/Makefile	Wed Oct 27 15:45:13 1993
--- rxvt.freebsd/Makefile	Wed Oct 27 21:28:25 1993
***************
*** 6,12 ****
  MANDIR=$(DESTDIR)/usr/man/man1
  BINDIR=$(DESTDIR)/usr/bin/X11
  USRLIBDIR=$(DESTDIR)/usr/lib/X11
! INCROOT=$(DESTDIR)/usr/include/X11
  
  # Rxvt now include optional utmp support.
  # including utmp support allows rxvt to update /etc/utmp so
--- 6,12 ----
  MANDIR=$(DESTDIR)/usr/man/man1
  BINDIR=$(DESTDIR)/usr/bin/X11
  USRLIBDIR=$(DESTDIR)/usr/lib/X11
! INCROOT=$(DESTDIR)/usr/X386/include/X11
  
  # Rxvt now include optional utmp support.
  # including utmp support allows rxvt to update /etc/utmp so
***************
*** 30,36 ****
  DEFS = -DUTMP_SUPPORT -DUTMP=\"/etc/utmp\" -DBSD
  
  # for FreeBSD 
! #DEFS = -DUTMP_SUPPORT -DUTMP=\"/etc/utmp\" -DBSD -DFREEBSD
  
  # for most systems:
  LIBS = -L$(USRLIBDIR) -lX11 
--- 30,36 ----
  DEFS = -DUTMP_SUPPORT -DUTMP=\"/etc/utmp\" -DBSD
  
  # for FreeBSD 
! DEFS = -DUTMP_SUPPORT -DUTMP=\"/var/run/utmp\" -DBSD -DFREEBSD
  
  # for most systems:
  LIBS = -L$(USRLIBDIR) -lX11 
***************
*** 38,44 ****
  # for solaris2 & some others
  #LIBS = -L$(USRLIBDIR) -lX11 -lsocket
  
! CFLAGS= -O2 -s -I$(INCROOT) $(DEFS) -fomit-frame-pointer
  
  OBJ=rxvt.o xsetup.o command.o screen.o sbar.o utmp.o
  SRC=rxvt.c xsetup.c command.c screen.c sbar.c utmp.c
--- 38,44 ----
  # for solaris2 & some others
  #LIBS = -L$(USRLIBDIR) -lX11 -lsocket
  
! CFLAGS= -O2 -s -I$(INCROOT) $(DEFS) -fomit-frame-pointer -I/usr/X386/include
  
  OBJ=rxvt.o xsetup.o command.o screen.o sbar.o utmp.o
  SRC=rxvt.c xsetup.c command.c screen.c sbar.c utmp.c
diff -c rxvt/utmp.c rxvt.freebsd/utmp.c
*** rxvt/utmp.c	Wed Oct 27 15:43:58 1993
--- rxvt.freebsd/utmp.c	Wed Oct 27 21:38:49 1993
***************
*** 128,134 ****
    int found;
    struct utmp u;
    FILE *f;
!   f = fopen(UTMP,"r+");
    fseek(f, 900, 0);
    while(fread((char *)&u, sizeof(u), 1, f)) {
      for(found=-1, p = (char *)&u; p < (char *) &u+sizeof(u); p++)
--- 128,135 ----
    int found;
    struct utmp u;
    FILE *f;
!   if((f = fopen(UTMP,"r+"))== NULL)
!     return(-1);
    fseek(f, 900, 0);
    while(fread((char *)&u, sizeof(u), 1, f)) {
      for(found=-1, p = (char *)&u; p < (char *) &u+sizeof(u); p++)
***************
*** 146,153 ****
    int pos;
    FILE *utmp;
  
!   utmp = fopen(UTMP,"r+");
!   pos = utmp_end();
    utmp_pos = pos;
    fseek(utmp,pos,0);
    fwrite((char *)u, sizeof(struct utmp),1,utmp);
--- 147,156 ----
    int pos;
    FILE *utmp;
  
!   if((utmp = fopen(UTMP,"r+")) == NULL)
!     return(-1);
!   if((pos = utmp_end()) == -1)
!     return(-1);
    utmp_pos = pos;
    fseek(utmp,pos,0);
    fwrite((char *)u, sizeof(struct utmp),1,utmp);
***************
*** 211,217 ****
  {
    FILE *ut;
    struct utmp u;
!   
    ut = fopen(UTMP,"r+");
    fseek(ut,utmp_pos,0);
    memset(&u,0,sizeof(u));
--- 214,222 ----
  {
    FILE *ut;
    struct utmp u;
! 
!   if(!madeutent)
!     return;
    ut = fopen(UTMP,"r+");
    fseek(ut,utmp_pos,0);
    memset(&u,0,sizeof(u));

-------------------------------------------------------------
--
===========================csgr@alpha.ru.ac.za================================
 Geoff Rehmet, Parallel Processing Group, |  ____   _ o         /\
 Computer Science Department,             | ___  _-\_<,        /\/\/\
 Rhodes University, RSA.                  |     (*)/'(*)    /\/\/\/\/\