From e2b7e7c390de61b341897310d6e3e1fdf56b703a Mon Sep 17 00:00:00 2001 From: Itamar Date: Mon, 16 Mar 2020 22:30:25 +0200 Subject: [PATCH] SystemMenu: chdir to home directory before launching apps --- Applications/SystemMenu/main.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Applications/SystemMenu/main.cpp b/Applications/SystemMenu/main.cpp index a2321427b9..106cae5a5e 100644 --- a/Applications/SystemMenu/main.cpp +++ b/Applications/SystemMenu/main.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -80,6 +81,11 @@ int main(int argc, char** argv) return 1; } + if (chdir(get_current_user_home_path().characters()) < 0) { + perror("chdir"); + return 1; + } + if (unveil("/bin", "x")) { perror("unveil"); return 1; @@ -150,7 +156,8 @@ NonnullRefPtr build_system_menu() dbg() << "Activated app with ID " << app_identifier; if (fork() == 0) { const auto& bin = g_apps[app_identifier].executable; - execl(bin.characters(), bin.characters(), nullptr); + if (execl(bin.characters(), bin.characters(), nullptr) < 0) + perror("execl"); ASSERT_NOT_REACHED(); } }));