aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsghctoma <sghctoma@gmail.com>2018-08-30 10:33:48 +0200
committersghctoma <sghctoma@gmail.com>2018-08-30 10:33:48 +0200
commit67188b7cba2a985926647e049ed32c72b6ee98c8 (patch)
tree0a483fadd239ef2b9c23e594cb83627fe2d18548
parentac7a0aa038fd40472823c4514a846996c7fd2857 (diff)
downloadsway-67188b7cba2a985926647e049ed32c72b6ee98c8.tar.xz
Enable privilege dropping of FreeBSD
Privilege dropping works on FreeBSD too, so only the caps parts need to be Linux-only.
-rw-r--r--sway/main.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sway/main.c b/sway/main.c
index 7ed10c86..2f05dc38 100644
--- a/sway/main.c
+++ b/sway/main.c
@@ -366,13 +366,15 @@ int main(int argc, char **argv) {
return 1;
}
-#ifdef __linux__
+#if defined(__linux__) || defined(__FreeBSD__)
if (getuid() != geteuid() || getgid() != getegid()) {
+#ifdef __linux__
// Retain capabilities after setuid()
if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0)) {
wlr_log(WLR_ERROR, "Cannot keep caps after setuid()");
exit(EXIT_FAILURE);
}
+#endif
suid = true;
}
#endif
@@ -382,7 +384,7 @@ int main(int argc, char **argv) {
detect_proprietary();
detect_raspi();
-#ifdef __linux__
+#if defined(__linux__) || defined(__FreeBSD__)
drop_permissions(suid);
#endif
// handle SIGTERM signals