/*
SSSD
LDAP Enumeration Module
Authors:
Simo Sorce <ssorce@redhat.com>
Jakub Hrozek <jhrozek@redhat.com>
Copyright (C) 2013 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 "providers/ldap/ldap_common.h"
#include "providers/ldap/sdap_async.h"
#include "providers/ldap/sdap_async_enum.h"
#include "providers/ldap/sdap_idmap.h"
struct tevent_context *ev,
struct sdap_id_ctx *ctx,
struct sdap_domain *sdom,
struct sdap_id_op *op,
bool purge);
struct tevent_context *ev,
struct sdap_id_ctx *ctx,
struct sdap_domain *sdom,
struct sdap_id_op *op,
bool purge);
/* ==Enumeration-Request-with-connections=================================== */
struct sdap_dom_enum_ex_state {
bool purge;
};
struct sdap_id_op *op,
struct tevent_req *
struct tevent_context *ev,
struct sdap_id_ctx *ctx,
struct sdap_domain *sdom,
struct sdap_id_conn_ctx *user_conn,
struct sdap_id_conn_ctx *group_conn,
struct sdap_id_conn_ctx *svc_conn)
{
int t;
}
goto fail;
}
goto fail;
}
return req;
fail:
return req;
}
struct sdap_id_op *op,
{
struct sdap_dom_enum_ex_state);
"sdap_id_op_connect_send failed: %d\n", ret);
return ret;
}
return EOK;
}
{
int dp_error;
struct tevent_req);
if (dp_error == DP_ERR_OFFLINE) {
"Backend is marked offline, retry later!\n");
} else {
"Domain enumeration failed to connect to " \
}
return false;
}
return true;
}
{
struct tevent_req);
struct sdap_dom_enum_ex_state);
bool use_id_mapping;
if (sdap_dom_enum_ex_connected(subreq) == false) {
return;
}
/* If POSIX attributes have been requested with an AD server and we
* have no idea about POSIX attributes support, run a one-time check
*/
true)) {
return;
}
return;
}
return;
}
/* Execution resumes in sdap_dom_enum_ex_users_done */
}
{
bool has_posix;
int dp_error;
struct tevent_req);
struct sdap_dom_enum_ex_state);
/* We can only finish the id_op on error as the connection
* is re-used by the user search
*/
/* retry */
}
return;
} else if (dp_error == DP_ERR_OFFLINE) {
return;
} else {
/* Non-recoverable error */
return;
}
}
/* If the check ran to completion, we know for certain about the attributes
*/
if (has_posix == false) {
return;
}
return;
}
/* Execution resumes in sdap_dom_enum_ex_users_done */
}
{
struct sdap_dom_enum_ex_state);
return ENOMEM;
}
return EOK;
}
{
struct tevent_req);
struct sdap_dom_enum_ex_state);
int dp_error;
/* retry */
return;
}
return;
} else if (dp_error == DP_ERR_OFFLINE) {
return;
/* Non-recoverable error */
return;
}
return;
}
return;
}
/* Continues to sdap_dom_enum_ex_get_groups */
}
{
struct tevent_req);
struct sdap_dom_enum_ex_state);
if (sdap_dom_enum_ex_connected(subreq) == false) {
return;
}
return;
}
}
{
struct tevent_req);
struct sdap_dom_enum_ex_state);
int ret;
int dp_error;
/* retry */
return;
}
return;
} else if (dp_error == DP_ERR_OFFLINE) {
return;
/* Non-recoverable error */
return;
}
return;
}
return;
}
}
{
struct tevent_req);
struct sdap_dom_enum_ex_state);
if (sdap_dom_enum_ex_connected(subreq) == false) {
return;
}
if (!subreq) {
return;
}
}
{
struct tevent_req);
struct sdap_dom_enum_ex_state);
int ret;
int dp_error;
/* retry */
return;
}
return;
} else if (dp_error == DP_ERR_OFFLINE) {
return;
/* Non-recoverable error */
return;
}
/* 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
*/
"Could not mark domain as having enumerated.\n");
/* This error is non-fatal, so continue */
}
/* Not fatal, worst case we'll have stale entries that would be
* removed on a subsequent online lookup
*/
}
}
}
{
return EOK;
}
/* ==Enumeration-Request==================================================== */
struct tevent_req *
struct tevent_context *ev,
struct sdap_id_ctx *ctx,
struct sdap_domain *sdom,
struct sdap_id_conn_ctx *conn)
{
}
{
return sdap_dom_enum_ex_recv(req);
}
/* ==User-Enumeration===================================================== */
struct enum_users_state {
char *filter;
const char **attrs;
};
struct tevent_context *ev,
struct sdap_id_ctx *ctx,
struct sdap_domain *sdom,
struct sdap_id_op *op,
bool purge)
{
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: restrict the enumerations to using a single
* search base at a time.
*/
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) {
}
}
}
{
return EOK;
}
/* =Group-Enumeration===================================================== */
struct enum_groups_state {
char *filter;
const char **attrs;
};
struct tevent_context *ev,
struct sdap_id_ctx *ctx,
struct sdap_domain *sdom,
struct sdap_id_op *op,
bool purge)
{
int ret;
bool use_mapping;
bool non_posix = false;
char *oc_list;
non_posix = true;
}
/* We always want to filter on objectclass and an available name */
goto fail;
}
"Failed to build base filter\n");
goto fail;
}
if (!non_posix && 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: restrict the enumerations to using a single
* search base at a time.
*/
SDAP_LOOKUP_ENUMERATE, false);
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) {
}
}
}
{
return EOK;
}