From b776f0af14866051ab9dcdb696345643424261d5 Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Tue, 18 Aug 2009 15:55:03 -0400 Subject: Ensure nextID doesn't reuse an existing local UID or GID If there was no maxID set for a domain, the search filter to check whether the UID was available would always return empty (because no UIDs can be <= 0) This patch changes the search filter if the maxID is unset so that it has no upper limit --- server/db/sysdb_ops.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'server/db/sysdb_ops.c') diff --git a/server/db/sysdb_ops.c b/server/db/sysdb_ops.c index 687c754f6..e62711a2e 100644 --- a/server/db/sysdb_ops.c +++ b/server/db/sysdb_ops.c @@ -1334,15 +1334,27 @@ static void sysdb_get_new_id_base(struct tevent_req *subreq) /* verify the id is actually really free. * search all entries with id >= new_id and < max_id */ - filter = talloc_asprintf(state, - "(|(&(%s>=%u)(%s<=%u))(&(%s>=%u)(%s<=%u)))", - SYSDB_UIDNUM, state->new_id, - SYSDB_UIDNUM, state->domain->id_max, - SYSDB_GIDNUM, state->new_id, - SYSDB_GIDNUM, state->domain->id_max); - if (!filter) { - tevent_req_error(req, ENOMEM); - return; + if (state->domain->id_max) { + filter = talloc_asprintf(state, + "(|(&(%s>=%u)(%s<=%u))(&(%s>=%u)(%s<=%u)))", + SYSDB_UIDNUM, state->new_id, + SYSDB_UIDNUM, state->domain->id_max, + SYSDB_GIDNUM, state->new_id, + SYSDB_GIDNUM, state->domain->id_max); + if (!filter) { + tevent_req_error(req, ENOMEM); + return; + } + } + else { + filter = talloc_asprintf(state, + "(|(%s>=%u)(%s>=%u))", + SYSDB_UIDNUM, state->new_id, + SYSDB_GIDNUM, state->new_id); + if (!filter) { + tevent_req_error(req, ENOMEM); + return; + } } ret = ldb_build_search_req(&ldbreq, state->handle->ctx->ldb, state, -- cgit