Commit 1f61d23a authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Accept UID 0 as a valid though dangerous user

parent fedbe507
...@@ -67,7 +67,7 @@ static uid_t parse_user (const char *name) ...@@ -67,7 +67,7 @@ static uid_t parse_user (const char *name)
pw = getpwnam (name); pw = getpwnam (name);
if (pw == NULL) if (pw == NULL)
return 0; return (uid_t)(-1);
return pw->pw_uid; return pw->pw_uid;
} }
...@@ -91,7 +91,7 @@ static uid_t guess_user (void) ...@@ -91,7 +91,7 @@ static uid_t guess_user (void)
if (name != NULL) if (name != NULL)
{ {
uid = parse_user (name); uid = parse_user (name);
if (uid != 0) if (uid != (uid_t)(-1))
return uid; return uid;
} }
...@@ -100,18 +100,18 @@ static uid_t guess_user (void) ...@@ -100,18 +100,18 @@ static uid_t guess_user (void)
if (name != NULL) if (name != NULL)
{ {
uid = parse_user (name); uid = parse_user (name);
if (uid != 0) if (uid != (uid_t)(-1))
return uid; return uid;
} }
/* Try vlc */ /* Try vlc */
uid = parse_user ("vlc"); uid = parse_user ("vlc");
if (uid != 0) if (uid != (uid_t)(-1))
return uid; return uid;
/* Try nobody */ /* Try nobody */
uid = parse_user ("nobody"); uid = parse_user ("nobody");
if (uid != 0) if (uid != (uid_t)(-1))
return uid; return uid;
return 65534; return 65534;
...@@ -287,6 +287,17 @@ void rootwrap (void) ...@@ -287,6 +287,17 @@ void rootwrap (void)
g = guess_gid (u); g = guess_gid (u);
fprintf (stderr, ", using GID %u\n", (unsigned)g); fprintf (stderr, ", using GID %u\n", (unsigned)g);
if (u == 0)
{
fputs ("***************************************\n"
"* Running VLC as root is discouraged. *\n"
"***************************************\n"
"\n"
" It is potentially dangerous, "
"and might not even work properly.", stderr);
return;
}
/* GID */ /* GID */
setgid (g); setgid (g);
setgroups (0, NULL); setgroups (0, NULL);
......
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