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