Skip to content

Commit

Permalink
krb5: write kdcinfo.* file with port configuration
Browse files Browse the repository at this point in the history
When writing the 'kdcinfo.*' file take into account all the information
set in the 'krb5_server' option, including the port. This wasn't taken
into account and that's why the kerberos child only used the address
part, thus being unable to contact the service in the server.

Resolves: #5919

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>

Reviewed-by: Tomáš Halman <thalman@redhat.com>
  • Loading branch information
ikerexxe authored and alexey-tikhonov committed Dec 17, 2021
1 parent 46843d0 commit 1e747fa
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/providers/krb5/krb5_common.c
Expand Up @@ -698,6 +698,7 @@ errno_t write_krb5info_file_from_fo_server(struct krb5_service *krb5_service,
size_t server_idx;
struct fo_server *item;
int primary;
int port;
const char *address;
errno_t ret;
size_t n_lookahead_primary;
Expand Down Expand Up @@ -730,6 +731,16 @@ errno_t write_krb5info_file_from_fo_server(struct krb5_service *krb5_service,
if (filter == NULL || filter(server) == false) {
address = fo_server_address_or_name(tmp_ctx, server);
if (address) {
port = fo_get_server_port(server);
if (port != 0) {
address = talloc_asprintf(tmp_ctx, "%s:%d", address, port);
if (address == NULL) {
DEBUG(SSSDBG_CRIT_FAILURE, "talloc_asprintf failed.\n");
talloc_free(tmp_ctx);
return ENOMEM;
}
}

server_list[server_idx++] = address;
if (fo_is_server_primary(server)) {
if (n_lookahead_primary > 0) {
Expand Down Expand Up @@ -764,6 +775,16 @@ errno_t write_krb5info_file_from_fo_server(struct krb5_service *krb5_service,
continue;
}

port = fo_get_server_port(item);
if (port != 0) {
address = talloc_asprintf(tmp_ctx, "%s:%d", address, port);
if (address == NULL) {
DEBUG(SSSDBG_CRIT_FAILURE, "talloc_asprintf failed.\n");
talloc_free(tmp_ctx);
return ENOMEM;
}
}

server_list[server_idx++] = address;
if (primary) {
n_lookahead_primary--;
Expand Down

0 comments on commit 1e747fa

Please sign in to comment.