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

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