diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2019-05-16 14:36:59 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2019-05-16 14:36:59 +0000 |
commit | 41a4b190665ced8da5cf2b95c3984d2764441563 (patch) | |
tree | 6243f29e44d1b714eadfa9393be9fdef087e202c /usr.sbin/sensorsd | |
parent | 2dec407cd5245c6407ac374404a8f58d9751e246 (diff) |
unveil code was unaware of -f option.
From Anton Borowka.
ok sthen
Diffstat (limited to 'usr.sbin/sensorsd')
-rw-r--r-- | usr.sbin/sensorsd/sensorsd.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/usr.sbin/sensorsd/sensorsd.c b/usr.sbin/sensorsd/sensorsd.c index f122a7315a4..ba696e0f3a0 100644 --- a/usr.sbin/sensorsd/sensorsd.c +++ b/usr.sbin/sensorsd/sensorsd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sensorsd.c,v 1.63 2018/12/10 13:35:54 landry Exp $ */ +/* $OpenBSD: sensorsd.c,v 1.64 2019/05/16 14:36:58 deraadt Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -114,14 +114,6 @@ main(int argc, char *argv[]) int ch, check_period = CHECK_PERIOD; const char *errstr; - if (unveil("/etc/sensorsd.conf", "r") == -1) - err(1, "unveil"); - if (unveil("/", "x") == -1) - err(1, "unveil"); - - if (pledge("stdio rpath proc exec", NULL) == -1) - err(1, "pledge"); - while ((ch = getopt(argc, argv, "c:df:")) != -1) { switch (ch) { case 'c': @@ -148,15 +140,24 @@ main(int argc, char *argv[]) if (argc > 0) usage(); - openlog("sensorsd", LOG_PID | LOG_NDELAY, LOG_DAEMON); - - create(); - if (configfile == NULL) if (asprintf(&configfile, "/etc/sensorsd.conf") == -1) err(1, "out of memory"); + + if (unveil(configfile, "r") == -1) + err(1, "unveil"); + if (unveil("/", "x") == -1) + err(1, "unveil"); + + if (pledge("stdio rpath proc exec", NULL) == -1) + err(1, "pledge"); + parse_config(configfile); + openlog("sensorsd", LOG_PID | LOG_NDELAY, LOG_DAEMON); + + create(); + if (debug == 0 && daemon(0, 0) == -1) err(1, "unable to fork"); |