- if (domain[0] == '\0') {
- struct hostent *he;
- char hname[64], *c;
-
- if (gethostname(hname, sizeof(hname)) == -1)
- errx(1, "Error getting hostname");
-
- if ((he = gethostbyname(hname)) == NULL)
- errx(1, "Error resolving hostname: %s", hname);
-
- if ((c = strchr(he->h_name, '.')) == NULL || *++c == '\0')
- errx(1, "Error resolving domain, "
- "please use the -d switch");
-
- strlcpy(domain, c, sizeof(domain));
- }
-