summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/pool-buffer.c2
-rw-r--r--common/ipc-client.c8
-rw-r--r--meson.build4
-rw-r--r--sway/commands.c2
-rw-r--r--sway/commands/bar.c2
-rw-r--r--sway/commands/output/background.c2
-rw-r--r--sway/desktop/render.c3
-rw-r--r--sway/ipc-server.c8
-rw-r--r--sway/main.c6
-rw-r--r--sway/server.c4
-rw-r--r--sway/tree/workspace.c2
-rw-r--r--swaybar/ipc.c2
-rw-r--r--swaylock/meson.build17
-rw-r--r--swaylock/pam/swaylock.freebsd6
-rw-r--r--swaylock/pam/swaylock.linux (renamed from swaylock/pam/swaylock)0
15 files changed, 45 insertions, 23 deletions
diff --git a/client/pool-buffer.c b/client/pool-buffer.c
index fa468c0d..588bd06c 100644
--- a/client/pool-buffer.c
+++ b/client/pool-buffer.c
@@ -1,4 +1,4 @@
-#define _XOPEN_SOURCE 500
+#define _POSIX_C_SOURCE 200809
#include <assert.h>
#include <cairo/cairo.h>
#include <fcntl.h>
diff --git a/common/ipc-client.c b/common/ipc-client.c
index 24a2f9c2..496fd131 100644
--- a/common/ipc-client.c
+++ b/common/ipc-client.c
@@ -78,8 +78,8 @@ struct ipc_response *ipc_recv_response(int socketfd) {
}
total = 0;
- response->size = data32[0];
- response->type = data32[1];
+ memcpy(&response->size, &data32[0], sizeof(data32[0]));
+ memcpy(&response->type, &data32[1], sizeof(data32[1]));
char *payload = malloc(response->size + 1);
if (!payload) {
goto error_2;
@@ -112,8 +112,8 @@ char *ipc_single_command(int socketfd, uint32_t type, const char *payload, uint3
char data[ipc_header_size];
uint32_t *data32 = (uint32_t *)(data + sizeof(ipc_magic));
memcpy(data, ipc_magic, sizeof(ipc_magic));
- data32[0] = *len;
- data32[1] = type;
+ memcpy(&data32[0], len, sizeof(*len));
+ memcpy(&data32[1], &type, sizeof(type));
if (write(socketfd, data, ipc_header_size) == -1) {
sway_abort("Unable to send IPC header");
diff --git a/meson.build b/meson.build
index eb5cba84..253a4e96 100644
--- a/meson.build
+++ b/meson.build
@@ -38,7 +38,7 @@ pango = dependency('pango')
pangocairo = dependency('pangocairo')
gdk_pixbuf = dependency('gdk-pixbuf-2.0', required: false)
pixman = dependency('pixman-1')
-libcap = dependency('libcap')
+libcap = dependency('libcap', required: false)
libinput = dependency('libinput', version: '>=1.6.0')
libpam = cc.find_library('pam')
systemd = dependency('libsystemd', required: false)
@@ -104,7 +104,7 @@ if scdoc.found()
endforeach
endif
-add_project_arguments('-DSYSCONFDIR="/@0@"'.format(sysconfdir), language : 'c')
+add_project_arguments('-DSYSCONFDIR="/@0@/@1@"'.format(prefix, sysconfdir), language : 'c')
version = get_option('sway-version')
if version != ''
diff --git a/sway/commands.c b/sway/commands.c
index 359856cc..e72b8916 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -1,4 +1,4 @@
-#define _XOPEN_SOURCE 500
+#define _POSIX_C_SOURCE 200809
#include <ctype.h>
#include <stdarg.h>
#include <stdlib.h>
diff --git a/sway/commands/bar.c b/sway/commands/bar.c
index f6a70c17..f760888e 100644
--- a/sway/commands/bar.c
+++ b/sway/commands/bar.c
@@ -1,4 +1,4 @@
-#define _XOPEN_SOURCE 500
+#define _POSIX_C_SOURCE 200809
#include <string.h>
#include <strings.h>
#include <wlr/util/log.h>
diff --git a/sway/commands/output/background.c b/sway/commands/output/background.c
index 74894812..ddad679d 100644
--- a/sway/commands/output/background.c
+++ b/sway/commands/output/background.c
@@ -1,4 +1,4 @@
-#define _XOPEN_SOURCE 500
+#define _POSIX_C_SOURCE 200809
#include <libgen.h>
#include <strings.h>
#include <unistd.h>
diff --git a/sway/desktop/render.c b/sway/desktop/render.c
index 5556e5b3..695213eb 100644
--- a/sway/desktop/render.c
+++ b/sway/desktop/render.c
@@ -346,7 +346,8 @@ static void render_titlebar(struct sway_output *output,
float output_scale = output->wlr_output->scale;
enum sway_container_layout layout = state->parent->current.layout;
list_t *children = state->parent->current.children;
- bool is_last_child = children->items[children->length - 1] == con;
+ bool is_last_child = children->length == 0 ||
+ children->items[children->length - 1] == con;
double output_x = output->swayc->current.swayc_x;
double output_y = output->swayc->current.swayc_y;
diff --git a/sway/ipc-server.c b/sway/ipc-server.c
index ed710be5..fb5be27b 100644
--- a/sway/ipc-server.c
+++ b/sway/ipc-server.c
@@ -253,8 +253,8 @@ int ipc_client_handle_readable(int client_fd, uint32_t mask, void *data) {
return 0;
}
- client->payload_length = buf32[0];
- client->current_command = (enum ipc_command_type)buf32[1];
+ memcpy(&client->payload_length, &buf32[0], sizeof(buf32[0]));
+ memcpy(&client->current_command, &buf32[1], sizeof(buf32[1]));
if (read_available - received >= (long)client->payload_length) {
ipc_client_handle_command(client);
@@ -832,8 +832,8 @@ bool ipc_send_reply(struct ipc_client *client, const char *payload, uint32_t pay
uint32_t *data32 = (uint32_t*)(data + sizeof(ipc_magic));
memcpy(data, ipc_magic, sizeof(ipc_magic));
- data32[0] = payload_length;
- data32[1] = client->current_command;
+ memcpy(&data32[0], &payload_length, sizeof(payload_length));
+ memcpy(&data32[1], &client->current_command, sizeof(client->current_command));
while (client->write_buffer_len + ipc_header_size + payload_length >=
client->write_buffer_size) {
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
diff --git a/sway/server.c b/sway/server.c
index 8b5bc93c..749365cb 100644
--- a/sway/server.c
+++ b/sway/server.c
@@ -140,6 +140,10 @@ bool server_init(struct sway_server *server) {
void server_fini(struct sway_server *server) {
// TODO: free sway-specific resources
+#ifdef HAVE_XWAYLAND
+ wlr_xwayland_destroy(server->xwayland.wlr_xwayland);
+#endif
+ wl_display_destroy_clients(server->wl_display);
wl_display_destroy(server->wl_display);
list_free(server->dirty_containers);
list_free(server->transactions);
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c
index 60256336..1957d94f 100644
--- a/sway/tree/workspace.c
+++ b/sway/tree/workspace.c
@@ -1,4 +1,4 @@
-#define _XOPEN_SOURCE 500
+#define _POSIX_C_SOURCE 200809
#include <ctype.h>
#include <limits.h>
#include <stdbool.h>
diff --git a/swaybar/ipc.c b/swaybar/ipc.c
index c2d05920..0e60c10c 100644
--- a/swaybar/ipc.c
+++ b/swaybar/ipc.c
@@ -1,4 +1,4 @@
-#define _XOPEN_SOURCE 500
+#define _POSIX_C_SOURCE 200809
#include <limits.h>
#include <string.h>
#include <strings.h>
diff --git a/swaylock/meson.build b/swaylock/meson.build
index 63f694b9..675b8c69 100644
--- a/swaylock/meson.build
+++ b/swaylock/meson.build
@@ -24,7 +24,16 @@ executable(
install: true
)
-install_data(
- 'pam/swaylock',
- install_dir: sysconfdir + '/pam.d/'
-)
+if is_freebsd
+ install_data(
+ 'pam/swaylock.freebsd',
+ install_dir: sysconfdir + '/pam.d/',
+ rename: 'swaylock'
+ )
+else
+ install_data(
+ 'pam/swaylock.linux',
+ install_dir: sysconfdir + '/pam.d/',
+ rename: 'swaylock'
+ )
+endif
diff --git a/swaylock/pam/swaylock.freebsd b/swaylock/pam/swaylock.freebsd
new file mode 100644
index 00000000..603fc185
--- /dev/null
+++ b/swaylock/pam/swaylock.freebsd
@@ -0,0 +1,6 @@
+#
+# PAM configuration file for the swaylock screen locker. By default, it includes
+# the 'passwd' configuration file (see /etc/pam.d/passwd)
+#
+
+auth include passwd
diff --git a/swaylock/pam/swaylock b/swaylock/pam/swaylock.linux
index 6a36b0d6..6a36b0d6 100644
--- a/swaylock/pam/swaylock
+++ b/swaylock/pam/swaylock.linux