summaryrefslogtreecommitdiff
path: root/src/providers/ldap/ldap_id_enum.c
diff options
context:
space:
mode:
authorJan Zeleny <jzeleny@redhat.com>2011-04-29 09:45:10 -0400
committerStephen Gallagher <sgallagh@redhat.com>2011-05-04 10:14:40 -0400
commit772764e048dcd15c6d9732574126eb83b53a60e2 (patch)
tree46763c6dbe81436742c9439a3ccd42bb70e3d201 /src/providers/ldap/ldap_id_enum.c
parentd3750f3c3a9e232629c8b634b7b5407114667700 (diff)
downloadsssd-772764e048dcd15c6d9732574126eb83b53a60e2.tar.gz
sssd-772764e048dcd15c6d9732574126eb83b53a60e2.tar.bz2
sssd-772764e048dcd15c6d9732574126eb83b53a60e2.zip
Fixed lastUSN checking improvements
This patch fixes some issues with setting lastUSN attribute and it adds check against the highest user/group USN after enumeration to keep better track of the real highest USN. Optimal solution here would be to schedule a check of rootDSE entry right after the enumeration finishes, but for the moment this is good enough.
Diffstat (limited to 'src/providers/ldap/ldap_id_enum.c')
-rw-r--r--src/providers/ldap/ldap_id_enum.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/providers/ldap/ldap_id_enum.c b/src/providers/ldap/ldap_id_enum.c
index d7dd33e4..68d113bf 100644
--- a/src/providers/ldap/ldap_id_enum.c
+++ b/src/providers/ldap/ldap_id_enum.c
@@ -511,6 +511,8 @@ static void enum_users_op_done(struct tevent_req *subreq)
struct enum_users_state *state = tevent_req_data(req,
struct enum_users_state);
char *usn_value;
+ char *endptr = NULL;
+ unsigned usn_number;
int ret;
ret = sdap_get_users_recv(subreq, state, &usn_value);
@@ -523,6 +525,12 @@ static void enum_users_op_done(struct tevent_req *subreq)
if (usn_value) {
talloc_zfree(state->ctx->srv_opts->max_user_value);
state->ctx->srv_opts->max_user_value = talloc_steal(state->ctx, usn_value);
+
+ usn_number = strtoul(usn_value, &endptr, 10);
+ if ((endptr == NULL || (*endptr == '\0' && endptr != usn_value))
+ && (usn_number > state->ctx->srv_opts->last_usn)) {
+ state->ctx->srv_opts->last_usn = usn_number;
+ }
}
DEBUG(4, ("Users higher USN value: [%s]\n",
@@ -629,6 +637,8 @@ static void enum_groups_op_done(struct tevent_req *subreq)
struct enum_groups_state *state = tevent_req_data(req,
struct enum_groups_state);
char *usn_value;
+ char *endptr = NULL;
+ unsigned usn_number;
int ret;
ret = sdap_get_groups_recv(subreq, state, &usn_value);
@@ -642,6 +652,11 @@ static void enum_groups_op_done(struct tevent_req *subreq)
talloc_zfree(state->ctx->srv_opts->max_group_value);
state->ctx->srv_opts->max_group_value =
talloc_steal(state->ctx, usn_value);
+ usn_number = strtoul(usn_value, &endptr, 10);
+ if ((endptr == NULL || (*endptr == '\0' && endptr != usn_value))
+ && (usn_number > state->ctx->srv_opts->last_usn)) {
+ state->ctx->srv_opts->last_usn = usn_number;
+ }
}
DEBUG(4, ("Groups higher USN value: [%s]\n",