SCCS-vsn: usr.sbin/rwhod/rwhod.c 5.7
#endif not lint
#ifndef lint
#endif not lint
#ifndef lint
-static char sccsid[] = "@(#)rwhod.c 5.6 (Berkeley) %G%";
+static char sccsid[] = "@(#)rwhod.c 5.7 (Berkeley) %G%";
#endif not lint
#include <sys/types.h>
#endif not lint
#include <sys/types.h>
+ if (chdir(RWHODIR) < 0) {
+ perror(RWHODIR);
+ exit(1);
+ }
(void) signal(SIGHUP, getkmem);
openlog("rwhod", LOG_PID, LOG_DAEMON);
/*
(void) signal(SIGHUP, getkmem);
openlog("rwhod", LOG_PID, LOG_DAEMON);
/*
from.sin_addr);
continue;
}
from.sin_addr);
continue;
}
- (void) sprintf(path, "%s/whod.%s", RWHODIR, wd.wd_hostname);
- whod = creat(path, 0666);
+ (void) sprintf(path, "whod.%s", wd.wd_hostname);
+ whod = open(path, O_WRONLY); /* much faster than creat() */
+ { struct stat s;
+ if (whod < 0 || fstat(whod, &s) < 0 || s.st_size > cc) {
+ (void) close(whod);
+ whod = creat(path, 0666);
+ }
+ }
if (whod < 0) {
syslog(LOG_WARNING, "%s: %m", path);
continue;
if (whod < 0) {
syslog(LOG_WARNING, "%s: %m", path);
continue;
}
we = mywd.wd_we;
for (i = 0; i < utmpent; i++) {
}
we = mywd.wd_we;
for (i = 0; i < utmpent; i++) {
- if (stat(we->we_utmp.out_line, &stb) >= 0)
+ char path[64];
+ (void) sprintf(path, "/dev/%s", we->we_utmp.out_line);
+ if (stat(path, &stb) >= 0)
we->we_idle = htonl(now - stb.st_atime);
we++;
}
we->we_idle = htonl(now - stb.st_atime);
we++;
}