comparison src/sysdep.c @ 19639:fb3c3590498e

(init_system_name): Don't try to use getdomainname.
author Richard M. Stallman <rms@gnu.org>
date Sun, 31 Aug 1997 18:03:03 +0000
parents cf4b06e6a5ab
children ce0b47a57e23
comparison
equal deleted inserted replaced
19638:19215d7e44ee 19639:fb3c3590498e
2281 } 2281 }
2282 #endif 2282 #endif
2283 } 2283 }
2284 } 2284 }
2285 #endif /* HAVE_SOCKETS */ 2285 #endif /* HAVE_SOCKETS */
2286 #if (HAVE_SYSINFO && defined (SI_SRPC_DOMAIN)) || HAVE_GETDOMAINNAME 2286 /* We used to try using getdomainname as an alternative
2287 to sysinfo, here, but NIIBE Yutaka <gniibe@etl.go.jp> says that
2288 getdomainname gets the NIS/YP domain which often is not the same
2289 as in Internet domain name. */
2290 #if (HAVE_SYSINFO && defined (SI_SRPC_DOMAIN))
2287 if (! index (hostname, '.')) 2291 if (! index (hostname, '.'))
2288 { 2292 {
2289 /* The hostname is not fully qualified. Append the domain name. */ 2293 /* The hostname is not fully qualified. Append the domain name. */
2290 2294
2291 int hostlen = strlen (hostname); 2295 int hostlen = strlen (hostname);
2293 2297
2294 for (;;) 2298 for (;;)
2295 { 2299 {
2296 char *domain = (char *) alloca (domain_size + 1); 2300 char *domain = (char *) alloca (domain_size + 1);
2297 char *fqdn = (char *) alloca (hostlen + 1 + domain_size + 1); 2301 char *fqdn = (char *) alloca (hostlen + 1 + domain_size + 1);
2298 #if HAVE_SYSINFO && defined (SI_SRPC_DOMAIN)
2299 int sys_domain_size = sysinfo (SI_SRPC_DOMAIN, domain, domain_size); 2302 int sys_domain_size = sysinfo (SI_SRPC_DOMAIN, domain, domain_size);
2300 if (sys_domain_size <= 0) 2303 if (sys_domain_size <= 0)
2301 break; 2304 break;
2302 if (domain_size < sys_domain_size) 2305 if (domain_size < sys_domain_size)
2303 { 2306 {
2304 domain_size = sys_domain_size; 2307 domain_size = sys_domain_size;
2305 continue; 2308 continue;
2306 } 2309 }
2307 #else /* HAVE_GETDOMAINNAME */
2308 if (getdomainname (domain, domain_size - 1) != 0 || ! *domain)
2309 break;
2310 domain[domain_size - 1] = '\0';
2311 if (strlen (domain) == domain_size - 1)
2312 {
2313 domain_size *= 2;
2314 continue;
2315 }
2316 /* If we get an answer which means "domain unknown",
2317 don't use a domain. */
2318 if (!strcmp (domain, "(none)"))
2319 {
2320 *domain = 0;
2321 break;
2322 }
2323 #endif /* HAVE_GETDOMAINNAME */
2324 strcpy (fqdn, hostname); 2310 strcpy (fqdn, hostname);
2325 if (domain[0] == '.') 2311 if (domain[0] == '.')
2326 strcpy (fqdn + hostlen, domain); 2312 strcpy (fqdn + hostlen, domain);
2327 else if (domain[0] != 0) 2313 else if (domain[0] != 0)
2328 { 2314 {
2331 } 2317 }
2332 hostname = fqdn; 2318 hostname = fqdn;
2333 break; 2319 break;
2334 } 2320 }
2335 } 2321 }
2336 #endif /*! ((HAVE_SYSINFO && defined (SI_SRPC_DOMAIN)) || HAVE_GETDOMAINNAME)*/ 2322 #endif /* HAVE_SYSINFO && defined (SI_SRPC_DOMAIN) */
2337 Vsystem_name = build_string (hostname); 2323 Vsystem_name = build_string (hostname);
2338 #endif /* HAVE_GETHOSTNAME */ 2324 #endif /* HAVE_GETHOSTNAME */
2339 #endif /* VMS */ 2325 #endif /* VMS */
2340 #endif /* BSD4_1 */ 2326 #endif /* BSD4_1 */
2341 { 2327 {