Commit a77080d5 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont
Browse files

Support for sudo

parent bf19c9ed
......@@ -205,12 +205,24 @@ int main (int argc, char *argv[])
setrlimit (RLIMIT_RTPRIO, &rlim);
setuid (getuid ());
uid_t uid = getuid ();
if (uid == 0)
const char *sudo = getenv ("SUDO_UID");
if (sudo)
uid = atoi (sudo);
if (uid == 0)
fprintf (stderr, "Cannot determine unprivileged user for VLC!\n");
exit (1);
setuid (uid);
if (!setuid (0)) /* sanity check: we cannot get root back */
exit (1);
/* Yeah, the user can force to execute just about anything from here.
/* Yeah, the user can execute just about anything from here.
* But we've dropped privileges, so it does not matter. */
if (strlen (argv[0]) < sizeof ("-wrapper"))
goto error;
Markdown is supported
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