From 26f2e1bb29e29d6e7df6cebd7be9bc5c8d1d6c46 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Mon, 25 May 2015 12:22:03 +0200 Subject: [PATCH] helper: If old CWD is not mapped, use $HOME --- xdg-app-helper.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/xdg-app-helper.c b/xdg-app-helper.c index b14d9ec1..7ab9676f 100644 --- a/xdg-app-helper.c +++ b/xdg-app-helper.c @@ -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 */