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

Follow XDG specification for ~/.vpnns-NAME #27

Open
bigodel opened this issue Nov 4, 2023 · 0 comments
Open

Follow XDG specification for ~/.vpnns-NAME #27

bigodel opened this issue Nov 4, 2023 · 0 comments

Comments

@bigodel
Copy link

bigodel commented Nov 4, 2023

This is a very simple request, and should be pretty easy to implement, but could vpnns use the XDG Base Directory Specification for where it puts its state files? I think it would be as simple as replacing getenv("HOME") in

if (asprintf(&statedir, "%s/.vpnns-%s", getenv("HOME"), name) < 0)

with

	char* state_home = getenv("XDG_STATE_HOME");
	if (!state_home || strlen(state_home) == 0) {
		state_home = getenv("HOME");
		strncat(state_home, "/.local/state",
			sizeof(state_home) - strlen(state_home) - 1);
	}
	if (asprintf(&statedir, "%s/.vpnns-%s", getenv("HOME"), name) < 0)

Note that this might be improved as I haven't really done any serious projects in C before, but this takes into account the cases where the variable is set to the empty string as well.

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

No branches or pull requests

1 participant