mirror of
https://github.com/swaywm/sway.git
synced 2024-11-10 20:44:01 +01:00
ipc: Put socket into proper user runtime dir.
This commit is contained in:
parent
5c3f40111a
commit
253204efb9
13
sway/ipc.c
13
sway/ipc.c
@ -94,14 +94,15 @@ struct sockaddr_un *ipc_user_sockaddr(void) {
|
||||
}
|
||||
|
||||
ipc_sockaddr->sun_family = AF_UNIX;
|
||||
|
||||
int path_size = sizeof(ipc_sockaddr->sun_path);
|
||||
|
||||
// Without logind:
|
||||
int allocating_path_size = snprintf(ipc_sockaddr->sun_path, path_size,
|
||||
"/tmp/sway-ipc.%i.%i.sock", getuid(), getpid());
|
||||
|
||||
if (allocating_path_size >= path_size) {
|
||||
// Env var typically set by logind, e.g. "/run/user/<user-id>"
|
||||
const char *dir = getenv("XDG_RUNTIME_DIR");
|
||||
if (!dir) {
|
||||
dir = "/tmp";
|
||||
}
|
||||
if (path_size <= snprintf(ipc_sockaddr->sun_path, path_size,
|
||||
"%s/sway-ipc.%i.%i.sock", dir, getuid(), getpid())) {
|
||||
sway_abort("socket path won't fit into ipc_sockaddr->sun_path");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user