Changeset 3232 in MondoRescue for branches/3.2/mindi-busybox/libbb/safe_gethostname.c
- Timestamp:
- Jan 1, 2014, 12:47:38 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/mindi-busybox/libbb/safe_gethostname.c
r2725 r3232 51 51 return xstrndup(!uts.nodename[0] ? "?" : uts.nodename, sizeof(uts.nodename)); 52 52 } 53 54 /*55 * On success return the current malloced and NUL terminated domainname.56 * On error return malloced and NUL terminated string "?".57 * This is an illegal first character for a domainname.58 * The returned malloced string must be freed by the caller.59 */60 char* FAST_FUNC safe_getdomainname(void)61 {62 #if defined(__linux__)63 /* The field domainname of struct utsname is Linux specific. */64 struct utsname uts;65 uname(&uts);66 return xstrndup(!uts.domainname[0] ? "?" : uts.domainname, sizeof(uts.domainname));67 #else68 /* 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);73 #endif74 }
Note:
See TracChangeset
for help on using the changeset viewer.