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

Move socket to $XDG_RUNTIME_DIR/cod #51

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

BurnerWah
Copy link

Currently, cod's socket and lock file are placed at $XDG_DATA_DIR/cod/var, which isn't a particularly standard location for them.

The XDG Base Directory Specification specifies the locations which various files should be stored at. It states:

There is a single base directory relative to which user-specific runtime files and other file objects should be placed. This directory is defined by the environment variable $XDG_RUNTIME_DIR.

It further states a fallback for when the variable isn't set:

If $XDG_RUNTIME_DIR is not set applications should fall back to a replacement directory with similar capabilities and print a warning message.

This PR changes it so that cod will use $XDG_RUNTIME_DIR/cod for the socket & lockfile when $XDG_RUNTIME_DIR is set, and will fall back upon $XDG_DATA_DIR/cod/var.
Since $XDG_RUNTIME_DIR has no default value, falling back upon the old seems like the best choice there.

In my experience, $XDG_RUNTIME_DIR is usually set by pam_systemd, and ends up being set to /run/user/$UID (which it creates it as a tmpfs). However, I'd prefer to just go with general spec compliance here.

I'm probably not the best with Go programming, but I think this implementation should work fine.

@dim-an
Copy link
Owner

dim-an commented Oct 18, 2021

I like you patch, but I have one concern.

If someone is running version before your change and updates cod binary to version containing your patch. cod will go crazy I believe. Am I right? Can we do something with this?

@dim-an
Copy link
Owner

dim-an commented Oct 18, 2021

I mean old running version of cod will continue to listen old socket, and new cod binary will try to connect to new socket and I believe two version of cod working on the same DB will run in parallel. That's not good.

@BurnerWah
Copy link
Author

I could try and figure that out during the weekend.

@SuperSandro2000
Copy link
Contributor

SuperSandro2000 commented Jan 21, 2022

You will get an error like this:

openstack --help
cod: error: dial unix /home/user/.local/share/cod/var/cod.sock: connect: no such file or directory
cod: error: dial unix /home/user/.local/share/cod/var/cod.sock: connect: no such file or directory

closing and reopeing your shell or sourcing your rc file fixes that.

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