Check that $XDG_RUNTIME_DIR is valid and accessible

Signed-off-by: David Adam <zanchey@ucc.gu.uwa.edu.au>
This commit is contained in:
Tanner Bruce 2015-10-08 21:44:38 -05:00 committed by David Adam
parent a0eef2663a
commit b4b5c2188f

View file

@ -147,7 +147,12 @@ static wcstring get_runtime_path()
{
wcstring result;
const char *dir = getenv("XDG_RUNTIME_DIR");
if (dir != NULL)
// Check that the path is actually usable
// Technically this is guaranteed by the fdo spec but in practice
// it is not always the case: see #1828 and #2222
int mode = R_OK | W_OK | X_OK;
if (dir != NULL && access(dir, mode) == 0 && check_runtime_path(dir) == 0)
{
result = str2wcstring(dir);
}