From 4113d7d1d89d6ad5fb47f56ad8ffa6049cd354b8 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Sun, 25 Mar 2012 20:46:00 +0100 Subject: Revise conditional compilation of safe_gethostname.c --- libbb/safe_gethostname.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libbb/safe_gethostname.c b/libbb/safe_gethostname.c index 33ca2b9f3..580baafab 100644 --- a/libbb/safe_gethostname.c +++ b/libbb/safe_gethostname.c @@ -69,12 +69,18 @@ char* FAST_FUNC safe_gethostname(void) */ char* FAST_FUNC safe_getdomainname(void) { -#if !ENABLE_PLATFORM_MINGW32 +#if defined(__linux__) /* The field domainname of struct utsname is Linux specific. */ struct utsname uts; uname(&uts); return xstrndup(!uts.domainname[0] ? "?" : uts.domainname, sizeof(uts.domainname)); -#else +#elif ENABLE_PLATFORM_MINGW32 return xstrdup("?"); +#else + /* We really don't care about people with domain names wider than most screens */ + char buf[256]; + int r = getdomainname(buf, sizeof(buf)); + buf[sizeof(buf)-1] = '\0'; + return xstrdup(r < 0 ? "?" : buf); #endif } -- cgit v1.2.3-55-g6feb