Hi,
By now we are already confident that pledge(2) "just works(tm)" and that it can
be used to effectively remove filesystem access.
That being said, in spamd(8) when I pledge(2)d it the main priv process got
"stdio inet" which means there's no fs access at all so calling
chroot(2)/chdir(2) here doesn't make sense anymore. Just remove them.
Comments? OK?
Index: spamd.c
===================================================================
RCS file: /cvs/src/libexec/spamd/spamd.c,v
retrieving revision 1.155
diff -u -p -u -r1.155 spamd.c
--- spamd.c 22 Oct 2018 17:31:24 -0000 1.155
+++ spamd.c 31 Jul 2019 07:06:53 -0000
@@ -1519,15 +1519,6 @@ main(int argc, char *argv[])
}
close(trappipe[1]);
- if (chroot("/var/empty") == -1) {
- syslog(LOG_ERR, "cannot chroot to /var/empty.");
- exit(1);
- }
- if (chdir("/") == -1) {
- syslog(LOG_ERR, "cannot chdir to /");
- exit(1);
- }
-
if (setgroups(1, &pw->pw_gid) ||
setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) ||
setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid))