-/* $OpenBSD: privsep.c,v 1.68 2018/04/26 13:40:09 bluhm Exp $ */
+/* $OpenBSD: privsep.c,v 1.69 2018/08/07 18:36:49 deraadt Exp $ */
/*
* Copyright (c) 2003 Anil Madhavapeddy <anil@recoil.org>
if (pw == NULL)
errx(1, "unknown user _syslogd");
- if (pledge("stdio rpath wpath cpath dns sendfd id proc exec",
+ if (unveil(conf, "r") == -1)
+ err(1, "unveil");
+ if (unveil(_PATH_UTMP, "r") == -1)
+ err(1, "unveil");
+ if (unveil(_PATH_DEV, "rw") == -1)
+ err(1, "unveil");
+
+ /* for pipes */
+ if (unveil(_PATH_BSHELL, "x") == -1)
+ err(1, "unveil");
+
+ /* For HUP / re-exec */
+ if (unveil("/usr/sbin/syslogd", "x") == -1)
+ err(1, "unveil");
+ if (argv[0][0] == '/')
+ if (unveil(argv[0], "x") == -1)
+ err(1, "unveil");
+
+ if (pledge("stdio unveil rpath wpath cpath dns sendfd id proc exec",
NULL) == -1)
err(1, "pledge priv");
break;
case PRIV_DONE_CONFIG_PARSE:
+ if (pledge("stdio rpath wpath cpath dns sendfd id proc exec",
+ NULL) == -1)
+ err(1, "pledge done config");
log_debug("[priv]: msg PRIV_DONE_CONFIG_PARSE "
"received");
increase_state(STATE_RUNNING);
err(1, "check_log_name() malloc");
strlcpy(lg->path, lognam, PATH_MAX);
TAILQ_INSERT_TAIL(&lognames, lg, next);
+ if (lognam[0] != '|') {
+ if (unveil(lognam, "w") == -1)
+ goto bad_path;
+ }
break;
case STATE_RUNNING:
TAILQ_FOREACH(lg, &lognames, next)