diff options
author | Alexander Bokovoy <abokovoy@redhat.com> | 2013-07-18 17:10:01 +0300 |
---|---|---|
committer | Alexander Bokovoy <abokovoy@redhat.com> | 2013-07-18 17:16:48 +0300 |
commit | 8e17f1e9579b9171639c109be51ada9032c52df7 (patch) | |
tree | ec32b4f0273e1e71817c10f1d52a84e86dfad7ad /daemons/ipa-kdb/ipa_kdb_mspac.c | |
parent | e375aca57cfea570e2b92d7f555bda6267d05d7a (diff) | |
download | freeipa-8e17f1e9579b9171639c109be51ada9032c52df7.tar.gz freeipa-8e17f1e9579b9171639c109be51ada9032c52df7.tar.xz freeipa-8e17f1e9579b9171639c109be51ada9032c52df7.zip |
ipa-kdb: cache KDC hostname on startup
We need KDC hostname for several purposes:
- short-circuit detection of principals on the same server as KDC
- generating NetBIOS name
Make sure we cache hostname information on startup and use it
instead of detecting the hostname in run-time. This will miss the
case that KDC hostname got changed but such cases are not supported
anyway without restarting KDC and making changes to principals.
Diffstat (limited to 'daemons/ipa-kdb/ipa_kdb_mspac.c')
-rw-r--r-- | daemons/ipa-kdb/ipa_kdb_mspac.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/daemons/ipa-kdb/ipa_kdb_mspac.c b/daemons/ipa-kdb/ipa_kdb_mspac.c index 96eac6f27..d6c4f9a6a 100644 --- a/daemons/ipa-kdb/ipa_kdb_mspac.c +++ b/daemons/ipa-kdb/ipa_kdb_mspac.c @@ -1905,16 +1905,13 @@ done: return kerr; } -static char *get_server_netbios_name(void) +static char *get_server_netbios_name(struct ipadb_context *ipactx) { char hostname[MAXHOSTNAMELEN + 1]; /* NOTE: this is 64, too little ? */ char *p; int ret; - ret = gethostname(hostname, MAXHOSTNAMELEN); - if (ret) { - return NULL; - } + strncpy(hostname, ipactx->kdc_hostname, MAXHOSTNAMELEN); /* May miss termination */ hostname[MAXHOSTNAMELEN] = '\0'; for (p = hostname; *p; p++) { @@ -2245,7 +2242,7 @@ krb5_error_code ipadb_reinit_mspac(struct ipadb_context *ipactx) free(resstr); free(ipactx->mspac->flat_server_name); - ipactx->mspac->flat_server_name = get_server_netbios_name(); + ipactx->mspac->flat_server_name = get_server_netbios_name(ipactx); if (!ipactx->mspac->flat_server_name) { kerr = ENOMEM; goto done; |