sdap_async_initgroups.c revision 1c386aa2c11d1bdbb3f42f722ec4599ce9f278c8
b4c47b77878eb0eaaeb1e377de936a77fad4d144Aki Tuomi Async LDAP Helper routines - initgroups operation
24fed8aca238e6878aa9c85c82e83a0a7ee3ced3Timo Sirainen Copyright (C) Simo Sorce <ssorce@redhat.com> - 2009
a7c6667c80d7363f5110ec1ab1ae9198833411d3Timo Sirainen Copyright (C) 2010, Ralf Haferkamp <rhafer@suse.de>, Novell Inc.
32f02789693d38b5470f0406bda0cbdf6fc1560eTimo Sirainen Copyright (C) Jan Zeleny <jzeleny@redhat.com> - 2011
32f02789693d38b5470f0406bda0cbdf6fc1560eTimo Sirainen This program is free software; you can redistribute it and/or modify
a7c6667c80d7363f5110ec1ab1ae9198833411d3Timo Sirainen it under the terms of the GNU General Public License as published by
285bfe946c2d54928b272270dd5eef9041b24271Timo Sirainen the Free Software Foundation; either version 3 of the License, or
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomi (at your option) any later version.
32f02789693d38b5470f0406bda0cbdf6fc1560eTimo Sirainen This program is distributed in the hope that it will be useful,
78919bf7cb55e84e5f289f33526579f63c4797d7Timo Sirainen but WITHOUT ANY WARRANTY; without even the implied warranty of
379175cfba8150d481d9898b78330b719d128d84Timo Sirainen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32f02789693d38b5470f0406bda0cbdf6fc1560eTimo Sirainen GNU General Public License for more details.
a7c6667c80d7363f5110ec1ab1ae9198833411d3Timo Sirainen You should have received a copy of the GNU General Public License
792813592c69ddc0389b6f071d8120a7706b914dStephan Bosch along with this program. If not, see <http://www.gnu.org/licenses/>.
ed77b0bf3a094fff279804e4f50ec0799680342fTimo Sirainen/* ==Save-fake-group-list=====================================*/
8b7e479f8d3d43eb8b98932a562dd5330b0d02bdTimo Sirainenstatic errno_t sdap_add_incomplete_groups(struct sysdb_ctx *sysdb,
a7c6667c80d7363f5110ec1ab1ae9198833411d3Timo Sirainen /* There are no groups in LDAP but we should add user to groups ?? */
52cb31b413be19de11cdf9ad84b9ccde7740b5cfTimo Sirainen missing = talloc_array(tmp_ctx, char *, ldap_groups_count+1);
a6ab8f00351265e35b79f3a22b1f5a4978ae5c35Timo Sirainen DEBUG(1, ("Cannot start sysdb transaction [%d]: %s\n",
in_transaction = true;
for (i=0; groupnames[i]; i++) {
i, groupnames[i]));
mi++;
goto fail;
if (mi == 0) {
goto done;
for (i=0; missing[i]; i++) {
&name);
goto fail;
posix = true;
&gid);
gid = 0;
posix = false;
} else if (ret) {
goto fail;
&original_dn);
if (ret) {
goto fail;
goto fail;
done:
goto fail;
in_transaction = false;
fail:
if (in_transaction) {
return ret;
const char *name,
char **sysdb_grouplist,
int ldap_groups_count)
char **add_groups;
char **del_groups;
bool in_transaction = false;
if (ldap_groups_count == 0) {
goto done;
goto done;
in_transaction = true;
goto done;
(const char *const *) add_groups,
(const char *const *) del_groups);
goto done;
goto done;
in_transaction = false;
done:
if (in_transaction) {
return ret;
struct sdap_initgr_rfc2307_state {
const char **attrs;
const char *name;
const char *base_filter;
const char *orig_dn;
char *filter;
int timeout;
const char *name)
char *clean_name;
goto done;
return NULL;
return NULL;
return NULL;
return NULL;
done:
return req;
return ENOMEM;
if (!subreq) {
return ENOMEM;
return EOK;
int ret;
if (ret) {
if (count > 0) {
struct sysdb_attrs *,
for (i = 0; i < count; i++) {
if (!sysdb_grouplist) {
&sysdb_grouplist[i]);
return EOK;
static errno_t
unsigned long count)
bool in_transaction = false;
if (count > 0) {
goto done;
goto done;
in_transaction = true;
goto done;
goto done;
in_transaction = false;
done:
if (in_transaction) {
return ret;
struct membership_diff {
const char *name;
char **add;
char **del;
static errno_t
char **add_groups;
char **del_groups;
if (!tmp_ctx) {
goto done;
if (!mdiff) {
goto done;
goto done;
goto done;
done:
return ret;
struct sdap_initgr_nested_state {
const char *username;
const char *orig_dn;
const char **grp_attrs;
char *filter;
char **group_dns;
int cur;
int groups_cur;
const char **grp_attrs)
int deref_threshold;
goto immediate;
goto immediate;
goto immediate;
return req;
return req;
return ENOMEM;
return ENOMEM;
return ENOMEM;
if (!subreq) {
return ENOMEM;
return EAGAIN;
const char **sdap_attrs;
int timeout;
if (!subreq) {
goto fail;
return EAGAIN;
fail:
return ret;
size_t i;
&deref_result);
for (i=0; i < num_results; i++) {
int ret;
if (ret) {
groups[0]);
if (!subreq) {
static errno_t
static errno_t
static errno_t
bool in_transaction = false;
goto fail;
in_transaction = true;
goto fail;
goto fail;
goto fail;
goto fail;
in_transaction = false;
fail:
if (in_transaction) {
static errno_t
static errno_t
int groups_count,
int ngroups,
int *_ndirect);
static errno_t
int i, tret;
bool in_transaction = false;
&miter);
if (ret) {
goto done;
goto done;
in_transaction = true;
goto done;
goto done;
in_transaction = false;
done:
if (in_transaction) {
return ret;
static errno_t
int tret;
const char *orig_dn;
int nparents;
int i, mi;
char **add_groups;
char **del_groups;
bool in_transaction = false;
if (!tmp_ctx) {
goto done;
goto done;
if (!ldap_parentlist) {
goto done;
nparents = 0;
if (ret) {
goto done;
nparents++;
if (nparents == 0) {
goto done;
if (ret) {
goto done;
goto done;
goto done;
in_transaction = true;
(const char *const *) add_groups,
(const char *const *) del_groups);
goto done;
goto done;
in_transaction = false;
done:
if (in_transaction) {
return ret;
static errno_t
int groups_count,
const char *group_name;
int parents_count;
if (!tmp_ctx) {
goto done;
&group_name);
goto done;
if (ret) {
goto done;
goto done;
if (parents_count > 0) {
goto done;
goto done;
done:
return ret;
int ngroups,
int *_ndirect)
int i, mi;
int ret;
const char *orig_dn;
int ndirect;
if (!direct_groups) {
goto done;
ndirect = 0;
goto done;
for (i=0; i < ngroups; i++) {
if (ret) {
ndirect++;
done:
return ret;
return EOK;
struct sdap_initgr_rfc2307bis_state {
const char *name;
const char *base_filter;
char *filter;
const char **attrs;
const char *orig_dn;
int timeout;
struct sdap_nested_group {
const char *name,
const char *orig_dn)
char *clean_orig_dn;
goto done;
return NULL;
goto done;
done:
return req;
return ENOMEM;
if (!subreq) {
return ENOMEM;
return EOK;
size_t i;
int ret;
&count,
&ldap_groups);
if (ret) {
if (count > 0) {
struct sysdb_attrs *,
for (i = 0; i < count; i++) {
if (!subreq) {
static errno_t
static errno_t
bool in_transaction = false;
goto fail;
in_transaction = true;
goto fail;
goto fail;
goto fail;
goto fail;
in_transaction = false;
fail:
if (in_transaction) {
return EOK;
struct rfc2307bis_group_memberships_state {
int ret;
static errno_t
unsigned long count;
int hret, i;
goto done;
if (!groups) {
goto done;
for (i = 0; i < count; i++) {
struct sdap_nested_group);
goto done;
done:
return ret;
static errno_t
int hret;
bool in_transaction = false;
struct rfc2307bis_group_memberships_state);
if (!membership_state) {
goto done;
goto done;
goto done;
in_transaction = true;
goto done;
goto done;
in_transaction = false;
done:
if (in_transaction) {
return ret;
char *group_name;
char **sysdb_parents_names_list;
if (!tmp_ctx) {
goto done;
if (ret) {
goto done;
goto done;
goto done;
done:
char **ldap_grouplist;
char **sysdb_parent_name_list;
char **add_groups;
char **del_groups;
bool in_transaction = false;
if(!tmp_ctx) {
return ENOMEM;
goto error;
in_transaction = true;
if (ret) {
goto error;
goto error;
goto error;
(const char *const *)add_groups,
(const char *const *)del_groups);
goto error;
goto error;
in_transaction = false;
return EOK;
if (in_transaction) {
return ret;
struct sdap_rfc2307bis_nested_ctx {
int timeout;
const char *base_filter;
char *filter;
const char *orig_dn;
const char **attrs;
const char *primary_name;
struct sdap_rfc2307bis_nested_ctx);
if ((num_groups == 0) ||
return req;
goto done;
struct sdap_nested_group *,
goto done;
done:
return req;
char *clean_orig_dn;
if (!tmp_ctx) {
goto done;
goto done;
goto done;
goto done;
goto done;
goto done;
goto done;
goto done;
goto done;
done:
return ret;
return ENOMEM;
if (!subreq) {
return ENOMEM;
req);
return EOK;
size_t i;
int hret;
&count,
&ldap_groups);
if (ret) {
if (count > 0) {
struct sysdb_attrs *,
for (i = 0; i < count; i++) {
if (!subreq) {
return EOK;
struct sdap_get_initgr_state {
const char *name;
const char **grp_attrs;
const char **user_attrs;
const char *user_base_filter;
char *filter;
int timeout;
const char *name,
const char **grp_attrs)
int ret;
char *clean_name;
goto done;
return NULL;
return NULL;
if (ret) {
return NULL;
done:
return req;
return ENOMEM;
if (!subreq) {
return ENOMEM;
return EOK;
const char *name,
const char *orig_dn);
struct tevent_req);
struct sdap_get_initgr_state);
int ret;
const char *orig_dn;
const char *cname;
if (ret) {
if (count == 0) {
if (ret) {
true, NULL, 0);
if (ret) {
if (ret) {
case SDAP_SCHEMA_RFC2307:
cname);
if (!subreq) {
case SDAP_SCHEMA_RFC2307BIS:
&orig_dn);
if (!subreq) {
case SDAP_SCHEMA_IPA_V1:
case SDAP_SCHEMA_AD:
if (!subreq) {
struct tevent_req);
struct sdap_get_initgr_state);
int ret;
char *gid;
case SDAP_SCHEMA_RFC2307:
case SDAP_SCHEMA_RFC2307BIS:
case SDAP_SCHEMA_IPA_V1:
case SDAP_SCHEMA_AD:
if (ret) {
if (!subreq) {
return EOK;