diff options
author | bubulle <bubulle@alioth.debian.org> | 2011-11-12 13:00:54 +0000 |
---|---|---|
committer | bubulle <bubulle@alioth.debian.org> | 2011-11-12 13:00:54 +0000 |
commit | 6fba685eec3a1165ec0b82d72d3ae71e946a1404 (patch) | |
tree | f3c0543c8f9df4a22ed62e3bd99d9d7bc1054c14 /source4/dsdb/samdb/samdb_privilege.c | |
parent | 77a7925c0509068d5cd2affd94a3996d0a86035a (diff) | |
download | samba-6fba685eec3a1165ec0b82d72d3ae71e946a1404.tar.gz |
Merge upstream 3.6.1 source
git-svn-id: svn://svn.debian.org/svn/pkg-samba/trunk/samba@3972 fc4039ab-9d04-0410-8cac-899223bdd6b0
Diffstat (limited to 'source4/dsdb/samdb/samdb_privilege.c')
-rw-r--r-- | source4/dsdb/samdb/samdb_privilege.c | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/source4/dsdb/samdb/samdb_privilege.c b/source4/dsdb/samdb/samdb_privilege.c index e9c6f4c527..c50243c06a 100644 --- a/source4/dsdb/samdb/samdb_privilege.c +++ b/source4/dsdb/samdb/samdb_privilege.c @@ -26,24 +26,34 @@ #include "libcli/security/security.h" #include "../lib/util/util_ldb.h" #include "param/param.h" +#include "ldb_wrap.h" + +/* connect to the privilege database */ +struct ldb_context *privilege_connect(TALLOC_CTX *mem_ctx, + struct loadparm_context *lp_ctx) +{ + return ldb_wrap_connect(mem_ctx, NULL, lp_ctx, "privilege.ldb", + NULL, NULL, 0); +} /* add privilege bits for one sid to a security_token */ -static NTSTATUS samdb_privilege_setup_sid(void *samctx, TALLOC_CTX *mem_ctx, +static NTSTATUS samdb_privilege_setup_sid(struct ldb_context *pdb, TALLOC_CTX *mem_ctx, struct security_token *token, const struct dom_sid *sid) { const char * const attrs[] = { "privilege", NULL }; struct ldb_message **res = NULL; struct ldb_message_element *el; - int ret, i; + unsigned int i; + int ret; char *sidstr; sidstr = ldap_encode_ndr_dom_sid(mem_ctx, sid); NT_STATUS_HAVE_NO_MEMORY(sidstr); - ret = gendb_search(samctx, mem_ctx, NULL, &res, attrs, "objectSid=%s", sidstr); + ret = gendb_search(pdb, mem_ctx, NULL, &res, attrs, "objectSid=%s", sidstr); talloc_free(sidstr); if (ret != 1) { /* not an error to not match */ @@ -58,9 +68,13 @@ static NTSTATUS samdb_privilege_setup_sid(void *samctx, TALLOC_CTX *mem_ctx, for (i=0;i<el->num_values;i++) { const char *priv_str = (const char *)el->values[i].data; enum sec_privilege privilege = sec_privilege_id(priv_str); - if (privilege == -1) { - DEBUG(1,("Unknown privilege '%s' in samdb\n", - priv_str)); + if (privilege == SEC_PRIV_INVALID) { + uint32_t right_bit = sec_right_bit(priv_str); + security_token_set_right_bit(token, right_bit); + if (right_bit == 0) { + DEBUG(1,("Unknown privilege '%s' in samdb\n", + priv_str)); + } continue; } security_token_set_privilege(token, privilege); @@ -73,16 +87,15 @@ static NTSTATUS samdb_privilege_setup_sid(void *samctx, TALLOC_CTX *mem_ctx, setup the privilege mask for this security token based on our local SAM */ -NTSTATUS samdb_privilege_setup(struct tevent_context *ev_ctx, - struct loadparm_context *lp_ctx, struct security_token *token) +NTSTATUS samdb_privilege_setup(struct loadparm_context *lp_ctx, struct security_token *token) { - void *samctx; + struct ldb_context *pdb; TALLOC_CTX *mem_ctx; - int i; + unsigned int i; NTSTATUS status; /* Shortcuts to prevent recursion and avoid lookups */ - if (token->user_sid == NULL) { + if (token->sids == NULL) { token->privilege_mask = 0; return NT_STATUS_OK; } @@ -98,8 +111,8 @@ NTSTATUS samdb_privilege_setup(struct tevent_context *ev_ctx, } mem_ctx = talloc_new(token); - samctx = samdb_connect(mem_ctx, ev_ctx, lp_ctx, system_session(mem_ctx, lp_ctx)); - if (samctx == NULL) { + pdb = privilege_connect(mem_ctx, lp_ctx); + if (pdb == NULL) { talloc_free(mem_ctx); return NT_STATUS_INTERNAL_DB_CORRUPTION; } @@ -107,8 +120,8 @@ NTSTATUS samdb_privilege_setup(struct tevent_context *ev_ctx, token->privilege_mask = 0; for (i=0;i<token->num_sids;i++) { - status = samdb_privilege_setup_sid(samctx, mem_ctx, - token, token->sids[i]); + status = samdb_privilege_setup_sid(pdb, mem_ctx, + token, &token->sids[i]); if (!NT_STATUS_IS_OK(status)) { talloc_free(mem_ctx); return status; |