Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:12.3:Update
leafnode
leafnode-1.11.8-gethostbyname-2-getaddrinfo.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File leafnode-1.11.8-gethostbyname-2-getaddrinfo.patch of Package leafnode
Index: miscutil.c =================================================================== --- miscutil.c.orig 2011-08-18 23:46:27.000000000 +0200 +++ miscutil.c 2011-08-19 01:30:14.948752733 +0200 @@ -491,34 +491,33 @@ chdirgroup(const char *group, int creatd static void whoami(void) { - struct hostent *he; + struct addrinfo hints, *res, *p; int debugqual = 0; char *x; if ((x = getenv("LN_DEBUG_QUALIFICATION")) != NULL && *x) debugqual = 1; + memset(&hints, 0, sizeof hints); + hints.ai_flags = AI_CANONNAME; - if (!gethostname(fqdn, sizeof(fqdn)) && (he = gethostbyname(fqdn)) != NULL) { - xstrlcpy(fqdn, he->h_name, sizeof(fqdn)); - if (debugqual) syslog(LOG_DEBUG, "canonical hostname: %s", fqdn); - if (!is_validfqdn(fqdn)) { - char **alias; - alias = he->h_aliases; - while (alias && *alias) { - if (debugqual) { - syslog(LOG_DEBUG, "alias for my hostname: %s", *alias); - } - if (is_validfqdn(*alias)) { - xstrlcpy(fqdn, *alias, sizeof(fqdn)); - break; - } else { - alias++; - } - } - } - endhostent(); + if (!gethostname(fqdn, sizeof(fqdn)) && !getaddrinfo(fqdn, NULL, &hints, &res)) { + xstrlcpy(fqdn,res->ai_canonname, sizeof(fqdn)); + if (debugqual) syslog(LOG_DEBUG, "canonical hostname: %s", fqdn); + if (!is_validfqdn(fqdn)) { + for (p = res; p != NULL; p = p->ai_next) { + if (debugqual) { + syslog(LOG_DEBUG, "alias for my hostname: %s", p->ai_canonname); + } + if (is_validfqdn(p->ai_canonname)) { + xstrlcpy(fqdn, p->ai_canonname, sizeof(fqdn)); + break; + } + } + } + freeaddrinfo(res); } + } /*
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor