Ignore:
Timestamp:
Nov 29, 2012, 1:59:04 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.9

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/server/source3/modules/vfs_acl_common.c

    r745 r751  
    167167*******************************************************************/
    168168
    169 static void add_directory_inheritable_components(vfs_handle_struct *handle,
     169static add_directory_inheritable_components(vfs_handle_struct *handle,
    170170                                const char *name,
    171171                                SMB_STRUCT_STAT *psbuf,
     
    185185
    186186        if (new_ace_list == NULL) {
    187                 return;
     187                return;
    188188        }
    189189
     
    237237                                SEC_ACE_FLAG_OBJECT_INHERIT|
    238238                                SEC_ACE_FLAG_INHERIT_ONLY);
    239         psd->dacl->aces = new_ace_list;
    240         psd->dacl->num_aces += 3;
     239        if (psd->dacl) {
     240                psd->dacl->aces = new_ace_list;
     241                psd->dacl->num_aces += 3;
     242        } else {
     243                psd->dacl = make_sec_acl(talloc_tos(),
     244                                NT4_ACL_REVISION,
     245                                3,
     246                                new_ace_list);
     247                if (psd->dacl == NULL) {
     248                        return NT_STATUS_NO_MEMORY;
     249                }
     250        }
     251        return NT_STATUS_OK;
    241252}
    242253
     
    253264                                struct security_descriptor **ppdesc)
    254265{
    255         DATA_BLOB blob;
     266        DATA_BLOB blob;
    256267        NTSTATUS status;
    257268        uint16_t hash_type = XATTR_SD_HASH_TYPE_NONE;
     
    379390                        }
    380391                }
    381                 is_directory = S_ISDIR(sbuf.st_ex_mode);
     392                is_directory = S_ISDIR(st_ex_mode);
    382393
    383394                if (ignore_file_system_acl) {
     
    394405                                !sd_has_inheritable_components(psd,
    395406                                                        true)) {
    396                                 add_directory_inheritable_components(handle,
     407                                status = add_directory_inheritable_components(
     408                                                        handle,
    397409                                                        name,
    398410                                                        psbuf,
    399411                                                        psd);
     412
     413
     414
    400415                        }
    401416                        /* The underlying POSIX module always sets
     
    414429        }
    415430        if (!(security_info & SECINFO_DACL)) {
     431
    416432                psd->dacl = NULL;
    417433        }
    418434        if (!(security_info & SECINFO_SACL)) {
     435
    419436                psd->sacl = NULL;
    420437        }
     
    538555                                        (SECINFO_OWNER |
    539556                                         SECINFO_GROUP |
    540                                          SECINFO_DACL),
     557                                         SECINFO_DACL  |
     558                                         SECINFO_SACL),
    541559                                        pp_parent_desc);
    542560
     
    557575                                struct security_descriptor **pp_parent_desc)
    558576{
    559         char *parent_name = NULL;
    560577        struct security_descriptor *parent_desc = NULL;
    561578        uint32_t access_granted = 0;
     
    576593        if(!NT_STATUS_IS_OK(status)) {
    577594                DEBUG(10,("check_parent_acl_common: access check "
    578                         "on directory %s for "
     595                        "on "
    579596                        "path %s for mask 0x%x returned %s\n",
    580                         parent_name,
    581597                        path,
    582598                        access_mask,
     
    621637                                (SECINFO_OWNER |
    622638                                 SECINFO_GROUP |
    623                                  SECINFO_DACL),
     639                                 SECINFO_DACL  |
     640                                 SECINFO_SACL),
    624641                                &pdesc);
    625642        if (NT_STATUS_IS_OK(status)) {
     
    632649                if (!NT_STATUS_IS_OK(status)) {
    633650                        DEBUG(10,("open_acl_xattr: %s open "
     651
    634652                                "refused with error %s\n",
    635653                                fsp_str_dbg(fsp),
     654
     655
    636656                                nt_errstr(status) ));
    637657                        goto err;
     
    800820                        CONST_DISCARD(struct security_descriptor *,psd));
    801821        }
    802         create_acl_blob(psd, &blob, XATTR_SD_HASH_TYPE_SHA256, hash);
    803         store_acl_blob_fsp(handle, fsp, &blob);
    804 
    805         return NT_STATUS_OK;
     822        status = create_acl_blob(psd, &blob, XATTR_SD_HASH_TYPE_SHA256, hash);
     823        if (!NT_STATUS_IS_OK(status)) {
     824                DEBUG(10, ("fset_nt_acl_xattr: create_acl_blob failed\n"));
     825                return status;
     826        }
     827
     828        status = store_acl_blob_fsp(handle, fsp, &blob);
     829
     830        return status;
    806831}
    807832
     
    809834                        const char *fname, const char *mask, uint32 attr)
    810835{
    811         NTSTATUS status = check_parent_acl_common(handle, fname,
    812                                         SEC_DIR_LIST, NULL);
    813 
    814         if (!NT_STATUS_IS_OK(status)) {
     836        NTSTATUS status;
     837        uint32_t access_granted = 0;
     838        struct security_descriptor *sd = NULL;
     839
     840        status = get_nt_acl_internal(handle,
     841                                NULL,
     842                                fname,
     843                                (SECINFO_OWNER |
     844                                 SECINFO_GROUP |
     845                                 SECINFO_DACL  |
     846                                 SECINFO_SACL),
     847                                &sd);
     848        if (!NT_STATUS_IS_OK(status)) {
     849                DEBUG(10,("opendir_acl_common: "
     850                        "get_nt_acl_internal for dir %s "
     851                        "failed with error %s\n",
     852                        fname,
     853                        nt_errstr(status) ));
    815854                errno = map_errno_from_nt_status(status);
    816855                return NULL;
    817856        }
     857
     858
     859
     860
     861
     862
     863
     864
     865
     866
     867
     868
     869
     870
     871
     872
     873
    818874        return SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);
    819875}
     
    831887        struct smb_filename local_fname;
    832888        int saved_errno = 0;
     889
     890
     891
     892
     893
     894
     895
    833896
    834897        if (!parent_dirname(talloc_tos(), path,
     
    843906
    844907        /* cd into the parent dir to pin it. */
    845         ret = SMB_VFS_CHDIR(conn, parent_dir);
     908        ret = (conn, parent_dir);
    846909        if (ret == -1) {
    847910                saved_errno = errno;
     
    862925        id = vfs_file_id_from_sbuf(conn, &local_fname.st);
    863926        for (fsp = file_find_di_first(conn->sconn, id); fsp;
    864             file_find_di_next(fsp)) {
     927        file_find_di_next(fsp)) {
    865928                if (fsp->access_mask & DELETE_ACCESS &&
    866929                                fsp->delete_on_close) {
     
    897960        TALLOC_FREE(parent_dir);
    898961
    899         vfs_ChDir(conn, conn->connectpath);
     962        if (saved_dir) {
     963                vfs_ChDir(conn, saved_dir);
     964        }
    900965        if (saved_errno) {
    901966                errno = saved_errno;
     
    909974        int ret;
    910975
     976
    911977        ret = SMB_VFS_NEXT_RMDIR(handle, path);
    912         if (!(ret == -1 && (errno == EACCES || errno == EPERM))) {
    913                 DEBUG(10,("rmdir_acl_common: unlink of %s failed %s\n",
    914                         path,
    915                         strerror(errno) ));
    916                 return ret;
    917         }
    918 
    919         return acl_common_remove_object(handle,
    920                                         path,
    921                                         true);
     978        if (ret == 0) {
     979                return 0;
     980        }
     981        if (errno == EACCES || errno == EPERM) {
     982                /* Failed due to access denied,
     983                   see if we need to root override. */
     984                return acl_common_remove_object(handle,
     985                                                path,
     986                                                true);
     987        }
     988
     989        DEBUG(10,("rmdir_acl_common: unlink of %s failed %s\n",
     990                path,
     991                strerror(errno) ));
     992        return -1;
    922993}
    923994
     
    10391110        int ret;
    10401111
     1112
    10411113        ret = SMB_VFS_NEXT_UNLINK(handle, smb_fname);
    1042         if (!(ret == -1 && (errno == EACCES || errno == EPERM))) {
    1043                 DEBUG(10,("unlink_acl_common: unlink of %s failed %s\n",
    1044                         smb_fname->base_name,
    1045                         strerror(errno) ));
    1046                 return ret;
    1047         }
    1048         /* Don't do anything fancy for streams. */
    1049         if (smb_fname->stream_name) {
    1050                 return ret;
    1051         }
    1052 
    1053         return acl_common_remove_object(handle,
     1114        if () {
     1115               
     1116       
     1117       
     1118               
     1119       
     1120
     1121       
     1122               
     1123       
     1124                }
     1125        return acl_common_remove_object(handle,
    10541126                                        smb_fname->base_name,
    10551127                                        false);
     1128
     1129
     1130
     1131
     1132
     1133
    10561134}
    10571135
Note: See TracChangeset for help on using the changeset viewer.