[PATCH xserver v2] xorg-wrapper: when starting the server as root, reset its environment

Hans de Goede hdegoede at redhat.com
Mon Oct 19 07:01:01 PDT 2015


Hi,

On 19-10-15 15:42, Julien Cristau wrote:
> 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
> https://bugs.freedesktop.org/show_bug.cgi?id=52202
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=83849
> Signed-off-by: Julien Cristau <jcristau at debian.org>

Looks good to me:

Reviewed-by: Hans de Goede <hdegoede at redhat.com>

Adam, can you pick this one up please ?

Regards,

Hans


>
> v2: rename envp to empty_envp (Jeremy)
> ---
>   hw/xfree86/xorg-wrapper.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/hw/xfree86/xorg-wrapper.c b/hw/xfree86/xorg-wrapper.c
> index 22e97ad..f2c7c2b 100644
> --- a/hw/xfree86/xorg-wrapper.c
> +++ b/hw/xfree86/xorg-wrapper.c
> @@ -190,6 +190,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];
>
> @@ -265,7 +266,10 @@ int main(int argc, char *argv[])
>       }
>
>       argv[0] = buf;
> -    (void) execv(argv[0], argv);
> +    if (getuid() == geteuid())
> +        (void) execv(argv[0], argv);
> +    else
> +        (void) execve(argv[0], argv, empty_envp);
>       fprintf(stderr, "%s: Failed to execute %s: %s\n",
>           progname, buf, strerror(errno));
>       exit(1);
>


More information about the xorg-devel mailing list