Ignore:
Timestamp:
Nov 27, 2012, 4:43:17 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.0

Location:
trunk/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/source3/smbd/trans2.c

    r599 r745  
    2525
    2626#include "includes.h"
     27
    2728#include "version.h"
     29
    2830#include "smbd/globals.h"
    2931#include "../libcli/auth/libcli_auth.h"
     32
     33
     34
     35
     36
     37
     38
     39
    3040
    3141#define DIR_ENTRY_SAFETY_MARGIN 4096
     
    150160        } else {
    151161#else
    152                 {
     162        {
    153163#endif
    154164                pea->name = talloc_strdup(mem_ctx, ea_name);
     
    508518        if (!lp_ea_support(SNUM(conn))) {
    509519                return NT_STATUS_EAS_NOT_SUPPORTED;
     520
     521
     522
     523
    510524        }
    511525
     
    792806        int data_alignment_offset = 0;
    793807        bool overflow = False;
    794         struct smbd_server_connection *sconn = smbd_server_conn;
     808        struct smbd_server_connection *sconn = conn;
    795809        int max_send = sconn->smb1.sessions.max_send;
    796810
     
    812826                reply_outbuf(req, 10, 0);
    813827                show_msg((char *)req->outbuf);
    814                 if (!srv_send_smb(smbd_server_fd(),
     828                if (!srv_send_smb(s,
    815829                                (char *)req->outbuf,
    816830                                true, req->seqnum+1,
     
    951965                /* Send the packet */
    952966                show_msg((char *)req->outbuf);
    953                 if (!srv_send_smb(smbd_server_fd(),
     967                if (!srv_send_smb(s,
    954968                                (char *)req->outbuf,
    955969                                true, req->seqnum+1,
     
    10141028        uint32 create_disposition;
    10151029        uint32 create_options = 0;
     1030
    10161031        TALLOC_CTX *ctx = talloc_tos();
    10171032
     
    10851100                                         &access_mask, &share_mode,
    10861101                                         &create_disposition,
    1087                                          &create_options)) {
     1102                                         &create_options,
     1103                                         &private_flags)) {
    10881104                reply_nterror(req, NT_STATUS_ACCESS_DENIED);
    10891105                goto out;
     
    11291145                oplock_request,                         /* oplock_request */
    11301146                open_size,                              /* allocation_size */
     1147
    11311148                NULL,                                   /* sd */
    11321149                ea_list,                                /* ea_list */
     
    11471164        mtime = convert_timespec_to_time_t(smb_fname->st.st_ex_mtime);
    11481165        inode = smb_fname->st.st_ex_ino;
    1149         if (fattr & aDIR) {
     1166        if (fattr & ) {
    11501167                close_file(req, fsp, ERROR_CLOSE);
    11511168                reply_nterror(req, NT_STATUS_ACCESS_DENIED);
     
    14921509                                    const char *fname,
    14931510                                    const struct smb_filename *smb_fname,
    1494                                     uint64_t space_remaining,
     1511                                    t space_remaining,
    14951512                                    uint8_t align,
    14961513                                    bool do_pad,
     
    15131530        char *last_entry_ptr;
    15141531        bool was_8_3;
    1515         off_t off;
    1516         off_t pad = 0;
     1532        t off;
     1533        t pad = 0;
    15171534
    15181535        *out_of_space = false;
     
    15231540        ZERO_STRUCT(cdate_ts);
    15241541
    1525         if (!(mode & aDIR)) {
     1542        if (!(mode & )) {
    15261543                file_size = get_file_size_stat(&smb_fname->st);
    15271544        }
     
    15481565
    15491566        /* align the record */
    1550         off = PTR_DIFF(pdata, base_data);
     1567        SMB_ASSERT(align >= 1);
     1568
     1569        off = (int)PTR_DIFF(pdata, base_data);
    15511570        pad = (off + (align-1)) & ~(align-1);
    15521571        pad -= off;
     1572
     1573
     1574
     1575
     1576
     1577
     1578
     1579
     1580
     1581
    15531582        off += pad;
    15541583        /* initialize padding to 0 */
     
    15571586        }
    15581587        space_remaining -= pad;
     1588
     1589
     1590
    15591591
    15601592        pdata += pad;
     
    16721704                if (PTR_DIFF(p + 255 + ea_len,pdata) > space_remaining) {
    16731705                        *out_of_space = true;
    1674                         DEBUG(9,("smbd_marshall_dir_entry: out of space\n"));
     1706                        DEBUG(9,("smbd_marshall_dir_entry: out of space "
     1707                                "(wanted %u, had %d)\n",
     1708                                (unsigned int)PTR_DIFF(p + 255 + ea_len,pdata),
     1709                                space_remaining ));
    16751710                        return False; /* Not finished - just out of space */
    16761711                }
     
    20502085        if (PTR_DIFF(p,pdata) > space_remaining) {
    20512086                *out_of_space = true;
    2052                 DEBUG(9,("smbd_marshall_dir_entry: out of space\n"));
     2087                DEBUG(9,("smbd_marshall_dir_entry: out of space "
     2088                        "(wanted %u, had %d)\n",
     2089                        (unsigned int)PTR_DIFF(p,pdata),
     2090                        space_remaining ));
    20532091                return false; /* Not finished - just out of space */
    20542092        }
     
    22452283        TALLOC_CTX *ctx = talloc_tos();
    22462284        struct dptr_struct *dirptr = NULL;
    2247         struct smbd_server_connection *sconn = smbd_server_conn;
     2285        struct smbd_server_connection *sconn = conn;
    22482286
    22492287        if (total_params < 13) {
     
    23352373                        mask_contains_wcard = True;
    23362374                }
    2337                 directory = talloc_strdup(talloc_tos(), "./");
     2375        } else {
     2376                *p = 0;
     2377        }
     2378
     2379        if (p == NULL || p == directory) {
     2380                /* Ensure we don't have a directory name of "". */
     2381                directory = talloc_strdup(talloc_tos(), ".");
    23382382                if (!directory) {
    23392383                        reply_nterror(req, NT_STATUS_NO_MEMORY);
    23402384                        goto out;
    23412385                }
    2342         } else {
    2343                 *p = 0;
    23442386        }
    23452387
     
    23962438
    23972439        ntstatus = dptr_create(conn,
     2440
    23982441                                directory,
    23992442                                False,
     
    25842627        TALLOC_CTX *ctx = talloc_tos();
    25852628        struct dptr_struct *dirptr;
    2586         struct smbd_server_connection *sconn = smbd_server_conn;
     2629        struct smbd_server_connection *sconn = conn;
    25872630
    25882631        if (total_params < 13) {
     
    28792922#endif
    28802923        extended_info->samba_gitcommitdate = 0;
    2881 #ifdef SAMBA_VERSION_GIT_COMMIT_TIME
    2882         unix_to_nt_time(&extended_info->samba_gitcommitdate, SAMBA_VERSION_GIT_COMMIT_TIME);
     2924#ifdef SAMBA_VERSION_COMMIT_TIME
     2925        unix_to_nt_time(&extended_info->samba_gitcommitdate, SAMBA_VERSION_COMMIT_TIME);
    28832926#endif
    28842927
     
    31303173                case SMB_QUERY_FS_DEVICE_INFO:
    31313174                case SMB_FS_DEVICE_INFORMATION:
     3175
     3176
     3177
     3178
     3179
     3180
    31323181                        data_len = 8;
    3133                         SIVAL(pdata,0,0); /* dev type */
    3134                         SIVAL(pdata,4,0); /* characteristics */
    3135                         break;
     3182                        SIVAL(pdata,0,FILE_DEVICE_DISK); /* dev type */
     3183                        SIVAL(pdata,4,characteristics);
     3184                        break;
     3185                }
    31363186
    31373187#ifdef HAVE_SYS_QUOTAS
     
    31703220
    31713221                        /* access check */
    3172                         if (conn->server_info->utok.uid != sec_initial_uid() &&
    3173                                         !conn->admin_user) {
     3222                        if (get_current_uid(conn) != 0) {
    31743223                                DEBUG(0,("set_user_quota: access_denied "
    31753224                                         "service [%s] user [%s]\n",
    31763225                                         lp_servicename(SNUM(conn)),
    3177                                          conn->server_info->unix_name));
     3226                                         conn->se_info->unix_name));
    31783227                                return NT_STATUS_ACCESS_DENIED;
    31793228                        }
     
    32333282                {
    32343283                        bool large_write = lp_min_receive_file_size() &&
    3235                                         !srv_is_signing_active(smbd_server_conn);
    3236                         bool large_read = !srv_is_signing_active(smbd_server_conn);
     3284                                        !srv_is_signing_active(conn);
     3285                        bool large_read = !srv_is_signing_active(conn);
    32373286                        int encrypt_caps = 0;
    32383287
     
    33283377                         */
    33293378                        if (nt_token_check_sid(&global_sid_Builtin_Guests,
    3330                                                conn->server_info->ptok)) {
     3379                                               conn->se)) {
    33313380                                flags |= SMB_WHOAMI_GUEST;
    33323381                        }
     
    33363385                         */
    33373386                        if (nt_token_check_sid(&global_sid_Authenticated_Users,
    3338                                                conn->server_info->ptok)) {
     3387                                               conn->se)) {
    33393388                                flags &= ~SMB_WHOAMI_GUEST;
    33403389                        }
     
    33523401                            + 4 /* SID bytes */
    33533402                            + 4 /* pad/reserved */
    3354                             + (conn->server_info->utok.ngroups * 8)
     3403                            + (conn->se_info->utok.ngroups * 8)
    33553404                                /* groups list */
    3356                             + (conn->server_info->ptok->num_sids *
     3405                            + (conn->se->num_sids *
    33573406                                    SID_MAX_SIZE)
    33583407                                /* SID list */;
     
    33613410                        SIVAL(pdata, 4, SMB_WHOAMI_MASK);
    33623411                        SBIG_UINT(pdata, 8,
    3363                                   (uint64_t)conn->server_info->utok.uid);
     3412                                  (uint64_t)conn->se_info->utok.uid);
    33643413                        SBIG_UINT(pdata, 16,
    3365                                   (uint64_t)conn->server_info->utok.gid);
     3414                                  (uint64_t)conn->se_info->utok.gid);
    33663415
    33673416
     
    33783427                        }
    33793428
    3380                         SIVAL(pdata, 24, conn->server_info->utok.ngroups);
    3381                         SIVAL(pdata, 28, conn->server_info->num_sids);
     3429                        SIVAL(pdata, 24, conn->se_info->utok.ngroups);
     3430                        SIVAL(pdata, 28, conn->se->num_sids);
    33823431
    33833432                        /* We walk the SID list twice, but this call is fairly
     
    33863435                         */
    33873436                        for (i = 0, sid_bytes = 0;
    3388                              i < conn->server_info->ptok->num_sids; ++i) {
     3437                             i < conn->se->num_sids; ++i) {
    33893438                                sid_bytes += ndr_size_dom_sid(
    3390                                         &conn->server_info->ptok->user_sids[i],
    3391                                         NULL,
     3439                                        &conn->session_info->security_token->sids[i],
    33923440                                        0);
    33933441                        }
     
    34013449
    34023450                        /* GID list */
    3403                         for (i = 0; i < conn->server_info->utok.ngroups; ++i) {
     3451                        for (i = 0; i < conn->se_info->utok.ngroups; ++i) {
    34043452                                SBIG_UINT(pdata, data_len,
    3405                                           (uint64_t)conn->server_info->utok.groups[i]);
     3453                                          (uint64_t)conn->se_info->utok.groups[i]);
    34063454                                data_len += 8;
    34073455                        }
     
    34093457                        /* SID list */
    34103458                        for (i = 0;
    3411                             i < conn->server_info->ptok->num_sids; ++i) {
     3459                            i < conn->se->num_sids; ++i) {
    34123460                                int sid_len = ndr_size_dom_sid(
    3413                                         &conn->server_info->ptok->user_sids[i],
    3414                                         NULL,
     3461                                        &conn->session_info->security_token->sids[i],
    34153462                                        0);
    34163463
    34173464                                sid_linearize(pdata + data_len, sid_len,
    3418                                     &conn->server_info->ptok->user_sids[i]);
     3465                                    &conn->sesids[i]);
    34193466                                data_len += sid_len;
    34203467                        }
     
    36153662                                }
    36163663
     3664
     3665
     3666
     3667
     3668
     3669
     3670
     3671
     3672
     3673
    36173674                                DEBUG( 4,("call_trans2setfsinfo: "
    36183675                                        "request transport encryption.\n"));
     
    36583715
    36593716                                /* access check */
    3660                                 if (((conn->server_info->utok.uid != sec_initial_uid()) && !conn->admin_user)
    3661                                     ||!CAN_WRITE(conn)) {
     3717                                if ((get_current_uid(conn) != 0) || !CAN_WRITE(conn)) {
    36623718                                        DEBUG(0,("set_user_quota: access_denied service [%s] user [%s]\n",
    36633719                                                 lp_servicename(SNUM(conn)),
    3664                                                  conn->server_info->unix_name));
     3720                                                 conn->se_info->unix_name));
    36653721                                        reply_nterror(req, NT_STATUS_ACCESS_DENIED);
    36663722                                        return;
     
    36933749
    36943750                                /* the soft quotas 8 bytes (uint64_t)*/
    3695                                 quotas.softlim = (uint64_t)IVAL(pdata,24);
    3696 #ifdef LARGE_SMB_OFF_T
    3697                                 quotas.softlim |= (((uint64_t)IVAL(pdata,28)) << 32);
    3698 #else /* LARGE_SMB_OFF_T */
    3699                                 if ((IVAL(pdata,28) != 0)&&
    3700                                         ((quotas.softlim != 0xFFFFFFFF)||
    3701                                         (IVAL(pdata,28)!=0xFFFFFFFF))) {
    3702                                         /* more than 32 bits? */
    3703                                         reply_nterror(
    3704                                                 req,
    3705                                                 NT_STATUS_INVALID_PARAMETER);
    3706                                         return;
    3707                                 }
    3708 #endif /* LARGE_SMB_OFF_T */
     3751                                quotas.softlim = BVAL(pdata,24);
    37093752
    37103753                                /* the hard quotas 8 bytes (uint64_t)*/
    3711                                 quotas.hardlim = (uint64_t)IVAL(pdata,32);
    3712 #ifdef LARGE_SMB_OFF_T
    3713                                 quotas.hardlim |= (((uint64_t)IVAL(pdata,36)) << 32);
    3714 #else /* LARGE_SMB_OFF_T */
    3715                                 if ((IVAL(pdata,36) != 0)&&
    3716                                         ((quotas.hardlim != 0xFFFFFFFF)||
    3717                                         (IVAL(pdata,36)!=0xFFFFFFFF))) {
    3718                                         /* more than 32 bits? */
    3719                                         reply_nterror(
    3720                                                 req,
    3721                                                 NT_STATUS_INVALID_PARAMETER);
    3722                                         return;
    3723                                 }
    3724 #endif /* LARGE_SMB_OFF_T */
     3754                                quotas.hardlim = BVAL(pdata,32);
    37253755
    37263756                                /* quota_flags 2 bytes **/
     
    41764206                               bool delete_pending,
    41774207                               struct timespec write_time_ts,
    4178                                bool ms_dfs_link,
    41794208                               struct ea_list *ea_list,
    41804209                               int lock_data_count,
     
    42114240                 info_level, max_data_bytes));
    42124241
    4213         if (ms_dfs_link) {
    4214                 mode = dos_mode_msdfs(conn, smb_fname);
    4215         } else {
    4216                 mode = dos_mode(conn, smb_fname);
    4217         }
    4218 
     4242        mode = dos_mode(conn, smb_fname);
    42194243        nlink = psbuf->st_ex_nlink;
    42204244
    4221         if (nlink && (mode&aDIR)) {
     4245        if (nlink && (mode&)) {
    42224246                nlink = 1;
    42234247        }
     
    42944318                files_struct *fsp1;
    42954319                struct file_id fileid = vfs_file_id_from_sbuf(conn, psbuf);
    4296                 fsp1 = file_find_di_first(fileid);
     4320                fsp1 = file_find_di_first(fileid);
    42974321                if (fsp1 && fsp1->initial_allocation_size) {
    42984322                        allocation_size = SMB_VFS_GET_ALLOC_SIZE(conn, fsp1, psbuf);
     
    43004324        }
    43014325
    4302         if (!(mode & aDIR)) {
     4326        if (!(mode & )) {
    43034327                file_size = get_file_size_stat(psbuf);
    43044328        }
     
    44704494                        SIVAL(pdata,16,nlink);
    44714495                        SCVAL(pdata,20,delete_pending?1:0);
    4472                         SCVAL(pdata,21,(mode&aDIR)?1:0);
     4496                        SCVAL(pdata,21,(mode&)?1:0);
    44734497                        SSVAL(pdata,22,0); /* Padding. */
    44744498                        break;
     
    45534577                        SIVAL(pdata,16,nlink);
    45544578                        SCVAL(pdata,20,delete_pending);
    4555                         SCVAL(pdata,21,(mode&aDIR)?1:0);
     4579                        SCVAL(pdata,21,(mode&)?1:0);
    45564580                        SSVAL(pdata,22,0);
    45574581                        pdata += 24;
     
    45844608                        SIVAL(pdata,    0x38, nlink);
    45854609                        SCVAL(pdata,    0x3C, delete_pending);
    4586                         SCVAL(pdata,    0x3D, (mode&aDIR)?1:0);
     4610                        SCVAL(pdata,    0x3D, (mode&)?1:0);
    45874611                        SSVAL(pdata,    0x3E, 0); /* padding */
    45884612                        SBVAL(pdata,    0x40, file_index);
     
    47344758                        data_size = PTR_DIFF(pdata,(*ppdata));
    47354759
    4736                         {
    4737                                 int i;
    4738                                 DEBUG(4,("smbd_do_qfilepathinfo: SMB_QUERY_FILE_UNIX_BASIC "));
    4739 
    4740                                 for (i=0; i<100; i++)
    4741                                         DEBUG(4,("%d=%x, ",i, (*ppdata)[i]));
    4742                                 DEBUG(4,("\n"));
    4743                         }
     4760                        DEBUG(4,("smbd_do_qfilepathinfo: "
     4761                                 "SMB_QUERY_FILE_UNIX_BASIC\n"));
     4762                        dump_data(4, (uint8_t *)(*ppdata), data_size);
    47444763
    47454764                        break;
     
    48034822                                uint16 num_def_acls = 0;
    48044823
    4805                                 if (fsp && !fsp->is_directory && (fsp->fh->fd != -1)) {
     4824                                if (fsp && ) {
    48064825                                        file_acl = SMB_VFS_SYS_ACL_GET_FD(fsp);
    48074826                                } else {
     
    48924911                        uint64_t count;
    48934912                        uint64_t offset;
    4894                         uint32 lock_pid;
     4913                        uint;
    48954914                        enum brl_type lock_type;
    48964915
    48974916                        /* We need an open file with a real fd for this. */
    4898                         if (!fsp || fsp->is_directory || fsp->fh->fd == -1) {
     4917                        if (!fsp || fsp->fh->fd == -1) {
    48994918                                return NT_STATUS_INVALID_LEVEL;
    49004919                        }
     
    49174936                        }
    49184937
    4919                         lock_pid = IVAL(pdata, POSIX_LOCK_PID_OFFSET);
     4938                        IVAL(pdata, POSIX_LOCK_PID_OFFSET);
    49204939#if defined(HAVE_LONGLONG)
    49214940                        offset = (((uint64_t) IVAL(pdata,(POSIX_LOCK_START_OFFSET+4))) << 32) |
     
    49294948
    49304949                        status = query_lock(fsp,
    4931                                         &lock_pid,
     4950                                        &,
    49324951                                        &count,
    49334952                                        &offset,
     
    49414960                                SSVAL(pdata, POSIX_LOCK_TYPE_OFFSET, lock_type);
    49424961                                SSVAL(pdata, POSIX_LOCK_FLAGS_OFFSET, 0);
    4943                                 SIVAL(pdata, POSIX_LOCK_PID_OFFSET, lock_pid);
     4962                                SIVAL(pdata, POSIX_LOCK_PID_OFFSET, );
    49444963#if defined(HAVE_LONGLONG)
    49454964                                SIVAL(pdata, POSIX_LOCK_START_OFFSET, (uint32)(offset & 0xFFFFFFFF));
     
    49975016        int lock_data_count = 0;
    49985017        char *lock_data = NULL;
    4999         bool ms_dfs_link = false;
    50005018        NTSTATUS status = NT_STATUS_OK;
    50015019
     
    50505068                        /* We know this name is ok, it's already passed the checks. */
    50515069
    5052                 } else if(fsp->is_directory || fsp->fh->fd == -1) {
     5070                } else if(fsp->fh->fd == -1) {
    50535071                        /*
    50545072                         * This is actually a QFILEINFO on a directory
     
    50805098
    50815099                        fileid = vfs_file_id_from_sbuf(conn, &smb_fname->st);
    5082                         get_file_infos(fileid, &delete_pending, &write_time_ts);
     5100                        get_file_infos(fileid, &delete_pending, &write_time_ts);
    50835101                } else {
    50845102                        /*
    50855103                         * Original code - this is an open file.
    50865104                         */
    5087                         if (!check_fsp(conn, req, fsp)) {
    5088                                 return;
    5089                         }
    5090 
    50915105                        if (SMB_VFS_FSTAT(fsp, &smb_fname->st) != 0) {
    50925106                                DEBUG(3, ("fstat of fnum %d failed (%s)\n",
     
    50975111                        }
    50985112                        fileid = vfs_file_id_from_sbuf(conn, &smb_fname->st);
    5099                         get_file_infos(fileid, &delete_pending, &write_time_ts);
     5113                        get_file_infos(fileid, &delete_pending, &write_time_ts);
    51005114                }
    51015115
    51025116        } else {
     5117
    51035118                char *fname = NULL;
    51045119
     
    51875202                        }
    51885203
     5204
     5205
     5206
     5207
     5208
     5209
     5210
     5211
     5212
    51895213                        fileid = vfs_file_id_from_sbuf(conn,
    51905214                                                       &smb_fname_base->st);
    51915215                        TALLOC_FREE(smb_fname_base);
    5192                         get_file_infos(fileid, &delete_pending, NULL);
     5216                        get_file_infos(fileid, &delete_pending, NULL);
    51935217                        if (delete_pending) {
    51945218                                reply_nterror(req, NT_STATUS_DELETE_PENDING);
     
    52095233                        }
    52105234
    5211                 } else if (!VALID_STAT(smb_fname->st) &&
    5212                            SMB_VFS_STAT(conn, smb_fname) &&
    5213                            (info_level != SMB_INFO_IS_NAME_VALID)) {
    5214                         ms_dfs_link = check_msdfs_link(conn,
    5215                                                        smb_fname->base_name,
    5216                                                        &smb_fname->st);
    5217 
    5218                         if (!ms_dfs_link) {
     5235                } else {
     5236                        if (SMB_VFS_STAT(conn, smb_fname) != 0) {
    52195237                                DEBUG(3,("call_trans2qfilepathinfo: "
    52205238                                         "SMB_VFS_STAT of %s failed (%s)\n",
     
    52275245                }
    52285246
     5247
     5248
     5249
     5250
     5251
     5252
     5253
     5254
    52295255                fileid = vfs_file_id_from_sbuf(conn, &smb_fname->st);
    5230                 get_file_infos(fileid, &delete_pending, &write_time_ts);
     5256                get_file_infos(fileid, &delete_pending, &write_time_ts);
    52315257                if (delete_pending) {
    52325258                        reply_nterror(req, NT_STATUS_DELETE_PENDING);
     
    53405366                                       fsp, smb_fname,
    53415367                                       delete_pending, write_time_ts,
    5342                                        ms_dfs_link, ea_list,
     5368                                       ea_list,
    53435369                                       lock_data_count, lock_data,
    53445370                                       req->flags2, max_data_bytes,
     
    53625388NTSTATUS hardlink_internals(TALLOC_CTX *ctx,
    53635389                connection_struct *conn,
     5390
     5391
    53645392                const struct smb_filename *smb_fname_old,
    5365                 const struct smb_filename *smb_fname_new)
     5393                struct smb_filename *smb_fname_new)
    53665394{
    53675395        NTSTATUS status = NT_STATUS_OK;
     
    53725400        }
    53735401
    5374         /* Disallow if newname already exists. */
    53755402        if (VALID_STAT(smb_fname_new->st)) {
    5376                 return NT_STATUS_OBJECT_NAME_COLLISION;
     5403                if (overwrite_if_exists) {
     5404                        if (S_ISDIR(smb_fname_new->st.st_ex_mode)) {
     5405                                return NT_STATUS_FILE_IS_A_DIRECTORY;
     5406                        }
     5407                        status = unlink_internals(conn,
     5408                                                req,
     5409                                                FILE_ATTRIBUTE_NORMAL,
     5410                                                smb_fname_new,
     5411                                                false);
     5412                        if (!NT_STATUS_IS_OK(status)) {
     5413                                return status;
     5414                        }
     5415                } else {
     5416                        /* Disallow if newname already exists. */
     5417                        return NT_STATUS_OBJECT_NAME_COLLISION;
     5418                }
    53775419        }
    53785420
     
    54215463        }
    54225464
     5465
     5466
     5467
     5468
    54235469        /* get some defaults (no modifications) if any info is zero or -1. */
    54245470        if (null_timespec(ft->create_time)) {
     
    55335579        if (dosmode) {
    55345580                if (S_ISDIR(smb_fname_base->st.st_ex_mode)) {
    5535                         dosmode |= aDIR;
     5581                        dosmode |= ;
    55365582                } else {
    5537                         dosmode &= ~aDIR;
     5583                        dosmode &= ~;
    55385584                }
    55395585        }
     
    55835629        }
    55845630
     5631
     5632
     5633
     5634
    55855635        DEBUG(6,("smb_set_file_size: size: %.0f ", (double)size));
    55865636
     
    56135663                0,                                      /* root_dir_fid */
    56145664                smb_fname_tmp,                          /* fname */
    5615                 FILE_WRITE_ATTRIBUTES,                  /* access_mask */
     5665                FILE_WRITE_,                        /* access_mask */
    56165666                (FILE_SHARE_READ | FILE_SHARE_WRITE |   /* share_access */
    56175667                    FILE_SHARE_DELETE),
     
    56215671                FORCE_OPLOCK_BREAK_TO_NONE,             /* oplock_request */
    56225672                0,                                      /* allocation_size */
     5673
    56235674                NULL,                                   /* sd */
    56245675                NULL,                                   /* ea_list */
     
    56885739                return NT_STATUS_INVALID_PARAMETER;
    56895740        }
     5741
     5742
     5743
     5744
     5745
    56905746        status = set_ea(conn, fsp, smb_fname, ea_list);
    56915747
     
    57305786                return NT_STATUS_INVALID_PARAMETER;
    57315787        }
     5788
     5789
     5790
     5791
     5792
    57325793        status = set_ea(conn, fsp, fsp->fsp_name, ea_list);
    57335794
     
    57805841        /* The set is across all open files on this dev/inode pair. */
    57815842        if (!set_delete_on_close(fsp, delete_on_close,
    5782                                  &conn->server_info->utok)) {
     5843                                 &conn->se_info->utok)) {
    57835844                return NT_STATUS_ACCESS_DENIED;
    57845845        }
     
    58925953                                        struct smb_request *req,
    58935954                                        const char *pdata, int total_data,
    5894                                         const struct smb_filename *smb_fname_new)
     5955                                        struct smb_filename *smb_fname_new)
    58955956{
    58965957        char *oldname = NULL;
     
    59245985        }
    59255986
    5926         return hardlink_internals(ctx, conn, smb_fname_old, smb_fname_new);
     5987        return hardlink_internals(ctx, conn, req, false,
     5988                        smb_fname_old, smb_fname_new);
     5989}
     5990
     5991/****************************************************************************
     5992 Deal with SMB2_FILE_RENAME_INFORMATION_INTERNAL
     5993****************************************************************************/
     5994
     5995static NTSTATUS smb2_file_rename_information(connection_struct *conn,
     5996                                            struct smb_request *req,
     5997                                            const char *pdata,
     5998                                            int total_data,
     5999                                            files_struct *fsp,
     6000                                            struct smb_filename *smb_fname_src)
     6001{
     6002        bool overwrite;
     6003        uint32_t len;
     6004        char *newname = NULL;
     6005        struct smb_filename *smb_fname_dst = NULL;
     6006        NTSTATUS status = NT_STATUS_OK;
     6007        TALLOC_CTX *ctx = talloc_tos();
     6008
     6009        if (!fsp) {
     6010                return NT_STATUS_INVALID_HANDLE;
     6011        }
     6012
     6013        if (total_data < 20) {
     6014                return NT_STATUS_INVALID_PARAMETER;
     6015        }
     6016
     6017        overwrite = (CVAL(pdata,0) ? True : False);
     6018        len = IVAL(pdata,16);
     6019
     6020        if (len > (total_data - 20) || (len == 0)) {
     6021                return NT_STATUS_INVALID_PARAMETER;
     6022        }
     6023
     6024        srvstr_get_path(ctx, pdata, req->flags2, &newname,
     6025                                &pdata[20], len, STR_TERMINATE,
     6026                                &status);
     6027        if (!NT_STATUS_IS_OK(status)) {
     6028                return status;
     6029        }
     6030
     6031        DEBUG(10,("smb2_file_rename_information: got name |%s|\n",
     6032                                newname));
     6033
     6034        status = filename_convert(ctx,
     6035                                conn,
     6036                                req->flags2 & FLAGS2_DFS_PATHNAMES,
     6037                                newname,
     6038                                UCF_SAVE_LCOMP,
     6039                                NULL,
     6040                                &smb_fname_dst);
     6041        if (!NT_STATUS_IS_OK(status)) {
     6042                return status;
     6043        }
     6044
     6045        if (fsp->base_fsp) {
     6046                /* newname must be a stream name. */
     6047                if (newname[0] != ':') {
     6048                        return NT_STATUS_NOT_SUPPORTED;
     6049                }
     6050
     6051                /* Create an smb_fname to call rename_internals_fsp() with. */
     6052                status = create_synthetic_smb_fname(talloc_tos(),
     6053                    fsp->base_fsp->fsp_name->base_name, newname, NULL,
     6054                    &smb_fname_dst);
     6055                if (!NT_STATUS_IS_OK(status)) {
     6056                        goto out;
     6057                }
     6058
     6059                /*
     6060                 * Set the original last component, since
     6061                 * rename_internals_fsp() requires it.
     6062                 */
     6063                smb_fname_dst->original_lcomp = talloc_strdup(smb_fname_dst,
     6064                                                              newname);
     6065                if (smb_fname_dst->original_lcomp == NULL) {
     6066                        status = NT_STATUS_NO_MEMORY;
     6067                        goto out;
     6068                }
     6069
     6070        }
     6071
     6072        DEBUG(10,("smb2_file_rename_information: "
     6073                  "SMB_FILE_RENAME_INFORMATION (fnum %d) %s -> %s\n",
     6074                  fsp->fnum, fsp_str_dbg(fsp),
     6075                  smb_fname_str_dbg(smb_fname_dst)));
     6076        status = rename_internals_fsp(conn, fsp, smb_fname_dst,
     6077                                (FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM),
     6078                                overwrite);
     6079
     6080 out:
     6081        TALLOC_FREE(smb_fname_dst);
     6082        return status;
     6083}
     6084
     6085static NTSTATUS smb_file_link_information(connection_struct *conn,
     6086                                            struct smb_request *req,
     6087                                            const char *pdata,
     6088                                            int total_data,
     6089                                            files_struct *fsp,
     6090                                            struct smb_filename *smb_fname_src)
     6091{
     6092        bool overwrite;
     6093        uint32_t len;
     6094        char *newname = NULL;
     6095        struct smb_filename *smb_fname_dst = NULL;
     6096        NTSTATUS status = NT_STATUS_OK;
     6097        TALLOC_CTX *ctx = talloc_tos();
     6098
     6099        if (!fsp) {
     6100                return NT_STATUS_INVALID_HANDLE;
     6101        }
     6102
     6103        if (total_data < 20) {
     6104                return NT_STATUS_INVALID_PARAMETER;
     6105        }
     6106
     6107        overwrite = (CVAL(pdata,0) ? true : false);
     6108        len = IVAL(pdata,16);
     6109
     6110        if (len > (total_data - 20) || (len == 0)) {
     6111                return NT_STATUS_INVALID_PARAMETER;
     6112        }
     6113
     6114        srvstr_get_path(ctx, pdata, req->flags2, &newname,
     6115                                &pdata[20], len, STR_TERMINATE,
     6116                                &status);
     6117        if (!NT_STATUS_IS_OK(status)) {
     6118                return status;
     6119        }
     6120
     6121        DEBUG(10,("smb_file_link_information: got name |%s|\n",
     6122                                newname));
     6123
     6124        status = filename_convert(ctx,
     6125                                conn,
     6126                                req->flags2 & FLAGS2_DFS_PATHNAMES,
     6127                                newname,
     6128                                UCF_SAVE_LCOMP,
     6129                                NULL,
     6130                                &smb_fname_dst);
     6131        if (!NT_STATUS_IS_OK(status)) {
     6132                return status;
     6133        }
     6134
     6135        if (fsp->base_fsp) {
     6136                /* No stream names. */
     6137                return NT_STATUS_NOT_SUPPORTED;
     6138        }
     6139
     6140        DEBUG(10,("smb_file_link_information: "
     6141                  "SMB_FILE_LINK_INFORMATION (fnum %d) %s -> %s\n",
     6142                  fsp->fnum, fsp_str_dbg(fsp),
     6143                  smb_fname_str_dbg(smb_fname_dst)));
     6144        status = hardlink_internals(ctx,
     6145                                conn,
     6146                                req,
     6147                                overwrite,
     6148                                fsp->fsp_name,
     6149                                smb_fname_dst);
     6150
     6151        TALLOC_FREE(smb_fname_dst);
     6152        return status;
    59276153}
    59286154
     
    60356261                        p[1] = '\0';
    60366262                } else {
    6037                         base_name = talloc_strdup(ctx, "./");
     6263                        base_name = talloc_strdup(ctx, "");
    60386264                        if (!base_name) {
    60396265                                return NT_STATUS_NO_MEMORY;
     
    61716397        uint64_t count;
    61726398        uint64_t offset;
    6173         uint32 lock_pid;
     6399        uint;
    61746400        bool blocking_lock = False;
    61756401        enum brl_type lock_type;
     
    62156441        }
    62166442
    6217         lock_pid = IVAL(pdata, POSIX_LOCK_PID_OFFSET);
     6443        IVAL(pdata, POSIX_LOCK_PID_OFFSET);
    62186444#if defined(HAVE_LONGLONG)
    62196445        offset = (((uint64_t) IVAL(pdata,(POSIX_LOCK_START_OFFSET+4))) << 32) |
     
    62276453
    62286454        DEBUG(10,("smb_set_posix_lock: file %s, lock_type = %u,"
    6229                         "lock_pid = %u, count = %.0f, offset = %.0f\n",
     6455                        "u, count = %.0f, offset = %.0f\n",
    62306456                fsp_str_dbg(fsp),
    62316457                (unsigned int)lock_type,
    6232                 (unsigned int)lock_pid,
     6458                (unsigned ,
    62336459                (double)count,
    62346460                (double)offset ));
    62356461
    62366462        if (lock_type == UNLOCK_LOCK) {
    6237                 status = do_unlock(smbd_messaging_context(),
     6463                status = do_unlock(,
    62386464                                fsp,
    6239                                 lock_pid,
     6465                                ,
    62406466                                count,
    62416467                                offset,
    62426468                                POSIX_LOCK);
    62436469        } else {
    6244                 uint32 block_smbpid;
    6245 
    6246                 struct byte_range_lock *br_lck = do_lock(smbd_messaging_context(),
     6470                uint;
     6471
     6472                struct byte_range_lock *br_lck = do_lock(,
    62476473                                                        fsp,
    6248                                                         lock_pid,
     6474                                                        ,
    62496475                                                        count,
    62506476                                                        offset,
     
    62536479                                                        blocking_lock,
    62546480                                                        &status,
    6255                                                         &block_smbpid,
     6481                                                        &block_smb,
    62566482                                                        NULL);
    62576483
     
    62676493                                                -1, /* infinite timeout. */
    62686494                                                0,
    6269                                                 lock_pid,
     6495                                                ,
    62706496                                                lock_type,
    62716497                                                POSIX_LOCK,
    62726498                                                offset,
    62736499                                                count,
    6274                                                 block_smbpid)) {
     6500                                                block_smb)) {
    62756501                                TALLOC_FREE(br_lck);
    62766502                                return status;
     
    63046530        }
    63056531
     6532
     6533
     6534
     6535
    63066536        /* Set the attributes */
    63076537        dosmode = IVAL(pdata,32);
     
    63466576        if (total_data < 12) {
    63476577                return NT_STATUS_INVALID_PARAMETER;
     6578
     6579
     6580
     6581
    63486582        }
    63496583
     
    64046638        if (allocation_size) {
    64056639                allocation_size = smb_roundup(conn, allocation_size);
     6640
     6641
     6642
     6643
    64066644        }
    64076645
     
    64416679                FORCE_OPLOCK_BREAK_TO_NONE,             /* oplock_request */
    64426680                0,                                      /* allocation_size */
     6681
    64436682                NULL,                                   /* sd */
    64446683                NULL,                                   /* ea_list */
     
    65016740                  "file %s to %.0f\n", smb_fname_str_dbg(smb_fname),
    65026741                  (double)size));
     6742
     6743
     6744
     6745
    65036746
    65046747        return smb_set_file_size(conn, req,
     
    68067049
    68077050        id = vfs_file_id_from_sbuf(conn, &sbuf);
    6808         for(all_fsps = file_find_di_first(id); all_fsps;
     7051        for(all_fsps = file_find_di_first(id); all_fsps;
    68097052                        all_fsps = file_find_di_next(all_fsps)) {
    68107053                /*
     
    69507193                0,                                      /* oplock_request */
    69517194                0,                                      /* allocation_size */
     7195
    69527196                NULL,                                   /* sd */
    69537197                NULL,                                   /* ea_list */
     
    70067250 Open/Create a file with POSIX semantics.
    70077251****************************************************************************/
     7252
     7253
     7254
    70087255
    70097256static NTSTATUS smb_posix_open(connection_struct *conn,
     
    70227269        uint32 create_disp = 0;
    70237270        uint32 access_mask = 0;
    7024         uint32 create_options = 0;
     7271        uint32 create_options = ;
    70257272        NTSTATUS status = NT_STATUS_OK;
    70267273        mode_t unixmode = (mode_t)0;
     
    70527299        switch (wire_open_mode & SMB_ACCMODE) {
    70537300                case SMB_O_RDONLY:
    7054                         access_mask = FILE_READ_DATA;
     7301                        access_mask = ;
    70557302                        break;
    70567303                case SMB_O_WRONLY:
    7057                         access_mask = FILE_WRITE_DATA;
     7304                        access_mask = ;
    70587305                        break;
    70597306                case SMB_O_RDWR:
    7060                         access_mask = FILE_READ_DATA|FILE_WRITE_DATA;
     7307                        access_mask = (SMB_O_RDONLY_MAPPING|
     7308                                        SMB_O_WRONLY_MAPPING);
    70617309                        break;
    70627310                default:
     
    71437391        }
    71447392
     7393
     7394
     7395
     7396
     7397
     7398
     7399
     7400
     7401
    71457402        DEBUG(10,("smb_posix_open: file %s, smb_posix_flags = %u, mode 0%o\n",
    71467403                smb_fname_str_dbg(smb_fname),
     
    71577414                    FILE_SHARE_DELETE),
    71587415                create_disp,                            /* create_disposition*/
    7159                 FILE_NON_DIRECTORY_FILE,                /* create_options */
     7416                                /* create_options */
    71607417                mod_unixmode,                           /* file_attributes */
    71617418                oplock_request,                         /* oplock_request */
    71627419                0,                                      /* allocation_size */
     7420
    71637421                NULL,                                   /* sd */
    71647422                NULL,                                   /* ea_list */
     
    72907548                0,                                      /* oplock_request */
    72917549                0,                                      /* allocation_size */
     7550
    72927551                NULL,                                   /* sd */
    72937552                NULL,                                   /* ea_list */
     
    75507809                                                             pdata, total_data,
    75517810                                                             fsp, smb_fname);
     7811
     7812
     7813
     7814
     7815
     7816
     7817
     7818
     7819
     7820
     7821
     7822
     7823
     7824
     7825
     7826
     7827
    75527828                        break;
    75537829                }
     
    76607936                }
    76617937
    7662                 if(fsp->is_directory || fsp->fh->fd == -1) {
     7938                if(fsp->fh->fd == -1) {
    76637939                        /*
    76647940                         * This is actually a SETFILEINFO on a directory
     
    76927968                         */
    76937969                        if ((info_level == SMB_SET_FILE_DISPOSITION_INFO) && CVAL(pdata,0)) {
    7694                                 fsp->fh->private_options |= FILE_DELETE_ON_CLOSE;
     7970                                fsp->fh->private_options |= E_DELETE_ON_CLOSE;
    76957971
    76967972                                DEBUG(3,("call_trans2setfilepathinfo: "
     
    77127988                         * Original code - this is an open file.
    77137989                         */
    7714                         if (!check_fsp(conn, req, fsp)) {
    7715                                 return;
    7716                         }
    7717 
    77187990                        if (SMB_VFS_FSTAT(fsp, &smb_fname->st) != 0) {
    77197991                                DEBUG(3,("call_trans2setfilepathinfo: fstat "
     
    78038075                        return;
    78048076                }
    7805                 if (blocking_lock_was_deferred(req->mid)) {
     8077                if (blocking_lock_was_deferredreq->mid)) {
    78068078                        /* We have re-scheduled this call. */
    78078079                        return;
     
    81228394                        CAN ACCEPT THIS IN UNICODE. JRA. */
    81238395
    8124                 SSVAL(pdata,0,fsp->rap_print_jobid);                     /* Job number */
     8396                /* Job number */
     8397                if (fsp->print_file) {
     8398                        SSVAL(pdata, 0, fsp->print_file->rap_jobid);
     8399                } else {
     8400                        SSVAL(pdata, 0, 0);
     8401                }
    81258402                srvstr_push(pdata, req->flags2, pdata + 2,
    81268403                            global_myname(), 15,
     
    81458422{
    81468423        int dptr_num;
    8147         struct smbd_server_connection *sconn = smbd_server_conn;
     8424        struct smbd_server_connection *sconn = conn;
    81488425
    81498426        START_PROFILE(SMBfindclose);
Note: See TracChangeset for help on using the changeset viewer.