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

    r414 r745  
    2020
    2121#include "includes.h"
     22#include "smbd/smbd.h"
    2223#include "smbd/globals.h"
    2324#include "../libcli/smb/smb_common.h"
     
    2526static NTSTATUS smbd_smb2_close(struct smbd_smb2_request *req,
    2627                                uint16_t in_flags,
    27                                 uint64_t in_file_id_volatile);
     28                                uint64_t in_file_id_volatile,
     29                                DATA_BLOB *outbody);
    2830
    2931NTSTATUS smbd_smb2_request_process_close(struct smbd_smb2_request *req)
     
    5355        }
    5456
     57        outbody = data_blob_talloc(req->out.vector, NULL, 0x3C);
     58        if (outbody.data == NULL) {
     59                return smbd_smb2_request_error(req, NT_STATUS_NO_MEMORY);
     60        }
     61
    5562        in_flags                = SVAL(inbody, 0x02);
    5663        in_file_id_persistent   = BVAL(inbody, 0x08);
     
    5966        if (req->compat_chain_fsp) {
    6067                /* skip check */
    61         } else if (in_file_id_persistent != 0) {
     68        } else if (in_file_id_persistent != in_file_id_volatile) {
    6269                return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED);
    6370        }
     
    6572        status = smbd_smb2_close(req,
    6673                                in_flags,
    67                                 in_file_id_volatile);
     74                                in_file_id_volatile,
     75                                &outbody);
    6876        if (!NT_STATUS_IS_OK(status)) {
    6977                return smbd_smb2_request_error(req, status);
     
    7179
    7280        outhdr = (uint8_t *)req->out.vector[i].iov_base;
    73 
    74         outbody = data_blob_talloc(req->out.vector, NULL, 0x3C);
    75         if (outbody.data == NULL) {
    76                 return smbd_smb2_request_error(req, NT_STATUS_NO_MEMORY);
    77         }
    78 
    79         SSVAL(outbody.data, 0x00, 0x3C);        /* struct size */
    80         SSVAL(outbody.data, 0x02, 0);           /* flags */
    81         SIVAL(outbody.data, 0x04, 0);           /* reserved */
    82         SBVAL(outbody.data, 0x08, 0);           /* creation time */
    83         SBVAL(outbody.data, 0x10, 0);           /* last access time */
    84         SBVAL(outbody.data, 0x18, 0);           /* last write time */
    85         SBVAL(outbody.data, 0x20, 0);           /* change time */
    86         SBVAL(outbody.data, 0x28, 0);           /* allocation size */
    87         SBVAL(outbody.data, 0x30, 0);           /* end of size */
    88         SIVAL(outbody.data, 0x38, 0);           /* file attributes */
    89 
    9081        return smbd_smb2_request_done(req, outbody, NULL);
    9182}
     
    9384static NTSTATUS smbd_smb2_close(struct smbd_smb2_request *req,
    9485                                uint16_t in_flags,
    95                                 uint64_t in_file_id_volatile)
     86                                uint64_t in_file_id_volatile,
     87                                DATA_BLOB *outbody)
    9688{
    9789        NTSTATUS status;
     
    9991        connection_struct *conn = req->tcon->compat_conn;
    10092        files_struct *fsp;
     93        struct smb_filename *smb_fname = NULL;
     94        struct timespec mdate_ts, adate_ts, cdate_ts, create_date_ts;
     95        uint64_t allocation_size = 0;
     96        uint64_t file_size = 0;
     97        uint32_t dos_attrs = 0;
     98        uint16_t out_flags = 0;
     99        bool posix_open = false;
     100
     101        ZERO_STRUCT(create_date_ts);
     102        ZERO_STRUCT(adate_ts);
     103        ZERO_STRUCT(mdate_ts);
     104        ZERO_STRUCT(cdate_ts);
    101105
    102106        DEBUG(10,("smbd_smb2_close: file_id[0x%016llX]\n",
     
    119123        }
    120124
     125        posix_open = fsp->posix_open;
     126        status = copy_smb_filename(talloc_tos(),
     127                                fsp->fsp_name,
     128                                &smb_fname);
     129        if (!NT_STATUS_IS_OK(status)) {
     130                return status;
     131        }
     132
    121133        status = close_file(smbreq, fsp, NORMAL_CLOSE);
    122134        if (!NT_STATUS_IS_OK(status)) {
     
    126138        }
    127139
     140        if (in_flags & SMB2_CLOSE_FLAGS_FULL_INFORMATION) {
     141                int ret;
     142                if (posix_open) {
     143                        ret = SMB_VFS_LSTAT(conn, smb_fname);
     144                } else {
     145                        ret = SMB_VFS_STAT(conn, smb_fname);
     146                }
     147                if (ret == 0) {
     148                        out_flags = SMB2_CLOSE_FLAGS_FULL_INFORMATION;
     149                        dos_attrs = dos_mode(conn, smb_fname);
     150                        mdate_ts = smb_fname->st.st_ex_mtime;
     151                        adate_ts = smb_fname->st.st_ex_atime;
     152                        create_date_ts = get_create_timespec(conn, NULL, smb_fname);
     153                        cdate_ts = get_change_timespec(conn, NULL, smb_fname);
     154
     155                        if (lp_dos_filetime_resolution(SNUM(conn))) {
     156                                dos_filetime_timespec(&create_date_ts);
     157                                dos_filetime_timespec(&mdate_ts);
     158                                dos_filetime_timespec(&adate_ts);
     159                                dos_filetime_timespec(&cdate_ts);
     160                        }
     161                        if (!(dos_attrs & FILE_ATTRIBUTE_DIRECTORY)) {
     162                                file_size = get_file_size_stat(&smb_fname->st);
     163                        }
     164
     165                        allocation_size = SMB_VFS_GET_ALLOC_SIZE(conn, NULL, &smb_fname->st);
     166                }
     167        }
     168
     169        SSVAL(outbody->data, 0x00, 0x3C);       /* struct size */
     170        SSVAL(outbody->data, 0x02, out_flags);  /* flags */
     171        SIVAL(outbody->data, 0x04, 0);          /* reserved */
     172        put_long_date_timespec(conn->ts_res,
     173                (char *)&outbody->data[0x8],create_date_ts); /* creation time */
     174        put_long_date_timespec(conn->ts_res,
     175                (char *)&outbody->data[0x10],adate_ts); /* last access time */
     176        put_long_date_timespec(conn->ts_res,
     177                (char *)&outbody->data[0x18],mdate_ts); /* last write time */
     178        put_long_date_timespec(conn->ts_res,
     179                (char *)&outbody->data[0x20],cdate_ts); /* change time */
     180        SBVAL(outbody->data, 0x28, allocation_size);/* allocation size */
     181        SBVAL(outbody->data, 0x30, file_size);  /* end of file */
     182        SIVAL(outbody->data, 0x38, dos_attrs);  /* file attributes */
     183
    128184        return NT_STATUS_OK;
    129185}
Note: See TracChangeset for help on using the changeset viewer.