From 0f78feeca51a7abe49fbabf22991bf89eba7b12a Mon Sep 17 00:00:00 2001 From: Mark Reynolds Date: Tue, 12 Dec 2023 08:39:47 -0500 Subject: [PATCH] Issue 9497 - update debug logging in ipa_otp_counter Fixes: https://pagure.io/freeipa/issue/9497 Signed-off-by: Mark Reynolds Reviewed-By: Alexander Bokovoy --- .../ipa-otp-counter/ipa_otp_counter.c | 13 +++++++++---- daemons/ipa-slapi-plugins/ipa-otp-counter/ldapmod.h | 4 +++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/daemons/ipa-slapi-plugins/ipa-otp-counter/ipa_otp_counter.c b/daemons/ipa-slapi-plugins/ipa-otp-counter/ipa_otp_counter.c index da047d7dc58e27b37ad29c39bde44e33602ab4c5..5e03450c5164ee450736fc61b40ef769bc4572dd 100644 --- a/daemons/ipa-slapi-plugins/ipa-otp-counter/ipa_otp_counter.c +++ b/daemons/ipa-slapi-plugins/ipa-otp-counter/ipa_otp_counter.c @@ -33,7 +33,7 @@ * Authors: * Nathaniel McCallum * - * Copyright (C) 2014 Red Hat, Inc. + * Copyright (C) 2014-2023 Red Hat, Inc. * All rights reserved. * END COPYRIGHT BLOCK **/ @@ -295,14 +295,16 @@ preop_mod(Slapi_PBlock *pb) } if (!simulate(mods, attr, cpre, &cpost) && repl == 0) { - msg = slapi_ch_smprintf("Invalid operation sequence on %s", attr); + msg = slapi_ch_smprintf("Invalid operation sequence on %s (%s)", + attr, slapi_entry_get_dn_const(epre)); goto error; } if (cpost < cpre) { if (repl == 0) { - msg = slapi_ch_smprintf("Will not %s %s", - cpost == COUNTER_UNSET ? "delete" : "decrement", attr); + msg = slapi_ch_smprintf("Will not %s %s (%s)", + cpost == COUNTER_UNSET ? "delete" : "decrement", + attr, slapi_entry_get_dn_const(epre)); goto error; } @@ -321,6 +323,9 @@ preop_mod(Slapi_PBlock *pb) error: rc = LDAP_UNWILLING_TO_PERFORM; + if (msg) { + LOG("%s - error %d\n", msg, rc); + } slapi_send_ldap_result(pb, rc, NULL, msg, 0, NULL); if (slapi_pblock_set(pb, SLAPI_RESULT_CODE, &rc)) { LOG_FATAL("slapi_pblock_set failed!\n"); diff --git a/daemons/ipa-slapi-plugins/ipa-otp-counter/ldapmod.h b/daemons/ipa-slapi-plugins/ipa-otp-counter/ldapmod.h index 45f43904b2288a97802ad2d698a30be972e2d8b7..324107c487f53e11774c51f248b00043e44b0bcc 100644 --- a/daemons/ipa-slapi-plugins/ipa-otp-counter/ldapmod.h +++ b/daemons/ipa-slapi-plugins/ipa-otp-counter/ldapmod.h @@ -33,7 +33,7 @@ * Authors: * Nathaniel McCallum * - * Copyright (C) 2014 Red Hat, Inc. + * Copyright (C) 2014-2023 Red Hat, Inc. * All rights reserved. * END COPYRIGHT BLOCK **/ @@ -41,6 +41,8 @@ #include +#define IPA_PLUGIN_NAME "ipa-otp-counter" + long long ldapmod_get_value(const LDAPMod *mod, long long def); -- 2.43.0