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/open.c

    r590 r596  
    2323#include "smbd/globals.h"
    2424
     25extern struct current_user current_user;
    2526extern const struct generic_mapping file_generic_mapping;
    2627
     
    14791480        ZERO_STRUCT(id);
    14801481
     1482        /* Windows allows a new file to be created and
     1483           silently removes a FILE_ATTRIBUTE_DIRECTORY
     1484           sent by the client. Do the same. */
     1485
     1486        new_dos_attributes &= ~FILE_ATTRIBUTE_DIRECTORY;
     1487
    14811488        if (conn->printer) {
    14821489                /*
     
    19611968        if ((flags2 & O_CREAT) && lp_inherit_acls(SNUM(conn)) &&
    19621969            (def_acl = directory_has_default_acl(conn, parent_dir))) {
    1963                 unx_mode = 0777;
     1970                unx_mode = (0777 & lp_create_mask(SNUM(conn)));
    19641971        }
    19651972
     
    22652272****************************************************************************/
    22662273
    2267 NTSTATUS open_file_fchmod(struct smb_request *req, connection_struct *conn,
     2274NTSTATUS open_file_fchmod(connection_struct *conn,
    22682275                          struct smb_filename *smb_fname,
    22692276                          files_struct **result)
    22702277{
    2271         files_struct *fsp = NULL;
    2272         NTSTATUS status;
    2273 
    22742278        if (!VALID_STAT(smb_fname->st)) {
    22752279                return NT_STATUS_INVALID_PARAMETER;
    22762280        }
    22772281
    2278         status = file_new(req, conn, &fsp);
    2279         if(!NT_STATUS_IS_OK(status)) {
    2280                 return status;
    2281         }
    2282 
    2283         status = SMB_VFS_CREATE_FILE(
     2282        return SMB_VFS_CREATE_FILE(
    22842283                conn,                                   /* conn */
    22852284                NULL,                                   /* req */
     
    22922291                0,                                      /* create_options */
    22932292                0,                                      /* file_attributes */
    2294                 0,                                      /* oplock_request */
     2293                INTERNAL_OPEN_ONLY,                     /* oplock_request */
    22952294                0,                                      /* allocation_size */
    22962295                NULL,                                   /* sd */
    22972296                NULL,                                   /* ea_list */
    2298                 &fsp,                                   /* result */
     2297                result,                                 /* result */
    22992298                NULL);                                  /* pinfo */
    2300 
    2301         /*
    2302          * This is not a user visible file open.
    2303          * Don't set a share mode.
    2304          */
    2305 
    2306         if (!NT_STATUS_IS_OK(status)) {
    2307                 file_free(req, fsp);
    2308                 return status;
    2309         }
    2310 
    2311         *result = fsp;
    2312         return NT_STATUS_OK;
    2313 }
    2314 
    2315 /****************************************************************************
    2316  Close the fchmod file fd - ensure no locks are lost.
    2317 ****************************************************************************/
    2318 
    2319 NTSTATUS close_file_fchmod(struct smb_request *req, files_struct *fsp)
    2320 {
    2321         NTSTATUS status = fd_close(fsp);
    2322         file_free(req, fsp);
    2323         return status;
    23242299}
    23252300
     
    24402415        SMB_ASSERT(!is_ntfs_stream_smb_fname(smb_dname));
    24412416
     2417        /* Ensure we have a directory attribute. */
     2418        file_attributes |= FILE_ATTRIBUTE_DIRECTORY;
     2419
    24422420        DEBUG(5,("open_directory: opening directory %s, access_mask = 0x%x, "
    24432421                 "share_access = 0x%x create_options = 0x%x, "
     
    24682446        }
    24692447
    2470         /* We need to support SeSecurityPrivilege for this. */
    2471         if (access_mask & SEC_FLAG_SYSTEM_SECURITY) {
     2448        if ((access_mask & SEC_FLAG_SYSTEM_SECURITY) &&
     2449                        !user_has_privileges(current_user.nt_user_token, &se_security)) {
    24722450                DEBUG(10, ("open_directory: open on %s "
    24732451                        "failed - SEC_FLAG_SYSTEM_SECURITY denied.\n",
     
    29782956        }
    29792957
    2980 #if 0
    2981         /* We need to support SeSecurityPrivilege for this. */
    29822958        if ((access_mask & SEC_FLAG_SYSTEM_SECURITY) &&
    2983             !user_has_privileges(current_user.nt_user_token,
    2984                                  &se_security)) {
     2959                        !user_has_privileges(current_user.nt_user_token, &se_security)) {
     2960                DEBUG(10, ("create_file_unixpath:: open on %s "
     2961                        "failed - SEC_FLAG_SYSTEM_SECURITY denied.\n",
     2962                        smb_fname_str_dbg(smb_fname)));
    29852963                status = NT_STATUS_PRIVILEGE_NOT_HELD;
    29862964                goto fail;
    29872965        }
    2988 #else
    2989         /* We need to support SeSecurityPrivilege for this. */
    2990         if (access_mask & SEC_FLAG_SYSTEM_SECURITY) {
    2991                 status = NT_STATUS_PRIVILEGE_NOT_HELD;
    2992                 goto fail;
    2993         }
    2994         /* Don't allow a SACL set from an NTtrans create until we
    2995          * support SeSecurityPrivilege. */
    2996         if (!VALID_STAT(smb_fname->st) &&
    2997                         lp_nt_acl_support(SNUM(conn)) &&
    2998                         sd && (sd->sacl != NULL)) {
    2999                 status = NT_STATUS_PRIVILEGE_NOT_HELD;
    3000                 goto fail;
    3001         }
    3002 #endif
    30032966
    30042967        if ((conn->fs_capabilities & FILE_NAMED_STREAMS)
     
    32713234                                   struct smb_request *req,
    32723235                                   uint16_t root_dir_fid,
    3273                                    struct smb_filename *smb_fname)
     3236                                   const struct smb_filename *smb_fname,
     3237                                   struct smb_filename **smb_fname_out)
    32743238{
    32753239        files_struct *dir_fsp;
     
    33593323        }
    33603324
    3361         new_base_name = talloc_asprintf(smb_fname, "%s%s", parent_fname,
     3325        new_base_name = talloc_asprintf(talloc_tos(), "%s%s", parent_fname,
    33623326                                        smb_fname->base_name);
    33633327        if (new_base_name == NULL) {
     
    33663330        }
    33673331
    3368         TALLOC_FREE(smb_fname->base_name);
    3369         smb_fname->base_name = new_base_name;
    3370         status = NT_STATUS_OK;
     3332        status = filename_convert(req,
     3333                                conn,
     3334                                req->flags2 & FLAGS2_DFS_PATHNAMES,
     3335                                new_base_name,
     3336                                0,
     3337                                NULL,
     3338                                smb_fname_out);
     3339        if (!NT_STATUS_IS_OK(status)) {
     3340                goto out;
     3341        }
    33713342
    33723343 out:
     
    34153386
    34163387        if (root_dir_fid != 0) {
     3388                struct smb_filename *smb_fname_out = NULL;
    34173389                status = get_relative_fid_filename(conn, req, root_dir_fid,
    3418                                                    smb_fname);
     3390                                                   smb_fname, &smb_fname_out);
    34193391                if (!NT_STATUS_IS_OK(status)) {
    34203392                        goto fail;
    34213393                }
     3394                smb_fname = smb_fname_out;
    34223395        }
    34233396
Note: See TracChangeset for help on using the changeset viewer.