Ignore:
Timestamp:
May 24, 2009, 7:17:10 AM (16 years ago)
Author:
Herwig Bauernfeind
Message:

Update Samba 3.3 to 3.3.1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.3.x/source/smbd/open.c

    r206 r221  
    5151static NTSTATUS check_open_rights(struct connection_struct *conn,
    5252                                const char *fname,
    53                                 uint32_t access_mask)
     53                                uint32_t access_mask,
     54                                uint32_t *access_granted)
    5455{
    5556        /* Check if we have rights to open. */
    5657        NTSTATUS status;
    57         uint32_t access_granted = 0;
    5858        struct security_descriptor *sd;
     59
     60        *access_granted = 0;
    5961
    6062        status = SMB_VFS_GET_NT_ACL(conn, fname,
     
    7476                                conn->server_info->ptok,
    7577                                access_mask,
    76                                 &access_granted);
     78                                access_granted);
    7779
    7880        TALLOC_FREE(sd);
     81
     82        DEBUG(10,("check_open_rights: file %s requesting "
     83                "0x%x returning 0x%x (%s)\n",
     84                fname,
     85                (unsigned int)access_mask,
     86                (unsigned int)*access_granted,
     87                nt_errstr(status) ));
     88
    7989        return status;
    8090}
     
    399409                fsp->fh->fd = -1; /* What we used to call a stat open. */
    400410                if (file_existed) {
     411                        uint32_t access_granted = 0;
     412
    401413                        status = check_open_rights(conn,
    402414                                        path,
    403                                         access_mask);
     415                                        access_mask,
     416                                        &access_granted);
    404417                        if (!NT_STATUS_IS_OK(status)) {
    405                                 DEBUG(10, ("open_file: Access denied on "
    406                                         "file %s\n",
    407                                         path));
    408                                 return status;
     418                                if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) {
     419                                        if ((access_mask & DELETE_ACCESS) &&
     420                                                        (access_granted == DELETE_ACCESS) &&
     421                                                        can_delete_file_in_directory(conn, path)) {
     422                                                /* Were we trying to do a stat open
     423                                                 * for delete and didn't get DELETE
     424                                                 * access (only) ? Check if the
     425                                                 * directory allows DELETE_CHILD.
     426                                                 * See here:
     427                                                 * http://blogs.msdn.com/oldnewthing/archive/2004/06/04/148426.aspx
     428                                                 * for details. */
     429
     430                                                DEBUG(10,("open_file: overrode ACCESS_DENIED "
     431                                                        "on file %s\n",
     432                                                        path ));
     433                                        } else {
     434                                                DEBUG(10, ("open_file: Access denied on "
     435                                                        "file %s\n",
     436                                                        path));
     437                                                return status;
     438                                        }
     439                                } else if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND) &&
     440                                                        fsp->posix_open &&
     441                                                        S_ISLNK(psbuf->st_mode)) {
     442                                        /* This is a POSIX stat open for delete
     443                                         * or rename on a symlink that points
     444                                         * nowhere. Allow. */
     445                                        DEBUG(10, ("open_file: allowing POSIX open "
     446                                                "on bad symlink %s\n",
     447                                                path ));
     448                                } else {
     449                                        DEBUG(10, ("open_file: check_open_rights "
     450                                                "on file %s returned %s\n",
     451                                                path, nt_errstr(status) ));
     452                                        return status;
     453                                }
    409454                        }
    410455                }
     
    13141359        bool posix_open = False;
    13151360        bool new_file_created = False;
     1361        bool clear_ads = false;
    13161362        struct file_id id;
    13171363        NTSTATUS fsp_open = NT_STATUS_ACCESS_DENIED;
     
    13671413                   "unix mode=0%o oplock_request=%d\n",
    13681414                   fname, new_dos_attributes, access_mask, share_access,
    1369                    create_disposition, create_options, unx_mode,
     1415                   create_disposition, create_options, (unsigned int)unx_mode,
    13701416                   oplock_request));
    13711417
     
    14461492                         * exist create. */
    14471493                        flags2 |= (O_CREAT | O_TRUNC);
     1494                        clear_ads = true;
    14481495                        break;
    14491496
     
    14521499                         * exist create. */
    14531500                        flags2 |= (O_CREAT | O_TRUNC);
     1501                        clear_ads = true;
    14541502                        break;
    14551503
     
    14761524                        }
    14771525                        flags2 |= O_TRUNC;
     1526                        clear_ads = true;
    14781527                        break;
    14791528
     
    19081957
    19091958        SMB_ASSERT(lck != NULL);
     1959
     1960        /* Delete streams if create_disposition requires it */
     1961        if (file_existed && clear_ads && !is_ntfs_stream_name(fname)) {
     1962                status = delete_all_streams(conn, fname);
     1963                if (!NT_STATUS_IS_OK(status)) {
     1964                        TALLOC_FREE(lck);
     1965                        fd_close(fsp);
     1966                        return status;
     1967                }
     1968        }
    19101969
    19111970        /* note that we ignore failure for the following. It is
     
    23992458
    24002459        if (info == FILE_WAS_OPENED) {
     2460                uint32_t access_granted = 0;
    24012461                status = check_open_rights(conn,
    24022462                                        fname,
    2403                                         access_mask);
     2463                                        access_mask,
     2464                                        &access_granted);
    24042465                if (!NT_STATUS_IS_OK(status)) {
    24052466                        DEBUG(10, ("open_directory: check_open_rights on "
     
    28202881            && (share_access & FILE_SHARE_DELETE)
    28212882            && (access_mask & DELETE_ACCESS)
    2822             && (!can_delete_file_in_directory(conn, fname))) {
     2883            && (!(can_delete_file_in_directory(conn, fname) ||
     2884                 can_access_file_acl(conn, fname, DELETE_ACCESS)))) {
    28232885                status = NT_STATUS_ACCESS_DENIED;
     2886                DEBUG(10,("create_file_unixpath: open file %s "
     2887                        "for delete ACCESS_DENIED\n", fname ));
    28242888                goto fail;
    28252889        }
Note: See TracChangeset for help on using the changeset viewer.