--- acct-6.3.2/lastcomm.c.strictmatch 2005-02-01 17:01:54.000000000 -0500 +++ acct-6.3.2/lastcomm.c 2005-02-02 00:06:41.000000000 -0500 @@ -43,7 +43,9 @@ #ifdef HAVE_UNISTD_H #include #endif - +#ifdef HAVE_STDLIB_H +#include +#endif #include #include "common.h" @@ -80,7 +82,7 @@ /* protos */ -void main PARAMS((int, char *[])); +int main PARAMS((int, char *[])); void give_usage PARAMS((void)); void parse_entries PARAMS((void)); char *devname PARAMS((long)); @@ -90,7 +92,7 @@ /* code */ -void +int main (int argc, char *argv[]) { int c; @@ -349,12 +351,30 @@ { /* All categories must have one match. */ - if (all_list - && hashtab_find (all_list, uid, 0) == NULL - && hashtab_find (all_list, dev, 0) == NULL - && hashtab_find (all_list, comm, COMM_LEN) == NULL) - return 0; - + if (all_list) + { + struct hashtab_order ho; + struct hashtab_elem* he; + char *key; + int haveall = 1; + + /* walk the all_list hash */ + he = hashtab_first( all_list, &ho ); + if( he == NULL ) return 0; /* empty hash??? */ + while (haveall && he) + { + key = (char *) hashtab_get_key(he); + /* every element must match at least one of {uid,dev,comm} + * our parameters + */ + haveall &= !strcmp( key, uid ) || !strcmp( key, dev ) + || !strncmp( key, comm, COMM_LEN ); + + he = hashtab_next( &ho ); + } + return haveall; + } + if (tty_list && hashtab_find (tty_list, dev, 0) == NULL) return 0;