Hi there,

I wrote some patch allowing to specify the path of the configuration
file of sensorsd like it's done for other daemons.

Greetings,
Matthias

Index: sensorsd.8
===================================================================
RCS file: /usr/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  14 Mar 2017 06:32:55 -0000
@@ -26,6 +26,7 @@
 .Nm sensorsd
 .Op Fl d
 .Op Fl c Ar check
+.Op Fl f Ar file
 .Sh DESCRIPTION
 The
 .Nm
@@ -63,6 +64,11 @@ seconds.
 The shortest reporting period for state changes
 will be three times this value.
 The default is 20.
+.It Fl f Ar file
+Read configuration from
+.Ar file
+instead of the default configuration file
+.Pa /etc/sensorsd.conf .
 .It Fl d
 Do not daemonize.
 If this option is specified,
Index: sensorsd.c
===================================================================
RCS file: /usr/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  14 Mar 2017 06:31:45 -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, "Cannot access configuration file %s",
+                               configfile);
                        break;
                default:
                        usage();

Reply via email to