URL: https://github.com/SSSD/sssd/pull/5920
Author: ikerexxe
 Title: #5920: krb5: write kdcinfo.* file with port configuration
Action: synchronized

To pull the PR as Git branch:
git remote add ghsssd https://github.com/SSSD/sssd
git fetch ghsssd pull/5920/head:pr5920
git checkout pr5920
From 7f76353d419c214685579de785ba64a44179c353 Mon Sep 17 00:00:00 2001
From: Iker Pedrosa <ipedr...@redhat.com>
Date: Wed, 15 Dec 2021 12:01:08 +0100
Subject: [PATCH] krb5: write kdcinfo.* file with port configuration

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: https://github.com/SSSD/sssd/issues/5919

Signed-off-by: Iker Pedrosa <ipedr...@redhat.com>
---
 src/providers/krb5/krb5_common.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/src/providers/krb5/krb5_common.c b/src/providers/krb5/krb5_common.c
index 2b2e8c550c..719ce6a12b 100644
--- a/src/providers/krb5/krb5_common.c
+++ b/src/providers/krb5/krb5_common.c
@@ -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;
@@ -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) {
@@ -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--;
_______________________________________________
sssd-devel mailing list -- sssd-devel@lists.fedorahosted.org
To unsubscribe send an email to sssd-devel-le...@lists.fedorahosted.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedorahosted.org/archives/list/sssd-devel@lists.fedorahosted.org
Do not reply to spam on the list, report it: 
https://pagure.io/fedora-infrastructure

Reply via email to