]> code.delx.au - pulseaudio/commitdiff
if we are run as root, always use 'root' as username, regardless of any env vars
authorLennart Poettering <lennart@poettering.net>
Fri, 28 Mar 2008 17:12:01 +0000 (17:12 +0000)
committerLennart Poettering <lennart@poettering.net>
Fri, 28 Mar 2008 17:12:01 +0000 (17:12 +0000)
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/prepare-0.9.10@2185 fefdeb5f-60dc-0310-8127-8f9354f1896f

src/pulse/util.c

index d3ac9f66e17d01a0ad5f22d5818a8fb609d9c1b3..b6f57b9642954d15fe7aa800207350c17f10bf6a 100644 (file)
@@ -65,7 +65,7 @@
 #include "util.h"
 
 char *pa_get_user_name(char *s, size_t l) {
-    char *p;
+    const char *p;
     char buf[1024];
 
 #ifdef HAVE_PWD_H
@@ -75,7 +75,10 @@ char *pa_get_user_name(char *s, size_t l) {
     pa_assert(s);
     pa_assert(l > 0);
 
-    if (!(p = getenv("USER")) && !(p = getenv("LOGNAME")) && !(p = getenv("USERNAME"))) {
+    if (!(p = (getuid() == 0 ? "root" : NULL)) &&
+        !(p = getenv("USER")) &&
+        !(p = getenv("LOGNAME")) &&
+        !(p = getenv("USERNAME"))) {
 #ifdef HAVE_PWD_H
 
 #ifdef HAVE_GETPWUID_R