Don't parse config until after daemonization
And consequently, until after pledge(2) and unveil(2) on OpenBSD. Replace parsing before daemonization with a simple check that the file is readable. There's not much that can go wrong in parsing anyway.
This commit is contained in:
parent
bdcb9ab46f
commit
f346f61ea0
7
daemon.c
7
daemon.c
@ -216,6 +216,9 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
}
|
||||
|
||||
error = access(configPath, R_OK);
|
||||
if (error) err(EX_NOINPUT, "%s", configPath);
|
||||
|
||||
error = access(serviceDir, X_OK);
|
||||
if (error) err(EX_NOINPUT, "%s", serviceDir);
|
||||
|
||||
@ -269,9 +272,6 @@ int main(int argc, char *argv[]) {
|
||||
int writer = open(fifoPath, O_WRONLY | O_NONBLOCK | O_CLOEXEC);
|
||||
if (writer < 0) err(EX_CANTCREAT, "%s", fifoPath);
|
||||
|
||||
error = parseConfig(configPath);
|
||||
if (error) return EX_DATAERR;
|
||||
|
||||
if (daemonize) {
|
||||
error = daemon(0, 0);
|
||||
if (error) {
|
||||
@ -306,6 +306,7 @@ int main(int argc, char *argv[]) {
|
||||
signal(SIGCHLD, signalHandler);
|
||||
signal(SIGINFO, signalHandler);
|
||||
|
||||
parseConfig(configPath);
|
||||
for (size_t i = 0; i < services.len; ++i) {
|
||||
serviceStart(&services.ptr[i]);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user