summaryrefslogtreecommitdiffstats
path: root/daemons/ipa-slapi-plugins/ipa-pwd-extop/syncreq.c
diff options
context:
space:
mode:
authorNathaniel McCallum <npmccallum@redhat.com>2014-05-23 13:01:59 -0400
committerMartin Kosek <mkosek@redhat.com>2014-06-25 14:22:01 +0200
commit7b15fcd57b06482be36e95e50cbec596777955b4 (patch)
tree97345a8957f29edbfd6e0bce40e35e0ba51fbc77 /daemons/ipa-slapi-plugins/ipa-pwd-extop/syncreq.c
parent6af1fc47636ea758c81dfd4351a41cddb452e266 (diff)
downloadfreeipa-7b15fcd57b06482be36e95e50cbec596777955b4.tar.gz
freeipa-7b15fcd57b06482be36e95e50cbec596777955b4.tar.xz
freeipa-7b15fcd57b06482be36e95e50cbec596777955b4.zip
Change OTPSyncRequest structure to use OctetString
This change has two motivations: 1. Clients don't have to parse the string. 2. Future token types may have new formats. Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
Diffstat (limited to 'daemons/ipa-slapi-plugins/ipa-pwd-extop/syncreq.c')
-rw-r--r--daemons/ipa-slapi-plugins/ipa-pwd-extop/syncreq.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/daemons/ipa-slapi-plugins/ipa-pwd-extop/syncreq.c b/daemons/ipa-slapi-plugins/ipa-pwd-extop/syncreq.c
index 27878776f..2bfcf10a2 100644
--- a/daemons/ipa-slapi-plugins/ipa-pwd-extop/syncreq.c
+++ b/daemons/ipa-slapi-plugins/ipa-pwd-extop/syncreq.c
@@ -58,10 +58,11 @@ bool sync_request_handle(Slapi_ComponentId *plugin_id, Slapi_PBlock *pb,
{
struct otptoken **tokens = NULL;
LDAPControl **controls = NULL;
+ struct berval *second = NULL;
+ struct berval *first = NULL;
BerElement *ber = NULL;
char *token_dn = NULL;
- int second = 0;
- int first = 0;
+ bool success;
if (slapi_pblock_get(pb, SLAPI_REQCONTROLS, &controls) != 0)
return false;
@@ -79,32 +80,30 @@ bool sync_request_handle(Slapi_ComponentId *plugin_id, Slapi_PBlock *pb,
return false;
/* Decode the token codes. */
- if (ber_scanf(ber, "{ii", &first, &second) == LBER_ERROR) {
+ if (ber_scanf(ber, "{OO", &first, &second) == LBER_ERROR) {
ber_free(ber, 1);
return false;
}
/* Decode the optional token DN. */
ber_scanf(ber, "a", &token_dn);
- if (ber_scanf(ber, "}") == LBER_ERROR) {
- ber_free(ber, 1);
- return false;
- }
- ber_free(ber, 1);
- /* Find all the tokens. */
- tokens = otptoken_find(plugin_id, user_dn, token_dn, true, NULL);
- ber_memfree(token_dn);
- if (tokens == NULL)
- return false;
-
- /* Synchronize the token. */
- if (!otptoken_sync(tokens, OTP_SYNC_MAX_STEPS, first, second)) {
- otptoken_free_array(tokens);
- return false;
+ /* Process the synchronization. */
+ success = false;
+ if (ber_scanf(ber, "}") != LBER_ERROR) {
+ tokens = otptoken_find(plugin_id, user_dn, token_dn, true, NULL);
+ if (tokens != NULL) {
+ success = otptoken_sync_berval(tokens, OTP_SYNC_MAX_STEPS, first, second);
+ otptoken_free_array(tokens);
+ }
}
- otptoken_free_array(tokens);
+ ber_memfree(token_dn); token_dn = NULL;
+ ber_bvfree(second);
+ ber_bvfree(first);
+ ber_free(ber, 1);
+ if (!success)
+ return false;
}
return true;