ldap_id_enum.c revision df0596ec12bc5091608371e2977f3111241e8caf
/*
SSSD
LDAP Identity Enumeration
Authors:
Simo Sorce <ssorce@redhat.com>
Copyright (C) 2009 Red Hat
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <errno.h>
#include <time.h>
#include "providers/ldap/ldap_common.h"
#include "providers/ldap/sdap_async.h"
struct tevent_context *ev,
struct sdap_id_ctx *ctx);
/* ==Enumeration-Task===================================================== */
struct tevent_timer *te,
struct tevent_timer *tt,
{
struct tevent_timer *timeout;
struct tevent_req *req;
int delay;
/* schedule starting from now, not the last run */
return;
}
if (!req) {
/* schedule starting from now, not the last run */
}
return;
}
/* if enumeration takes so long, either we try to enumerate too
* frequently, or something went seriously wrong */
/* If we can't guarantee a timeout, we
* need to cancel the request, to avoid
* the possibility of starting another
* concurrently
*/
/* schedule starting from now, not the last run */
}
return;
}
return;
}
struct tevent_timer *te,
{
struct sdap_id_ctx);
int delay;
}
{
struct sdap_id_ctx);
enum tevent_req_state tstate;
int delay;
/* On error schedule starting from now, not the last run */
tv = tevent_timeval_current();
} else {
/* Ok, we've completed an enumeration. Save this to the
* sysdb so we can postpone starting up the enumeration
* process on the next SSSD service restart (to avoid
* slowing down system boot-up
*/
/* This error is non-fatal, so continue */
}
}
}
{
struct tevent_timer *enum_task;
if (!enum_task) {
DEBUG(0, ("FATAL: failed to setup enumeration task!\n"));
return EFAULT;
}
return EOK;
}
#define MAX_ENUM_RESTARTS 3
struct global_enum_state {
struct tevent_context *ev;
struct sdap_id_ctx *ctx;
struct sdap_id_op *op;
bool purge;
};
struct tevent_context *ev,
struct sdap_id_ctx *ctx,
struct sdap_id_op *op,
bool purge);
struct tevent_context *ev,
struct sdap_id_ctx *ctx,
struct sdap_id_op *op,
bool purge);
struct sdap_id_ctx *ctx)
{
struct global_enum_state *state;
struct tevent_req *req;
int t;
return NULL;
}
} else {
}
return NULL;
}
return req;
}
{
struct global_enum_state);
struct tevent_req *subreq;
int ret;
if (!subreq) {
return ret;
}
return EOK;
}
{
struct tevent_req);
struct global_enum_state);
if (dp_error == DP_ERR_OFFLINE) {
} else {
}
return;
}
if(!subreq) {
return;
}
}
{
struct tevent_req);
struct global_enum_state);
enum tevent_req_state tstate;
if (tstate != TEVENT_REQ_USER_ERROR) {
}
}
}
/* We call sdap_id_op_done only on error
* as the connection is reused by groups enumeration */
/* retry */
return;
}
}
if (dp_error == DP_ERR_OFFLINE) {
} else {
}
return;
}
if (!subreq) {
return;
}
}
{
struct tevent_req);
struct global_enum_state);
enum tevent_req_state tstate;
if (tstate != TEVENT_REQ_USER_ERROR) {
}
}
}
/* We call sdap_id_op_done only on error
* as the connection is reused by services enumeration */
/* retry */
return;
}
}
if (dp_error == DP_ERR_OFFLINE) {
} else {
}
return;
}
}
if (!subreq) {
return;
}
}
{
int dp_error = DP_ERR_FATAL;
struct tevent_req);
struct global_enum_state);
/* All enumerations are complete, so conclude the
* id_op
*/
/* retry */
return;
}
}
if (dp_error == DP_ERR_OFFLINE) {
} else {
("Service enumeration failed with: (%d)[%s]\n",
}
return;
}
if (!subreq) {
return;
}
return;
}
}
{
struct tevent_req);
}
/* ==User-Enumeration===================================================== */
struct enum_users_state {
struct tevent_context *ev;
struct sdap_id_ctx *ctx;
struct sdap_id_op *op;
char *filter;
const char **attrs;
};
struct tevent_context *ev,
struct sdap_id_ctx *ctx,
struct sdap_id_op *op,
bool purge)
{
struct enum_users_state *state;
int ret;
bool use_mapping;
/* We always want to filter on objectclass and an available name */
"(&(objectclass=%s)(%s=*)",
("Failed to build base filter\n"));
goto fail;
}
if (use_mapping) {
/* If we're ID-mapping, check for the objectSID as well */
} else {
/* We're not ID-mapping, so make sure to only get entries
* that have UID and GID
*/
}
("Failed to build base filter\n"));
goto fail;
}
/* If we have lastUSN available and we're not doing a full
* refresh, limit to changes with a higher entryUSN value.
*/
"(%s>=%s)(!(%s=%s))",
("Failed to build base filter\n"));
goto fail;
}
}
/* Terminate the search filter */
goto fail;
}
/* TODO: handle attrs_type */
/* TODO: restrict the enumerations to using a single
* search base at a time.
*/
true);
if (!subreq) {
goto fail;
}
return req;
fail:
return req;
}
{
struct tevent_req);
struct enum_users_state);
char *usn_value;
unsigned usn_number;
int ret;
if (ret) {
return;
}
if (usn_value) {
}
}
}
/* =Group-Enumeration===================================================== */
struct enum_groups_state {
struct tevent_context *ev;
struct sdap_id_ctx *ctx;
struct sdap_id_op *op;
char *filter;
const char **attrs;
};
struct tevent_context *ev,
struct sdap_id_ctx *ctx,
struct sdap_id_op *op,
bool purge)
{
struct enum_groups_state *state;
int ret;
bool use_mapping;
/* We always want to filter on objectclass and an available name */
"(&(objectclass=%s)(%s=*)",
("Failed to build base filter\n"));
goto fail;
}
if (use_mapping) {
/* If we're ID-mapping, check for the objectSID as well */
} else {
/* We're not ID-mapping, so make sure to only get entries
* that have a non-zero GID.
*/
}
("Failed to build base filter\n"));
goto fail;
}
"(%s>=%s)(!(%s=%s))",
("Failed to build base filter\n"));
goto fail;
}
}
/* Terminate the search filter */
("Failed to build base filter\n"));
goto fail;
}
/* TODO: handle attrs_type */
/* TODO: restrict the enumerations to using a single
* search base at a time.
*/
true);
if (!subreq) {
goto fail;
}
return req;
fail:
return req;
}
{
struct tevent_req);
struct enum_groups_state);
char *usn_value;
unsigned usn_number;
int ret;
if (ret) {
return;
}
if (usn_value) {
}
}
}