The branch, master has been updated via bf6fcc6... s4-pvfs: when uwrap is enabled, ignore chown errors via dbebe0f... s4-torture: fixed the default ACL for s4 via 05f5f22... s4-torture: minor debugging enhancements via 8c7a814... s4-schema: We should not need Samba4TopExtra now via 6b1ab9c... s4-pvfs: don't auto-apply privilege bits in unix acl handling either via c3b09d1... s4-acl: SEC_FLAG_MAXIMUM_ALLOWED doesn't auto-apply privilege access masks via 53dec86... s4-torture: the BASE-CREATEX_ACCESS test is broken for non-administrators via 533b102... s4-torture: cleanup after the MAXIMUM_ALLOWED test via 5d5d951... s4-pvfs: use privileges rather than "uid == 0" in unix access check via 9da4af0... s4-security: honor more of the privilege access bits via 7226ba7... s4-torture: add a special check for administrators and privileges via 9526487... s4-lsasrv: make sure only admins can alter privileges via f794e8d... s4-provision: added the default privileges db via cc3e1d9... s4-provision: removed the old privilege attributes via f3f695f... s4-torture: show the sid we are basing privilege tests on via 30be3fd... s4-privileges: moved privileges to private/privilege.ldb via b6a1beb... added NT_STATUS_NOT_OK_RETURN_AND_FREE() from f1d9960... Add comment explaining about symlink following & posix. Jeremy.
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit bf6fcc612139c27d4b5837611cdafbb05f48d11d Author: Andrew Tridgell <tri...@samba.org> Date: Sat Oct 17 12:58:17 2009 +1100 s4-pvfs: when uwrap is enabled, ignore chown errors chown is expected to fail under uwrap commit dbebe0f6216d4e727424ca666b58f58928ddaa08 Author: Andrew Tridgell <tri...@samba.org> Date: Sat Oct 17 12:50:51 2009 +1100 s4-torture: fixed the default ACL for s4 s4 returns group and world ACEs in the default acl, based on unix permissions commit 05f5f22361f18091222c9d20a754ba3c81e8b5c9 Author: Andrew Tridgell <tri...@samba.org> Date: Sat Oct 17 10:54:46 2009 +1100 s4-torture: minor debugging enhancements commit 8c7a81408a34779f58e52e471c79886dbfc7f3d7 Author: Andrew Tridgell <tri...@samba.org> Date: Sat Oct 17 10:50:08 2009 +1100 s4-schema: We should not need Samba4TopExtra now The last attribute this contained was 'privilege' which is now gone commit 6b1ab9cd478dc63c1c7f1fef42b2e1b896907bed Author: Andrew Tridgell <tri...@samba.org> Date: Sat Oct 17 09:09:42 2009 +1100 s4-pvfs: don't auto-apply privilege bits in unix acl handling either commit c3b09d18a8bad730fce1d01531ea7684a5c105e1 Author: Andrew Tridgell <tri...@samba.org> Date: Sat Oct 17 09:09:19 2009 +1100 s4-acl: SEC_FLAG_MAXIMUM_ALLOWED doesn't auto-apply privilege access masks commit 53dec869b83c55122e2cde6274ba6ebe328e12c1 Author: Andrew Tridgell <tri...@samba.org> Date: Fri Oct 16 23:06:02 2009 +1100 s4-torture: the BASE-CREATEX_ACCESS test is broken for non-administrators See my msg to samba-technical about this test and privilege testing. commit 533b1024938f83ed4cddb16e01be8a22eb55a23e Author: Andrew Tridgell <tri...@samba.org> Date: Fri Oct 16 23:04:01 2009 +1100 s4-torture: cleanup after the MAXIMUM_ALLOWED test commit 5d5d95131100c595d642f5dc4e4eb247736d81db Author: Andrew Tridgell <tri...@samba.org> Date: Fri Oct 16 23:03:42 2009 +1100 s4-pvfs: use privileges rather than "uid == 0" in unix access check This makes the unix access check much closer to the full ACL check commit 9da4af062b333750d9cbdf5ef9a47c5ac3723a81 Author: Andrew Tridgell <tri...@samba.org> Date: Fri Oct 16 23:02:58 2009 +1100 s4-security: honor more of the privilege access bits commit 7226ba73a0519f853b53adc3591d2358ff7429b2 Author: Andrew Tridgell <tri...@samba.org> Date: Fri Oct 16 18:23:42 2009 +1100 s4-torture: add a special check for administrators and privileges lsa privileges calls don't expand groups. darn. commit 9526487010fff240d2f55f29352e7f74d3cec65a Author: Andrew Tridgell <tri...@samba.org> Date: Fri Oct 16 18:22:48 2009 +1100 s4-lsasrv: make sure only admins can alter privileges commit f794e8d43de1c2fb577b883f0e0b49f392fa14a1 Author: Andrew Tridgell <tri...@samba.org> Date: Fri Oct 16 18:01:35 2009 +1100 s4-provision: added the default privileges db privileges are now stored in a separate database commit cc3e1d9022de8367b6576eac83e6664b7394e513 Author: Andrew Tridgell <tri...@samba.org> Date: Fri Oct 16 18:01:02 2009 +1100 s4-provision: removed the old privilege attributes Our schema is getting a bit cleaner :-) commit f3f695f18f9c5df90d464e4424e757aa813ce971 Author: Andrew Tridgell <tri...@samba.org> Date: Fri Oct 16 17:05:48 2009 +1100 s4-torture: show the sid we are basing privilege tests on commit 30be3fd143bc558ffdac2a6fcf992d5a39f8f7d9 Author: Andrew Tridgell <tri...@samba.org> Date: Fri Oct 16 17:05:27 2009 +1100 s4-privileges: moved privileges to private/privilege.ldb We were storing privileges in the sam, which was OK when we were a standalone DC, but is no good when we replicate with a windows DC. This moves the privileges to a separate (local) database commit b6a1beb13139a6aa89ac1d4bb201a9c9d1453262 Author: Andrew Tridgell <tri...@samba.org> Date: Fri Oct 16 17:04:19 2009 +1100 added NT_STATUS_NOT_OK_RETURN_AND_FREE() Try to make it a bit easier to avoid leaks in common code ----------------------------------------------------------------------- Summary of changes: libcli/util/ntstatus.h | 7 ++ source4/dsdb/samdb/samdb_privilege.c | 31 ++++++++-- source4/libcli/security/access_check.c | 8 ++- source4/ntvfs/posix/pvfs_acl.c | 25 ++++++-- source4/rpc_server/lsa/dcesrv_lsa.c | 71 +++++++++++++---------- source4/rpc_server/lsa/lsa.h | 1 + source4/rpc_server/lsa/lsa_init.c | 7 ++ source4/scripting/python/samba/provision.py | 21 +++++++ source4/selftest/knownfail | 1 + source4/setup/provision_privilege.ldif | 78 +++++++++++++++++++++++++ source4/setup/provision_users.ldif | 40 ------------- source4/setup/schema_samba4.ldif | 50 +++++----------- source4/torture/basic/denytest.c | 21 ++++--- source4/torture/raw/acls.c | 84 ++++++++++++++++++--------- source4/torture/util.h | 3 + source4/torture/util_smb.c | 36 +++++++++++ 16 files changed, 328 insertions(+), 156 deletions(-) create mode 100644 source4/setup/provision_privilege.ldif Changeset truncated at 500 lines: diff --git a/libcli/util/ntstatus.h b/libcli/util/ntstatus.h index 1025f47..88b4353 100644 --- a/libcli/util/ntstatus.h +++ b/libcli/util/ntstatus.h @@ -674,6 +674,13 @@ extern bool ntstatus_check_dos_mapping; }\ } while (0) +#define NT_STATUS_NOT_OK_RETURN_AND_FREE(x, ctx) do { \ + if (!NT_STATUS_IS_OK(x)) {\ + talloc_free(ctx); \ + return x;\ + }\ +} while (0) + #define NT_STATUS_IS_ERR_RETURN(x) do { \ if (NT_STATUS_IS_ERR(x)) {\ return x;\ diff --git a/source4/dsdb/samdb/samdb_privilege.c b/source4/dsdb/samdb/samdb_privilege.c index e9c6f4c..e7742c6 100644 --- a/source4/dsdb/samdb/samdb_privilege.c +++ b/source4/dsdb/samdb/samdb_privilege.c @@ -26,11 +26,30 @@ #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 tevent_context *ev_ctx, + struct loadparm_context *lp_ctx) +{ + char *path; + struct ldb_context *pdb; + + path = private_path(mem_ctx, lp_ctx, "privilege.ldb"); + if (!path) return NULL; + + pdb = ldb_wrap_connect(mem_ctx, ev_ctx, lp_ctx, path, + NULL, NULL, 0, NULL); + talloc_free(path); + + return pdb; +} /* 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) { @@ -43,7 +62,7 @@ static NTSTATUS samdb_privilege_setup_sid(void *samctx, TALLOC_CTX *mem_ctx, 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 */ @@ -76,7 +95,7 @@ static NTSTATUS samdb_privilege_setup_sid(void *samctx, TALLOC_CTX *mem_ctx, NTSTATUS samdb_privilege_setup(struct tevent_context *ev_ctx, struct loadparm_context *lp_ctx, struct security_token *token) { - void *samctx; + struct ldb_context *pdb; TALLOC_CTX *mem_ctx; int i; NTSTATUS status; @@ -98,8 +117,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, ev_ctx, lp_ctx); + if (pdb == NULL) { talloc_free(mem_ctx); return NT_STATUS_INTERNAL_DB_CORRUPTION; } @@ -107,7 +126,7 @@ 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, + status = samdb_privilege_setup_sid(pdb, mem_ctx, token, token->sids[i]); if (!NT_STATUS_IS_OK(status)) { talloc_free(mem_ctx); diff --git a/source4/libcli/security/access_check.c b/source4/libcli/security/access_check.c index 543b0f7..954c54c 100644 --- a/source4/libcli/security/access_check.c +++ b/source4/libcli/security/access_check.c @@ -125,9 +125,13 @@ NTSTATUS sec_access_check(const struct security_descriptor *sd, security_token_has_sid(token, sd->owner_sid)) { bits_remaining &= ~(SEC_STD_WRITE_DAC|SEC_STD_READ_CONTROL|SEC_STD_DELETE); } - if ((bits_remaining & SEC_STD_DELETE) && + if ((bits_remaining & SEC_RIGHTS_PRIV_RESTORE) && security_token_has_privilege(token, SEC_PRIV_RESTORE)) { - bits_remaining &= ~SEC_STD_DELETE; + bits_remaining &= ~(SEC_RIGHTS_PRIV_RESTORE); + } + if ((bits_remaining & SEC_RIGHTS_PRIV_BACKUP) && + security_token_has_privilege(token, SEC_PRIV_BACKUP)) { + bits_remaining &= ~(SEC_RIGHTS_PRIV_BACKUP); } if (sd->dacl == NULL) { diff --git a/source4/ntvfs/posix/pvfs_acl.c b/source4/ntvfs/posix/pvfs_acl.c index 4680b17..26515cf 100644 --- a/source4/ntvfs/posix/pvfs_acl.c +++ b/source4/ntvfs/posix/pvfs_acl.c @@ -384,6 +384,9 @@ NTSTATUS pvfs_acl_set(struct pvfs_state *pvfs, } else { ret = fchown(fd, new_uid, new_gid); } + if (errno == EPERM && uwrap_enabled()) { + ret = 0; + } if (ret == -1) { return pvfs_map_errno(pvfs, errno); } @@ -490,16 +493,16 @@ NTSTATUS pvfs_access_check_unix(struct pvfs_state *pvfs, { uid_t uid = geteuid(); uint32_t max_bits = SEC_RIGHTS_FILE_READ | SEC_FILE_ALL; + struct security_token *token = req->session_info->security_token; if (pvfs_read_only(pvfs, *access_mask)) { return NT_STATUS_ACCESS_DENIED; } - /* owner and root get extra permissions */ - if (uid == 0) { - max_bits |= SEC_STD_ALL | SEC_FLAG_SYSTEM_SECURITY; - } else if (uid == name->st.st_uid) { + if (uid == name->st.st_uid) { max_bits |= SEC_STD_ALL; + } else if (security_token_has_privilege(token, SEC_PRIV_RESTORE)) { + max_bits |= SEC_STD_DELETE; } if ((name->st.st_mode & S_IWOTH) || @@ -521,8 +524,18 @@ NTSTATUS pvfs_access_check_unix(struct pvfs_state *pvfs, *access_mask &= ~SEC_FLAG_MAXIMUM_ALLOWED; } - if (uid != 0 && (*access_mask & SEC_FLAG_SYSTEM_SECURITY)) { - return NT_STATUS_ACCESS_DENIED; + if ((*access_mask & SEC_FLAG_SYSTEM_SECURITY) && + security_token_has_privilege(token, SEC_PRIV_SECURITY)) { + max_bits |= SEC_FLAG_SYSTEM_SECURITY; + } + + if (((*access_mask & ~max_bits) & SEC_RIGHTS_PRIV_RESTORE) && + security_token_has_privilege(token, SEC_PRIV_RESTORE)) { + max_bits |= ~(SEC_RIGHTS_PRIV_RESTORE); + } + if (((*access_mask & ~max_bits) & SEC_RIGHTS_PRIV_BACKUP) && + security_token_has_privilege(token, SEC_PRIV_BACKUP)) { + max_bits |= ~(SEC_RIGHTS_PRIV_BACKUP); } if (*access_mask & ~max_bits) { diff --git a/source4/rpc_server/lsa/dcesrv_lsa.c b/source4/rpc_server/lsa/dcesrv_lsa.c index 3d6352a..0e6a55e 100644 --- a/source4/rpc_server/lsa/dcesrv_lsa.c +++ b/source4/rpc_server/lsa/dcesrv_lsa.c @@ -80,7 +80,7 @@ static NTSTATUS dcesrv_build_lsa_sd(TALLOC_CTX *mem_ctx, TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx); status = dom_sid_split_rid(tmp_ctx, sid, &domain_sid, &rid); - NT_STATUS_NOT_OK_RETURN(status); + NT_STATUS_NOT_OK_RETURN_AND_FREE(status, tmp_ctx); domain_admins_sid = dom_sid_add_rid(tmp_ctx, domain_sid, DOMAIN_RID_ADMINS); NT_STATUS_HAVE_NO_MEMORY_AND_FREE(domain_admins_sid, tmp_ctx); @@ -694,7 +694,7 @@ static NTSTATUS dcesrv_lsa_EnumAccounts(struct dcesrv_call_state *dce_call, TALL /* NOTE: This call must only return accounts that have at least one privilege set */ - ret = gendb_search(state->sam_ldb, mem_ctx, NULL, &res, attrs, + ret = gendb_search(state->pdb, mem_ctx, NULL, &res, attrs, "(&(objectSid=*)(privilege=*))"); if (ret < 0) { return NT_STATUS_NO_SUCH_USER; @@ -1830,7 +1830,7 @@ static NTSTATUS dcesrv_lsa_EnumPrivsAccount(struct dcesrv_call_state *dce_call, return NT_STATUS_NO_MEMORY; } - ret = gendb_search(astate->policy->sam_ldb, mem_ctx, NULL, &res, attrs, + ret = gendb_search(astate->policy->pdb, mem_ctx, NULL, &res, attrs, "objectSid=%s", sidstr); if (ret != 1) { return NT_STATUS_OK; @@ -1886,7 +1886,7 @@ static NTSTATUS dcesrv_lsa_EnumAccountRights(struct dcesrv_call_state *dce_call, return NT_STATUS_NO_MEMORY; } - ret = gendb_search(state->sam_ldb, mem_ctx, NULL, &res, attrs, + ret = gendb_search(state->pdb, mem_ctx, NULL, &res, attrs, "(&(objectSid=%s)(privilege=*))", sidstr); if (ret == 0) { return NT_STATUS_OBJECT_NAME_NOT_FOUND; @@ -1897,7 +1897,7 @@ static NTSTATUS dcesrv_lsa_EnumAccountRights(struct dcesrv_call_state *dce_call, if (ret == -1) { DEBUG(3, ("searching for account rights for SID: %s failed: %s", dom_sid_string(mem_ctx, r->in.sid), - ldb_errstring(state->sam_ldb))); + ldb_errstring(state->pdb))); return NT_STATUS_INTERNAL_DB_CORRUPTION; } @@ -1932,15 +1932,17 @@ static NTSTATUS dcesrv_lsa_AddRemoveAccountRights(struct dcesrv_call_state *dce_ struct dom_sid *sid, const struct lsa_RightSet *rights) { - const char *sidstr; + const char *sidstr, *sidndrstr; struct ldb_message *msg; struct ldb_message_element *el; int i, ret; struct lsa_EnumAccountRights r2; + char *dnstr; - sidstr = ldap_encode_ndr_dom_sid(mem_ctx, sid); - if (sidstr == NULL) { - return NT_STATUS_NO_MEMORY; + if (security_session_user_level(dce_call->conn->auth_state.session_info) < + SECURITY_ADMINISTRATOR) { + DEBUG(0,("lsa_AddRemoveAccount refused for supplied security token\n")); + return NT_STATUS_ACCESS_DENIED; } msg = ldb_msg_new(mem_ctx); @@ -1948,24 +1950,17 @@ static NTSTATUS dcesrv_lsa_AddRemoveAccountRights(struct dcesrv_call_state *dce_ return NT_STATUS_NO_MEMORY; } - msg->dn = samdb_search_dn(state->sam_ldb, mem_ctx, - NULL, "objectSid=%s", sidstr); - if (msg->dn == NULL) { - NTSTATUS status; - if (ldb_flag == LDB_FLAG_MOD_DELETE) { - return NT_STATUS_OBJECT_NAME_NOT_FOUND; - } - status = samdb_create_foreign_security_principal(state->sam_ldb, mem_ctx, - sid, &msg->dn); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - return NT_STATUS_NO_SUCH_USER; - } + sidndrstr = ldap_encode_ndr_dom_sid(msg, sid); + NT_STATUS_HAVE_NO_MEMORY_AND_FREE(sidndrstr, msg); - if (ldb_msg_add_empty(msg, "privilege", ldb_flag, NULL)) { - return NT_STATUS_NO_MEMORY; - } + sidstr = dom_sid_string(msg, sid); + NT_STATUS_HAVE_NO_MEMORY_AND_FREE(sidstr, msg); + + dnstr = talloc_asprintf(msg, "sid=%s", sidstr); + NT_STATUS_HAVE_NO_MEMORY_AND_FREE(dnstr, msg); + + msg->dn = ldb_dn_new(msg, state->pdb, dnstr); + NT_STATUS_HAVE_NO_MEMORY_AND_FREE(msg->dn, msg); if (ldb_flag == LDB_FLAG_MOD_ADD) { NTSTATUS status; @@ -1982,6 +1977,7 @@ static NTSTATUS dcesrv_lsa_AddRemoveAccountRights(struct dcesrv_call_state *dce_ for (i=0;i<rights->count;i++) { if (sec_privilege_id(rights->names[i].string) == -1) { + talloc_free(msg); return NT_STATUS_NO_SUCH_PRIVILEGE; } @@ -1998,26 +1994,41 @@ static NTSTATUS dcesrv_lsa_AddRemoveAccountRights(struct dcesrv_call_state *dce_ ret = ldb_msg_add_string(msg, "privilege", rights->names[i].string); if (ret != LDB_SUCCESS) { + talloc_free(msg); return NT_STATUS_NO_MEMORY; } } el = ldb_msg_find_element(msg, "privilege"); if (!el) { + talloc_free(msg); return NT_STATUS_OK; } - ret = ldb_modify(state->sam_ldb, msg); + el->flags = ldb_flag; + + ret = ldb_modify(state->pdb, msg); + if (ret == LDB_ERR_NO_SUCH_OBJECT) { + if (samdb_msg_add_dom_sid(state->pdb, msg, msg, "objectSid", sid) != LDB_SUCCESS) { + talloc_free(msg); + return NT_STATUS_NO_MEMORY; + } + samdb_msg_add_string(state->pdb, msg, msg, "comment", "added via LSA"); + ret = ldb_add(state->pdb, msg); + } if (ret != 0) { if (ldb_flag == LDB_FLAG_MOD_DELETE && ret == LDB_ERR_NO_SUCH_ATTRIBUTE) { - return NT_STATUS_OBJECT_NAME_NOT_FOUND; + talloc_free(msg); + return NT_STATUS_OK; } DEBUG(3, ("Could not %s attributes from %s: %s", ldb_flag == LDB_FLAG_MOD_DELETE ? "delete" : "add", - ldb_dn_get_linearized(msg->dn), ldb_errstring(state->sam_ldb))); + ldb_dn_get_linearized(msg->dn), ldb_errstring(state->pdb))); + talloc_free(msg); return NT_STATUS_UNEXPECTED_IO_ERROR; } + talloc_free(msg); return NT_STATUS_OK; } @@ -2880,7 +2891,7 @@ static NTSTATUS dcesrv_lsa_EnumAccountsWithUserRight(struct dcesrv_call_state *d return NT_STATUS_NO_SUCH_PRIVILEGE; } - ret = gendb_search(state->sam_ldb, mem_ctx, NULL, &res, attrs, + ret = gendb_search(state->pdb, mem_ctx, NULL, &res, attrs, "privilege=%s", privname); if (ret == -1) { return NT_STATUS_INTERNAL_DB_CORRUPTION; diff --git a/source4/rpc_server/lsa/lsa.h b/source4/rpc_server/lsa/lsa.h index ffdf96d..53fe102 100644 --- a/source4/rpc_server/lsa/lsa.h +++ b/source4/rpc_server/lsa/lsa.h @@ -40,6 +40,7 @@ struct lsa_policy_state { struct dcesrv_handle *handle; struct ldb_context *sam_ldb; + struct ldb_context *pdb; uint32_t access_mask; struct ldb_dn *domain_dn; struct ldb_dn *forest_dn; diff --git a/source4/rpc_server/lsa/lsa_init.c b/source4/rpc_server/lsa/lsa_init.c index ae565a3..dd7d46b 100644 --- a/source4/rpc_server/lsa/lsa_init.c +++ b/source4/rpc_server/lsa/lsa_init.c @@ -21,6 +21,7 @@ */ #include "rpc_server/lsa/lsa.h" +#include "dsdb/samdb/samdb_proto.h" NTSTATUS dcesrv_lsa_get_policy_state(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct lsa_policy_state **_state) @@ -48,6 +49,12 @@ NTSTATUS dcesrv_lsa_get_policy_state(struct dcesrv_call_state *dce_call, TALLOC_ return NT_STATUS_INVALID_SYSTEM_SERVICE; } + /* and the privilege database */ + state->pdb = privilege_connect(state, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx); + if (state->pdb == NULL) { + return NT_STATUS_INVALID_SYSTEM_SERVICE; + } + /* work out the domain_dn - useful for so many calls its worth fetching here */ state->domain_dn = ldb_get_default_basedn(state->sam_ldb); diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py index fdf1fe9..d7fadf3 100644 --- a/source4/scripting/python/samba/provision.py +++ b/source4/scripting/python/samba/provision.py @@ -369,6 +369,7 @@ def provision_paths_from_lp(lp, dnsdomain): paths.samdb = os.path.join(paths.private_dir, lp.get("sam database") or "samdb.ldb") paths.idmapdb = os.path.join(paths.private_dir, lp.get("idmap database") or "idmap.ldb") paths.secrets = os.path.join(paths.private_dir, lp.get("secrets database") or "secrets.ldb") + paths.privilege = os.path.join(paths.private_dir, "privilege.ldb") paths.dns = os.path.join(paths.private_dir, dnsdomain + ".zone") paths.namedconf = os.path.join(paths.private_dir, "named.conf") paths.namedtxt = os.path.join(paths.private_dir, "named.txt") @@ -830,6 +831,23 @@ def setup_secretsdb(path, setup_path, session_info, credentials, lp): return secrets_ldb +def setup_privileges(path, setup_path, session_info, lp): + """Setup the privileges database. + + :param path: Path to the privileges database. + :param setup_path: Get the path to a setup file. + :param session_info: Session info. + :param credentials: Credentials + :param lp: Loadparm context + :return: LDB handle for the created secrets database + """ + if os.path.exists(path): + os.unlink(path) + privilege_ldb = Ldb(path, session_info=session_info, lp=lp) + privilege_ldb.erase() + privilege_ldb.load_ldif_file_add(setup_path("provision_privilege.ldif")) + + def setup_registry(path, setup_path, session_info, lp): """Setup the registry. @@ -1301,6 +1319,9 @@ def provision(setup_dir, message, session_info, setup_registry(paths.hklm, setup_path, session_info, lp=lp) + message("Setting up the privileges database") + setup_privileges(paths.privilege, setup_path, session_info, lp=lp) + message("Setting up idmap db") idmap = setup_idmapdb(paths.idmapdb, setup_path, session_info=session_info, lp=lp) diff --git a/source4/selftest/knownfail b/source4/selftest/knownfail index 7bd4bac..5061171 100644 --- a/source4/selftest/knownfail +++ b/source4/selftest/knownfail @@ -62,3 +62,4 @@ samba4.winbind.struct.*.LOOKUP_NAME_SID # Not yet working in winbind samba4.ntvfs.cifs.base.createx_access samba4.ntvfs.cifs.base.createx_sharemodes_dir samba4.ntvfs.cifs.base.maximum_allowed +samba4.base.createx_access # this test is broken for non-administrator users diff --git a/source4/setup/provision_privilege.ldif b/source4/setup/provision_privilege.ldif new file mode 100644 index 0000000..0916c59 --- /dev/null +++ b/source4/setup/provision_privilege.ldif @@ -0,0 +1,78 @@ +# default privileges - more can be added via LSA or ldbedit +dn: @ATTRIBUTES +comment: CASE_INSENSITIVE +privilege: CASE_INSENSITIVE + +dn: @INDEXLIST +...@idxattr: objectSid +...@idxattr: privilege + +dn: sid=S-1-5-32-544 +objectClass: privilege +comment: Administrators +objectSid: S-1-5-32-544 +privilege: SeSecurityPrivilege +privilege: SeBackupPrivilege +privilege: SeRestorePrivilege +privilege: SeSystemtimePrivilege +privilege: SeShutdownPrivilege +privilege: SeRemoteShutdownPrivilege +privilege: SeTakeOwnershipPrivilege +privilege: SeDebugPrivilege +privilege: SeSystemEnvironmentPrivilege +privilege: SeSystemProfilePrivilege +privilege: SeProfileSingleProcessPrivilege +privilege: SeIncreaseBasePriorityPrivilege +privilege: SeLoadDriverPrivilege +privilege: SeCreatePagefilePrivilege +privilege: SeIncreaseQuotaPrivilege +privilege: SeChangeNotifyPrivilege +privilege: SeUndockPrivilege +privilege: SeManageVolumePrivilege +privilege: SeImpersonatePrivilege +privilege: SeCreateGlobalPrivilege +privilege: SeEnableDelegationPrivilege +privilege: SeInteractiveLogonRight +privilege: SeNetworkLogonRight +privilege: SeRemoteInteractiveLogonRight + +dn: sid=S-1-5-32-550 +objectClass: privilege +comment: Print Operators +objectSid: S-1-5-32-550 +privilege: SeLoadDriverPrivilege +privilege: SeShutdownPrivilege +privilege: SeInteractiveLogonRight + +dn: sid=S-1-5-32-551 +objectClass: privilege +comment: Backup Operators +objectSid: S-1-5-32-551 +privilege: SeBackupPrivilege +privilege: SeRestorePrivilege +privilege: SeShutdownPrivilege +privilege: SeInteractiveLogonRight + +dn: sid=S-1-5-32-549 +objectClass: privilege +comment: Server Operators +objectSid: S-1-5-32-549 +privilege: SeBackupPrivilege +privilege: SeSystemtimePrivilege +privilege: SeRemoteShutdownPrivilege +privilege: SeRestorePrivilege +privilege: SeShutdownPrivilege +privilege: SeInteractiveLogonRight + -- Samba Shared Repository