Use pledge(2) to prevent fork/exec, filesystem access and other
unused subsets of system calls, effectively leaving only shared
memory and networking capabilities at runtime.
(Those might be further reduced, but that warrants further analysis
and most likely more code shuffling.)
}
int main(int argc, char **argv) {
+#ifdef CONFIG_FOR_OPENBSD
+ if (pledge("stdio rpath tmppath inet dns id", NULL) == -1) {
+ die("pledge: %s", strerror(errno));
+ }
+#endif
int debug_level = 0;
int i;
setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid) == -1) {
die("cannot drop privileges to %s", shairport_user);
}
+
+ if (pledge("stdio tmppath inet dns", NULL) == -1) {
+ die("pledge: %s", strerror(errno));
+ }
#endif
// open the SMI