diff options
-rw-r--r-- | libbb/safe_gethostname.c | 10 |
1 files 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) | |||
69 | */ | 69 | */ |
70 | char* FAST_FUNC safe_getdomainname(void) | 70 | char* FAST_FUNC safe_getdomainname(void) |
71 | { | 71 | { |
72 | #if !ENABLE_PLATFORM_MINGW32 | 72 | #if defined(__linux__) |
73 | /* The field domainname of struct utsname is Linux specific. */ | 73 | /* The field domainname of struct utsname is Linux specific. */ |
74 | struct utsname uts; | 74 | struct utsname uts; |
75 | uname(&uts); | 75 | uname(&uts); |
76 | return xstrndup(!uts.domainname[0] ? "?" : uts.domainname, sizeof(uts.domainname)); | 76 | return xstrndup(!uts.domainname[0] ? "?" : uts.domainname, sizeof(uts.domainname)); |
77 | #else | 77 | #elif ENABLE_PLATFORM_MINGW32 |
78 | return xstrdup("?"); | 78 | return xstrdup("?"); |
79 | #else | ||
80 | /* We really don't care about people with domain names wider than most screens */ | ||
81 | char buf[256]; | ||
82 | int r = getdomainname(buf, sizeof(buf)); | ||
83 | buf[sizeof(buf)-1] = '\0'; | ||
84 | return xstrdup(r < 0 ? "?" : buf); | ||
79 | #endif | 85 | #endif |
80 | } | 86 | } |