summaryrefslogtreecommitdiffstats
path: root/src/pulse/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pulse/util.c')
-rw-r--r--src/pulse/util.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/pulse/util.c b/src/pulse/util.c
index d3ac9f66..b6f57b96 100644
--- a/src/pulse/util.c
+++ b/src/pulse/util.c
@@ -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