(krb5_get_krb524hst): add and restructure the support functions
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@9999 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -121,6 +121,22 @@ srv_find_realm(krb5_context context, char ***res, int *count,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* lookup the servers for realm `realm', looking for the config string
|
||||||
|
* `conf_string' in krb5.conf.
|
||||||
|
* return a malloc-ed list of servers in hostlist or NULL if ther are none
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
get_krbhst_conf (krb5_context context,
|
||||||
|
const krb5_realm *realm,
|
||||||
|
const char *conf_string,
|
||||||
|
char ***hostlist)
|
||||||
|
{
|
||||||
|
*hostlist = krb5_config_get_strings(context, NULL,
|
||||||
|
"realms", *realm, conf_string, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* lookup the servers for realm `realm', looking for the config string
|
* lookup the servers for realm `realm', looking for the config string
|
||||||
* `conf_string' in krb5.conf or for `serv_string' in SRV records.
|
* `conf_string' in krb5.conf or for `serv_string' in SRV records.
|
||||||
@@ -128,21 +144,17 @@ srv_find_realm(krb5_context context, char ***res, int *count,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static krb5_error_code
|
static krb5_error_code
|
||||||
get_krbhst (krb5_context context,
|
get_krbhst_dns (krb5_context context,
|
||||||
const krb5_realm *realm,
|
const krb5_realm *realm,
|
||||||
const char *conf_string,
|
|
||||||
const char *serv_string,
|
const char *serv_string,
|
||||||
char ***hostlist)
|
char ***hostlist,
|
||||||
|
krb5_boolean fallback)
|
||||||
{
|
{
|
||||||
char **res, **r;
|
char **res;
|
||||||
int count;
|
int count;
|
||||||
krb5_error_code ret;
|
krb5_error_code ret;
|
||||||
|
|
||||||
res = krb5_config_get_strings(context, NULL,
|
if(context->srv_lookup) {
|
||||||
"realms", *realm, conf_string, NULL);
|
|
||||||
for(r = res, count = 0; r && *r; r++, count++);
|
|
||||||
|
|
||||||
if(count == 0 && context->srv_lookup) {
|
|
||||||
char *s[] = { "udp", "tcp", "http" }, **q;
|
char *s[] = { "udp", "tcp", "http" }, **q;
|
||||||
for(q = s; q < s + sizeof(s) / sizeof(s[0]); q++) {
|
for(q = s; q < s + sizeof(s) / sizeof(s[0]); q++) {
|
||||||
ret = srv_find_realm(context, &res, &count, *realm, *q,
|
ret = srv_find_realm(context, &res, &count, *realm, *q,
|
||||||
@@ -154,7 +166,7 @@ get_krbhst (krb5_context context,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(count == 0) {
|
if(fallback && count == 0) {
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
snprintf(buf, sizeof(buf), "kerberos.%s", *realm);
|
snprintf(buf, sizeof(buf), "kerberos.%s", *realm);
|
||||||
ret = add_string(context, &res, &count, buf);
|
ret = add_string(context, &res, &count, buf);
|
||||||
@@ -168,6 +180,28 @@ get_krbhst (krb5_context context,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* lookup the servers for realm `realm', looking for the config string
|
||||||
|
* `conf_string' in krb5.conf or for `serv_string' in SRV records.
|
||||||
|
* return a malloc-ed list of servers in hostlist.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static krb5_error_code
|
||||||
|
get_krbhst (krb5_context context,
|
||||||
|
const krb5_realm *realm,
|
||||||
|
const char *conf_string,
|
||||||
|
const char *serv_string,
|
||||||
|
char ***hostlist,
|
||||||
|
krb5_boolean fallback)
|
||||||
|
{
|
||||||
|
krb5_error_code ret = 0;
|
||||||
|
|
||||||
|
get_krbhst_conf(context, realm, conf_string, hostlist);
|
||||||
|
if (*hostlist == NULL)
|
||||||
|
ret = get_krbhst_dns(context, realm, serv_string, hostlist, fallback);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* set `hostlist' to a malloced list of kadmin servers.
|
* set `hostlist' to a malloced list of kadmin servers.
|
||||||
*/
|
*/
|
||||||
@@ -178,7 +212,7 @@ krb5_get_krb_admin_hst (krb5_context context,
|
|||||||
char ***hostlist)
|
char ***hostlist)
|
||||||
{
|
{
|
||||||
return get_krbhst (context, realm, "admin_server", "kerberos-adm",
|
return get_krbhst (context, realm, "admin_server", "kerberos-adm",
|
||||||
hostlist);
|
hostlist, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -190,14 +224,37 @@ krb5_get_krb_changepw_hst (krb5_context context,
|
|||||||
const krb5_realm *realm,
|
const krb5_realm *realm,
|
||||||
char ***hostlist)
|
char ***hostlist)
|
||||||
{
|
{
|
||||||
krb5_error_code ret;
|
krb5_error_code ret = 0;
|
||||||
|
|
||||||
ret = get_krbhst (context, realm, "kpasswd_server", "kpasswd",
|
get_krbhst_conf (context, realm, "kpasswd_server",
|
||||||
hostlist);
|
hostlist);
|
||||||
|
if (hostlist == NULL)
|
||||||
|
ret = get_krbhst (context, realm, "admin_server", "kpasswd",
|
||||||
|
hostlist, TRUE);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* set `hostlist' to a malloced list of 524 servers (per default the
|
||||||
|
* KDCs)
|
||||||
|
*/
|
||||||
|
|
||||||
|
krb5_error_code
|
||||||
|
krb5_get_krb524hst (krb5_context context,
|
||||||
|
const krb5_realm *realm,
|
||||||
|
char ***hostlist)
|
||||||
|
{
|
||||||
|
krb5_error_code ret = 0;
|
||||||
|
|
||||||
|
get_krbhst_conf (context, realm, "krb524_server", hostlist);
|
||||||
|
if (hostlist == NULL) {
|
||||||
|
ret = get_krbhst (context, realm, "krb524_server", "krb524", hostlist,
|
||||||
|
FALSE);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
ret = get_krbhst (context, realm, "admin_server", "kpasswd",
|
if (hostlist == NULL)
|
||||||
hostlist);
|
return krb5_get_krbhst(context, realm, hostlist);
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,7 +267,7 @@ krb5_get_krbhst (krb5_context context,
|
|||||||
const krb5_realm *realm,
|
const krb5_realm *realm,
|
||||||
char ***hostlist)
|
char ***hostlist)
|
||||||
{
|
{
|
||||||
return get_krbhst (context, realm, "kdc", "kerberos", hostlist);
|
return get_krbhst (context, realm, "kdc", "kerberos", hostlist, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user