From owner-freebsd-ports-bugs@FreeBSD.ORG Wed Feb 3 05:10:01 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 5A6B7106566B for ; Wed, 3 Feb 2010 05:10:01 +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 365A78FC16 for ; Wed, 3 Feb 2010 05:10:01 +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 o135A1iO028193 for ; Wed, 3 Feb 2010 05:10:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id o135A1J9028192; Wed, 3 Feb 2010 05:10:01 GMT (envelope-from gnats) Resent-Date: Wed, 3 Feb 2010 05:10:01 GMT Resent-Message-Id: <201002030510.o135A1J9028192@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 8FDA31065672 for ; Wed, 3 Feb 2010 05:07:02 +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 7E96A8FC0A for ; Wed, 3 Feb 2010 05:07:02 +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 o135727s093235 for ; Wed, 3 Feb 2010 05:07:02 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id o13572IP093234; Wed, 3 Feb 2010 05:07:02 GMT (envelope-from nobody) Message-Id: <201002030507.o13572IP093234@www.freebsd.org> Date: Wed, 3 Feb 2010 05:07:02 GMT From: Rob Farmer To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: ports/143509: [PATCH] sysutils/whowatch utmp.h --> utmpx.h, take maintainership 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 05:10:01 -0000 >Number: 143509 >Category: ports >Synopsis: [PATCH] sysutils/whowatch utmp.h --> utmpx.h, take maintainership >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 05:10:00 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: * Fix with utmpx.h * Take maintainership >How-To-Repeat: >Fix: Patch attached with submission follows: Index: Makefile =================================================================== RCS file: /home/ncvs/ports/sysutils/whowatch/Makefile,v retrieving revision 1.12 diff -u -r1.12 Makefile --- Makefile 6 Jan 2009 17:59:31 -0000 1.12 +++ Makefile 3 Feb 2010 04:01:09 -0000 @@ -13,7 +13,7 @@ ${MASTER_SITE_PACKETSTORM} MASTER_SITE_SUBDIR= UNIX/IDS -MAINTAINER= ports@FreeBSD.org +MAINTAINER= rfarmer@predatorlabs.net COMMENT= Displays information in real time about users currently logged on GNU_CONFIGURE= yes @@ -21,8 +21,15 @@ MAN1= whowatch.1 PLIST_FILES= bin/whowatch +.include + +.if ${OSVERSION} > 900006 +EXTRA_PATCHES= ${PATCHDIR}/utmpx-whowatch.h \ + ${PATCHDIR}/utmpx-whowatch.c +.endif + pre-patch: @${FIND} ${WRKSRC} -name 'proc????.c' | ${XARGS} ${REINPLACE_CMD} -E \ -e 's/kp_.?proc\.._/ki_/ ; s/pcred\.p_//' -.include +.include Index: files/utmpx-whowatch.c =================================================================== RCS file: files/utmpx-whowatch.c diff -N files/utmpx-whowatch.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/utmpx-whowatch.c 3 Feb 2010 03:56:41 -0000 @@ -0,0 +1,105 @@ +--- whowatch.c.orig 2000-06-06 03:21:44.000000000 -0700 ++++ whowatch.c 2010-02-02 19:56:37.081269004 -0800 +@@ -119,21 +119,17 @@ + /* + * Create new user structure and fill it + */ +-struct user_t *allocate_user(struct utmp *entry) ++struct user_t *allocate_user(struct utmpx *entry) + { + struct user_t *u; + int ppid; + u = calloc(1, sizeof *u); + if(!u) errx(1, "Cannot allocate memory."); +- strncpy(u->name, entry->ut_user, UT_NAMESIZE); +- strncpy(u->tty, entry->ut_line, UT_LINESIZE); +- strncpy(u->host, entry->ut_host, UT_HOSTSIZE); ++ strncpy(u->name, entry->ut_user, sizeof(entry->ut_user)); ++ strncpy(u->tty, entry->ut_line, sizeof(entry->ut_line)); ++ strncpy(u->host, entry->ut_host, sizeof(entry->ut_host)); + +-#ifdef HAVE_UTPID + u->pid = entry->ut_pid; +-#else +- u->pid = get_login_pid(u->tty); +-#endif + + if((ppid = get_ppid(u->pid)) == -1) + strncpy(u->parent, "can't access", sizeof u->parent); +@@ -192,34 +188,24 @@ + */ + void read_utmp() + { +- int fd, i; +- static struct utmp entry; ++ static struct utmpx *entry; + struct user_t *u; ++ ++ while ((entry = getutxent()) != NULL) { + +- if ((fd = open(UTMP_FILE ,O_RDONLY)) == -1){ +- curses_end(); +- errx(1, "Cannot open " UTMP_FILE); +- } +- while((i = read(fd, &entry,sizeof entry)) > 0) { +- if(i != sizeof entry) errx(1, "Error reading " UTMP_FILE ); +-#ifdef HAVE_USER_PROCESS +- if(entry.ut_type != USER_PROCESS) continue; +-#else +- if(!entry.ut_name[0]) continue; +-#endif +- u = allocate_user(&entry); ++ if(entry->ut_type != USER_PROCESS) continue; ++ u = allocate_user(entry); + print_user(u); + update_nr_users(u->parent, &u->prot, LOGIN); + how_many ++; + users_list.d_lines = how_many; + addto_list(u, users); + } +- close(fd); + wnoutrefresh(users_list.wd); + return; + } + +-struct user_t* new_user(struct utmp *newone) ++struct user_t* new_user(struct utmpx *newone) + { + struct user_t *u; + u = allocate_user(newone); +@@ -246,7 +232,7 @@ + void check_wtmp() + { + struct user_t *u; +- struct utmp entry; ++ struct utmpx entry; + int i; + + while((i = read(wtmp_fd, &entry, sizeof entry)) > 0){ +@@ -256,25 +242,17 @@ + errx(1, "Error reading " WTMP_FILE ); + } + /* user just logged in */ +-#ifdef HAVE_USER_PROCESS + if(entry.ut_type == USER_PROCESS) { +-#else +- if(entry.ut_user[0]) { +-#endif + u = new_user(&entry); + print_user(u); + wrefresh(users_list.wd); + print_info(); + continue; + } +-#ifdef HAVE_DEAD_PROCESS + if(entry.ut_type != DEAD_PROCESS) continue; +-#else +-// if(entry.ut_line[0]) continue; +-#endif + /* user just logged out */ + for_each(u, users) { +- if(strncmp(u->tty, entry.ut_line, UT_LINESIZE)) ++ if(strncmp(u->tty, entry.ut_line, sizeof(entry.ut_line))) + continue; + if (state == USERS_LIST) + delete_line(&users_list, u->line); Index: files/utmpx-whowatch.h =================================================================== RCS file: files/utmpx-whowatch.h diff -N files/utmpx-whowatch.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/utmpx-whowatch.h 3 Feb 2010 03:21:33 -0000 @@ -0,0 +1,27 @@ +--- whowatch.h.orig 2010-02-02 19:18:34.763514932 -0800 ++++ whowatch.h 2010-02-02 19:20:44.905393020 -0800 +@@ -2,7 +2,7 @@ + #include + #include + #include +-#include ++#include + #include + #include + #include +@@ -75,12 +75,12 @@ + { + struct user_t *next; + struct user_t *prev; +- char name[UT_NAMESIZE + 1]; /* login name */ +- char tty[UT_LINESIZE + 1]; /* tty */ ++ char name[sizeof(((struct utmpx *)0)->ut_user)]; /* login name */ ++ char tty[sizeof(((struct utmpx *)0)->ut_line)]; /* tty */ + int prot; + int pid; /* pid of login shell */ + char parent[16]; +- char host[UT_HOSTSIZE + 1]; ++ char host[sizeof(((struct utmpx *)0)->ut_host)]; + int line; + }; + >Release-Note: >Audit-Trail: >Unformatted: