Use $USER instead of $LOGNAME for default friendly_name
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 <benoit.knecht@fsfe.org>
This commit is contained in:
18
minidlna.c
18
minidlna.c
@ -287,15 +287,19 @@ getfriendlyname(char *buf, int len)
|
|||||||
fclose(info);
|
fclose(info);
|
||||||
#else
|
#else
|
||||||
char * logname;
|
char * logname;
|
||||||
logname = getenv("LOGNAME");
|
logname = getenv("USER");
|
||||||
#ifndef STATIC // Disable for static linking
|
|
||||||
if (!logname)
|
if (!logname)
|
||||||
{
|
{
|
||||||
struct passwd *pwent = getpwuid(geteuid());
|
logname = getenv("LOGNAME");
|
||||||
if (pwent)
|
#ifndef STATIC // Disable for static linking
|
||||||
logname = pwent->pw_name;
|
if (!logname)
|
||||||
}
|
{
|
||||||
|
struct passwd *pwent = getpwuid(geteuid());
|
||||||
|
if (pwent)
|
||||||
|
logname = pwent->pw_name;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
snprintf(buf+off, len-off, "%s", logname?logname:"Unknown");
|
snprintf(buf+off, len-off, "%s", logname?logname:"Unknown");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user