simplify unveil/pledge calls

This commit is contained in:
Omar Polo 2021-01-01 13:03:04 +01:00
parent 6c6c7a0ed7
commit 4c4167393a
No known key found for this signature in database
GPG Key ID: 35F98C96A1786F0D
1 changed files with 9 additions and 11 deletions

20
gmid.c
View File

@ -885,17 +885,15 @@ main(int argc, char **argv)
if (!foreground && daemon(0, 1) == -1)
exit(1);
if (cgi != NULL) {
if (unveil(dir, "rx") == -1)
err(1, "unveil");
if (pledge("stdio rpath inet proc exec", NULL) == -1)
err(1, "pledge");
} else {
if (unveil(dir, "r") == -1)
err(1, "unveil");
if (pledge("stdio rpath inet", NULL) == -1)
err(1, "pledge");
}
if (unveil(dir, "rx") == -1)
err(1, "unveil");
if (pledge("stdio rpath inet proc exec", NULL) == -1)
err(1, "pledge");
/* drop proc and exec if cgi isn't enabled */
if (cgi == NULL && pledge("stdio rpath inet", NULL) == -1)
err(1, "pledge");
loop(ctx, sock);