gww@marduk.UUCP (Gary Winiger) (09/05/87)
Subject: Who always reports that it can't open utmp. +Fix
Index: bin/who.c 4.2BSD +Fix
Description:
When who is called with an alternate ``utmp'' file that does
not exist. It reports that it cannot open utmp when in fact
it isn't trying to open utmp, but rather ``utmp'' the file the
caller requested.
Repeat-By:
who /etc/foo
Fix:
The following code corrects this problem at Elxsi.
Gary..
{ucbvax!sun,lll-lcc!lll-tis,amdahl!altos86,bridge2}!elxsi!gww
--------- cut --------- snip --------- :.,$w diff -------------
*** /tmp/,RCSt1001827 Thu Dec 18 16:44:28 1986
--- who.c Thu Dec 18 15:04:29 1986
***************
*** 1,5 ****
--- 1,8 ----
/*
* $Log: who.c,v $
+ * Revision 1.2 86/12/18 15:04:13 gww
+ * Give the name of the actual ``utmp'' file used.
+ *
* Revision 1.1 86/12/17 18:15:24 gww
* Initial revision
*
***************
*** 17,23 ****
#endif not lint
#ifndef lint
! static char *ERcsId = "$Header: who.c,v 1.1 86/12/17 18:15:24 gww Exp $ ENIX BSD";
static char sccsid[] = "@(#)who.c 5.1 (Berkeley) 5/2/85";
#endif not lint
--- 20,26 ----
#endif not lint
#ifndef lint
! static char *ERcsId = "$Header: who.c,v 1.2 86/12/18 15:04:13 gww Exp $ ENIX BSD";
static char sccsid[] = "@(#)who.c 5.1 (Berkeley) 5/2/85";
#endif not lint
***************
*** 67,73 ****
}
}
if ((fi = fopen(s, "r")) == NULL) {
! puts("who: cannot open utmp");
exit(1);
}
while (fread((char *)&utmp, sizeof(utmp), 1, fi) == 1) {
--- 70,76 ----
}
}
if ((fi = fopen(s, "r")) == NULL) {
! printf("who: cannot open %s\n", s);
exit(1);
}
while (fread((char *)&utmp, sizeof(utmp), 1, fi) == 1) {ron@topaz.rutgers.edu (Ron Natalie) (09/06/87)
It is a shame you went to all the effort and still came up with a deficient program. How about a call to perror here? Why can't I open that file...not owner? no such file or directory? what! -Ron