Skip to content

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

Open

Description

@bigodel

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions