diff options
author | Simo Sorce <ssorce@redhat.com> | 2009-09-10 12:43:42 -0400 |
---|---|---|
committer | Simo Sorce <ssorce@redhat.com> | 2009-09-11 17:16:06 -0400 |
commit | ec56fb826b20b080bbfaf09da671d24faf6c5e88 (patch) | |
tree | 198c926b2d4420f7da0fca3d2a28933c350fc805 /server/db | |
parent | b187d74a6d6e4e0c1102b510f7fc8340d41ae30a (diff) | |
download | sssd-ec56fb826b20b080bbfaf09da671d24faf6c5e88.tar.gz sssd-ec56fb826b20b080bbfaf09da671d24faf6c5e88.tar.bz2 sssd-ec56fb826b20b080bbfaf09da671d24faf6c5e88.zip |
Complete the removal of "legacy" option.
The code was still dependent on it for the ldap driver.
Changed the driver code to depend on the schema type.
Fix defaults for user and groups trees.
ATM if you use the rfc2307bis schema you have to put users and groups
in 2 separate trees (what people does by default anyway.
If this limitation will turn to be too hard, we will change this later.
Diffstat (limited to 'server/db')
-rw-r--r-- | server/db/sysdb.c | 5 | ||||
-rw-r--r-- | server/db/sysdb.h | 6 | ||||
-rw-r--r-- | server/db/sysdb_ops.c | 72 |
3 files changed, 44 insertions, 39 deletions
diff --git a/server/db/sysdb.c b/server/db/sysdb.c index d4f25797..87d0de96 100644 --- a/server/db/sysdb.c +++ b/server/db/sysdb.c @@ -47,6 +47,11 @@ struct ldb_context *sysdb_ctx_get_ldb(struct sysdb_ctx *ctx) return ctx->ldb; } +struct ldb_context *sysdb_handle_get_ldb(struct sysdb_handle *handle) +{ + return handle->ctx->ldb; +} + struct sysdb_attrs *sysdb_new_attrs(TALLOC_CTX *memctx) { return talloc_zero(memctx, struct sysdb_attrs); diff --git a/server/db/sysdb.h b/server/db/sysdb.h index 2d8b3eae..9afb957f 100644 --- a/server/db/sysdb.h +++ b/server/db/sysdb.h @@ -177,6 +177,9 @@ struct ldb_dn *sysdb_group_dn(struct sysdb_ctx *ctx, void *memctx, struct ldb_dn *sysdb_domain_dn(struct sysdb_ctx *ctx, void *memctx, const char *domain); +struct ldb_context *sysdb_ctx_get_ldb(struct sysdb_ctx *ctx); +struct ldb_context *sysdb_handle_get_ldb(struct sysdb_handle *handle); + /* function to start and finish a transaction * sysdb_transaction_send() will queue a request for a transaction * when it is done it will call the tevent_req callback, which must @@ -477,7 +480,8 @@ struct tevent_req *sysdb_store_group_send(TALLOC_CTX *mem_ctx, struct sss_domain_info *domain, const char *name, gid_t gid, - const char **members, + const char **member_users, + const char **member_groups, struct sysdb_attrs *attrs); int sysdb_store_group_recv(struct tevent_req *req); diff --git a/server/db/sysdb_ops.c b/server/db/sysdb_ops.c index 57705275..3a53c9e5 100644 --- a/server/db/sysdb_ops.c +++ b/server/db/sysdb_ops.c @@ -2771,7 +2771,8 @@ struct sysdb_store_group_state { const char *name; gid_t gid; - const char **members; + const char **member_users; + const char **member_groups; struct sysdb_attrs *attrs; }; @@ -2786,7 +2787,8 @@ struct tevent_req *sysdb_store_group_send(TALLOC_CTX *mem_ctx, struct sss_domain_info *domain, const char *name, gid_t gid, - const char **members, + const char **member_users, + const char **member_groups, struct sysdb_attrs *attrs) { struct tevent_req *req, *subreq; @@ -2803,7 +2805,8 @@ struct tevent_req *sysdb_store_group_send(TALLOC_CTX *mem_ctx, state->domain = domain; state->name = name; state->gid = gid; - state->members = members; + state->member_users = member_users; + state->member_groups = member_groups; state->attrs = attrs; subreq = sysdb_search_group_by_name_send(state, ev, NULL, handle, @@ -2845,7 +2848,7 @@ static void sysdb_store_group_check(struct tevent_req *subreq) /* FIXME: use the remote modification timestamp to know if the * group needs any update */ - if (state->members) { + if (state->member_users || state->member_groups) { if (!state->attrs) { state->attrs = sysdb_new_attrs(state); if (!state->attrs) { @@ -2855,49 +2858,42 @@ static void sysdb_store_group_check(struct tevent_req *subreq) } } - for (i = 0; state->members[i]; i++) { - struct ldb_dn *tmp = NULL; - const struct ldb_val *val; - const char *mname; + for (i = 0; state->member_users && state->member_users[i]; i++) { char *member; - if (state->domain->legacy) { - mname = state->members[i]; - } else { - - tmp = ldb_dn_new(state, state->handle->ctx->ldb, - state->members[i]); - if (!tmp) { - DEBUG(2, ("Out of memory, converting DN [%s]!\n", - state->members[i])); - continue; - } - val = ldb_dn_get_rdn_val(tmp); - if (!val) { - DEBUG(2, ("Out of memory, converting DN [%s]!\n", - state->members[i])); - continue; - } - mname = talloc_strndup(tmp, - (const char *)val->data, val->length); - if (!mname) { - DEBUG(2, ("Out of memory, converting DN [%s]!\n", - state->members[i])); - continue; - } - } - member = talloc_asprintf(state, SYSDB_TMPL_USER, - mname, state->domain->name); + state->member_users[i], + state->domain->name); if (!member) { DEBUG(6, ("Error: Out of memory\n")); tevent_req_error(req, ENOMEM); return; } - DEBUG(9, ("adding member: %s [orig: %s] to group %s\n", - member, state->members[i], state->name)); + DEBUG(9, ("adding member: %s to group %s\n", + member, state->name)); + + ret = sysdb_attrs_steal_string(state->attrs, + SYSDB_MEMBER, member); + if (ret) { + DEBUG(6, ("Error: %d (%s)\n", ret, strerror(ret))); + tevent_req_error(req, ret); + return; + } + } - talloc_zfree(tmp); + for (i = 0; state->member_groups && state->member_groups[i]; i++) { + char *member; + + member = talloc_asprintf(state, SYSDB_TMPL_GROUP, + state->member_users[i], + state->domain->name); + if (!member) { + DEBUG(6, ("Error: Out of memory\n")); + tevent_req_error(req, ENOMEM); + return; + } + DEBUG(9, ("adding member: %s to group %s\n", + member, state->name)); ret = sysdb_attrs_steal_string(state->attrs, SYSDB_MEMBER, member); |