diff options
author | Greg V <greg@unrelenting.technology> | 2016-12-08 15:34:08 +0300 |
---|---|---|
committer | Greg V <greg@unrelenting.technology> | 2016-12-09 19:32:07 +0300 |
commit | da26d69cb1b21d582a81af0cad7342fab6596eed (patch) | |
tree | 18c24336e664111ba9c3a5bfedec5c340ec0a19d /sway | |
parent | Use return value of write (diff) | |
download | sway-da26d69cb1b21d582a81af0cad7342fab6596eed.tar.gz sway-da26d69cb1b21d582a81af0cad7342fab6596eed.tar.zst sway-da26d69cb1b21d582a81af0cad7342fab6596eed.zip |
Fix build on FreeBSD
- Make sure CMake always finds absolute paths for Cairo, Pango and GdkPixbuf
- Add forgotten json-c include path to swaymsg/CMakeLists.txt
- Disable -Werror because of assert warnings
- Add correct /proc/pid/file path for FreeBSD
- Use libepoll-shim on FreeBSD
- Only use Linux capabilities on, well, Linux
Diffstat (limited to 'sway')
-rw-r--r-- | sway/CMakeLists.txt | 5 | ||||
-rw-r--r-- | sway/ipc-server.c | 5 | ||||
-rw-r--r-- | sway/main.c | 2 | ||||
-rw-r--r-- | sway/security.c | 4 |
4 files changed, 15 insertions, 1 deletions
diff --git a/sway/CMakeLists.txt b/sway/CMakeLists.txt index d1afadb6..4532a6c3 100644 --- a/sway/CMakeLists.txt +++ b/sway/CMakeLists.txt | |||
@@ -55,9 +55,12 @@ target_link_libraries(sway | |||
55 | ${PANGO_LIBRARIES} | 55 | ${PANGO_LIBRARIES} |
56 | ${JSONC_LIBRARIES} | 56 | ${JSONC_LIBRARIES} |
57 | m | 57 | m |
58 | cap | ||
59 | ) | 58 | ) |
60 | 59 | ||
60 | if (CMAKE_SYSTEM_NAME STREQUAL Linux) | ||
61 | target_link_libraries(sway cap) | ||
62 | endif (CMAKE_SYSTEM_NAME STREQUAL Linux) | ||
63 | |||
61 | install( | 64 | install( |
62 | TARGETS sway | 65 | TARGETS sway |
63 | RUNTIME | 66 | RUNTIME |
diff --git a/sway/ipc-server.c b/sway/ipc-server.c index 815b232b..de72beca 100644 --- a/sway/ipc-server.c +++ b/sway/ipc-server.c | |||
@@ -126,6 +126,8 @@ struct sockaddr_un *ipc_user_sockaddr(void) { | |||
126 | } | 126 | } |
127 | 127 | ||
128 | static pid_t get_client_pid(int client_fd) { | 128 | static pid_t get_client_pid(int client_fd) { |
129 | // FreeBSD supports getting uid/gid, but not pid | ||
130 | #ifdef __linux__ | ||
129 | struct ucred ucred; | 131 | struct ucred ucred; |
130 | socklen_t len = sizeof(struct ucred); | 132 | socklen_t len = sizeof(struct ucred); |
131 | 133 | ||
@@ -134,6 +136,9 @@ static pid_t get_client_pid(int client_fd) { | |||
134 | } | 136 | } |
135 | 137 | ||
136 | return ucred.pid; | 138 | return ucred.pid; |
139 | #else | ||
140 | return -1; | ||
141 | #endif | ||
137 | } | 142 | } |
138 | 143 | ||
139 | int ipc_handle_connection(int fd, uint32_t mask, void *data) { | 144 | int ipc_handle_connection(int fd, uint32_t mask, void *data) { |
diff --git a/sway/main.c b/sway/main.c index eb103a1e..157c61b3 100644 --- a/sway/main.c +++ b/sway/main.c | |||
@@ -152,6 +152,7 @@ static void security_sanity_check() { | |||
152 | sway_log(L_ERROR, | 152 | sway_log(L_ERROR, |
153 | "!! DANGER !! /proc is not available - sway CANNOT enforce security rules!"); | 153 | "!! DANGER !! /proc is not available - sway CANNOT enforce security rules!"); |
154 | } | 154 | } |
155 | #ifdef __linux__ | ||
155 | cap_flag_value_t v; | 156 | cap_flag_value_t v; |
156 | cap_t cap = cap_get_proc(); | 157 | cap_t cap = cap_get_proc(); |
157 | if (!cap || cap_get_flag(cap, CAP_SYS_PTRACE, CAP_PERMITTED, &v) != 0 || v != CAP_SET) { | 158 | if (!cap || cap_get_flag(cap, CAP_SYS_PTRACE, CAP_PERMITTED, &v) != 0 || v != CAP_SET) { |
@@ -161,6 +162,7 @@ static void security_sanity_check() { | |||
161 | if (cap) { | 162 | if (cap) { |
162 | cap_free(cap); | 163 | cap_free(cap); |
163 | } | 164 | } |
165 | #endif | ||
164 | if (!stat(SYSCONFDIR "/sway", &s)) { | 166 | if (!stat(SYSCONFDIR "/sway", &s)) { |
165 | if (s.st_uid != 0 || s.st_gid != 0 | 167 | if (s.st_uid != 0 || s.st_gid != 0 |
166 | || (s.st_mode & S_IWGRP) || (s.st_mode & S_IWOTH)) { | 168 | || (s.st_mode & S_IWGRP) || (s.st_mode & S_IWOTH)) { |
diff --git a/sway/security.c b/sway/security.c index f16fdd1f..9cccd62e 100644 --- a/sway/security.c +++ b/sway/security.c | |||
@@ -28,7 +28,11 @@ struct command_policy *alloc_command_policy(const char *command) { | |||
28 | } | 28 | } |
29 | 29 | ||
30 | enum secure_feature get_feature_policy(pid_t pid) { | 30 | enum secure_feature get_feature_policy(pid_t pid) { |
31 | #ifdef __FreeBSD__ | ||
32 | const char *fmt = "/proc/%d/file"; | ||
33 | #else | ||
31 | const char *fmt = "/proc/%d/exe"; | 34 | const char *fmt = "/proc/%d/exe"; |
35 | #endif | ||
32 | int pathlen = snprintf(NULL, 0, fmt, pid); | 36 | int pathlen = snprintf(NULL, 0, fmt, pid); |
33 | char *path = malloc(pathlen + 1); | 37 | char *path = malloc(pathlen + 1); |
34 | snprintf(path, pathlen + 1, fmt, pid); | 38 | snprintf(path, pathlen + 1, fmt, pid); |