Wayfire socket path generated is not unique across multiple users
Describe the bug Currently, the wayfire socket path is created in the following manner:
const auto& dname = wf::get_core().wayland_display;
std::string socket = pre_socket ?: "/tmp/wayfire-" + dname + ".socket";
When two instances of wayfire are started by two different users, both the users are given the same wayland-display name: wayland-1, resulting in the same socket name for both ipc instances.
To Reproduce Steps to reproduce the behavior:
- Start Wayfire on TTY1 (with IPC plugin enabled)
- Switch to TTY 2, and start another instance of wayfire as another user
- The value of wayland display is
wayland-1for the instance in tty-2. - This causes IPC plugin to fail.
Expected behavior The generated socket path should be unique and the IPC plugin should not fail to load in all instances of wayfire
Suggested fix
Instead of using /tmp/, it would be beneficial to use XDG_RUNTIME_DIR as in the case of wayland sockets. Alternatively, one could also append a random 4-digit string to the end of the name.
Screenshots or stacktrace wayfire.log Check lines 172-173.
Wayfire version git
Absolutely true, the /tmp file path was created mostly in the beginning to debug things and I have forgotten to change it. If someone sends a PR, it would be very welcome :)
Absolutely true, the /tmp file path was created mostly in the beginning to debug things and I have forgotten to change it. If someone sends a PR, it would be very welcome :)
you could easily add it for us :D
pid_t pid = getpid();
std::string socket = pre_socket ? pre_socket : "/tmp/wayfire-" + dname + "-" + std::to_string(pid) + ".socket";
Fixed in #2490