From 379b66ca957b8b61cbaac9db3869436c190f0ca5 Mon Sep 17 00:00:00 2001 From: Justin Maggard Date: Fri, 23 Oct 2020 12:54:50 -0700 Subject: [PATCH] Use $USER instead of $LOGNAME for default friendly_name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using $USER in the friendly name will display which user minidlna is running as on the clients, which can be helpful for detecting problems. Using $LOGNAME on the other hand will display "root" as the username if minidlna was started using the init script, regardless of which user minidlna is currently running as. Originally added by BenoƮt Knecht --- minidlna.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/minidlna.c b/minidlna.c index 8243374..69780eb 100644 --- a/minidlna.c +++ b/minidlna.c @@ -287,15 +287,19 @@ getfriendlyname(char *buf, int len) fclose(info); #else char * logname; - logname = getenv("LOGNAME"); -#ifndef STATIC // Disable for static linking + logname = getenv("USER"); if (!logname) - { - struct passwd *pwent = getpwuid(geteuid()); - if (pwent) - logname = pwent->pw_name; - } + { + logname = getenv("LOGNAME"); +#ifndef STATIC // Disable for static linking + if (!logname) + { + struct passwd *pwent = getpwuid(geteuid()); + if (pwent) + logname = pwent->pw_name; + } #endif + } snprintf(buf+off, len-off, "%s", logname?logname:"Unknown"); #endif }