Skip to content
Permalink
Browse files

Merge pull request #21 from e7appew/fix-get_xdg_cache_home

Do not modify HOME environment variable.
  • Loading branch information...
kfish committed Aug 24, 2017
2 parents 30fd5db + 294a7f1 commit ee7b48111be2e2117b201962e9d1c0e1f9804ed4
Showing with 13 additions and 2 deletions.
  1. +13 −2 xsel.c
15 xsel.c
@@ -343,12 +343,21 @@ static char *
get_xdg_cache_home (void)
{
char * cachedir;
char * homedir;
static const char * slashbasename = "/.cache";

if ((cachedir = getenv ("XDG_CACHE_HOME")) == NULL) {
cachedir = strcat(getenv ("HOME"), "/.cache");
if ((homedir = getenv ("HOME")) == NULL) {
exit_err ("no HOME directory");
}
cachedir = xs_malloc (strlen (homedir) + strlen (slashbasename) + 1);
strcpy (cachedir, homedir);
strcat (cachedir, slashbasename);
} else {
cachedir = _xs_strdup (cachedir);
}

mkdir(cachedir, S_IRWXU|S_IRGRP|S_IXGRP);
mkdir (cachedir, S_IRWXU|S_IRGRP|S_IXGRP);

return cachedir;
}
@@ -515,6 +524,8 @@ become_daemon (void)
}

set_daemon_timeout ();

free (cachedir);
}

/*

0 comments on commit ee7b481

Please sign in to comment.
You can’t perform that action at this time.