From b9e1d63f9cf4919ac37f63dfe8f53c956e83eab7 Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Mon, 7 Jan 2013 23:59:52 +0100 Subject: [PATCH] Explicitly use chdir("/") instead of relying on ~user being set properly On non-systemd systems if the user is changed manually, polkitd will also change directory. The homedir of the user might not be set correctly, so just change to /. This is a no-op on systemd systems, as the user is set in the unit file, so this code never runs. --- src/polkitbackend/polkitd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/polkitbackend/polkitd.c b/src/polkitbackend/polkitd.c index 511ee2c8..52624460 100644 --- a/src/polkitbackend/polkitd.c +++ b/src/polkitbackend/polkitd.c @@ -184,10 +184,10 @@ become_user (const gchar *user, goto out; } - if (chdir (pw->pw_dir) != 0) + if (chdir ("/") != 0) { g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, - "Error changing to home directory %s: %m", + "Error changing to root directory %s: %m", pw->pw_dir); goto out; }