def test_setposixacl_group_getposixacl(self): BA_sid = security.dom_sid(security.SID_BUILTIN_ADMINISTRATORS) s4_passdb = passdb.PDB(self.lp.get("passdb backend")) (BA_gid,BA_type) = s4_passdb.sid_to_id(BA_sid) self.assertEquals(BA_type, idmap.ID_TYPE_BOTH) smbd.set_simple_acl(self.tempf, 0670, BA_gid) posix_acl = smbd.get_sys_acl(self.tempf, smb_acl.SMB_ACL_TYPE_ACCESS) self.assertEquals(posix_acl.count, 5, self.print_posix_acl(posix_acl)) self.assertEquals(posix_acl.acl[0].a_type, smb_acl.SMB_ACL_USER_OBJ) self.assertEquals(posix_acl.acl[0].a_perm, 6) self.assertEquals(posix_acl.acl[1].a_type, smb_acl.SMB_ACL_GROUP_OBJ) self.assertEquals(posix_acl.acl[1].a_perm, 7) self.assertEquals(posix_acl.acl[2].a_type, smb_acl.SMB_ACL_OTHER) self.assertEquals(posix_acl.acl[2].a_perm, 0) self.assertEquals(posix_acl.acl[3].a_type, smb_acl.SMB_ACL_GROUP) self.assertEquals(posix_acl.acl[3].a_perm, 7) self.assertEquals(posix_acl.acl[3].info.gid, BA_gid) self.assertEquals(posix_acl.acl[4].a_type, smb_acl.SMB_ACL_MASK) self.assertEquals(posix_acl.acl[4].a_perm, 7)
def test_setntacl_getposixacl(self): acl = "O:S-1-5-21-2212615479-2695158682-2101375467-512G:S-1-5-21-2212615479-2695158682-2101375467-513D:(A;OICI;0x001f01ff;;;S-1-5-21-2212615479-2695158682-2101375467-512)" setntacl(self.lp, self.tempf, acl, "S-1-5-21-2212615479-2695158682-2101375467", use_ntvfs=False) facl = getntacl(self.lp, self.tempf) anysid = security.dom_sid(security.SID_NT_SELF) self.assertEquals(facl.as_sddl(anysid),acl) posix_acl = smbd.get_sys_acl(self.tempf, smb_acl.SMB_ACL_TYPE_ACCESS)
def test_setposixacl_dir_getposixacl(self): smbd.set_simple_acl(self.tempdir, 0750) posix_acl = smbd.get_sys_acl(self.tempdir, smb_acl.SMB_ACL_TYPE_ACCESS) self.assertEquals(posix_acl.count, 4, self.print_posix_acl(posix_acl)) self.assertEquals(posix_acl.acl[0].a_type, smb_acl.SMB_ACL_USER_OBJ) self.assertEquals(posix_acl.acl[0].a_perm, 7) self.assertEquals(posix_acl.acl[1].a_type, smb_acl.SMB_ACL_GROUP_OBJ) self.assertEquals(posix_acl.acl[1].a_perm, 5) self.assertEquals(posix_acl.acl[2].a_type, smb_acl.SMB_ACL_OTHER) self.assertEquals(posix_acl.acl[2].a_perm, 0) self.assertEquals(posix_acl.acl[3].a_type, smb_acl.SMB_ACL_MASK) self.assertEquals(posix_acl.acl[3].a_perm, 7)
def test_setposixacl_getposixacl(self): smbd.set_simple_acl(self.tempf, 0640) posix_acl = smbd.get_sys_acl(self.tempf, smb_acl.SMB_ACL_TYPE_ACCESS) self.assertEquals(posix_acl.count, 4) self.assertEquals(posix_acl.acl[0].a_type, smb_acl.SMB_ACL_USER_OBJ) self.assertEquals(posix_acl.acl[0].a_perm, 6) self.assertEquals(posix_acl.acl[1].a_type, smb_acl.SMB_ACL_GROUP_OBJ) self.assertEquals(posix_acl.acl[1].a_perm, 4) self.assertEquals(posix_acl.acl[2].a_type, smb_acl.SMB_ACL_OTHER) self.assertEquals(posix_acl.acl[2].a_perm, 0) self.assertEquals(posix_acl.acl[3].a_type, smb_acl.SMB_ACL_MASK) self.assertEquals(posix_acl.acl[3].a_perm, 7)
def test_setntacl_policies_check_getposixacl(self): acl = provision.POLICIES_ACL domsid = passdb.get_global_sam_sid() setntacl(self.lp, self.tempf, acl, str(domsid), use_ntvfs=False) facl = getntacl(self.lp, self.tempf) self.assertEquals(facl.as_sddl(domsid),acl) posix_acl = smbd.get_sys_acl(self.tempf, smb_acl.SMB_ACL_TYPE_ACCESS) nwrap_module_so_path = os.getenv('NSS_WRAPPER_MODULE_SO_PATH') nwrap_module_fn_prefix = os.getenv('NSS_WRAPPER_MODULE_FN_PREFIX') nwrap_winbind_active = (nwrap_module_so_path != "" and nwrap_module_fn_prefix == "winbind") LA_sid = security.dom_sid(str(domsid)+"-"+str(security.DOMAIN_RID_ADMINISTRATOR)) BA_sid = security.dom_sid(security.SID_BUILTIN_ADMINISTRATORS) SO_sid = security.dom_sid(security.SID_BUILTIN_SERVER_OPERATORS) SY_sid = security.dom_sid(security.SID_NT_SYSTEM) AU_sid = security.dom_sid(security.SID_NT_AUTHENTICATED_USERS) PA_sid = security.dom_sid(str(domsid)+"-"+str(security.DOMAIN_RID_POLICY_ADMINS)) s4_passdb = passdb.PDB(self.lp.get("passdb backend")) # These assertions correct for current ad_dc selftest # configuration. When other environments have a broad range of # groups mapped via passdb, we can relax some of these checks (LA_uid,LA_type) = s4_passdb.sid_to_id(LA_sid) self.assertEquals(LA_type, idmap.ID_TYPE_UID) (BA_gid,BA_type) = s4_passdb.sid_to_id(BA_sid) self.assertEquals(BA_type, idmap.ID_TYPE_BOTH) (SO_gid,SO_type) = s4_passdb.sid_to_id(SO_sid) self.assertEquals(SO_type, idmap.ID_TYPE_BOTH) (SY_gid,SY_type) = s4_passdb.sid_to_id(SY_sid) self.assertEquals(SO_type, idmap.ID_TYPE_BOTH) (AU_gid,AU_type) = s4_passdb.sid_to_id(AU_sid) self.assertEquals(AU_type, idmap.ID_TYPE_BOTH) (PA_gid,PA_type) = s4_passdb.sid_to_id(PA_sid) self.assertEquals(PA_type, idmap.ID_TYPE_BOTH) self.assertEquals(posix_acl.count, 15, self.print_posix_acl(posix_acl)) self.assertEquals(posix_acl.acl[0].a_type, smb_acl.SMB_ACL_GROUP) self.assertEquals(posix_acl.acl[0].a_perm, 7) self.assertEquals(posix_acl.acl[0].info.gid, BA_gid) self.assertEquals(posix_acl.acl[1].a_type, smb_acl.SMB_ACL_USER) if nwrap_winbind_active: self.assertEquals(posix_acl.acl[1].a_perm, 7) else: self.assertEquals(posix_acl.acl[1].a_perm, 6) self.assertEquals(posix_acl.acl[1].info.uid, LA_uid) self.assertEquals(posix_acl.acl[2].a_type, smb_acl.SMB_ACL_OTHER) self.assertEquals(posix_acl.acl[2].a_perm, 0) self.assertEquals(posix_acl.acl[3].a_type, smb_acl.SMB_ACL_USER_OBJ) if nwrap_winbind_active: self.assertEquals(posix_acl.acl[3].a_perm, 7) else: self.assertEquals(posix_acl.acl[3].a_perm, 6) self.assertEquals(posix_acl.acl[4].a_type, smb_acl.SMB_ACL_USER) self.assertEquals(posix_acl.acl[4].a_perm, 7) self.assertEquals(posix_acl.acl[4].info.uid, BA_gid) self.assertEquals(posix_acl.acl[5].a_type, smb_acl.SMB_ACL_GROUP_OBJ) self.assertEquals(posix_acl.acl[5].a_perm, 7) self.assertEquals(posix_acl.acl[6].a_type, smb_acl.SMB_ACL_USER) self.assertEquals(posix_acl.acl[6].a_perm, 5) self.assertEquals(posix_acl.acl[6].info.uid, SO_gid) self.assertEquals(posix_acl.acl[7].a_type, smb_acl.SMB_ACL_GROUP) self.assertEquals(posix_acl.acl[7].a_perm, 5) self.assertEquals(posix_acl.acl[7].info.gid, SO_gid) self.assertEquals(posix_acl.acl[8].a_type, smb_acl.SMB_ACL_USER) self.assertEquals(posix_acl.acl[8].a_perm, 7) self.assertEquals(posix_acl.acl[8].info.uid, SY_gid) self.assertEquals(posix_acl.acl[9].a_type, smb_acl.SMB_ACL_GROUP) self.assertEquals(posix_acl.acl[9].a_perm, 7) self.assertEquals(posix_acl.acl[9].info.gid, SY_gid) self.assertEquals(posix_acl.acl[10].a_type, smb_acl.SMB_ACL_USER) self.assertEquals(posix_acl.acl[10].a_perm, 5) self.assertEquals(posix_acl.acl[10].info.uid, AU_gid) self.assertEquals(posix_acl.acl[11].a_type, smb_acl.SMB_ACL_GROUP) self.assertEquals(posix_acl.acl[11].a_perm, 5) self.assertEquals(posix_acl.acl[11].info.gid, AU_gid) self.assertEquals(posix_acl.acl[12].a_type, smb_acl.SMB_ACL_USER) self.assertEquals(posix_acl.acl[12].a_perm, 7) self.assertEquals(posix_acl.acl[12].info.uid, PA_gid) self.assertEquals(posix_acl.acl[13].a_type, smb_acl.SMB_ACL_GROUP) self.assertEquals(posix_acl.acl[13].a_perm, 7) self.assertEquals(posix_acl.acl[13].info.gid, PA_gid) self.assertEquals(posix_acl.acl[14].a_type, smb_acl.SMB_ACL_MASK) self.assertEquals(posix_acl.acl[14].a_perm, 7)
def test_setntacl_sysvol_dir_check_getposixacl(self): acl = provision.SYSVOL_ACL domsid = passdb.get_global_sam_sid() setntacl(self.lp, self.tempdir,acl,str(domsid), use_ntvfs=False) facl = getntacl(self.lp, self.tempdir) self.assertEquals(facl.as_sddl(domsid),acl) posix_acl = smbd.get_sys_acl(self.tempdir, smb_acl.SMB_ACL_TYPE_ACCESS) LA_sid = security.dom_sid(str(domsid)+"-"+str(security.DOMAIN_RID_ADMINISTRATOR)) BA_sid = security.dom_sid(security.SID_BUILTIN_ADMINISTRATORS) SO_sid = security.dom_sid(security.SID_BUILTIN_SERVER_OPERATORS) SY_sid = security.dom_sid(security.SID_NT_SYSTEM) AU_sid = security.dom_sid(security.SID_NT_AUTHENTICATED_USERS) s4_passdb = passdb.PDB(self.lp.get("passdb backend")) # These assertions correct for current ad_dc selftest # configuration. When other environments have a broad range of # groups mapped via passdb, we can relax some of these checks (LA_uid,LA_type) = s4_passdb.sid_to_id(LA_sid) self.assertEquals(LA_type, idmap.ID_TYPE_UID) (BA_gid,BA_type) = s4_passdb.sid_to_id(BA_sid) self.assertEquals(BA_type, idmap.ID_TYPE_BOTH) (SO_gid,SO_type) = s4_passdb.sid_to_id(SO_sid) self.assertEquals(SO_type, idmap.ID_TYPE_BOTH) (SY_gid,SY_type) = s4_passdb.sid_to_id(SY_sid) self.assertEquals(SO_type, idmap.ID_TYPE_BOTH) (AU_gid,AU_type) = s4_passdb.sid_to_id(AU_sid) self.assertEquals(AU_type, idmap.ID_TYPE_BOTH) self.assertEquals(posix_acl.count, 13, self.print_posix_acl(posix_acl)) self.assertEquals(posix_acl.acl[0].a_type, smb_acl.SMB_ACL_GROUP) self.assertEquals(posix_acl.acl[0].a_perm, 7) self.assertEquals(posix_acl.acl[0].info.gid, BA_gid) self.assertEquals(posix_acl.acl[1].a_type, smb_acl.SMB_ACL_USER) self.assertEquals(posix_acl.acl[1].a_perm, 7) self.assertEquals(posix_acl.acl[1].info.uid, LA_uid) self.assertEquals(posix_acl.acl[2].a_type, smb_acl.SMB_ACL_OTHER) self.assertEquals(posix_acl.acl[2].a_perm, 0) self.assertEquals(posix_acl.acl[3].a_type, smb_acl.SMB_ACL_USER_OBJ) self.assertEquals(posix_acl.acl[3].a_perm, 7) self.assertEquals(posix_acl.acl[4].a_type, smb_acl.SMB_ACL_USER) self.assertEquals(posix_acl.acl[4].a_perm, 7) self.assertEquals(posix_acl.acl[4].info.uid, BA_gid) self.assertEquals(posix_acl.acl[5].a_type, smb_acl.SMB_ACL_GROUP_OBJ) self.assertEquals(posix_acl.acl[5].a_perm, 7) self.assertEquals(posix_acl.acl[6].a_type, smb_acl.SMB_ACL_USER) self.assertEquals(posix_acl.acl[6].a_perm, 5) self.assertEquals(posix_acl.acl[6].info.uid, SO_gid) self.assertEquals(posix_acl.acl[7].a_type, smb_acl.SMB_ACL_GROUP) self.assertEquals(posix_acl.acl[7].a_perm, 5) self.assertEquals(posix_acl.acl[7].info.gid, SO_gid) self.assertEquals(posix_acl.acl[8].a_type, smb_acl.SMB_ACL_USER) self.assertEquals(posix_acl.acl[8].a_perm, 7) self.assertEquals(posix_acl.acl[8].info.uid, SY_gid) self.assertEquals(posix_acl.acl[9].a_type, smb_acl.SMB_ACL_GROUP) self.assertEquals(posix_acl.acl[9].a_perm, 7) self.assertEquals(posix_acl.acl[9].info.gid, SY_gid) self.assertEquals(posix_acl.acl[10].a_type, smb_acl.SMB_ACL_USER) self.assertEquals(posix_acl.acl[10].a_perm, 5) self.assertEquals(posix_acl.acl[10].info.uid, AU_gid) self.assertEquals(posix_acl.acl[11].a_type, smb_acl.SMB_ACL_GROUP) self.assertEquals(posix_acl.acl[11].a_perm, 5) self.assertEquals(posix_acl.acl[11].info.gid, AU_gid) self.assertEquals(posix_acl.acl[12].a_type, smb_acl.SMB_ACL_MASK) self.assertEquals(posix_acl.acl[12].a_perm, 7)