ipa_s2n_exop.c revision 3d29430867cf92b2d71afa95abb679711231117c
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina IPA Helper routines - external users and groups with s2n plugin
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina Copyright (C) Sumit Bose <sbose@redhat.com> - 2011
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina This program is free software; you can redistribute it and/or modify
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina it under the terms of the GNU General Public License as published by
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina the Free Software Foundation; either version 3 of the License, or
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina (at your option) any later version.
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina This program is distributed in the hope that it will be useful,
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina but WITHOUT ANY WARRANTY; without even the implied warranty of
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina GNU General Public License for more details.
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina You should have received a copy of the GNU General Public License
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina along with this program. If not, see <http://www.gnu.org/licenses/>.
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina/* ==Sid2Name Extended Operation============================================= */
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březinastatic void ipa_s2n_exop_done(struct sdap_op *op,
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březinastatic struct tevent_req *ipa_s2n_exop_send(TALLOC_CTX *mem_ctx,
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina req = tevent_req_create(mem_ctx, &state, struct ipa_s2n_exop_state);
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina DEBUG(SSSDBG_TRACE_FUNC, "Executing extended operation\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina ret = ldap_extended_operation(state->sh->ldap,
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina is_v1 ? EXOP_SID2NAME_V1_OID : EXOP_SID2NAME_OID,
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "ldap_extended_operation failed\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina DEBUG(SSSDBG_TRACE_INTERNAL, "ldap_extended_operation sent, msgid = %d\n",
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina ret = sdap_op_add(state, ev, state->sh, msgid, ipa_s2n_exop_done, req,
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Failed to set up operation!\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březinastatic void ipa_s2n_exop_done(struct sdap_op *op,
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina struct tevent_req *req = talloc_get_type(pvt, struct tevent_req);
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina struct ipa_s2n_exop_state *state = tevent_req_data(req,
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina ret = ldap_parse_result(state->sh->ldap, reply->msg,
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina DEBUG(SSSDBG_OP_FAILURE, "ldap_parse_result failed (%d)\n",
goto done;
ret);
goto done;
goto done;
goto done;
goto done;
goto done;
done:
struct ipa_s2n_exop_state);
return EOK;
int ret;
goto done;
goto done;
goto done;
done:
return ret;
const char *domain_name,
int entry_type,
int ret;
return ENOMEM;
switch (entry_type) {
case BE_REQ_USER:
goto done;
case BE_REQ_GROUP:
goto done;
case BE_REQ_BY_SECID:
goto done;
case BE_REQ_BY_CERT:
goto done;
goto done;
goto done;
goto done;
done:
return ret;
struct resp_attrs {
char *domain_name;
char *sid_str;
char *name;
char **groups;
char *ber_cookie;
char *name;
struct ldb_val v;
int ret;
size_t c;
return ENOMEM;
return EINVAL;
return EINVAL;
return EINVAL;
return ret;
return EOK;
int ret;
goto done;
goto done;
goto done;
goto done;
goto done;
goto done;
return ENOMEM;
goto done;
gc++;
goto done;
done:
return ret;
int ret;
goto done;
goto done;
goto done;
mc++;
goto done;
goto done;
done:
return ret;
const char *view_name,
bool update_initgr_timeout);
char *retoid,
int ret;
char *sid_str;
bool is_v1 = false;
return EINVAL;
is_v1 = true;
is_v1 = false;
return EINVAL;
return EINVAL;
goto done;
goto done;
switch (type) {
case RESP_USER:
case RESP_USER_GROUPLIST:
goto done;
goto done;
goto done;
goto done;
goto done;
case RESP_GROUP:
case RESP_GROUP_MEMBERS:
goto done;
goto done;
goto done;
goto done;
goto done;
case RESP_SID:
goto done;
goto done;
case RESP_NAME:
goto done;
goto done;
type);
goto done;
goto done;
done:
return ret;
struct ipa_s2n_get_list_state {
char **list;
int exop_timeout;
int entry_type;
int exop_timeout,
int entry_type,
char **list)
int ret;
return NULL;
goto done;
goto done;
done:
return req;
int ret;
struct ipa_s2n_get_list_state);
char *endptr;
bool need_v1 = false;
case REQ_INP_NAME:
return ret;
if (domain_name) {
domain_name, true);
return ENOMEM;
case REQ_INP_ID:
errno = 0;
return EINVAL;
case REQ_INP_SECID:
return EINVAL;
return EINVAL;
return ret;
need_v1 = true;
return ENOMEM;
return EOK;
int ret;
struct tevent_req);
struct ipa_s2n_get_list_state);
const char *sid_str;
goto fail;
goto fail;
goto fail;
&sid_str);
goto fail;
goto fail;
ar);
goto fail;
fail:
int ret;
struct tevent_req);
struct ipa_s2n_get_list_state);
goto fail;
goto fail;
fail:
int ret;
struct ipa_s2n_get_list_state);
return ret;
return EOK;
return ret;
return EAGAIN;
return EOK;
struct ipa_s2n_get_user_state {
int entry_type;
int exop_timeout;
int entry_type,
bool is_v1 = false;
return NULL;
is_v1 = true;
is_v1 = false;
goto fail;
goto fail;
goto fail;
return req;
fail:
return req;
char **members,
int ret;
size_t c;
const char *dn_str;
return EOK;
return ENOMEM;
goto done;
goto done;
&msg);
goto done;
dn_str);
goto done;
members[c]);
members[c]);
goto done;
members[c]);
goto done;
miss_count++;
goto done;
if (miss_count == 0) {
goto done;
done:
return ret;
char ***_missing_groups)
int ret;
size_t c;
return ENOMEM;
goto done;
for (c = 0; c < ngroups; c++) {
goto done;
&msg);
goto done;
n_dns++;
groups[c]);
goto done;
n_missing++;
goto done;
if (n_missing != 0) {
if (n_dns != 0) {
done:
return ret;
struct tevent_req);
struct ipa_s2n_get_user_state);
int ret;
const char *sid_str;
goto done;
case REQ_FULL_WITH_MEMBERS:
case REQ_FULL:
&attrs);
goto done;
goto done;
goto done;
goto done;
req);
goto done;
goto done;
req);
&bv_req);
goto done;
goto done;
case REQ_SIMPLE:
goto done;
goto done;
goto done;
&sid_str);
goto done;
goto done;
ar);
goto done;
req);
goto done;
done:
int ret;
char **dn_list;
return EOK;
return ENOMEM;
goto done;
goto done;
goto done;
done:
return ret;
const char *view_name,
bool update_initgr_timeout)
int ret;
char *realm;
const char *sid_str;
const char *tmp_str;
char **sysdb_grouplist;
char **add_groups;
char **add_groups_dns;
char **del_groups;
char **del_groups_dns;
bool in_transaction = false;
int tret;
return ENOMEM;
goto done;
goto done;
goto done;
tmp_str);
goto done;
goto done;
goto done;
goto done;
goto done;
case RESP_USER:
case RESP_USER_GROUPLIST:
&homedir_ctx);
goto done;
goto done;
if (!realm) {
goto done;
if (!upn) {
goto done;
upn);
goto done;
goto done;
goto done;
&& update_initgr_timeout) {
goto done;
gid = 0;
&orig_gid);
goto done;
goto done;
goto done;
goto done;
in_transaction = true;
goto done;
goto done;
goto done;
goto done;
goto done;
goto done;
goto done;
goto done;
goto done;
name);
(const char *const *) add_groups_dns,
(const char *const *) del_groups_dns);
goto done;
goto done;
in_transaction = false;
case RESP_GROUP:
case RESP_GROUP_MEMBERS:
goto done;
goto done;
goto done;
goto done;
now);
goto done;
goto done;
goto done;
goto done;
goto done;
done:
if (in_transaction) {
return ret;
int ret;
struct tevent_req);
struct ipa_s2n_get_user_state);
const char *sid_str;
&sid_str);
goto fail;
goto fail;
goto fail;
ar);
goto fail;
req);
fail:
int ret;
struct tevent_req);
struct ipa_s2n_get_user_state);
override_attrs, true);
return EOK;
char *username;
char **missing_sids;
char **cached_groups;
int ret;
char *user_sid;
char *primary_group_sid;
char **group_sids;
return NULL;
goto done;
goto done;
goto done;
goto done;
return req;
done:
return req;
int ret;
struct tevent_req);
char **cached_groups;
/* from ad_pac.c */
goto done;
goto done;
goto done;
done:
return EOK;