On 14.03.2017 12:55, Alexander Bluhm wrote: > All other error messages are lower case. I would write "err(1, > "access configuration file %s", configfile)" as err(3) privides a > reason anyway. > > apart from that OK bluhm@ >
Upated diff. -- Matthias Index: sensorsd.8 =================================================================== RCS file: /mount/cvsdev/cvs/openbsd/src/usr.sbin/sensorsd/sensorsd.8,v retrieving revision 1.22 diff -u -p -u -p -r1.22 sensorsd.8 --- sensorsd.8 27 Jul 2015 17:28:40 -0000 1.22 +++ sensorsd.8 15 Mar 2017 07:45:39 -0000 @@ -26,6 +26,7 @@ .Nm sensorsd .Op Fl d .Op Fl c Ar check +.Op Fl f Ar file .Sh DESCRIPTION The .Nm @@ -68,6 +69,11 @@ Do not daemonize. If this option is specified, .Nm will run in the foreground. +.It Fl f Ar file +Read configuration from +.Ar file +instead of the default configuration file +.Pa /etc/sensorsd.conf . .El .Sh FILES .Bl -tag -width "/etc/sensorsd.conf" Index: sensorsd.c =================================================================== RCS file: /mount/cvsdev/cvs/openbsd/src/usr.sbin/sensorsd/sensorsd.c,v retrieving revision 1.59 diff -u -p -u -p -r1.59 sensorsd.c --- sensorsd.c 12 Dec 2015 20:04:23 -0000 1.59 +++ sensorsd.c 15 Mar 2017 07:46:02 -0000 @@ -101,7 +101,8 @@ void usage(void) { extern char *__progname; - fprintf(stderr, "usage: %s [-d] [-c check]\n", __progname); + fprintf(stderr, "usage: %s [-d] [-c check] [-f file]\n", + __progname); exit(1); } @@ -115,7 +116,7 @@ main(int argc, char *argv[]) if (pledge("stdio rpath proc exec", NULL) == -1) err(1, "pledge"); - while ((ch = getopt(argc, argv, "c:d")) != -1) { + while ((ch = getopt(argc, argv, "c:df:")) != -1) { switch (ch) { case 'c': check_period = strtonum(optarg, 1, 600, &errstr); @@ -124,6 +125,12 @@ main(int argc, char *argv[]) break; case 'd': debug = 1; + break; + case 'f': + configfile = optarg; + if (access(configfile, R_OK) != 0) + err(1, "access configuration file %s", + configfile); break; default: usage();