Ignore:
Timestamp:
Jul 2, 2011, 3:35:33 PM (14 years ago)
Author:
Herwig Bauernfeind
Message:

Samba 3.5: Update trunk to 3.5.8

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/server/source3/smbd/posix_acls.c

    r429 r596  
    17461746                                           sid_string_dbg(&psa->trustee)));
    17471747                                SAFE_FREE(current_ace);
     1748                                continue;
     1749                        }
     1750
     1751                        if (lp_force_unknown_acl_user(SNUM(fsp->conn))) {
     1752                                DEBUG(10, ("create_canon_ace_lists: ignoring "
     1753                                        "unknown or foreign SID %s\n",
     1754                                        sid_string_dbg(&psa->trustee)));
     1755                                        SAFE_FREE(current_ace);
    17481756                                continue;
    17491757                        }
     
    35923600        }
    35933601
    3594         if (!NT_STATUS_IS_OK(open_file_fchmod(NULL, conn, smb_fname, &fsp))) {
     3602        if (!NT_STATUS_IS_OK(open_file_fchmod(conn, smb_fname, &fsp))) {
    35953603                return -1;
    35963604        }
     
    36113619        unbecome_root();
    36123620
    3613         close_file_fchmod(NULL, fsp);
     3621        close_file(NULL, fsp, NORMAL_CLOSE);
    36143622
    36153623        return ret;
     
    38233831****************************************************************************/
    38243832
    3825 NTSTATUS set_nt_acl(files_struct *fsp, uint32 security_info_sent, const SEC_DESC *psd)
     3833NTSTATUS set_nt_acl(files_struct *fsp, uint32 security_info_sent, const SEC_DESC *psd_orig)
    38263834{
    38273835        connection_struct *conn = fsp->conn;
     
    38383846        bool acl_set_support = false;
    38393847        bool ret = false;
     3848        SEC_DESC *psd = NULL;
    38403849
    38413850        DEBUG(10,("set_nt_acl: called for file %s\n",
     
    38473856        }
    38483857
     3858        if (!psd_orig) {
     3859                return NT_STATUS_INVALID_PARAMETER;
     3860        }
     3861
     3862        psd = dup_sec_desc(talloc_tos(), psd_orig);
     3863        if (!psd) {
     3864                return NT_STATUS_NO_MEMORY;
     3865        }
     3866
    38493867        /*
    38503868         * Get the current state of the file.
     
    38623880         * Unpack the user/group/world id's.
    38633881         */
     3882
     3883        /* POSIX can't cope with missing owner/group. */
     3884        if ((security_info_sent & SECINFO_OWNER) && (psd->owner_sid == NULL)) {
     3885                security_info_sent &= ~SECINFO_OWNER;
     3886        }
     3887        if ((security_info_sent & SECINFO_GROUP) && (psd->group_sid == NULL)) {
     3888                security_info_sent &= ~SECINFO_GROUP;
     3889        }
    38643890
    38653891        status = unpack_nt_owners( SNUM(conn), &user, &grp, security_info_sent, psd);
     
    39123938
    39133939        create_file_sids(&fsp->fsp_name->st, &file_owner_sid, &file_grp_sid);
     3940
     3941        if((security_info_sent & SECINFO_DACL) &&
     3942                        (psd->type & SEC_DESC_DACL_PRESENT) &&
     3943                        (psd->dacl == NULL)) {
     3944                SEC_ACE ace[3];
     3945
     3946                /* We can't have NULL DACL in POSIX.
     3947                   Use owner/group/Everyone -> full access. */
     3948
     3949                init_sec_ace(&ace[0],
     3950                                &file_owner_sid,
     3951                                SEC_ACE_TYPE_ACCESS_ALLOWED,
     3952                                GENERIC_ALL_ACCESS,
     3953                                0);
     3954                init_sec_ace(&ace[1],
     3955                                &file_grp_sid,
     3956                                SEC_ACE_TYPE_ACCESS_ALLOWED,
     3957                                GENERIC_ALL_ACCESS,
     3958                                0);
     3959                init_sec_ace(&ace[2],
     3960                                &global_sid_World,
     3961                                SEC_ACE_TYPE_ACCESS_ALLOWED,
     3962                                GENERIC_ALL_ACCESS,
     3963                                0);
     3964                psd->dacl = make_sec_acl(talloc_tos(),
     3965                                        NT4_ACL_REVISION,
     3966                                        3,
     3967                                        ace);
     3968                if (psd->dacl == NULL) {
     3969                        return NT_STATUS_NO_MEMORY;
     3970                }
     3971                security_acl_map_generic(psd->dacl, &file_generic_mapping);
     3972        }
    39143973
    39153974        acl_perms = unpack_canon_ace(fsp, &fsp->fsp_name->st, &file_owner_sid,
     
    47574816        return ret_sd;
    47584817}
     4818
     4819/* Stolen shamelessly from pvfs_default_acl() in source4 :-). */
     4820
     4821NTSTATUS make_default_filesystem_acl(TALLOC_CTX *ctx,
     4822                                        const char *name,
     4823                                        SMB_STRUCT_STAT *psbuf,
     4824                                        SEC_DESC **ppdesc)
     4825{
     4826        struct dom_sid owner_sid, group_sid;
     4827        size_t size = 0;
     4828        SEC_ACE aces[4];
     4829        uint32_t access_mask = 0;
     4830        mode_t mode = psbuf->st_ex_mode;
     4831        SEC_ACL *new_dacl = NULL;
     4832        int idx = 0;
     4833
     4834        DEBUG(10,("make_default_filesystem_acl: file %s mode = 0%o\n",
     4835                name, (int)mode ));
     4836
     4837        uid_to_sid(&owner_sid, psbuf->st_ex_uid);
     4838        gid_to_sid(&group_sid, psbuf->st_ex_gid);
     4839
     4840        /*
     4841         We provide up to 4 ACEs
     4842                - Owner
     4843                - Group
     4844                - Everyone
     4845                - NT System
     4846        */
     4847
     4848        if (mode & S_IRUSR) {
     4849                if (mode & S_IWUSR) {
     4850                        access_mask |= SEC_RIGHTS_FILE_ALL;
     4851                } else {
     4852                        access_mask |= SEC_RIGHTS_FILE_READ | SEC_FILE_EXECUTE;
     4853                }
     4854        }
     4855        if (mode & S_IWUSR) {
     4856                access_mask |= SEC_RIGHTS_FILE_WRITE | SEC_STD_DELETE;
     4857        }
     4858
     4859        init_sec_ace(&aces[idx],
     4860                        &owner_sid,
     4861                        SEC_ACE_TYPE_ACCESS_ALLOWED,
     4862                        access_mask,
     4863                        0);
     4864        idx++;
     4865
     4866        access_mask = 0;
     4867        if (mode & S_IRGRP) {
     4868                access_mask |= SEC_RIGHTS_FILE_READ | SEC_FILE_EXECUTE;
     4869        }
     4870        if (mode & S_IWGRP) {
     4871                /* note that delete is not granted - this matches posix behaviour */
     4872                access_mask |= SEC_RIGHTS_FILE_WRITE;
     4873        }
     4874        if (access_mask) {
     4875                init_sec_ace(&aces[idx],
     4876                        &group_sid,
     4877                        SEC_ACE_TYPE_ACCESS_ALLOWED,
     4878                        access_mask,
     4879                        0);
     4880                idx++;
     4881        }
     4882
     4883        access_mask = 0;
     4884        if (mode & S_IROTH) {
     4885                access_mask |= SEC_RIGHTS_FILE_READ | SEC_FILE_EXECUTE;
     4886        }
     4887        if (mode & S_IWOTH) {
     4888                access_mask |= SEC_RIGHTS_FILE_WRITE;
     4889        }
     4890        if (access_mask) {
     4891                init_sec_ace(&aces[idx],
     4892                        &global_sid_World,
     4893                        SEC_ACE_TYPE_ACCESS_ALLOWED,
     4894                        access_mask,
     4895                        0);
     4896                idx++;
     4897        }
     4898
     4899        init_sec_ace(&aces[idx],
     4900                        &global_sid_System,
     4901                        SEC_ACE_TYPE_ACCESS_ALLOWED,
     4902                        SEC_RIGHTS_FILE_ALL,
     4903                        0);
     4904        idx++;
     4905
     4906        new_dacl = make_sec_acl(ctx,
     4907                        NT4_ACL_REVISION,
     4908                        idx,
     4909                        aces);
     4910
     4911        if (!new_dacl) {
     4912                return NT_STATUS_NO_MEMORY;
     4913        }
     4914
     4915        *ppdesc = make_sec_desc(ctx,
     4916                        SECURITY_DESCRIPTOR_REVISION_1,
     4917                        SEC_DESC_SELF_RELATIVE|SEC_DESC_DACL_PRESENT,
     4918                        &owner_sid,
     4919                        &group_sid,
     4920                        NULL,
     4921                        new_dacl,
     4922                        &size);
     4923        if (!*ppdesc) {
     4924                return NT_STATUS_NO_MEMORY;
     4925        }
     4926        return NT_STATUS_OK;
     4927}
Note: See TracChangeset for help on using the changeset viewer.