From f3ee1ed5fa40dcfe4a64c10905ef159ca4069c9f Mon Sep 17 00:00:00 2001 From: Sumit Bose Date: Wed, 28 Oct 2009 13:09:51 +0100 Subject: set ipa_hostname if not given in config file --- server/providers/ipa/ipa_common.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/server/providers/ipa/ipa_common.c b/server/providers/ipa/ipa_common.c index d3249707..3f4d25de 100644 --- a/server/providers/ipa/ipa_common.c +++ b/server/providers/ipa/ipa_common.c @@ -144,7 +144,9 @@ int ipa_get_options(TALLOC_CTX *memctx, struct ipa_options *opts; char *domain; char *server; + char *ipa_hostname; int ret; + char hostname[HOST_NAME_MAX + 1]; opts = talloc_zero(memctx, struct ipa_options); if (!opts) return ENOMEM; @@ -173,6 +175,24 @@ int ipa_get_options(TALLOC_CTX *memctx, goto done; } + ipa_hostname = dp_opt_get_string(opts->basic, IPA_HOSTNAME); + if (ipa_hostname == NULL) { + ret = gethostname(hostname, HOST_NAME_MAX); + if (ret != EOK) { + DEBUG(1, ("gethostname failed [%d][%s].\n", errno, + strerror(errno))); + ret = errno; + goto done; + } + hostname[HOST_NAME_MAX] = '\0'; + DEBUG(9, ("Setting ipa_hostname to [%s].\n", hostname)); + ret = dp_opt_set_string(opts->basic, IPA_HOSTNAME, hostname); + if (ret != EOK) { + goto done; + } + } + + ret = EOK; *_opts = opts; -- cgit