[vlc-devel] commit: Support for sudo ( Rémi Denis-Courmont )

git version control git at videolan.org
Mon Jun 9 20:50:04 CEST 2008


vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Mon Jun  9 21:49:29 2008 +0300| [a77080d567d0ba6598a06af6f02c7ef24bfbadcb]

Support for sudo

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a77080d567d0ba6598a06af6f02c7ef24bfbadcb
---

 src/network/rootwrap.c |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/network/rootwrap.c b/src/network/rootwrap.c
index fdf7365..f2c851a 100644
--- a/src/network/rootwrap.c
+++ b/src/network/rootwrap.c
@@ -205,12 +205,24 @@ int main (int argc, char *argv[])
     setrlimit (RLIMIT_RTPRIO, &rlim);
 #endif
 
-    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;




More information about the vlc-devel mailing list