Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wayfire socket path generated is not unique across multiple users #2489

Closed
marcusbritanicus opened this issue Oct 6, 2024 · 3 comments
Closed
Labels
bug easy Issues that do not require knowledge about the whole codebase good first issue

Comments

@marcusbritanicus
Copy link
Contributor

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:

  1. Start Wayfire on TTY1 (with IPC plugin enabled)
  2. Switch to TTY 2, and start another instance of wayfire as another user
  3. The value of wayland display is wayland-1 for the instance in tty-2.
  4. 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

@marcusbritanicus marcusbritanicus changed the title Wayfire socket path generated is not unique Wayfire socket path generated is not unique across multiple users Oct 6, 2024
@ammen99
Copy link
Member

ammen99 commented Oct 6, 2024

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 :)

@ammen99 ammen99 added easy Issues that do not require knowledge about the whole codebase good first issue labels Oct 6, 2024
@killown
Copy link
Contributor

killown commented Oct 7, 2024

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";

@ammen99
Copy link
Member

ammen99 commented Nov 12, 2024

Fixed in #2490

@ammen99 ammen99 closed this as completed Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug easy Issues that do not require knowledge about the whole codebase good first issue
Projects
None yet
Development

No branches or pull requests

3 participants