diff options
-rw-r--r-- | libbb/safe_gethostname.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/libbb/safe_gethostname.c b/libbb/safe_gethostname.c index e93254b2b..05e095448 100644 --- a/libbb/safe_gethostname.c +++ b/libbb/safe_gethostname.c | |||
@@ -59,12 +59,16 @@ char* FAST_FUNC safe_gethostname(void) | |||
59 | */ | 59 | */ |
60 | char* FAST_FUNC safe_getdomainname(void) | 60 | char* FAST_FUNC safe_getdomainname(void) |
61 | { | 61 | { |
62 | /* The field domainname of struct utsname is Linux specific. */ | ||
63 | #if defined(__linux__) | 62 | #if defined(__linux__) |
63 | /* The field domainname of struct utsname is Linux specific. */ | ||
64 | struct utsname uts; | 64 | struct utsname uts; |
65 | uname(&uts); | 65 | uname(&uts); |
66 | return xstrndup(!uts.domainname[0] ? "?" : uts.domainname, sizeof(uts.domainname)); | 66 | return xstrndup(!uts.domainname[0] ? "?" : uts.domainname, sizeof(uts.domainname)); |
67 | #else | 67 | #else |
68 | return xstrdup("?"); | 68 | /* We really don't care about people with domain names wider than most screens */ |
69 | char buf[256]; | ||
70 | int r = getdomainname(buf, sizeof(buf)); | ||
71 | buf[sizeof(buf)-1] = '\0'; | ||
72 | return xstrdup(r < 0 ? "?" : buf); | ||
69 | #endif | 73 | #endif |
70 | } | 74 | } |