diff options
author | Drew DeVault <sir@cmpwn.com> | 2015-11-13 08:15:14 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2015-11-13 08:15:14 -0500 |
commit | f3fc48f69210a90f599d784df9db60840fcfc9b7 (patch) | |
tree | 2850d3438137f5c56026288eb8b9d0daabb874e2 | |
parent | f0ceb4e909bb0182d10ce09d34019497aa8d5715 (diff) | |
parent | 253204efb9517181c386036cae5ea5595a26b55a (diff) |
Merge pull request #225 from sce/logind_socket_path
ipc: Put socket into proper user runtime dir.
-rw-r--r-- | sway/ipc.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -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"); } |