Skip to content

Commit

Permalink
ipa-kdb: Rework ipadb_reinit_mspac()
Browse files Browse the repository at this point in the history
Modify ipadb_reinit_mspac() to allocate and initialize ipactx->mspac
only if all its attributes can be set. If not, ipactx->mspac is set to
NULL. This makes easier to determine if the KDC is able to generate PACs
or not.

Also ipadb_reinit_mspac() is now able to return a status message
explaining why initialization of the PAC generator failed. This message
is printed in KDC logs.

Fixes: https://pagure.io/freeipa/issue/9535

Signed-off-by: Julien Rische <jrische@redhat.com>
Reviewed-By: Alexander Bokovoy <abbra@users.noreply.github.com>
  • Loading branch information
jrisc authored and flo-renaud committed Feb 16, 2024
1 parent e5bb0f3 commit 8359293
Show file tree
Hide file tree
Showing 7 changed files with 219 additions and 170 deletions.
14 changes: 4 additions & 10 deletions daemons/ipa-kdb/ipa_kdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ int ipadb_get_connection(struct ipadb_context *ipactx)
struct timeval tv = { 5, 0 };
LDAPMessage *res = NULL;
LDAPMessage *first;
const char *stmsg;
int ret;
int v3;

Expand Down Expand Up @@ -528,16 +529,9 @@ int ipadb_get_connection(struct ipadb_context *ipactx)
}

/* get adtrust options using default refresh interval */
ret = ipadb_reinit_mspac(ipactx, false);
if (ret && ret != ENOENT) {
/* TODO: log that there is an issue with adtrust settings */
if (ipactx->lcontext == NULL) {
/* for some reason ldap connection was reset in ipadb_reinit_mspac
* and is no longer established => failure of ipadb_get_connection
*/
goto done;
}
}
ret = ipadb_reinit_mspac(ipactx, false, &stmsg);
if (ret && stmsg)
krb5_klog_syslog(LOG_WARNING, "MS-PAC generator: %s", stmsg);

ret = 0;

Expand Down
4 changes: 3 additions & 1 deletion daemons/ipa-kdb/ipa_kdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,9 @@ krb5_error_code ipadb_v9_issue_pac(krb5_context context, unsigned int flags,
krb5_data ***auth_indicators);
#endif

krb5_error_code ipadb_reinit_mspac(struct ipadb_context *ipactx, bool force_reinit);
krb5_error_code ipadb_reinit_mspac(struct ipadb_context *ipactx,
bool force_reinit,
const char **stmsg);

void ipadb_mspac_struct_free(struct ipadb_mspac **mspac);
krb5_error_code ipadb_check_transited_realms(krb5_context kcontext,
Expand Down

0 comments on commit 8359293

Please sign in to comment.