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

Make socket path unique #2490

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

marcusbritanicus
Copy link
Contributor

The solution proposed by @killown to make the socket path unique. I have tested this and confirm that it works.

@ammen99
Copy link
Member

ammen99 commented Oct 7, 2024

If we're going to do this, move the socket to XDG_RUNTIME_DIR :)

@killown
Copy link
Contributor

killown commented Oct 7, 2024

If we're going to do this, move the socket to XDG_RUNTIME_DIR :)

void init() override
{
    char *pre_socket = getenv("_WAYFIRE_SOCKET");
    const char *runtime_dir = getenv("XDG_RUNTIME_DIR");
    const auto& dname = wf::get_core().wayland_display;
    pid_t pid = getpid();

    std::string socket;
    if (pre_socket)
    {
        socket = pre_socket;
    }
    else if (runtime_dir)
    {
        socket = std::string(runtime_dir) + "/wayfire-" + dname + "-" + std::to_string(pid) + ".socket";
    }
    else
    {
        socket = "/tmp/wayfire-" + dname + "-" + std::to_string(pid) + ".socket";
    }

    setenv("WAYFIRE_SOCKET", socket.c_str(), 1);
    server->init(socket);
}

@marcusbritanicus
Copy link
Contributor Author

@killown I think you should open a PR. You're clearly doing a much better job than I can.

@ammen99
Copy link
Member

ammen99 commented Oct 9, 2024

I don't think we need the pid when the socket is in $XDG_RUNTIME_DIR, without the pid I also think it is just a little bit simpler to find the socket when running from somewhere where $WAYFIRE_SOCKET is not set. Otherwise @killown's patch lgtm, I don't know why you won't send a pr :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants