...and open() only needs the mode argument if O_CREAT is present.
ok?
Index: libexec/comsat/comsat.c
===================================================================
RCS file: /cvs/src/libexec/comsat/comsat.c,v
retrieving revision 1.45
diff -u -p -r1.45 comsat.c
--- libexec/comsat/comsat.c 2 Apr 2016 16:33:28 -0000 1.45
+++ libexec/comsat/comsat.c 2 Apr 2017 00:39:51 -0000
@@ -100,7 +100,7 @@ main(int argc, char *argv[])
(void) recv(0, msgbuf, sizeof(msgbuf) - 1, 0);
exit(1);
}
- if ((uf = open(_PATH_UTMP, O_RDONLY, 0)) == -1) {
+ if ((uf = open(_PATH_UTMP, O_RDONLY)) == -1) {
syslog(LOG_ERR, "open: %s: %m", _PATH_UTMP);
(void) recv(0, msgbuf, sizeof(msgbuf) - 1, 0);
exit(1);
@@ -194,8 +194,7 @@ doreadutmp(void)
utmp = u;
utmpsize = nutmpsize;
}
- (void)lseek(uf, 0, SEEK_SET);
- nutmp = read(uf, utmp, statbf.st_size)/sizeof(struct utmp);
+ nutmp = pread(uf, utmp, statbf.st_size, 0)/sizeof(struct utmp);
dsyslog(LOG_DEBUG, "read %d utmp entries", nutmp);
}
(void)alarm(15);