From owner-freebsd-ports-bugs@FreeBSD.ORG Wed Feb 3 07:30:02 2010 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2C5561065676 for ; Wed, 3 Feb 2010 07:30:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 07D0B8FC1B for ; Wed, 3 Feb 2010 07:30:02 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id o137U1Ni070481 for ; Wed, 3 Feb 2010 07:30:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id o137U1QF070473; Wed, 3 Feb 2010 07:30:01 GMT (envelope-from gnats) Resent-Date: Wed, 3 Feb 2010 07:30:01 GMT Resent-Message-Id: <201002030730.o137U1QF070473@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Rob Farmer Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4CF34106566B for ; Wed, 3 Feb 2010 07:26:35 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 3B8CB8FC0C for ; Wed, 3 Feb 2010 07:26:35 +0000 (UTC) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o137QYWx005933 for ; Wed, 3 Feb 2010 07:26:35 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id o137QYqM005932; Wed, 3 Feb 2010 07:26:34 GMT (envelope-from nobody) Message-Id: <201002030726.o137QYqM005932@www.freebsd.org> Date: Wed, 3 Feb 2010 07:26:34 GMT From: Rob Farmer To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: ports/143518: [PATCH] misc/orville-write utmp.h --> utmpx.h X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Feb 2010 07:30:02 -0000 >Number: 143518 >Category: ports >Synopsis: [PATCH] misc/orville-write utmp.h --> utmpx.h >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: update >Submitter-Id: current-users >Arrival-Date: Wed Feb 03 07:30:01 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Rob Farmer >Release: 9.0-CURRENT >Organization: >Environment: FreeBSD coretwo.predatorlabs.net 9.0-CURRENT FreeBSD 9.0-CURRENT #0 r203366: Mon Feb 1 17:42:33 PST 2010 rfarmer@coretwo.predatorlabs.net:/usr/obj/usr/src/sys/CORETWO amd64 >Description: * Convert to using utmpx.h on current >How-To-Repeat: >Fix: Patch attached with submission follows: Index: Makefile =================================================================== RCS file: /home/ncvs/ports/misc/orville-write/Makefile,v retrieving revision 1.10 diff -u -r1.10 Makefile --- Makefile 13 Oct 2005 19:18:53 -0000 1.10 +++ Makefile 3 Feb 2010 07:18:24 -0000 @@ -17,6 +17,22 @@ MAN1= amin.1 helpers.1 huh.1 mesg.1 write.1 +.include + +.if ${OSVERSION} > 900006 +EXTRA_PATCHES= ${PATCHDIR}/utmpx-wrttmp.h \ + ${PATCHDIR}/utmpx-wrt_him.c \ + ${PATCHDIR}/utmpx-wrt_me.c \ + ${PATCHDIR}/utmpx-lib_common.c \ + ${PATCHDIR}/utmpx-lib_common.h \ + ${PATCHDIR}/utmpx-getutent.h \ + ${PATCHDIR}/utmpx-getutent.c \ + ${PATCHDIR}/utmpx-mesg.c \ + ${PATCHDIR}/utmpx-amin.c \ + ${PATCHDIR}/utmpx-huh.c \ + ${PATCHDIR}/utmpx-helpers.c +.endif + do-install: .for i in amin helpers huh mesg ${INSTALL_PROGRAM} -m 4711 ${WRKSRC}/${i} ${PREFIX}/bin @@ -37,4 +53,4 @@ ${INSTALL_MAN} ${WRKSRC}/${i} ${MANPREFIX}/man/man1 .endfor -.include +.include Index: files/utmpx-amin.c =================================================================== RCS file: files/utmpx-amin.c diff -N files/utmpx-amin.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/utmpx-amin.c 3 Feb 2010 07:07:01 -0000 @@ -0,0 +1,40 @@ +--- amin.c.orig 2010-02-02 23:04:35.773467035 -0800 ++++ amin.c 2010-02-02 23:06:45.674814831 -0800 +@@ -194,16 +194,16 @@ + + void locate_wrttmp(char *tty, struct wrttmp *wbuf, long *pos) + { +-struct utmp *ut; ++struct utmpx *ut; + + /* Find utmp entry */ +- if ((ut= find_utmp(tty)) == NULL || ut->ut_name[0] == '\0') ++ if ((ut= find_utmp(tty)) == NULL || ut->ut_user[0] == '\0') + { + printf("%s: Can't find your tty (%s) in utmp\n",progname,tty); + exit(1); + } + +- find_wrttmp(tty, ut->ut_time, wbuf, pos); ++ find_wrttmp(tty, ut->ut_tv.tv_sec, wbuf, pos); + } + + +@@ -230,7 +230,7 @@ + } + + /* Close utmp file */ +- endutent(); ++ endutxent(); + + /* Figure out name of program being exec'ed */ + if ((shortcmd= strrchr(fullcmd,'/')) == NULL) +@@ -241,7 +241,7 @@ + /* Fix my entry in wrttmp */ + newwrt= mywrt; + newwrt.wrt_what[0]= '!'; +- strncpy(newwrt.wrt_what+1, shortcmd, UT_NAMESIZE-1); ++ strncpy(newwrt.wrt_what+1, shortcmd, sizeof(((struct utmpx *)0)->ut_user)-2); + #ifndef TTYPERMS + if (tmp_mesg != 's') newwrt.wrt_mesg= tmp_mesg; + #endif Index: files/utmpx-getutent.c =================================================================== RCS file: files/utmpx-getutent.c diff -N files/utmpx-getutent.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/utmpx-getutent.c 3 Feb 2010 06:53:35 -0000 @@ -0,0 +1,106 @@ +--- getutent.c.orig 2000-01-31 22:02:45.000000000 -0800 ++++ getutent.c 2010-02-02 22:53:30.347068707 -0800 +@@ -20,18 +20,8 @@ + { + if (utmp.state == 0) + { +- if ((utmp.fd= open(utmp.fname ? utmp.fname : _PATH_UTMP, +- O_RDONLY)) < 0) +- { +- utmp.state= -1; +- return -1; +- } +- else +- { + utmp.state= 1; +- fcntl(utmp.fd, F_SETFD, 1); /* Close over execs */ + return 0; +- } + } + } + +@@ -42,8 +32,7 @@ + void endutent() + { + if (utmp.state == 1) +- close(utmp.fd); +- utmp.state= 0; ++ utmp.state= 0; + } + + +@@ -52,8 +41,7 @@ + + void setutent() + { +- if (utmp.state == 1) +- lseek(utmp.fd, 0L, 0); ++ ; + } + + +@@ -75,9 +63,9 @@ + /* GETUTENT - Read the next entry from the utmp file into static storage. + */ + +-struct utmp *getutent() ++struct utmpx *getutent() + { +-static struct utmp ut; ++static struct utmpx *ut; + + switch (utmp.state) + { +@@ -85,11 +73,11 @@ + openut(); + /* Drop through */ + case 1: +- if (read(utmp.fd, &ut, sizeof(struct utmp)) == sizeof(struct utmp)) +- return &ut; ++ if ((ut = getutxent()) != NULL) ++ return ut; + /* Drop through */ + default: +- return (struct utmp *)NULL; ++ return (struct utmpx *)NULL; + } + } + +@@ -100,9 +88,9 @@ + * we conform with Linux and Solaris. + */ + +-struct utmp *getutline(const struct utmp *in) ++struct utmpx *getutline(const struct utmpx *in) + { +-static struct utmp ut; ++static struct utmpx *ut; + + switch (utmp.state) + { +@@ -110,20 +98,20 @@ + openut(); + /* Drop through */ + case 1: +- while (read(utmp.fd, &ut, sizeof(struct utmp)) == sizeof(struct utmp)) ++ while ((ut = getutxent()) != NULL) + { + if ( + #if defined(USER_PROCESS) && defined(LOGIN_PROCESS) +- (ut.ut_type == USER_PROCESS || ut.ut_type == LOGIN_PROCESS) && ++ (ut->ut_type == USER_PROCESS || ut->ut_type == LOGIN_PROCESS) && + #endif +- !strncmp(ut.ut_line, in->ut_line, UT_LINESIZE)) ++ !strncmp(ut->ut_line, in->ut_line, sizeof(ut->ut_line))) + { +- return &ut; ++ return ut; + } + } + /* Drop through */ + default: +- return (struct utmp *)NULL; ++ return (struct utmpx *)NULL; + } + } + Index: files/utmpx-getutent.h =================================================================== RCS file: files/utmpx-getutent.h diff -N files/utmpx-getutent.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/utmpx-getutent.h 3 Feb 2010 06:50:03 -0000 @@ -0,0 +1,13 @@ +--- getutent.h.orig 2000-01-31 22:01:13.000000000 -0800 ++++ getutent.h 2010-02-02 22:49:58.043092643 -0800 +@@ -14,8 +14,8 @@ + int utmpname(const char *file); + void endutent(void); + void setutent(void); +-struct utmp *getutent(void); +-struct utmp *getutline(const struct utmp *ut); ++struct utmpx *getutent(void); ++struct utmpx *getutline(const struct utmpx *ut); + #endif /*HAVE_GETUTENT*/ + + #endif /* GETUTENT_H */ Index: files/utmpx-helpers.c =================================================================== RCS file: files/utmpx-helpers.c diff -N files/utmpx-helpers.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/utmpx-helpers.c 3 Feb 2010 07:20:28 -0000 @@ -0,0 +1,84 @@ +--- helpers.c.orig 2000-02-20 09:28:08.000000000 -0800 ++++ helpers.c 2010-02-02 23:20:25.434811144 -0800 +@@ -11,7 +11,7 @@ + + struct hlp { + time_t time; /* login time from wrttmp file */ +- char line[UT_LINESIZE]; /* ttyline occupied by a helper */ ++ char line[sizeof(((struct utmpx *)0)->ut_line) -1]; /* ttyline occupied by a helper */ + int busy; /* is he busy? */ + struct hlp *next; /* next helper */ + } *list= NULL; +@@ -27,7 +27,7 @@ + + for (curr= list, prev= NULL; curr != NULL; prev= curr,curr= prev->next) + { +- if (!strncmp(tty, curr->line, UT_LINESIZE)) ++ if (!strncmp(tty, curr->line, ((struct utmpx *)0)->ut_line -1)) + { + if (prev == NULL) + list= curr->next; +@@ -47,7 +47,7 @@ + int perms_on(struct wrttmp *w) + { + struct stat st; +-char devname[UT_LINESIZE+7]; ++char devname[sizeof(((struct utmpx *)0)->ut_line) +6]; + + #ifdef TTYPERMS + #define MASK 022 +@@ -59,7 +59,7 @@ + + /* Is his tty physically writable? */ + +- sprintf(devname,"/dev/%.*s",UT_LINESIZE,w->wrt_line); ++ sprintf(devname,"/dev/%.*s",((struct utmpx *)0)->ut_line -1,w->wrt_line); + if (stat(devname,&st)) + return(0); + +@@ -72,7 +72,7 @@ + FILE *fp; + struct wrttmp w; + struct wrthdr wt_head; +-struct utmp *u; ++struct utmpx *u; + struct hlp *tmp; + int i, j; + int slot= 0; +@@ -146,7 +146,7 @@ + if (list != NULL) + { + /* Do the scan */ +- while ((u= getutent()) != NULL) ++ while ((u= getutxent()) != NULL) + { + #ifdef USER_PROCESS + if (u->ut_type != USER_PROCESS) +@@ -155,15 +155,15 @@ + if ((tmp= findlist(u->ut_line)) != NULL) + { + /* If the time stamps don't match, this isn't a real helper */ +- if (u->ut_time == tmp->time) ++ if (u->ut_tv.tv_sec == tmp->time) + { + /* Found a real helper -- count and print */ + count++; + + if (listthem) + printf("%-*.*s %-*.*s%s\n", +- UT_NAMESIZE, UT_NAMESIZE, u->ut_name, +- UT_LINESIZE, UT_LINESIZE, u->ut_line, ++ sizeof(u->ut_user)-1, sizeof(u->ut_user)-1, u->ut_user, ++ sizeof(u->ut_line)-1, sizeof(u->ut_user)-1, u->ut_line, + tmp->busy ? " [busy]" : ""); + + } +@@ -172,7 +172,7 @@ + } + } + +- endutent(); ++ endutxent(); + } + + if (!listthem) Index: files/utmpx-huh.c =================================================================== RCS file: files/utmpx-huh.c diff -N files/utmpx-huh.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/utmpx-huh.c 3 Feb 2010 07:12:11 -0000 @@ -0,0 +1,35 @@ +--- huh.c.orig 2010-02-02 23:11:01.823876514 -0800 ++++ huh.c 2010-02-02 23:11:54.475034412 -0800 +@@ -34,13 +34,13 @@ + + int record_on() + { +-struct utmp *ut; ++struct utmpx *ut; + struct wrttmp wt; + char *tty; + long pos; + + /* Open the utmp file */ +- setutent(); ++ setutxent(); + + /* Open the wrttmp file */ + if (init_wstream(O_RDONLY)) return 1; +@@ -50,13 +50,13 @@ + tty= mydevname+5; + + /* Find our entry in the utmp file */ +- if ((ut= find_utmp(tty)) == NULL || ut->ut_name[0] == '\0') return 1; ++ if ((ut= find_utmp(tty)) == NULL || ut->ut_user[0] == '\0') return 1; + + /* Find the entry in the wrttmp file */ +- find_wrttmp(tty, ut->ut_time, &wt, &pos); ++ find_wrttmp(tty, ut->ut_tv.tv_sec, &wt, &pos); + + /* Close utmp file */ +- endutent(); ++ endutxent(); + + return (wt.wrt_record != 'n'); + } Index: files/utmpx-lib_common.c =================================================================== RCS file: files/utmpx-lib_common.c diff -N files/utmpx-lib_common.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/utmpx-lib_common.c 3 Feb 2010 06:36:48 -0000 @@ -0,0 +1,19 @@ +--- lib_common.c.orig 2010-02-02 22:34:36.829638978 -0800 ++++ lib_common.c 2010-02-02 22:36:28.170798539 -0800 +@@ -141,13 +141,13 @@ + * fail. The tty name need not be null terminated. + */ + +-struct utmp *find_utmp(char *tty) ++struct utmpx *find_utmp(char *tty) + { +-struct utmp tmputmp; ++struct utmpx tmputmp; + + strncpy(tmputmp.ut_line, tty, UT_LINESIZE); + setutent(); /* open and/or rewind */ +- return getutline(&tmputmp); ++ return getutxline(&tmputmp); + } + + Index: files/utmpx-lib_common.h =================================================================== RCS file: files/utmpx-lib_common.h diff -N files/utmpx-lib_common.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/utmpx-lib_common.h 3 Feb 2010 06:40:43 -0000 @@ -0,0 +1,11 @@ +--- lib_common.h.orig 2010-02-02 22:40:13.646402561 -0800 ++++ lib_common.h 2010-02-02 22:40:30.475105092 -0800 +@@ -6,7 +6,7 @@ + #include "getutent.h" + + int init_wstream(int mode); +-struct utmp *find_utmp(char *tty); ++struct utmpx *find_utmp(char *tty); + void find_wrttmp(char *tty, time_t time,struct wrttmp *wbuf, long *pos); + void dflt_wrttmp(struct wrttmp *wbuf, char *tty, time_t time); + char *leafname(char *fullpath); Index: files/utmpx-mesg.c =================================================================== RCS file: files/utmpx-mesg.c diff -N files/utmpx-mesg.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/utmpx-mesg.c 3 Feb 2010 07:01:49 -0000 @@ -0,0 +1,159 @@ +--- mesg.c.orig 2010-02-02 22:54:21.613120678 -0800 ++++ mesg.c 2010-02-02 23:01:31.739763589 -0800 +@@ -19,7 +19,7 @@ + char *mytty; /* my tty name in tty?? format */ + long mypos; /* offset of my entry in wrttmp file */ + struct wrttmp mywrt; /* my wrttmp entry */ +-struct utmp myutmp; /* A tmp buffer for reading utmp entries */ ++struct utmpx myutmp; /* A tmp buffer for reading utmp entries */ + + char silent= FALSE; /* generates no output if true */ + int verbose= FALSE; /* generate whole table of output if true */ +@@ -335,7 +335,7 @@ + } + + /* Close the utmp file */ +- endutent(); ++ endutxent(); + + if (f_wrthist != NULL && + !wassilent && (new[SMESG] == 'n' || new[SEXCP] == 'y')) +@@ -549,12 +549,12 @@ + + void do_disconnect() + { +-struct utmp *ut; /* A tmp buffer for reading utmp entries */ ++struct utmpx *ut; /* A tmp buffer for reading utmp entries */ + struct wrttmp hiswrt; /* Someone's wrttmp entry */ + int slot= 0; + + /* Rewind utmp file */ +- setutent(); ++ setutxent(); + + /* For each user who is writing me */ + for (;;) +@@ -564,16 +564,16 @@ + sizeof(struct wrttmp)) + break; + +- if (!strncmp(hiswrt.wrt_what, myutmp.ut_name, UT_NAMESIZE)) ++ if (!strncmp(hiswrt.wrt_what, myutmp.ut_user, sizeof(myutmp.ut_user))) + { + setutent(); + /* Check apparant writer against utmp file */ +- while ((ut= getutent()) != NULL) ++ while ((ut= getutxent()) != NULL) + if ( + #ifdef USER_PROCESS + ut->ut_type == USER_PROCESS && + #endif +- !strncmp(hiswrt.wrt_line, ut->ut_line, UT_LINESIZE)) ++ !strncmp(hiswrt.wrt_line, ut->ut_line, sizeof(ut->ut_line))) + { + /* Writer is for real: bonk him one */ + kill(hiswrt.wrt_pid, SIGTERM); +@@ -590,10 +590,10 @@ + + int find_me() + { +-struct utmp *ut; ++struct utmpx *ut; + + /* Find our entry in the Utmp file */ +- if ((ut= find_utmp(mytty)) == NULL || ut->ut_name[0] == '\0') ++ if ((ut= find_utmp(mytty)) == NULL || ut->ut_user[0] == '\0') + { + printf("%s: Unable to find your tty (%s) in utmp file\n", + progname,mytty); +@@ -602,7 +602,7 @@ + myutmp= *ut; + + /* Find the entry in the wrttmp file */ +- find_wrttmp(mytty,myutmp.ut_time,&mywrt,&mypos); ++ find_wrttmp(mytty,myutmp.ut_tv.tv_sec,&mywrt,&mypos); + } + + +@@ -616,13 +616,13 @@ + #define BUFSZ 80 + FILE *hfp; + char buf[BUFSZ+1]; +-char myname[UT_NAMESIZE+2]; ++char myname[sizeof(myutmp.ut_user)+1]; + + if (f_helperlist == NULL || (hfp= fopen(f_helperlist,"r")) == NULL) + return TRUE; + +- strncpy(myname,myutmp.ut_name,UT_NAMESIZE); +- myname[UT_NAMESIZE]= '\0'; ++ strncpy(myname,myutmp.ut_user,sizeof(myutmp.ut_user) -1); ++ myname[sizeof(myutmp.ut_user)]= '\0'; + strcat(myname,"\n"); + + while (fgets(buf,BUFSZ,hfp) != NULL) +@@ -645,7 +645,7 @@ + { + struct wrthist *hist; + struct wrttmp w; +-struct utmp *u; ++struct utmpx *u; + long writer, writee; + time_t now; + int n, foundsome= 0; +@@ -669,7 +669,7 @@ + + for (writee= 0; writee < n; writee++) + { +- if (hist[writee].tm > myutmp.ut_time && ++ if (hist[writee].tm > myutmp.ut_tv.tv_sec && + now - hist[writee].tm <= f_answertel) + { + /* Fetch "his" wrttmp entry - it may actually belong to a previous +@@ -688,12 +688,12 @@ + /* Fetch his utmp entry, and confirm that the current user was + * already logged in there when we sent our last telegram there. + */ +- if ((u= find_utmp(w.wrt_line)) == NULL || u->ut_name[0] == '\0' || +- hist[writee].tm < u->ut_time) ++ if ((u= find_utmp(w.wrt_line)) == NULL || u->ut_user[0] == '\0' || ++ hist[writee].tm < u->ut_tv.tv_sec) + continue; + + /* Check if due to exceptions he may write us anyway */ +- if (f_exceptions && newmode > 1 && maywriteme(u->ut_name, newmode)) ++ if (f_exceptions && newmode > 1 && maywriteme(u->ut_user, newmode)) + continue; + + if (!foundsome) +@@ -703,8 +703,8 @@ + foundsome= 1; + } + printf(" %-*.*s %-*.*s %4.1f more minutes\n", +- UT_NAMESIZE, UT_NAMESIZE, u->ut_name, +- UT_LINESIZE, UT_LINESIZE, u->ut_line, ++ sizeof(u->ut_user) -1, sizeof(u->ut_user) -1, u->ut_user, ++ sizeof(u->ut_line) -1, sizeof(u->ut_line) -1, u->ut_line, + (float)(f_answertel - now + hist[writee].tm)/60.0); + } + } +@@ -717,7 +717,7 @@ + + char *myhomedir() + { +-char myname[UT_NAMESIZE+2]; ++char myname[sizeof(myutmp.ut_user)+1]; + struct passwd *pw; + char *dir, *getenv(); + +@@ -726,8 +726,8 @@ + return dir; + + /* If that don't work, try passwd file */ +- strncpy(myname,myutmp.ut_name,UT_NAMESIZE); +- myname[UT_NAMESIZE]= '\0'; ++ strncpy(myname,myutmp.ut_user,sizeof(myutmp.ut_user) -1); ++ myname[sizeof(myutmp.ut_user)]= '\0'; + if ((pw= getpwnam(myname)) != NULL) + return pw->pw_dir; + Index: files/utmpx-wrt_him.c =================================================================== RCS file: files/utmpx-wrt_him.c diff -N files/utmpx-wrt_him.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/utmpx-wrt_him.c 3 Feb 2010 06:31:14 -0000 @@ -0,0 +1,150 @@ +--- wrt_him.c.orig 2004-09-28 20:32:13.000000000 -0700 ++++ wrt_him.c 2010-02-02 22:31:08.634155195 -0800 +@@ -116,7 +116,7 @@ + extern struct wrttmp mywrt; + + /* Open utmp file */ +- setutent(); ++ setutxent(); + + /* Look me up */ + find_me(); +@@ -204,7 +204,7 @@ + int perm, hisperm= 0; + time_t hisatime= 0; + time_t atime; +-struct utmp *ut; ++struct utmpx *ut; + struct wrttmp tmpwrt; + long tmppos; + +@@ -213,16 +213,14 @@ + { + /* Check if this is the target user, ignoring X-window lines */ + if (ut->ut_line[0] != ':' && +-#ifdef USER_PROCESS + ut->ut_type == USER_PROCESS && +-#endif +- !strncmp(hisname, ut->ut_name, UT_NAMESIZE)) ++ !strncmp(hisname, ut->ut_user, UT_NAMESIZE)) + { + /* Count matches */ + cnt++; + + /* Find wrttmp entry */ +- find_wrttmp(ut->ut_line, ut->ut_time, &tmpwrt, &tmppos); ++ find_wrttmp(ut->ut_line, ut->ut_tv.tv_sec, &tmpwrt, &tmppos); + + /* Is this guy writing me? */ + write_me= !strncmp(tmpwrt.wrt_what,myname,UT_NAMESIZE); +@@ -283,7 +281,7 @@ + + int find_tty() + { +-struct utmp *ut; ++struct utmpx *ut; + + if ((ut= find_utmp(histty)) == NULL) + return(1); +@@ -291,23 +289,23 @@ + if (*hisname != '\0') + { + /* Does the name not match? */ +- if (strncmp(hisname, ut->ut_name, UT_NAMESIZE)) ++ if (strncmp(hisname, ut->ut_user, UT_NAMESIZE)) + return(2); + } + else + { + /* Is anyone on that line? */ +- if (*ut->ut_name == '\0') ++ if (*ut->ut_user == '\0') + { + printf("No one logged onto %s\n",histty); + wrtlog("FAIL: empty tty"); + done(1); + } +- strncpy(hisname, ut->ut_name, UT_NAMESIZE); ++ strncpy(hisname, ut->ut_user, UT_NAMESIZE); + } + printf("%s to %s on %s...",what[telegram],hisname,histty); + if (!telegram) putchar('\n'); +- find_wrttmp(histty,ut->ut_time,&hiswrt,&hispos); ++ find_wrttmp(histty,ut->ut_tv.tv_sec,&hiswrt,&hispos); + return(0); + } + +@@ -321,7 +319,7 @@ + + void find_answer() + { +-struct utmp *ut; ++struct utmpx *ut; + int slot; + + lseek(wstream,hispos= wrttmp_offset(slot= 0),0); +@@ -332,9 +330,9 @@ + { + /* Found someone writing me - get his name from utmp */ + strncpy(histty,hiswrt.wrt_line,UT_LINESIZE); +- if ((ut= find_utmp(histty)) != NULL && ut->ut_name[0] != '\0') ++ if ((ut= find_utmp(histty)) != NULL && ut->ut_user[0] != '\0') + { +- strncpy(hisname,ut->ut_name,UT_NAMESIZE); ++ strncpy(hisname,ut->ut_user,UT_NAMESIZE); + printf("Replying to %s on %s...",hisname,histty); + if (!telegram) putchar('\n'); + return; +@@ -363,7 +361,7 @@ + int ahelpers= 0; /* Number of helpers available */ + int previous; + int slot= 0; +-struct utmp *ut; ++struct utmpx *ut; + struct wrttmp tmpwrt; + long tmppos; + +@@ -387,7 +385,7 @@ + + /* Find the helper candidate in utmp - if he's not there skip out */ + if ((ut= find_utmp(tmpwrt.wrt_line)) == NULL || +- ut->ut_name[0] == '\0' || ut->ut_time != tmpwrt.wrt_time) ++ ut->ut_user[0] == '\0' || ut->ut_tv.tv_sec != tmpwrt.wrt_time) + continue; + + /* Reject helpers with their message permissions off */ +@@ -397,14 +395,14 @@ + { + /* Perms off - but am I in .yeswrite file? */ + if (!f_exceptions || tmpwrt.wrt_except != 'y' || +- !isuexception(ut->ut_name, 1, myname)) ++ !isuexception(ut->ut_user, 1, myname)) + continue; + } + else + { + /* Perms on - but am I in .nowrite file? */ + if (f_exceptions && tmpwrt.wrt_except == 'y' && +- isuexception(ut->ut_name, 0, myname)) ++ isuexception(ut->ut_user, 0, myname)) + continue; + } + } +@@ -422,7 +420,7 @@ + ahelpers++; + + /* Has he helped us before? */ +- previous= !strncmp(ut->ut_name, mywrt.wrt_last, UT_NAMESIZE); ++ previous= !strncmp(ut->ut_user, mywrt.wrt_last, UT_NAMESIZE); + + /* So roll the dice to see if we will choose him */ + if (!previous && (unsigned)RAND() > (unsigned)RAND_MAX / ahelpers) +@@ -430,7 +428,7 @@ + + /* We chose him, so make him our helper candidate so far */ + strncpy(histty, tmpwrt.wrt_line, UT_LINESIZE); +- strncpy(hisname, ut->ut_name, UT_NAMESIZE); ++ strncpy(hisname, ut->ut_user, UT_NAMESIZE); + hiswrt= tmpwrt; + hispos= tmppos; + Index: files/utmpx-wrt_me.c =================================================================== RCS file: files/utmpx-wrt_me.c diff -N files/utmpx-wrt_me.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/utmpx-wrt_me.c 3 Feb 2010 06:33:33 -0000 @@ -0,0 +1,34 @@ +--- wrt_me.c.orig 2010-02-02 22:31:42.972816673 -0800 ++++ wrt_me.c 2010-02-02 22:33:09.915329757 -0800 +@@ -14,19 +14,19 @@ + + void find_me() + { +-struct utmp *ut; ++struct utmpx *ut; + struct passwd *pw; + int myuid; + + /* Search utmp for myself */ + +- if ((ut= find_utmp(mytty)) == NULL || ut->ut_name[0] == '\0') ++ if ((ut= find_utmp(mytty)) == NULL || ut->ut_user[0] == '\0') + { + printf("%s: Panic - Unable to find your tty (%s) in "_PATH_UTMP"\n", + progname, mytty); + done(1); + } +- strncpy(myname, ut->ut_name, UT_NAMESIZE); ++ strncpy(myname, ut->ut_user, UT_NAMESIZE); + + /* Check if this is our real identity */ + #ifndef SLOWPASSWD +@@ -48,7 +48,7 @@ + + /* Find my wrt_tmp entry */ + +- find_wrttmp(mytty, ut->ut_time, &mywrt, &mypos); ++ find_wrttmp(mytty, ut->ut_tv.tv_sec, &mywrt, &mypos); + } + + Index: files/utmpx-wrttmp.h =================================================================== RCS file: files/utmpx-wrttmp.h diff -N files/utmpx-wrttmp.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/utmpx-wrttmp.h 3 Feb 2010 06:18:37 -0000 @@ -0,0 +1,37 @@ +--- wrttmp.h.orig 2010-02-02 22:10:42.237520427 -0800 ++++ wrttmp.h 2010-02-02 22:18:11.802300308 -0800 +@@ -30,7 +30,7 @@ + #define WRTTMP_H + + #include +-#include ++#include + + /* BSDI is only Unix I know of that threatens to change namesize from 8 to + * anything else. Most don't even have a define for it. Here we default +@@ -38,10 +38,10 @@ + * for us. + */ + #ifndef UT_NAMESIZE +-#define UT_NAMESIZE 8 ++#define UT_NAMESIZE (sizeof(((struct utmpx *)0)->ut_user) -1) + #endif + #ifndef UT_LINESIZE +-#define UT_LINESIZE 8 ++#define UT_LINESIZE (sizeof(((struct utmpx *)0)->ut_line) -1) + #endif + + #if defined(TTY_GROUP) || defined(TTY_OTHERS) +@@ -65,9 +65,9 @@ + }; + + struct wrttmp { +- char wrt_line[UT_LINESIZE]; /* a tty line */ +- char wrt_what[UT_NAMESIZE]; /* what this user is doing? */ +- char wrt_last[UT_NAMESIZE]; /* Who did he last write to? */ ++ char wrt_line[sizeof(((struct utmpx *)0)->ut_line) -1]; /* a tty line */ ++ char wrt_what[sizeof(((struct utmpx *)0)->ut_user) -1]; /* what this user is doing? */ ++ char wrt_last[sizeof(((struct utmpx *)0)->ut_user) -1]; /* Who did he last write to? */ + #ifndef TTYPERMS + char wrt_mesg; /* user's write perms (y or n) */ + #endif /*TTYPERMS*/ >Release-Note: >Audit-Trail: >Unformatted: