helper: If old CWD is not mapped, use $HOME

This commit is contained in:
Alexander Larsson
2015-05-25 12:22:03 +02:00
parent ee867058a9
commit 26f2e1bb29

View File

@@ -1890,7 +1890,12 @@ main (int argc,
/* Now we have everything we need CAP_SYS_ADMIN for, so drop it */
drop_caps ();
chdir (old_cwd);
if (chdir (old_cwd) < 0)
{
/* If the old cwd is not mapped, go to home */
const char *home = getenv("HOME");
chdir (home);
}
/* We can't pass regular LD_LIBRARY_PATH, as it would affect the
setuid helper aspect, so we use _LD_LIBRARY_PATH */