Commit 1d4aa672 authored by Julien Cristau's avatar Julien Cristau Committed by Adam Jackson
Browse files

xorg-wrapper: when starting the server as root, reset its environment

When the server is privileged, we shouldn't be passing the user's
environment directly.

Clearing the environment is recommended by the libdbus maintainers, see

v2: rename envp to empty_envp (Jeremy)
Reviewed-by: default avatarHans de Goede <>

Signed-off-by: Julien Cristau's avatarJulien Cristau <>
parent 08c49124
......@@ -194,6 +194,7 @@ int main(int argc, char *argv[])
int total_cards = 0;
int allowed = CONSOLE_ONLY;
int needs_root_rights = -1;
char *const empty_envp[1] = { NULL, };
progname = argv[0];
......@@ -271,7 +272,10 @@ int main(int argc, char *argv[])
argv[0] = buf;
(void) execv(argv[0], argv);
if (getuid() == geteuid())
(void) execv(argv[0], argv);
(void) execve(argv[0], argv, empty_envp);
fprintf(stderr, "%s: Failed to execute %s: %s\n",
progname, buf, strerror(errno));
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment