krb5 commit: Add a master flag to struct server_entry
Greg Hudson
ghudson at mit.edu
Mon Sep 19 12:31:08 EDT 2016
https://github.com/krb5/krb5/commit/0df76499101d10f71e975e30ba899e63b158792c
commit 0df76499101d10f71e975e30ba899e63b158792c
Author: Matt Rogers <mrogers at redhat.com>
Date: Wed Jul 13 16:27:57 2016 -0400
Add a master flag to struct server_entry
URI lookups will contain a flag to indicate if the KDC is a master or
normal KDC, so add a master variable to server_entry. The default
value is -1 and means that the status has not been determined by the
information source. If the flag is set, use it to avoid a seperate
lookup in k5_kdc_is_master().
Also add a "master" argument to add_host_to_list(). Adjust the
existing calls of add_host_to_list() for the new argument (set to -1
as they are from non-URI lookups).
ticket: 8496
src/lib/krb5/os/locate_kdc.c | 12 +++++++++---
src/lib/krb5/os/os-proto.h | 1 +
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/lib/krb5/os/locate_kdc.c b/src/lib/krb5/os/locate_kdc.c
index 1e791e9..6ed8fa6 100644
--- a/src/lib/krb5/os/locate_kdc.c
+++ b/src/lib/krb5/os/locate_kdc.c
@@ -125,6 +125,7 @@ new_server_entry(struct serverlist *list)
list->servers = newservers;
entry = &newservers[list->nservers];
memset(entry, 0, sizeof(*entry));
+ entry->master = -1;
return entry;
}
@@ -151,7 +152,8 @@ add_addr_to_list(struct serverlist *list, k5_transport transport, int family,
/* Add a hostname entry to list. */
static int
add_host_to_list(struct serverlist *list, const char *hostname, int port,
- k5_transport transport, int family, char *uri_path)
+ k5_transport transport, int family, char *uri_path,
+ int master)
{
struct server_entry *entry;
@@ -169,6 +171,7 @@ add_host_to_list(struct serverlist *list, const char *hostname, int port,
goto oom;
}
entry->port = port;
+ entry->master = master;
list->nservers++;
return 0;
oom:
@@ -261,7 +264,7 @@ locate_srv_conf_1(krb5_context context, const krb5_data *realm,
goto cleanup;
code = add_host_to_list(serverlist, host, port_num, this_transport,
- AF_UNSPEC, uri_path);
+ AF_UNSPEC, uri_path, -1);
if (code)
goto cleanup;
@@ -317,7 +320,7 @@ locate_srv_dns_1(const krb5_data *realm, const char *service,
for (entry = head; entry != NULL; entry = entry->next) {
transport = (strcmp(protocol, "_tcp") == 0) ? TCP : UDP;
code = add_host_to_list(serverlist, entry->host, entry->port,
- transport, AF_UNSPEC, NULL);
+ transport, AF_UNSPEC, NULL, -1);
if (code)
goto cleanup;
}
@@ -645,6 +648,9 @@ k5_kdc_is_master(krb5_context context, const krb5_data *realm,
struct serverlist list;
krb5_boolean found;
+ if (server->master != -1)
+ return server->master;
+
if (locate_server(context, realm, &list, locate_service_master_kdc,
server->transport) != 0)
return FALSE;
diff --git a/src/lib/krb5/os/os-proto.h b/src/lib/krb5/os/os-proto.h
index 2134426..7cf5a48 100644
--- a/src/lib/krb5/os/os-proto.h
+++ b/src/lib/krb5/os/os-proto.h
@@ -58,6 +58,7 @@ struct server_entry {
k5_transport transport; /* May be 0 for UDP/TCP if hostname set */
char *uri_path; /* Used only if transport is HTTPS */
int family; /* May be 0 (aka AF_UNSPEC) if hostname set */
+ int master; /* True, false, or -1 for unknown. */
size_t addrlen;
struct sockaddr_storage addr;
};
More information about the cvs-krb5
mailing list