commit 8a08cb62d3b10a1f20aabb7976de5a2533b24cb5 from: Martijn van Duren date: Tue Mar 17 10:55:30 2026 UTC Reorder pledge to be a little more strict commit - 8b2200400f8201d7fb3b5f0c2ebcfe85cbf0845a commit + 8a08cb62d3b10a1f20aabb7976de5a2533b24cb5 blob - 89600edc8ee876fb09530238614b61afc9313a67 blob + fe2b5ddf378b416615554ecb25cad478695eae1e --- vias.c +++ vias.c @@ -439,23 +439,20 @@ main(int argc, char **argv) if ((tfd = mkstemp(tmpfile)) == -1) err(1, "mkstemp failed"); - - if (pledge("stdio rpath wpath cpath exec proc tty", NULL) == -1) - err(1, "pledge"); - - if (!fcpy(tfd, ofd)) { - unlink(tmpfile); - err(1, "temp copy failed"); - } - + ttyfd = open("/dev/tty", O_RDWR | O_CLOFORK); if (getcwd(cwdpath, sizeof(cwdpath)) == NULL) cwd = "(failed)"; else cwd = cwdpath; - if (pledge("stdio rpath wpath cpath exec proc tty", NULL) == -1) + if (pledge("stdio cpath exec proc tty", NULL) == -1) err(1, "pledge"); + if (!fcpy(tfd, ofd)) { + unlink(tmpfile); + err(1, "temp copy failed"); + } + syslog(LOG_AUTHPRIV | LOG_INFO, "%s edited %s from %s", myname, file, cwd); @@ -483,13 +480,10 @@ main(int argc, char **argv) execvp(eargv[0], eargv); err(1, "execvp failed"); default: - if (pledge("stdio rpath wpath cpath proc tty", NULL) == -1) - err(1, "pledge"); - - (void)setpgid(vipid, 0); - ttyfd = open("/dev/tty", O_RDWR); if (pledge("stdio cpath proc tty", NULL) == -1) err(1, "pledge"); + + (void)setpgid(vipid, 0); if (ttyfd != -1) (void)tcsetpgrp(ttyfd, vipid); while ((ret = waitpid(vipid, &status, 0)) == -1 &&