summaryrefslogtreecommitdiff
path: root/nslcd/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'nslcd/common.c')
-rw-r--r--nslcd/common.c66
1 files changed, 0 insertions, 66 deletions
diff --git a/nslcd/common.c b/nslcd/common.c
index 3c82d71..da508f6 100644
--- a/nslcd/common.c
+++ b/nslcd/common.c
@@ -113,72 +113,6 @@ const char *signame(int signum)
}
}
-/* return the fully qualified domain name of the current host */
-const char *getfqdn(void)
-{
- static char *fqdn = NULL;
- char hostname[BUFLEN_HOSTNAME];
- int hostnamelen;
- int i;
- struct hostent *host = NULL;
- /* if we already have a fqdn return that */
- if (fqdn != NULL)
- return fqdn;
- /* get system hostname */
- if (gethostname(hostname, sizeof(hostname)) < 0)
- {
- log_log(LOG_ERR, "gethostname() failed: %s", strerror(errno));
- return NULL;
- }
- hostnamelen = strlen(hostname);
- /* lookup hostent */
- host = gethostbyname(hostname);
- if (host == NULL)
- {
- log_log(LOG_ERR, "gethostbyname(%s): %s", hostname, hstrerror(h_errno));
- /* fall back to hostname */
- fqdn = strdup(hostname);
- return fqdn;
- }
- /* check h_name for fqdn starting with our hostname */
- if ((strncasecmp(hostname, host->h_name, hostnamelen) == 0) &&
- (host->h_name[hostnamelen] == '.') &&
- (host->h_name[hostnamelen + 1] != '\0'))
- {
- fqdn = strdup(host->h_name);
- return fqdn;
- }
- /* also check h_aliases */
- for (i = 0; host->h_aliases[i] != NULL; i++)
- {
- if ((strncasecmp(hostname, host->h_aliases[i], hostnamelen) == 0) &&
- (host->h_aliases[i][hostnamelen] == '.') &&
- (host->h_aliases[i][hostnamelen + 1] != '\0'))
- {
- fqdn = strdup(host->h_aliases[i]);
- return fqdn;
- }
- }
- /* fall back to h_name if it has a dot in it */
- if (strchr(host->h_name, '.') != NULL)
- {
- fqdn = strdup(host->h_name);
- return fqdn;
- }
- /* also check h_aliases */
- for (i = 0; host->h_aliases[i] != NULL; i++)
- {
- if (strchr(host->h_aliases[i], '.') != NULL)
- {
- fqdn = strdup(host->h_aliases[i]);
- return fqdn;
- }
- }
- /* nothing found, fall back to hostname */
- fqdn = strdup(hostname);
- return fqdn;
-}
-
/* Checks if the specified name seems to be a valid user or group name. */
int isvalidname(const char *name)
{