Blame SOURCES/0009-ipa-kdb-do-not-use-OpenLDAP-functions-with-NULL-LDAP_rhbz#1932784.patch

5c8636
From 2832810891acfaca68142df7271d6f0a50a588eb Mon Sep 17 00:00:00 2001
5c8636
From: Alexander Bokovoy <abokovoy@redhat.com>
5c8636
Date: Fri, 19 Feb 2021 15:37:47 +0200
5c8636
Subject: [PATCH] ipa-kdb: do not use OpenLDAP functions with NULL LDAP context
5c8636
5c8636
Calling to ipadb_get_connection() will remove LDAP context if any error
5c8636
happens. This means upper layers must always verify that LDAP context
5c8636
exists after such calls.
5c8636
5c8636
ipadb_get_user_auth() may re-read global configuration and that may fail
5c8636
and cause IPA context to have NULL LDAP context.
5c8636
5c8636
Fixes: https://pagure.io/freeipa/issue/8681
5c8636
5c8636
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
5c8636
Reviewed-By: Robbie Harwood <rharwood@redhat.com>
5c8636
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
5c8636
---
5c8636
 daemons/ipa-kdb/ipa_kdb.c            |  1 +
5c8636
 daemons/ipa-kdb/ipa_kdb_mspac.c      | 32 +++++++++++++++-------------
5c8636
 daemons/ipa-kdb/ipa_kdb_principals.c | 26 ++++++++++++++++------
5c8636
 3 files changed, 37 insertions(+), 22 deletions(-)
5c8636
5c8636
diff --git a/daemons/ipa-kdb/ipa_kdb.c b/daemons/ipa-kdb/ipa_kdb.c
5c8636
index 43ba955ac..6e1e3e351 100644
5c8636
--- a/daemons/ipa-kdb/ipa_kdb.c
5c8636
+++ b/daemons/ipa-kdb/ipa_kdb.c
5c8636
@@ -57,6 +57,7 @@ static void ipadb_context_free(krb5_context kcontext,
5c8636
         /* ldap free lcontext */
5c8636
         if ((*ctx)->lcontext) {
5c8636
             ldap_unbind_ext_s((*ctx)->lcontext, NULL, NULL);
5c8636
+            (*ctx)->lcontext = NULL;
5c8636
         }
5c8636
         free((*ctx)->supp_encs);
5c8636
         free((*ctx)->def_encs);
5c8636
diff --git a/daemons/ipa-kdb/ipa_kdb_mspac.c b/daemons/ipa-kdb/ipa_kdb_mspac.c
5c8636
index 31f617129..81a8fd483 100644
5c8636
--- a/daemons/ipa-kdb/ipa_kdb_mspac.c
5c8636
+++ b/daemons/ipa-kdb/ipa_kdb_mspac.c
5c8636
@@ -418,7 +418,6 @@ static krb5_error_code ipadb_fill_info3(struct ipadb_context *ipactx,
5c8636
                                         krb5_timestamp authtime,
5c8636
                                         struct netr_SamInfo3 *info3)
5c8636
 {
5c8636
-    LDAP *lcontext = ipactx->lcontext;
5c8636
     LDAPDerefRes *deref_results = NULL;
5c8636
     struct dom_sid sid;
5c8636
     gid_t prigid = -1;
5c8636
@@ -435,7 +434,7 @@ static krb5_error_code ipadb_fill_info3(struct ipadb_context *ipactx,
5c8636
     bool is_idobject = false;
5c8636
     krb5_principal princ;
5c8636
 
5c8636
-    ret = ipadb_ldap_attr_to_strlist(lcontext, lentry, "objectClass",
5c8636
+    ret = ipadb_ldap_attr_to_strlist(ipactx->lcontext, lentry, "objectClass",
5c8636
                                      &objectclasses);
5c8636
     if (ret == 0 && objectclasses != NULL) {
5c8636
         for (c = 0; objectclasses[c] != NULL; c++) {
5c8636
@@ -472,13 +471,14 @@ static krb5_error_code ipadb_fill_info3(struct ipadb_context *ipactx,
5c8636
     }
5c8636
 
5c8636
     if (is_host) {
5c8636
-        ret = ipadb_ldap_attr_to_str(lcontext, lentry, "fqdn", &strres);
5c8636
+        ret = ipadb_ldap_attr_to_str(ipactx->lcontext, lentry, "fqdn", &strres);
5c8636
         if (ret) {
5c8636
             /* fqdn is mandatory for hosts */
5c8636
             return ret;
5c8636
         }
5c8636
     } else if (is_service) {
5c8636
-        ret = ipadb_ldap_attr_to_str(lcontext, lentry, "krbCanonicalName", &strres);
5c8636
+        ret = ipadb_ldap_attr_to_str(ipactx->lcontext, lentry,
5c8636
+                                     "krbCanonicalName", &strres);
5c8636
         if (ret) {
5c8636
             /* krbCanonicalName is mandatory for services */
5c8636
             return ret;
5c8636
@@ -498,7 +498,7 @@ static krb5_error_code ipadb_fill_info3(struct ipadb_context *ipactx,
5c8636
             return ENOENT;
5c8636
         }
5c8636
     } else {
5c8636
-        ret = ipadb_ldap_attr_to_str(lcontext, lentry, "uid", &strres);
5c8636
+        ret = ipadb_ldap_attr_to_str(ipactx->lcontext, lentry, "uid", &strres);
5c8636
         if (ret) {
5c8636
             /* uid is mandatory */
5c8636
             return ret;
5c8636
@@ -511,7 +511,8 @@ static krb5_error_code ipadb_fill_info3(struct ipadb_context *ipactx,
5c8636
     if (is_host || is_service) {
5c8636
         prigid = 515; /* Well known RID for domain computers group */
5c8636
     } else {
5c8636
-        ret = ipadb_ldap_attr_to_int(lcontext, lentry, "gidNumber", &intres);
5c8636
+        ret = ipadb_ldap_attr_to_int(ipactx->lcontext, lentry,
5c8636
+                                     "gidNumber", &intres);
5c8636
         if (ret) {
5c8636
             /* gidNumber is mandatory */
5c8636
             return ret;
5c8636
@@ -544,7 +545,7 @@ static krb5_error_code ipadb_fill_info3(struct ipadb_context *ipactx,
5c8636
     info3->base.kickoff_time = INT64_MAX;
5c8636
 #endif
5c8636
 
5c8636
-    ret = ipadb_ldap_attr_to_time_t(lcontext, lentry,
5c8636
+    ret = ipadb_ldap_attr_to_time_t(ipactx->lcontext, lentry,
5c8636
                                     "krbLastPwdChange", &timeres);
5c8636
     switch (ret) {
5c8636
     case 0:
5c8636
@@ -562,7 +563,7 @@ static krb5_error_code ipadb_fill_info3(struct ipadb_context *ipactx,
5c8636
     info3->base.allow_password_change = info3->base.last_password_change;
5c8636
     info3->base.force_password_change = INT64_MAX;
5c8636
 
5c8636
-    ret = ipadb_ldap_attr_to_str(lcontext, lentry, "cn", &strres);
5c8636
+    ret = ipadb_ldap_attr_to_str(ipactx->lcontext, lentry, "cn", &strres);
5c8636
     switch (ret) {
5c8636
     case 0:
5c8636
         info3->base.full_name.string = talloc_strdup(memctx, strres);
5c8636
@@ -575,7 +576,7 @@ static krb5_error_code ipadb_fill_info3(struct ipadb_context *ipactx,
5c8636
         return ret;
5c8636
     }
5c8636
 
5c8636
-    ret = ipadb_ldap_attr_to_str(lcontext, lentry,
5c8636
+    ret = ipadb_ldap_attr_to_str(ipactx->lcontext, lentry,
5c8636
                                  "ipaNTLogonScript", &strres);
5c8636
     switch (ret) {
5c8636
     case 0:
5c8636
@@ -589,7 +590,7 @@ static krb5_error_code ipadb_fill_info3(struct ipadb_context *ipactx,
5c8636
         return ret;
5c8636
     }
5c8636
 
5c8636
-    ret = ipadb_ldap_attr_to_str(lcontext, lentry,
5c8636
+    ret = ipadb_ldap_attr_to_str(ipactx->lcontext, lentry,
5c8636
                                  "ipaNTProfilePath", &strres);
5c8636
     switch (ret) {
5c8636
     case 0:
5c8636
@@ -603,7 +604,7 @@ static krb5_error_code ipadb_fill_info3(struct ipadb_context *ipactx,
5c8636
         return ret;
5c8636
     }
5c8636
 
5c8636
-    ret = ipadb_ldap_attr_to_str(lcontext, lentry,
5c8636
+    ret = ipadb_ldap_attr_to_str(ipactx->lcontext, lentry,
5c8636
                                  "ipaNTHomeDirectory", &strres);
5c8636
     switch (ret) {
5c8636
     case 0:
5c8636
@@ -617,7 +618,7 @@ static krb5_error_code ipadb_fill_info3(struct ipadb_context *ipactx,
5c8636
         return ret;
5c8636
     }
5c8636
 
5c8636
-    ret = ipadb_ldap_attr_to_str(lcontext, lentry,
5c8636
+    ret = ipadb_ldap_attr_to_str(ipactx->lcontext, lentry,
5c8636
                                  "ipaNTHomeDirectoryDrive", &strres);
5c8636
     switch (ret) {
5c8636
     case 0:
5c8636
@@ -648,7 +649,7 @@ static krb5_error_code ipadb_fill_info3(struct ipadb_context *ipactx,
5c8636
             info3->base.rid = 515;
5c8636
         }
5c8636
     } else {
5c8636
-        ret = ipadb_ldap_attr_to_str(lcontext, lentry,
5c8636
+        ret = ipadb_ldap_attr_to_str(ipactx->lcontext, lentry,
5c8636
                                      "ipaNTSecurityIdentifier", &strres);
5c8636
         if (ret) {
5c8636
             /* SID is mandatory */
5c8636
@@ -665,7 +666,7 @@ static krb5_error_code ipadb_fill_info3(struct ipadb_context *ipactx,
5c8636
         }
5c8636
     }
5c8636
 
5c8636
-    ret = ipadb_ldap_deref_results(lcontext, lentry, &deref_results);
5c8636
+    ret = ipadb_ldap_deref_results(ipactx->lcontext, lentry, &deref_results);
5c8636
     switch (ret) {
5c8636
     LDAPDerefRes *dres;
5c8636
     LDAPDerefVal *dval;
5c8636
@@ -2511,7 +2512,7 @@ static void ipadb_free_sid_blacklists(char ***sid_blocklist_incoming, char ***si
5c8636
 krb5_error_code ipadb_mspac_get_trusted_domains(struct ipadb_context *ipactx)
5c8636
 {
5c8636
     struct ipadb_adtrusts *t;
5c8636
-    LDAP *lc = ipactx->lcontext;
5c8636
+    LDAP *lc = NULL;
5c8636
     char *attrs[] = { "cn", "ipaNTTrustPartner", "ipaNTFlatName",
5c8636
                       "ipaNTTrustedDomainSID", "ipaNTSIDBlacklistIncoming",
5c8636
                       "ipaNTSIDBlacklistOutgoing", "ipaNTAdditionalSuffixes", NULL };
5c8636
@@ -2545,6 +2546,7 @@ krb5_error_code ipadb_mspac_get_trusted_domains(struct ipadb_context *ipactx)
5c8636
         goto done;
5c8636
     }
5c8636
 
5c8636
+    lc = ipactx->lcontext;
5c8636
     for (le = ldap_first_entry(lc, res); le; le = ldap_next_entry(lc, le)) {
5c8636
         dnstr = ldap_get_dn(lc, le);
5c8636
 
5c8636
diff --git a/daemons/ipa-kdb/ipa_kdb_principals.c b/daemons/ipa-kdb/ipa_kdb_principals.c
5c8636
index d1fa51578..cf1b4f53e 100644
5c8636
--- a/daemons/ipa-kdb/ipa_kdb_principals.c
5c8636
+++ b/daemons/ipa-kdb/ipa_kdb_principals.c
5c8636
@@ -333,6 +333,11 @@ static enum ipadb_user_auth ipadb_get_user_auth(struct ipadb_context *ipactx,
5c8636
     if (gcfg != NULL)
5c8636
         gua = gcfg->user_auth;
5c8636
 
5c8636
+    /* lcontext == NULL means ipadb_get_global_config() failed to load
5c8636
+     * global config and cleared the ipactx */
5c8636
+    if (ipactx->lcontext == NULL)
5c8636
+        return IPADB_USER_AUTH_NONE;
5c8636
+
5c8636
     /* Get the user's user_auth settings if not disabled. */
5c8636
     if ((gua & IPADB_USER_AUTH_DISABLED) == 0)
5c8636
         ipadb_parse_user_auth(ipactx->lcontext, lentry, &ua);
5c8636
@@ -607,8 +612,16 @@ static krb5_error_code ipadb_parse_ldap_entry(krb5_context kcontext,
5c8636
         free(entry);
5c8636
         return KRB5_KDB_DBNOTINITED;
5c8636
     }
5c8636
-    lcontext = ipactx->lcontext;
5c8636
-    if (!lcontext) {
5c8636
+
5c8636
+    entry->magic = KRB5_KDB_MAGIC_NUMBER;
5c8636
+    entry->len = KRB5_KDB_V1_BASE_LENGTH;
5c8636
+
5c8636
+    /* Get User Auth configuration. */
5c8636
+    ua = ipadb_get_user_auth(ipactx, lentry);
5c8636
+
5c8636
+    /* ipadb_get_user_auth() calls into ipadb_get_global_config()
5c8636
+     * and that might fail, causing lcontext to become NULL */
5c8636
+    if (!ipactx->lcontext) {
5c8636
         krb5_klog_syslog(LOG_INFO,
5c8636
                          "No LDAP connection in ipadb_parse_ldap_entry(); retrying...\n");
5c8636
         ret = ipadb_get_connection(ipactx);
5c8636
@@ -620,11 +633,10 @@ static krb5_error_code ipadb_parse_ldap_entry(krb5_context kcontext,
5c8636
         }
5c8636
     }
5c8636
 
5c8636
-    entry->magic = KRB5_KDB_MAGIC_NUMBER;
5c8636
-    entry->len = KRB5_KDB_V1_BASE_LENGTH;
5c8636
-
5c8636
-    /* Get User Auth configuration. */
5c8636
-    ua = ipadb_get_user_auth(ipactx, lentry);
5c8636
+    /* If any code below would result in invalidating ipactx->lcontext,
5c8636
+     * lcontext must be updated with the new ipactx->lcontext value.
5c8636
+     * We rely on the fact that none of LDAP-parsing helpers does it. */
5c8636
+    lcontext = ipactx->lcontext;
5c8636
 
5c8636
     /* ignore mask for now */
5c8636
 
5c8636
-- 
5c8636
2.29.2
5c8636
5c8636
From 0da9de495ca41a1bf0926aef7c9c75c3e53dcd63 Mon Sep 17 00:00:00 2001
5c8636
From: Alexander Bokovoy <abokovoy@redhat.com>
5c8636
Date: Tue, 23 Feb 2021 10:06:25 +0200
5c8636
Subject: [PATCH] ipa-kdb: fix compiler warnings
5c8636
5c8636
There are few fields in KDB structures that have 'conflicting' types but
5c8636
need to be compared. They come from MIT Kerberos and we have no choice
5c8636
here.
5c8636
5c8636
In the same way, SID structures have own requirements.
5c8636
5c8636
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
5c8636
Reviewed-By: Robbie Harwood <rharwood@redhat.com>
5c8636
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
5c8636
---
5c8636
 daemons/ipa-kdb/ipa_kdb_audit_as.c   | 4 ++--
5c8636
 daemons/ipa-kdb/ipa_kdb_mspac.c      | 6 +++---
5c8636
 daemons/ipa-kdb/ipa_kdb_principals.c | 6 +++---
5c8636
 daemons/ipa-kdb/ipa_kdb_pwdpolicy.c  | 2 +-
5c8636
 4 files changed, 9 insertions(+), 9 deletions(-)
5c8636
5c8636
diff --git a/daemons/ipa-kdb/ipa_kdb_audit_as.c b/daemons/ipa-kdb/ipa_kdb_audit_as.c
5c8636
index ed48ea758..ec2046bfe 100644
5c8636
--- a/daemons/ipa-kdb/ipa_kdb_audit_as.c
5c8636
+++ b/daemons/ipa-kdb/ipa_kdb_audit_as.c
5c8636
@@ -112,13 +112,13 @@ void ipadb_audit_as_req(krb5_context kcontext,
5c8636
 
5c8636
         if (krb5_ts_after(krb5_ts_incr(client->last_failed,
5c8636
                         ied->pol->lockout_duration), authtime) &&
5c8636
-            (client->fail_auth_count >= ied->pol->max_fail && 
5c8636
+            (client->fail_auth_count >= (krb5_kvno) ied->pol->max_fail &&
5c8636
              ied->pol->max_fail != 0)) {
5c8636
             /* client already locked, nothing more to do */
5c8636
             break;
5c8636
         }
5c8636
         if (ied->pol->max_fail == 0 ||
5c8636
-            client->fail_auth_count < ied->pol->max_fail) {
5c8636
+            client->fail_auth_count < (krb5_kvno) ied->pol->max_fail) {
5c8636
             /* let's increase the fail counter */
5c8636
             client->fail_auth_count++;
5c8636
             client->mask |= KMASK_FAIL_AUTH_COUNT;
5c8636
diff --git a/daemons/ipa-kdb/ipa_kdb_mspac.c b/daemons/ipa-kdb/ipa_kdb_mspac.c
5c8636
index 81a8fd483..9691b14f6 100644
5c8636
--- a/daemons/ipa-kdb/ipa_kdb_mspac.c
5c8636
+++ b/daemons/ipa-kdb/ipa_kdb_mspac.c
5c8636
@@ -148,9 +148,9 @@ int string_to_sid(const char *str, struct dom_sid *sid)
5c8636
 
5c8636
 char *dom_sid_string(TALLOC_CTX *memctx, const struct dom_sid *dom_sid)
5c8636
 {
5c8636
-    size_t c;
5c8636
+    int8_t c;
5c8636
     size_t len;
5c8636
-    int ofs;
5c8636
+    size_t ofs;
5c8636
     uint32_t ia;
5c8636
     char *buf;
5c8636
 
5c8636
@@ -2612,7 +2612,7 @@ krb5_error_code ipadb_mspac_get_trusted_domains(struct ipadb_context *ipactx)
5c8636
 
5c8636
         t[n].upn_suffixes_len = NULL;
5c8636
         if (t[n].upn_suffixes != NULL) {
5c8636
-            size_t len = 0;
5c8636
+            int len = 0;
5c8636
 
5c8636
             for (; t[n].upn_suffixes[len] != NULL; len++);
5c8636
 
5c8636
diff --git a/daemons/ipa-kdb/ipa_kdb_principals.c b/daemons/ipa-kdb/ipa_kdb_principals.c
5c8636
index cf1b4f53e..0a98ff054 100644
5c8636
--- a/daemons/ipa-kdb/ipa_kdb_principals.c
5c8636
+++ b/daemons/ipa-kdb/ipa_kdb_principals.c
5c8636
@@ -494,7 +494,7 @@ static krb5_error_code ipadb_get_ldap_auth_ind(krb5_context kcontext,
5c8636
     l = len;
5c8636
     for (i = 0; i < count; i++) {
5c8636
         ret = snprintf(ap, l, "%s ", authinds[i]);
5c8636
-        if (ret <= 0 || ret > l) {
5c8636
+        if (ret <= 0 || ret > (int) l) {
5c8636
             ret = ENOMEM;
5c8636
             goto cleanup;
5c8636
         }
5c8636
@@ -2086,7 +2086,7 @@ static krb5_error_code ipadb_get_ldap_mod_auth_ind(krb5_context kcontext,
5c8636
     char *s = NULL;
5c8636
     size_t ai_size = 0;
5c8636
     int cnt = 0;
5c8636
-    int i = 0;
5c8636
+    size_t i = 0;
5c8636
 
5c8636
     ret = krb5_dbe_get_string(kcontext, entry, "require_auth", &ais);
5c8636
     if (ret) {
5c8636
@@ -2467,7 +2467,7 @@ static krb5_error_code ipadb_entry_default_attrs(struct ipadb_mods *imods)
5c8636
 {
5c8636
     krb5_error_code kerr;
5c8636
     LDAPMod *m = NULL;
5c8636
-    int i;
5c8636
+    size_t i;
5c8636
 
5c8636
     kerr = ipadb_mods_new(imods, &m);
5c8636
     if (kerr) {
5c8636
diff --git a/daemons/ipa-kdb/ipa_kdb_pwdpolicy.c b/daemons/ipa-kdb/ipa_kdb_pwdpolicy.c
5c8636
index 4965e6d7f..6f21ef867 100644
5c8636
--- a/daemons/ipa-kdb/ipa_kdb_pwdpolicy.c
5c8636
+++ b/daemons/ipa-kdb/ipa_kdb_pwdpolicy.c
5c8636
@@ -361,7 +361,7 @@ krb5_error_code ipadb_check_policy_as(krb5_context kcontext,
5c8636
     }
5c8636
 
5c8636
     if (ied->pol->max_fail == 0 ||
5c8636
-        client->fail_auth_count < ied->pol->max_fail) {
5c8636
+        client->fail_auth_count < (krb5_kvno) ied->pol->max_fail) {
5c8636
         /* still within allowed failures range */
5c8636
         return 0;
5c8636
     }
5c8636
-- 
5c8636
2.29.2
5c8636
5c8636
From c7ce801b590e29263e9b1904995c603735007771 Mon Sep 17 00:00:00 2001
5c8636
From: Alexander Bokovoy <abokovoy@redhat.com>
5c8636
Date: Wed, 24 Feb 2021 20:51:40 +0200
5c8636
Subject: [PATCH] ipa-kdb: add missing prototypes
5c8636
5c8636
On Fedora 33 GCC defaults to -Wmissing-prototypes and emits warnings
5c8636
about function prototypes missing. If -Werror is specified, this breaks
5c8636
compilation.
5c8636
5c8636
We also default to -Werror=implicit-function-declaration
5c8636
5c8636
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
5c8636
Reviewed-By: Robbie Harwood <rharwood@redhat.com>
5c8636
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
5c8636
---
5c8636
 daemons/ipa-kdb/ipa_kdb_kdcpolicy.c     |  4 ++++
5c8636
 daemons/ipa-kdb/ipa_kdb_mspac.c         | 20 ++++++++++++--------
5c8636
 daemons/ipa-kdb/ipa_kdb_mspac_private.h |  4 ++++
5c8636
 3 files changed, 20 insertions(+), 8 deletions(-)
5c8636
5c8636
diff --git a/daemons/ipa-kdb/ipa_kdb_kdcpolicy.c b/daemons/ipa-kdb/ipa_kdb_kdcpolicy.c
5c8636
index a89f8bbda..aa61a2d1b 100644
5c8636
--- a/daemons/ipa-kdb/ipa_kdb_kdcpolicy.c
5c8636
+++ b/daemons/ipa-kdb/ipa_kdb_kdcpolicy.c
5c8636
@@ -14,6 +14,10 @@
5c8636
 #define ONE_DAY_SECONDS (24 * 60 * 60)
5c8636
 #define JITTER_WINDOW_SECONDS (1 * 60 * 60)
5c8636
 
5c8636
+krb5_error_code kdcpolicy_ipakdb_initvt(krb5_context context,
5c8636
+                                        int maj_ver, int min_ver,
5c8636
+                                        krb5_plugin_vtable vtable);
5c8636
+
5c8636
 static void
5c8636
 jitter(krb5_deltat baseline, krb5_deltat *lifetime_out)
5c8636
 {
5c8636
diff --git a/daemons/ipa-kdb/ipa_kdb_mspac.c b/daemons/ipa-kdb/ipa_kdb_mspac.c
5c8636
index 9691b14f6..47b12a16f 100644
5c8636
--- a/daemons/ipa-kdb/ipa_kdb_mspac.c
5c8636
+++ b/daemons/ipa-kdb/ipa_kdb_mspac.c
5c8636
@@ -2408,9 +2408,10 @@ void ipadb_mspac_struct_free(struct ipadb_mspac **mspac)
5c8636
     *mspac = NULL;
5c8636
 }
5c8636
 
5c8636
-krb5_error_code ipadb_adtrusts_fill_sid_blacklist(char **source_sid_blacklist,
5c8636
-                                                  struct dom_sid **result_sids,
5c8636
-                                                  int *result_length)
5c8636
+static krb5_error_code
5c8636
+ipadb_adtrusts_fill_sid_blacklist(char **source_sid_blacklist,
5c8636
+                                  struct dom_sid **result_sids,
5c8636
+                                  int *result_length)
5c8636
 {
5c8636
     int len, i;
5c8636
     char **source;
5c8636
@@ -2441,9 +2442,10 @@ krb5_error_code ipadb_adtrusts_fill_sid_blacklist(char **source_sid_blacklist,
5c8636
     return 0;
5c8636
 }
5c8636
 
5c8636
-krb5_error_code ipadb_adtrusts_fill_sid_blacklists(struct ipadb_adtrusts *adtrust,
5c8636
-                                                   char **sid_blocklist_incoming,
5c8636
-                                                   char **sid_blocklist_outgoing)
5c8636
+static krb5_error_code
5c8636
+ipadb_adtrusts_fill_sid_blacklists(struct ipadb_adtrusts *adtrust,
5c8636
+                                   char **sid_blocklist_incoming,
5c8636
+                                   char **sid_blocklist_outgoing)
5c8636
 {
5c8636
     krb5_error_code kerr;
5c8636
 
5c8636
@@ -2464,7 +2466,8 @@ krb5_error_code ipadb_adtrusts_fill_sid_blacklists(struct ipadb_adtrusts *adtrus
5c8636
     return 0;
5c8636
 }
5c8636
 
5c8636
-krb5_error_code ipadb_mspac_check_trusted_domains(struct ipadb_context *ipactx)
5c8636
+static krb5_error_code
5c8636
+ipadb_mspac_check_trusted_domains(struct ipadb_context *ipactx)
5c8636
 {
5c8636
     char *attrs[] = { NULL };
5c8636
     char *filter = "(objectclass=ipaNTTrustedDomain)";
5c8636
@@ -2509,7 +2512,8 @@ static void ipadb_free_sid_blacklists(char ***sid_blocklist_incoming, char ***si
5c8636
     }
5c8636
 }
5c8636
 
5c8636
-krb5_error_code ipadb_mspac_get_trusted_domains(struct ipadb_context *ipactx)
5c8636
+static krb5_error_code
5c8636
+ipadb_mspac_get_trusted_domains(struct ipadb_context *ipactx)
5c8636
 {
5c8636
     struct ipadb_adtrusts *t;
5c8636
     LDAP *lc = NULL;
5c8636
diff --git a/daemons/ipa-kdb/ipa_kdb_mspac_private.h b/daemons/ipa-kdb/ipa_kdb_mspac_private.h
5c8636
index d23a14a0b..8c8a3a001 100644
5c8636
--- a/daemons/ipa-kdb/ipa_kdb_mspac_private.h
5c8636
+++ b/daemons/ipa-kdb/ipa_kdb_mspac_private.h
5c8636
@@ -53,3 +53,7 @@ struct ipadb_adtrusts {
5c8636
 
5c8636
 int string_to_sid(const char *str, struct dom_sid *sid);
5c8636
 char *dom_sid_string(TALLOC_CTX *memctx, const struct dom_sid *dom_sid);
5c8636
+krb5_error_code filter_logon_info(krb5_context context, TALLOC_CTX *memctx,
5c8636
+                                  krb5_data realm, struct PAC_LOGON_INFO_CTR *info);
5c8636
+void get_authz_data_types(krb5_context context, krb5_db_entry *entry,
5c8636
+                          bool *_with_pac, bool *_with_pad);
5c8636
\ No newline at end of file
5c8636
-- 
5c8636
2.29.2
5c8636
5c8636
From f340baa4283c76957d9e0a85896c7fa3a994bba6 Mon Sep 17 00:00:00 2001
5c8636
From: Alexander Bokovoy <abokovoy@redhat.com>
5c8636
Date: Wed, 24 Feb 2021 20:52:15 +0200
5c8636
Subject: [PATCH] ipa-kdb: reformat ipa_kdb_certauth
5c8636
5c8636
Add prototype to the exported function
5c8636
5c8636
Replace few tabs by spaces and mark static code as static.
5c8636
5c8636
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
5c8636
Reviewed-By: Robbie Harwood <rharwood@redhat.com>
5c8636
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
5c8636
---
5c8636
 daemons/ipa-kdb/ipa_kdb_certauth.c | 25 ++++++++++++++-----------
5c8636
 1 file changed, 14 insertions(+), 11 deletions(-)
5c8636
5c8636
diff --git a/daemons/ipa-kdb/ipa_kdb_certauth.c b/daemons/ipa-kdb/ipa_kdb_certauth.c
5c8636
index bc6b26578..3a3060c92 100644
5c8636
--- a/daemons/ipa-kdb/ipa_kdb_certauth.c
5c8636
+++ b/daemons/ipa-kdb/ipa_kdb_certauth.c
5c8636
@@ -71,10 +71,13 @@ struct krb5_certauth_moddata_st {
5c8636
     time_t valid_until;
5c8636
 };
5c8636
 
5c8636
-void ipa_certmap_debug(void *private,
5c8636
-                       const char *file, long line,
5c8636
-                       const char *function,
5c8636
-                       const char *format, ...)
5c8636
+krb5_error_code certauth_ipakdb_initvt(krb5_context context,
5c8636
+                                       int maj_ver, int min_ver,
5c8636
+                                       krb5_plugin_vtable vtable);
5c8636
+
5c8636
+static void ipa_certmap_debug(void *private, const char *file, long line,
5c8636
+                              const char *function,
5c8636
+                              const char *format, ...)
5c8636
 {
5c8636
     va_list ap;
5c8636
     char str[255] = { 0 };
5c8636
@@ -354,12 +357,12 @@ static krb5_error_code ipa_certauth_authorize(krb5_context context,
5c8636
      * so there is nothing more to add here. */
5c8636
     auth_inds = calloc(2, sizeof(char *));
5c8636
     if (auth_inds != NULL) {
5c8636
-	ret = asprintf(&auth_inds[0], "pkinit");
5c8636
-	if (ret != -1) {
5c8636
+        ret = asprintf(&auth_inds[0], "pkinit");
5c8636
+        if (ret != -1) {
5c8636
             auth_inds[1] = NULL;
5c8636
             *authinds_out = auth_inds;
5c8636
-	} else {
5c8636
-	    free(auth_inds);
5c8636
+        } else {
5c8636
+            free(auth_inds);
5c8636
         }
5c8636
     }
5c8636
 
5c8636
@@ -404,12 +407,12 @@ static void ipa_certauth_free_indicator(krb5_context context,
5c8636
     size_t i = 0;
5c8636
 
5c8636
     if ((authinds == NULL) || (moddata == NULL)) {
5c8636
-	return;
5c8636
+        return;
5c8636
     }
5c8636
 
5c8636
     for(i=0; authinds[i]; i++) {
5c8636
-	free(authinds[i]);
5c8636
-	authinds[i] = NULL;
5c8636
+        free(authinds[i]);
5c8636
+        authinds[i] = NULL;
5c8636
     }
5c8636
 
5c8636
     free(authinds);
5c8636
-- 
5c8636
2.29.2
5c8636
5c8636
From 2968609fd9f8f91b704dc8167d39ecc67beb8ddd Mon Sep 17 00:00:00 2001
5c8636
From: Alexander Bokovoy <abokovoy@redhat.com>
5c8636
Date: Wed, 24 Feb 2021 20:55:41 +0200
5c8636
Subject: [PATCH] ipa-kdb: mark test functions as static
5c8636
5c8636
No need to define missing prototypes to single use test functions.
5c8636
5c8636
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
5c8636
Reviewed-By: Robbie Harwood <rharwood@redhat.com>
5c8636
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
5c8636
---
5c8636
 daemons/ipa-kdb/tests/ipa_kdb_tests.c | 13 +++++--------
5c8636
 1 file changed, 5 insertions(+), 8 deletions(-)
5c8636
5c8636
diff --git a/daemons/ipa-kdb/tests/ipa_kdb_tests.c b/daemons/ipa-kdb/tests/ipa_kdb_tests.c
5c8636
index 2a174ce6b..0b51ffb96 100644
5c8636
--- a/daemons/ipa-kdb/tests/ipa_kdb_tests.c
5c8636
+++ b/daemons/ipa-kdb/tests/ipa_kdb_tests.c
5c8636
@@ -181,7 +181,7 @@ extern krb5_error_code filter_logon_info(krb5_context context,
5c8636
                                   krb5_data realm,
5c8636
                                   struct PAC_LOGON_INFO_CTR *info);
5c8636
 
5c8636
-void test_filter_logon_info(void **state)
5c8636
+static void test_filter_logon_info(void **state)
5c8636
 {
5c8636
     krb5_error_code kerr;
5c8636
     krb5_data realm = {KV5M_DATA, REALM_LEN, REALM};
5c8636
@@ -316,10 +316,7 @@ void test_filter_logon_info(void **state)
5c8636
 
5c8636
 }
5c8636
 
5c8636
-extern void get_authz_data_types(krb5_context context, krb5_db_entry *entry,
5c8636
-                                 bool *with_pac, bool *with_pad);
5c8636
-
5c8636
-void test_get_authz_data_types(void **state)
5c8636
+static void test_get_authz_data_types(void **state)
5c8636
 {
5c8636
     bool with_pac;
5c8636
     bool with_pad;
5c8636
@@ -437,7 +434,7 @@ void test_get_authz_data_types(void **state)
5c8636
     krb5_free_principal(test_ctx->krb5_ctx, non_nfs_princ);
5c8636
 }
5c8636
 
5c8636
-void test_string_to_sid(void **state)
5c8636
+static void test_string_to_sid(void **state)
5c8636
 {
5c8636
     int ret;
5c8636
     struct dom_sid sid;
5c8636
@@ -469,7 +466,7 @@ void test_string_to_sid(void **state)
5c8636
     assert_memory_equal(&exp_sid, &sid, sizeof(struct dom_sid));
5c8636
 }
5c8636
 
5c8636
-void test_dom_sid_string(void **state)
5c8636
+static void test_dom_sid_string(void **state)
5c8636
 {
5c8636
     struct test_ctx *test_ctx;
5c8636
     char *str_sid;
5c8636
@@ -495,7 +492,7 @@ void test_dom_sid_string(void **state)
5c8636
 }
5c8636
 
5c8636
 
5c8636
-void test_check_trusted_realms(void **state)
5c8636
+static void test_check_trusted_realms(void **state)
5c8636
 {
5c8636
     struct test_ctx *test_ctx;
5c8636
     krb5_error_code kerr = 0;
5c8636
-- 
5c8636
2.29.2
5c8636