Ignore:
Timestamp:
Nov 24, 2016, 1:14:11 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/smbd/nttrans.c

    r914 r988  
    2828#include "passdb/lookup_sid.h"
    2929#include "auth.h"
    30 #include "ntioctl.h"
    3130#include "smbprofile.h"
    3231#include "libsmb/libsmb.h"
     32#include "lib/util_ea.h"
    3333
    3434extern const struct generic_mapping file_generic_mapping;
     
    5555****************************************************************************/
    5656
    57 void send_nt_replies(connection_struct *conn,
    58                         struct smb_request *req, NTSTATUS nt_error,
    59                      char *params, int paramsize,
    60                      char *pdata, int datasize)
     57static void send_nt_replies(connection_struct *conn,
     58                            struct smb_request *req, NTSTATUS nt_error,
     59                            char *params, int paramsize,
     60                            char *pdata, int datasize)
    6161{
    6262        int data_to_send = datasize;
     
    6868        int alignment_offset = 1;
    6969        int data_alignment_offset = 0;
    70         struct smbd_server_connection *sconn = req->sconn;
    71         int max_send = sconn->smb1.sessions.max_send;
     70        struct smbXsrv_connection *xconn = req->xconn;
     71        int max_send = xconn->smb1.sessions.max_send;
    7272
    7373        /*
     
    8484                }
    8585                show_msg((char *)req->outbuf);
    86                 if (!srv_send_smb(sconn,
     86                if (!srv_send_smb(xconn,
    8787                                (char *)req->outbuf,
    8888                                true, req->seqnum+1,
     
    248248                /* Send the packet */
    249249                show_msg((char *)req->outbuf);
    250                 if (!srv_send_smb(sconn,
     250                if (!srv_send_smb(xconn,
    251251                                (char *)req->outbuf,
    252252                                true, req->seqnum+1,
     
    281281
    282282static void nt_open_pipe(char *fname, connection_struct *conn,
    283                          struct smb_request *req, int *ppnum)
     283                         struct smb_request *req, uint16_t *ppnum)
    284284{
    285285        files_struct *fsp;
     
    288288        DEBUG(4,("nt_open_pipe: Opening pipe %s.\n", fname));
    289289
    290         /* Strip \\ off the name. */
    291         fname++;
     290        /* Strip \\ off the name if present. */
     291        while (fname[0] == '\\') {
     292                fname++;
     293        }
    292294
    293295        status = open_np_file(req, fname, &fsp);
     
    314316{
    315317        char *fname = NULL;
    316         int pnum = -1;
     318        uint16_t pnum = FNUM_FIELD_INVALID;
    317319        char *p = NULL;
    318         uint32 flags = IVAL(req->vwv+3, 1);
     320        uint32_t flags = IVAL(req->vwv+3, 1);
    319321        TALLOC_CTX *ctx = talloc_tos();
    320322
     
    340342                /* This is very strange. We
    341343                 * return 50 words, but only set
    342                  * the wcnt to 42 ? It's definately
     344                 * the wcnt to 42 ? It's definitely
    343345                 * what happens on the wire....
    344346                 */
     
    348350                reply_outbuf(req, 34, 0);
    349351        }
     352
     353        SSVAL(req->outbuf, smb_vwv0, 0xff); /* andx chain ends */
     354        SSVAL(req->outbuf, smb_vwv1, 0);    /* no andx offset */
    350355
    351356        p = (char *)req->outbuf + smb_vwv2;
     
    376381
    377382        DEBUG(5,("do_ntcreate_pipe_open: open pipe = %s\n", fname));
    378 
    379         chain_reply(req);
    380383}
    381384
     
    436439        struct smb_filename *smb_fname = NULL;
    437440        char *fname = NULL;
    438         uint32 flags;
    439         uint32 access_mask;
    440         uint32 file_attributes;
    441         uint32 share_access;
    442         uint32 create_disposition;
    443         uint32 create_options;
    444         uint16 root_dir_fid;
     441        uint32_t flags;
     442        uint32_t access_mask;
     443        uint32_t file_attributes;
     444        uint32_t share_access;
     445        uint32_t create_disposition;
     446        uint32_t create_options;
     447        uint16_t root_dir_fid;
    445448        uint64_t allocation_size;
    446449        /* Breakout the oplock request bits so we can set the
    447450           reply bits separately. */
    448         uint32 fattr=0;
    449         SMB_OFF_T file_len = 0;
     451        uint32_t fattr=0;
     452        off_t file_len = 0;
    450453        int info = 0;
    451454        files_struct *fsp = NULL;
     
    455458        struct timespec a_timespec;
    456459        struct timespec m_timespec;
    457         struct timespec write_time_ts;
    458460        NTSTATUS status;
    459461        int oplock_request;
    460462        uint8_t oplock_granted = NO_OPLOCK_RETURN;
    461463        struct case_semantics_state *case_state = NULL;
     464        uint32_t ucf_flags = UCF_PREP_CREATEFILE |
     465                        (req->posix_pathnames ? UCF_POSIX_PATHNAMES : 0);
    462466        TALLOC_CTX *ctx = talloc_tos();
    463467
     
    475479        create_disposition = IVAL(req->vwv+17, 1);
    476480        create_options = IVAL(req->vwv+19, 1);
    477         root_dir_fid = (uint16)IVAL(req->vwv+5, 1);
     481        root_dir_fid = (uint16_t)IVAL(req->vwv+5, 1);
    478482
    479483        allocation_size = BVAL(req->vwv+9, 1);
     
    537541                                req->flags2 & FLAGS2_DFS_PATHNAMES,
    538542                                fname,
    539                                 (create_disposition == FILE_CREATE)
    540                                         ? UCF_CREATING_FILE : 0,
     543                                ucf_flags,
    541544                                NULL,
    542545                                &smb_fname);
     
    573576                file_attributes,                        /* file_attributes */
    574577                oplock_request,                         /* oplock_request */
     578                NULL,                                   /* lease */
    575579                allocation_size,                        /* allocation_size */
    576580                0,                                      /* private_flags */
     
    578582                NULL,                                   /* ea_list */
    579583                &fsp,                                   /* result */
    580                 &info);                                 /* pinfo */
     584                &info,                                  /* pinfo */
     585                NULL, NULL);                            /* create context */
    581586
    582587        if (!NT_STATUS_IS_OK(status)) {
    583                 if (open_was_deferred(req->mid)) {
     588                if (open_was_deferred(req->xconn, req->mid)) {
    584589                        /* We have re-scheduled this call, no error. */
    585590                        goto out;
     
    623628                /* This is very strange. We
    624629                 * return 50 words, but only set
    625                  * the wcnt to 42 ? It's definately
     630                 * the wcnt to 42 ? It's definitely
    626631                 * what happens on the wire....
    627632                 */
     
    631636                reply_outbuf(req, 34, 0);
    632637        }
     638
     639        SSVAL(req->outbuf, smb_vwv0, 0xff); /* andx chain ends */
     640        SSVAL(req->outbuf, smb_vwv1, 0);    /* no andx offset */
    633641
    634642        p = (char *)req->outbuf + smb_vwv2;
     
    650658        if (fattr == 0) {
    651659                fattr = FILE_ATTRIBUTE_NORMAL;
    652         }
    653 
    654         /* Deal with other possible opens having a modified
    655            write time. JRA. */
    656         ZERO_STRUCT(write_time_ts);
    657         get_file_infos(fsp->file_id, 0, NULL, &write_time_ts);
    658         if (!null_timespec(write_time_ts)) {
    659                 update_stat_ex_mtime(&smb_fname->st, write_time_ts);
    660660        }
    661661
     
    712712
    713713        if (flags & EXTENDED_RESPONSE_REQUIRED) {
    714                 uint32 perms = 0;
     714                uint32_t perms = 0;
    715715                p += 25;
    716716                if (fsp->is_directory ||
     717                    fsp->can_write ||
    717718                    can_write_to_file(conn, smb_fname)) {
    718719                        perms = FILE_GENERIC_ALL;
     
    723724        }
    724725
    725         DEBUG(5,("reply_ntcreate_and_X: fnum = %d, open name = %s\n",
    726                 fsp->fnum, smb_fname_str_dbg(smb_fname)));
    727 
    728         chain_reply(req);
     726        DEBUG(5,("reply_ntcreate_and_X: %s, open name = %s\n",
     727                fsp_fnum_dbg(fsp), smb_fname_str_dbg(smb_fname)));
     728
    729729 out:
    730730        END_PROFILE(SMBntcreateX);
     
    738738static void do_nt_transact_create_pipe(connection_struct *conn,
    739739                                       struct smb_request *req,
    740                                        uint16 **ppsetup, uint32 setup_count,
    741                                        char **ppparams, uint32 parameter_count,
    742                                        char **ppdata, uint32 data_count)
     740                                       uint16_t **ppsetup, uint32_t setup_count,
     741                                       char **ppparams, uint32_t parameter_count,
     742                                       char **ppdata, uint32_t data_count)
    743743{
    744744        char *fname = NULL;
    745745        char *params = *ppparams;
    746         int pnum = -1;
     746        uint16_t pnum = FNUM_FIELD_INVALID;
    747747        char *p = NULL;
    748748        NTSTATUS status;
    749749        size_t param_len;
    750         uint32 flags;
     750        uint32_t flags;
    751751        TALLOC_CTX *ctx = talloc_tos();
    752752
     
    763763        flags = IVAL(params,0);
    764764
    765         srvstr_get_path(ctx, params, req->flags2, &fname, params+53,
    766                         parameter_count-53, STR_TERMINATE,
     765        if (req->posix_pathnames) {
     766                srvstr_get_path_posix(ctx,
     767                        params,
     768                        req->flags2,
     769                        &fname,
     770                        params+53,
     771                        parameter_count-53,
     772                        STR_TERMINATE,
    767773                        &status);
     774        } else {
     775                srvstr_get_path(ctx,
     776                        params,
     777                        req->flags2,
     778                        &fname,
     779                        params+53,
     780                        parameter_count-53,
     781                        STR_TERMINATE,
     782                        &status);
     783        }
    768784        if (!NT_STATUS_IS_OK(status)) {
    769785                reply_nterror(req, status);
     
    878894        }
    879895
     896        if (S_ISLNK(fsp->fsp_name->st.st_ex_mode)) {
     897                DEBUG(10, ("ACL set on symlink %s denied.\n",
     898                        fsp_str_dbg(fsp)));
     899                return NT_STATUS_ACCESS_DENIED;
     900        }
     901
    880902        if (psd->owner_sid == NULL) {
    881903                security_info_sent &= ~SECINFO_OWNER;
     
    962984
    963985/****************************************************************************
    964  Read a list of EA names and data from an incoming data buffer. Create an ea_list with them.
    965 ****************************************************************************/
    966 
    967 struct ea_list *read_nttrans_ea_list(TALLOC_CTX *ctx, const char *pdata, size_t data_size)
    968 {
    969         struct ea_list *ea_list_head = NULL;
    970         size_t offset = 0;
    971 
    972         if (data_size < 4) {
    973                 return NULL;
    974         }
    975 
    976         while (offset + 4 <= data_size) {
    977                 size_t next_offset = IVAL(pdata,offset);
    978                 struct ea_list *eal = read_ea_list_entry(ctx, pdata + offset + 4, data_size - offset - 4, NULL);
    979 
    980                 if (!eal) {
    981                         return NULL;
    982                 }
    983 
    984                 DLIST_ADD_END(ea_list_head, eal, struct ea_list *);
    985                 if (next_offset == 0) {
    986                         break;
    987                 }
    988 
    989                 /* Integer wrap protection for the increment. */
    990                 if (offset + next_offset < offset) {
    991                         break;
    992                 }
    993 
    994                 offset += next_offset;
    995 
    996                 /* Integer wrap protection for while loop. */
    997                 if (offset + 4 < offset) {
    998                         break;
    999                 }
    1000 
    1001         }
    1002 
    1003         return ea_list_head;
    1004 }
    1005 
    1006 /****************************************************************************
    1007986 Reply to a NT_TRANSACT_CREATE call (needs to process SD's).
    1008987****************************************************************************/
     
    1010989static void call_nt_transact_create(connection_struct *conn,
    1011990                                    struct smb_request *req,
    1012                                     uint16 **ppsetup, uint32 setup_count,
    1013                                     char **ppparams, uint32 parameter_count,
    1014                                     char **ppdata, uint32 data_count,
    1015                                     uint32 max_data_count)
     991                                    uint16_t **ppsetup, uint32_t setup_count,
     992                                    char **ppparams, uint32_t parameter_count,
     993                                    char **ppdata, uint32_t data_count,
     994                                    uint32_t max_data_count)
    1016995{
    1017996        struct smb_filename *smb_fname = NULL;
     
    1020999        char *data = *ppdata;
    10211000        /* Breakout the oplock request bits so we can set the reply bits separately. */
    1022         uint32 fattr=0;
    1023         SMB_OFF_T file_len = 0;
     1001        uint32_t fattr=0;
     1002        off_t file_len = 0;
    10241003        int info = 0;
    10251004        files_struct *fsp = NULL;
    10261005        char *p = NULL;
    1027         uint32 flags;
    1028         uint32 access_mask;
    1029         uint32 file_attributes;
    1030         uint32 share_access;
    1031         uint32 create_disposition;
    1032         uint32 create_options;
    1033         uint32 sd_len;
     1006        uint32_t flags;
     1007        uint32_t access_mask;
     1008        uint32_t file_attributes;
     1009        uint32_t share_access;
     1010        uint32_t create_disposition;
     1011        uint32_t create_options;
     1012        uint32_t sd_len;
    10341013        struct security_descriptor *sd = NULL;
    1035         uint32 ea_len;
    1036         uint16 root_dir_fid;
     1014        uint32_t ea_len;
     1015        uint16_t root_dir_fid;
    10371016        struct timespec create_timespec;
    10381017        struct timespec c_timespec;
    10391018        struct timespec a_timespec;
    10401019        struct timespec m_timespec;
    1041         struct timespec write_time_ts;
    10421020        struct ea_list *ea_list = NULL;
    10431021        NTSTATUS status;
     
    10471025        uint8_t oplock_granted;
    10481026        struct case_semantics_state *case_state = NULL;
     1027        uint32_t ucf_flags = UCF_PREP_CREATEFILE |
     1028                        (req->posix_pathnames ? UCF_POSIX_PATHNAMES : 0);
    10491029        TALLOC_CTX *ctx = talloc_tos();
    10501030
     
    10861066        sd_len = IVAL(params,36);
    10871067        ea_len = IVAL(params,40);
    1088         root_dir_fid = (uint16)IVAL(params,4);
     1068        root_dir_fid = (uint16_t)IVAL(params,4);
    10891069        allocation_size = BVAL(params,12);
    10901070
     
    10941074         */
    10951075        create_options &= ~NTCREATEX_OPTIONS_MUST_IGNORE_MASK;
     1076
     1077        if (req->posix_pathnames) {
     1078                srvstr_get_path_posix(ctx,
     1079                        params,
     1080                        req->flags2,
     1081                        &fname,
     1082                        params+53,
     1083                        parameter_count-53,
     1084                        STR_TERMINATE,
     1085                        &status);
     1086        } else {
     1087                srvstr_get_path(ctx,
     1088                        params,
     1089                        req->flags2,
     1090                        &fname,
     1091                        params+53,
     1092                        parameter_count-53,
     1093                        STR_TERMINATE,
     1094                        &status);
     1095        }
     1096        if (!NT_STATUS_IS_OK(status)) {
     1097                reply_nterror(req, status);
     1098                goto out;
     1099        }
     1100
     1101        if (file_attributes & FILE_FLAG_POSIX_SEMANTICS) {
     1102                case_state = set_posix_case_semantics(ctx, conn);
     1103                if (!case_state) {
     1104                        reply_nterror(req, NT_STATUS_NO_MEMORY);
     1105                        goto out;
     1106                }
     1107        }
     1108
     1109        status = filename_convert(ctx,
     1110                                conn,
     1111                                req->flags2 & FLAGS2_DFS_PATHNAMES,
     1112                                fname,
     1113                                ucf_flags,
     1114                                NULL,
     1115                                &smb_fname);
     1116
     1117        TALLOC_FREE(case_state);
     1118
     1119        if (!NT_STATUS_IS_OK(status)) {
     1120                if (NT_STATUS_EQUAL(status,NT_STATUS_PATH_NOT_COVERED)) {
     1121                        reply_botherror(req,
     1122                                NT_STATUS_PATH_NOT_COVERED,
     1123                                ERRSRV, ERRbadpath);
     1124                        goto out;
     1125                }
     1126                reply_nterror(req, status);
     1127                goto out;
     1128        }
    10961129
    10971130        /* Ensure the data_len is correct for the sd and ea values given. */
     
    11451178                        goto out;
    11461179                }
    1147         }
    1148 
    1149         srvstr_get_path(ctx, params, req->flags2, &fname,
    1150                         params+53, parameter_count-53,
    1151                         STR_TERMINATE, &status);
    1152         if (!NT_STATUS_IS_OK(status)) {
    1153                 reply_nterror(req, status);
    1154                 goto out;
    1155         }
    1156 
    1157         if (file_attributes & FILE_FLAG_POSIX_SEMANTICS) {
    1158                 case_state = set_posix_case_semantics(ctx, conn);
    1159                 if (!case_state) {
    1160                         reply_nterror(req, NT_STATUS_NO_MEMORY);
     1180
     1181                if (ea_list_has_invalid_name(ea_list)) {
     1182                        /* Realloc the size of parameters and data we will return */
     1183                        if (flags & EXTENDED_RESPONSE_REQUIRED) {
     1184                                /* Extended response is 32 more byyes. */
     1185                                param_len = 101;
     1186                        } else {
     1187                                param_len = 69;
     1188                        }
     1189                        params = nttrans_realloc(ppparams, param_len);
     1190                        if(params == NULL) {
     1191                                reply_nterror(req, NT_STATUS_NO_MEMORY);
     1192                                goto out;
     1193                        }
     1194
     1195                        memset(params, '\0', param_len);
     1196                        send_nt_replies(conn, req, STATUS_INVALID_EA_NAME,
     1197                                params, param_len, NULL, 0);
    11611198                        goto out;
    11621199                }
    1163         }
    1164 
    1165         status = filename_convert(ctx,
    1166                                 conn,
    1167                                 req->flags2 & FLAGS2_DFS_PATHNAMES,
    1168                                 fname,
    1169                                 (create_disposition == FILE_CREATE)
    1170                                         ? UCF_CREATING_FILE : 0,
    1171                                 NULL,
    1172                                 &smb_fname);
    1173 
    1174         TALLOC_FREE(case_state);
    1175 
    1176         if (!NT_STATUS_IS_OK(status)) {
    1177                 if (NT_STATUS_EQUAL(status,NT_STATUS_PATH_NOT_COVERED)) {
    1178                         reply_botherror(req,
    1179                                 NT_STATUS_PATH_NOT_COVERED,
    1180                                 ERRSRV, ERRbadpath);
    1181                         goto out;
    1182                 }
    1183                 reply_nterror(req, status);
    1184                 goto out;
    11851200        }
    11861201
     
    12091224                file_attributes,                        /* file_attributes */
    12101225                oplock_request,                         /* oplock_request */
     1226                NULL,                                   /* lease */
    12111227                allocation_size,                        /* allocation_size */
    12121228                0,                                      /* private_flags */
     
    12141230                ea_list,                                /* ea_list */
    12151231                &fsp,                                   /* result */
    1216                 &info);                                 /* pinfo */
     1232                &info,                                  /* pinfo */
     1233                NULL, NULL);                            /* create context */
    12171234
    12181235        if(!NT_STATUS_IS_OK(status)) {
    1219                 if (open_was_deferred(req->mid)) {
     1236                if (open_was_deferred(req->xconn, req->mid)) {
    12201237                        /* We have re-scheduled this call, no error. */
    12211238                        return;
     
    12861303        if (fattr == 0) {
    12871304                fattr = FILE_ATTRIBUTE_NORMAL;
    1288         }
    1289 
    1290         /* Deal with other possible opens having a modified
    1291            write time. JRA. */
    1292         ZERO_STRUCT(write_time_ts);
    1293         get_file_infos(fsp->file_id, 0, NULL, &write_time_ts);
    1294         if (!null_timespec(write_time_ts)) {
    1295                 update_stat_ex_mtime(&smb_fname->st, write_time_ts);
    12961305        }
    12971306
     
    13481357
    13491358        if (flags & EXTENDED_RESPONSE_REQUIRED) {
    1350                 uint32 perms = 0;
     1359                uint32_t perms = 0;
    13511360                p += 25;
    13521361                if (fsp->is_directory ||
     1362                    fsp->can_write ||
    13531363                    can_write_to_file(conn, smb_fname)) {
    13541364                        perms = FILE_GENERIC_ALL;
     
    13751385void reply_ntcancel(struct smb_request *req)
    13761386{
     1387        struct smbXsrv_connection *xconn = req->xconn;
     1388        struct smbd_server_connection *sconn = req->sconn;
     1389
    13771390        /*
    13781391         * Go through and cancel any pending change notifies.
     
    13801393
    13811394        START_PROFILE(SMBntcancel);
    1382         srv_cancel_sign_response(req->sconn);
    1383         remove_pending_change_notify_requests_by_mid(req->sconn, req->mid);
    1384         remove_pending_lock_requests_by_mid_smb1(req->sconn, req->mid);
     1395        srv_cancel_sign_response(xconn);
     1396        remove_pending_change_notify_requests_by_mid(sconn, req->mid);
     1397        remove_pending_lock_requests_by_mid_smb1(sconn, req->mid);
    13851398
    13861399        DEBUG(3,("reply_ntcancel: cancel called on mid = %llu.\n",
     
    14001413                                struct smb_filename *smb_fname_src,
    14011414                                struct smb_filename *smb_fname_dst,
    1402                                 uint32 attrs)
     1415                                uint32_t attrs)
    14031416{
    14041417        files_struct *fsp1,*fsp2;
    1405         uint32 fattr;
     1418        uint32_t fattr;
    14061419        int info;
    1407         SMB_OFF_T ret=-1;
     1420        off_t ret=-1;
    14081421        NTSTATUS status = NT_STATUS_OK;
    14091422        char *parent;
     
    14561469                FILE_ATTRIBUTE_NORMAL,                  /* file_attributes */
    14571470                NO_OPLOCK,                              /* oplock_request */
     1471                NULL,                                   /* lease */
    14581472                0,                                      /* allocation_size */
    14591473                0,                                      /* private_flags */
     
    14611475                NULL,                                   /* ea_list */
    14621476                &fsp1,                                  /* result */
    1463                 &info);                                 /* pinfo */
     1477                &info,                                  /* pinfo */
     1478                NULL, NULL);                            /* create context */
    14641479
    14651480        if (!NT_STATUS_IS_OK(status)) {
     
    14801495                fattr,                                  /* file_attributes */
    14811496                NO_OPLOCK,                              /* oplock_request */
     1497                NULL,                                   /* lease */
    14821498                0,                                      /* allocation_size */
    14831499                0,                                      /* private_flags */
     
    14851501                NULL,                                   /* ea_list */
    14861502                &fsp2,                                  /* result */
    1487                 &info);                                 /* pinfo */
     1503                &info,                                  /* pinfo */
     1504                NULL, NULL);                            /* create context */
    14881505
    14891506        if (!NT_STATUS_IS_OK(status)) {
     
    15201537        TALLOC_FREE(parent);
    15211538
    1522         if (ret < (SMB_OFF_T)smb_fname_src->st.st_ex_size) {
     1539        if (ret < (off_t)smb_fname_src->st.st_ex_size) {
    15231540                status = NT_STATUS_DISK_FULL;
    15241541                goto out;
     
    15491566        bool src_has_wcard = False;
    15501567        bool dest_has_wcard = False;
    1551         uint32 attrs;
    1552         uint32_t ucf_flags_src = 0;
    1553         uint32_t ucf_flags_dst = 0;
    1554         uint16 rename_type;
     1568        uint32_t attrs;
     1569        uint32_t ucf_flags_src = (req->posix_pathnames ? UCF_POSIX_PATHNAMES : 0);
     1570        uint32_t ucf_flags_dst = (req->posix_pathnames ? UCF_POSIX_PATHNAMES : 0);
     1571        uint16_t rename_type;
    15551572        TALLOC_CTX *ctx = talloc_tos();
    15561573        bool stream_rename = false;
     
    15741591        }
    15751592
    1576         if (ms_has_wild(oldname)) {
     1593        if (!req->posix_pathnames && ms_has_wild(oldname)) {
    15771594                reply_nterror(req, NT_STATUS_OBJECT_PATH_SYNTAX_BAD);
    15781595                goto out;
     
    15871604        }
    15881605
    1589         if (!lp_posix_pathnames()) {
     1606        if (!req->posix_pathnames) {
    15901607                /* The newname must begin with a ':' if the
    15911608                   oldname contains a ':'. */
     
    17001717
    17011718        if (!NT_STATUS_IS_OK(status)) {
    1702                 if (open_was_deferred(req->mid)) {
     1719                if (open_was_deferred(req->xconn, req->mid)) {
    17031720                        /* We have re-scheduled this call. */
    17041721                        goto out;
     
    17291746static void call_nt_transact_notify_change(connection_struct *conn,
    17301747                                           struct smb_request *req,
    1731                                            uint16 **ppsetup,
    1732                                            uint32 setup_count,
     1748                                           uint16_t **ppsetup,
     1749                                           uint32_t setup_count,
    17331750                                           char **ppparams,
    1734                                            uint32 parameter_count,
    1735                                            char **ppdata, uint32 data_count,
    1736                                            uint32 max_data_count,
    1737                                            uint32 max_param_count)
     1751                                           uint32_t parameter_count,
     1752                                           char **ppdata, uint32_t data_count,
     1753                                           uint32_t max_data_count,
     1754                                           uint32_t max_param_count)
    17381755{
    1739         uint16 *setup = *ppsetup;
     1756        uint16_t *setup = *ppsetup;
    17401757        files_struct *fsp;
    1741         uint32 filter;
     1758        uint32_t filter;
    17421759        NTSTATUS status;
    17431760        bool recursive;
     
    17911808        }
    17921809
    1793         if (fsp->notify->num_changes != 0) {
     1810        if (change_notify_fsp_has_changes(fsp)) {
    17941811
    17951812                /*
     
    18361853static void call_nt_transact_rename(connection_struct *conn,
    18371854                                    struct smb_request *req,
    1838                                     uint16 **ppsetup, uint32 setup_count,
    1839                                     char **ppparams, uint32 parameter_count,
    1840                                     char **ppdata, uint32 data_count,
    1841                                     uint32 max_data_count)
     1855                                    uint16_t **ppsetup, uint32_t setup_count,
     1856                                    char **ppparams, uint32_t parameter_count,
     1857                                    char **ppdata, uint32_t data_count,
     1858                                    uint32_t max_data_count)
    18421859{
    18431860        char *params = *ppparams;
     
    18571874                return;
    18581875        }
    1859         srvstr_get_path_wcard(ctx, params, req->flags2, &new_name, params+4,
    1860                               parameter_count - 4,
    1861                               STR_TERMINATE, &status, &dest_has_wcard);
     1876        if (req->posix_pathnames) {
     1877                srvstr_get_path_wcard_posix(ctx,
     1878                                params,
     1879                                req->flags2,
     1880                                &new_name,
     1881                                params+4,
     1882                                parameter_count - 4,
     1883                                STR_TERMINATE,
     1884                                &status,
     1885                                &dest_has_wcard);
     1886        } else {
     1887                srvstr_get_path_wcard(ctx,
     1888                                params,
     1889                                req->flags2,
     1890                                &new_name,
     1891                                params+4,
     1892                                parameter_count - 4,
     1893                                STR_TERMINATE,
     1894                                &status,
     1895                                &dest_has_wcard);
     1896        }
     1897
    18621898        if (!NT_STATUS_IS_OK(status)) {
    18631899                reply_nterror(req, status);
     
    18961932/****************************************************************************
    18971933 Reply to query a security descriptor.
    1898  Callable from SMB2 and SMB2.
     1934 Callable from SMB1 and SMB2.
    18991935 If it returns NT_STATUS_BUFFER_TOO_SMALL, pdata_size is initialized with
    19001936 the required size.
     
    19111947        NTSTATUS status;
    19121948        struct security_descriptor *psd = NULL;
     1949        TALLOC_CTX *frame = talloc_stackframe();
    19131950
    19141951        /*
     
    19181955        if ((security_info_wanted & SECINFO_SACL) &&
    19191956                        !(fsp->access_mask & SEC_FLAG_SYSTEM_SECURITY)) {
     1957                DEBUG(10, ("Access to SACL denied.\n"));
     1958                TALLOC_FREE(frame);
    19201959                return NT_STATUS_ACCESS_DENIED;
    19211960        }
     
    19231962        if ((security_info_wanted & (SECINFO_DACL|SECINFO_OWNER|SECINFO_GROUP)) &&
    19241963                        !(fsp->access_mask & SEC_STD_READ_CONTROL)) {
     1964                DEBUG(10, ("Access to DACL, OWNER, or GROUP denied.\n"));
     1965                TALLOC_FREE(frame);
     1966                return NT_STATUS_ACCESS_DENIED;
     1967        }
     1968
     1969        if (S_ISLNK(fsp->fsp_name->st.st_ex_mode)) {
     1970                DEBUG(10, ("ACL get on symlink %s denied.\n",
     1971                        fsp_str_dbg(fsp)));
     1972                TALLOC_FREE(frame);
    19251973                return NT_STATUS_ACCESS_DENIED;
    19261974        }
     
    19341982
    19351983        if (!lp_nt_acl_support(SNUM(conn))) {
    1936                 status = get_null_nt_acl(mem_ctx, &psd);
     1984                status = get_null_nt_acl(frame, &psd);
    19371985        } else if (security_info_wanted & SECINFO_LABEL) {
    19381986                /* Like W2K3 return a null object. */
    1939                 status = get_null_nt_acl(mem_ctx, &psd);
     1987                status = get_null_nt_acl(frame, &psd);
    19401988        } else {
    19411989                status = SMB_VFS_FGET_NT_ACL(
    1942                         fsp, security_info_wanted, &psd);
     1990                        fsp, security_info_wanted, frame, &psd);
    19431991        }
    19441992        if (!NT_STATUS_IS_OK(status)) {
     1993                TALLOC_FREE(frame);
    19451994                return status;
    19461995        }
     
    19912040
    19922041        if (max_data_count < *psd_size) {
    1993                 TALLOC_FREE(psd);
     2042                TALLOC_FREE(frame);
    19942043                return NT_STATUS_BUFFER_TOO_SMALL;
    19952044        }
     
    19992048
    20002049        if (!NT_STATUS_IS_OK(status)) {
    2001                 TALLOC_FREE(psd);
     2050                TALLOC_FREE(frame);
    20022051                return status;
    20032052        }
    20042053
    2005         TALLOC_FREE(psd);
     2054        TALLOC_FREE(frame);
    20062055        return NT_STATUS_OK;
    20072056}
     
    20132062static void call_nt_transact_query_security_desc(connection_struct *conn,
    20142063                                                 struct smb_request *req,
    2015                                                  uint16 **ppsetup,
    2016                                                  uint32 setup_count,
     2064                                                 uint16_t **ppsetup,
     2065                                                 uint32_t setup_count,
    20172066                                                 char **ppparams,
    2018                                                  uint32 parameter_count,
     2067                                                 uint32_t parameter_count,
    20192068                                                 char **ppdata,
    2020                                                  uint32 data_count,
    2021                                                  uint32 max_data_count)
     2069                                                 uint32_t data_count,
     2070                                                 uint32_t max_data_count)
    20222071{
    20232072        char *params = *ppparams;
    20242073        char *data = *ppdata;
    20252074        size_t sd_size = 0;
    2026         uint32 security_info_wanted;
     2075        uint32_t security_info_wanted;
    20272076        files_struct *fsp = NULL;
    20282077        NTSTATUS status;
     
    20592108                                        talloc_tos(),
    20602109                                        fsp,
    2061                                         security_info_wanted,
     2110                                        security_info_wanted &
     2111                                        SMB_SUPPORTED_SECINFO_FLAGS,
    20622112                                        max_data_count,
    20632113                                        &marshalled_sd,
     
    21092159static void call_nt_transact_set_security_desc(connection_struct *conn,
    21102160                                               struct smb_request *req,
    2111                                                uint16 **ppsetup,
    2112                                                uint32 setup_count,
     2161                                               uint16_t **ppsetup,
     2162                                               uint32_t setup_count,
    21132163                                               char **ppparams,
    2114                                                uint32 parameter_count,
     2164                                               uint32_t parameter_count,
    21152165                                               char **ppdata,
    2116                                                uint32 data_count,
    2117                                                uint32 max_data_count)
     2166                                               uint32_t data_count,
     2167                                               uint32_t max_data_count)
    21182168{
    21192169        char *params= *ppparams;
    21202170        char *data = *ppdata;
    21212171        files_struct *fsp = NULL;
    2122         uint32 security_info_sent = 0;
     2172        uint32_t security_info_sent = 0;
    21232173        NTSTATUS status;
    21242174
     
    21522202        }
    21532203
    2154         status = set_sd_blob(fsp, (uint8 *)data, data_count, security_info_sent);
    2155 
     2204        status = set_sd_blob(fsp, (uint8_t *)data, data_count,
     2205                             security_info_sent & SMB_SUPPORTED_SECINFO_FLAGS);
    21562206        if (!NT_STATUS_IS_OK(status)) {
    21572207                reply_nterror(req, status);
     
    21642214}
    21652215
    2166 /*
    2167  * Implement the default fsctl operation.
    2168  */
    2169 
    2170 static bool vfswrap_logged_ioctl_message = false;
    2171 
    2172 /*
    2173  * In 3.6 we do not have a SMB_VFS_FSCTL() function
    2174  * it's just faked to make it more look like
    2175  * master (4.0)
    2176  */
    2177 NTSTATUS smb_fsctl(struct files_struct *fsp,
    2178                        TALLOC_CTX *ctx,
    2179                        uint32_t function,
    2180                        uint16_t req_flags,  /* Needed for UNICODE ... */
    2181                        const uint8_t *_in_data,
    2182                        uint32_t in_len,
    2183                        uint8_t **_out_data,
    2184                        uint32_t max_out_len,
    2185                        uint32_t *out_len)
    2186 {
    2187         const char *in_data = (const char *)_in_data;
    2188         char **out_data = (char **)_out_data;
    2189 
    2190         switch (function) {
    2191         case FSCTL_SET_SPARSE:
    2192         {
    2193                 bool set_sparse = true;
    2194                 NTSTATUS status;
    2195 
    2196                 if (in_len >= 1 && in_data[0] == 0) {
    2197                         set_sparse = false;
    2198                 }
    2199 
    2200                 status = file_set_sparse(fsp->conn, fsp, set_sparse);
    2201 
    2202                 DEBUG(NT_STATUS_IS_OK(status) ? 10 : 9,
    2203                       ("FSCTL_SET_SPARSE: fname[%s] set[%u] - %s\n",
    2204                        smb_fname_str_dbg(fsp->fsp_name), set_sparse,
    2205                        nt_errstr(status)));
    2206 
    2207                 return status;
    2208         }
    2209 
    2210         case FSCTL_CREATE_OR_GET_OBJECT_ID:
    2211         {
    2212                 unsigned char objid[16];
    2213                 char *return_data = NULL;
    2214 
    2215                 /* This should return the object-id on this file.
    2216                  * I think I'll make this be the inode+dev. JRA.
    2217                  */
    2218 
    2219                 DEBUG(10,("FSCTL_CREATE_OR_GET_OBJECT_ID: called on FID[0x%04X]\n",fsp->fnum));
    2220 
    2221                 *out_len = (max_out_len >= 64) ? 64 : max_out_len;
    2222                 /* Hmmm, will this cause problems if less data asked for? */
    2223                 return_data = talloc_array(ctx, char, 64);
    2224                 if (return_data == NULL) {
    2225                         return NT_STATUS_NO_MEMORY;
    2226                 }
    2227 
    2228                 /* For backwards compatibility only store the dev/inode. */
    2229                 push_file_id_16(return_data, &fsp->file_id);
    2230                 memcpy(return_data+16,create_volume_objectid(fsp->conn,objid),16);
    2231                 push_file_id_16(return_data+32, &fsp->file_id);
    2232                 *out_data = return_data;
    2233                 return NT_STATUS_OK;
    2234         }
    2235 
    2236         case FSCTL_GET_REPARSE_POINT:
    2237         {
    2238                 /* Fail it with STATUS_NOT_A_REPARSE_POINT */
    2239                 DEBUG(10, ("FSCTL_GET_REPARSE_POINT: called on FID[0x%04X] Status: NOT_IMPLEMENTED\n", fsp->fnum));
    2240                 return NT_STATUS_NOT_A_REPARSE_POINT;
    2241         }
    2242 
    2243         case FSCTL_SET_REPARSE_POINT:
    2244         {
    2245                 /* Fail it with STATUS_NOT_A_REPARSE_POINT */
    2246                 DEBUG(10, ("FSCTL_SET_REPARSE_POINT: called on FID[0x%04X] Status: NOT_IMPLEMENTED\n", fsp->fnum));
    2247                 return NT_STATUS_NOT_A_REPARSE_POINT;
    2248         }
    2249 
    2250         case FSCTL_GET_SHADOW_COPY_DATA:
    2251         {
    2252                 /*
    2253                  * This is called to retrieve the number of Shadow Copies (a.k.a. snapshots)
    2254                  * and return their volume names.  If max_data_count is 16, then it is just
    2255                  * asking for the number of volumes and length of the combined names.
    2256                  *
    2257                  * pdata is the data allocated by our caller, but that uses
    2258                  * total_data_count (which is 0 in our case) rather than max_data_count.
    2259                  * Allocate the correct amount and return the pointer to let
    2260                  * it be deallocated when we return.
    2261                  */
    2262                 struct shadow_copy_data *shadow_data = NULL;
    2263                 bool labels = False;
    2264                 uint32 labels_data_count = 0;
    2265                 uint32 i;
    2266                 char *cur_pdata = NULL;
    2267 
    2268                 if (max_out_len < 16) {
    2269                         DEBUG(0,("FSCTL_GET_SHADOW_COPY_DATA: max_data_count(%u) < 16 is invalid!\n",
    2270                                 max_out_len));
    2271                         return NT_STATUS_INVALID_PARAMETER;
    2272                 }
    2273 
    2274                 if (max_out_len > 16) {
    2275                         labels = True;
    2276                 }
    2277 
    2278                 shadow_data = talloc_zero(ctx, struct shadow_copy_data);
    2279                 if (shadow_data == NULL) {
    2280                         DEBUG(0,("TALLOC_ZERO() failed!\n"));
    2281                         return NT_STATUS_NO_MEMORY;
    2282                 }
    2283 
    2284                 /*
    2285                  * Call the VFS routine to actually do the work.
    2286                  */
    2287                 if (SMB_VFS_GET_SHADOW_COPY_DATA(fsp, shadow_data, labels)!=0) {
    2288                         TALLOC_FREE(shadow_data);
    2289                         if (errno == ENOSYS) {
    2290                                 DEBUG(5,("FSCTL_GET_SHADOW_COPY_DATA: connectpath %s, not supported.\n",
    2291                                         fsp->conn->connectpath));
    2292                                 return NT_STATUS_NOT_SUPPORTED;
    2293                         } else {
    2294                                 DEBUG(0,("FSCTL_GET_SHADOW_COPY_DATA: connectpath %s, failed.\n",
    2295                                         fsp->conn->connectpath));
    2296                                 return NT_STATUS_UNSUCCESSFUL;
    2297                         }
    2298                 }
    2299 
    2300                 labels_data_count = (shadow_data->num_volumes * 2 *
    2301                                         sizeof(SHADOW_COPY_LABEL)) + 2;
    2302 
    2303                 if (!labels) {
    2304                         *out_len = 16;
    2305                 } else {
    2306                         *out_len = 12 + labels_data_count;
    2307                 }
    2308 
    2309                 if (max_out_len < *out_len) {
    2310                         DEBUG(0,("FSCTL_GET_SHADOW_COPY_DATA: max_data_count(%u) too small (%u) bytes needed!\n",
    2311                                 max_out_len, *out_len));
    2312                         TALLOC_FREE(shadow_data);
    2313                         return NT_STATUS_BUFFER_TOO_SMALL;
    2314                 }
    2315 
    2316                 cur_pdata = talloc_zero_array(ctx, char, *out_len);
    2317                 if (cur_pdata == NULL) {
    2318                         TALLOC_FREE(shadow_data);
    2319                         return NT_STATUS_NO_MEMORY;
    2320                 }
    2321 
    2322                 *out_data = cur_pdata;
    2323 
    2324                 /* num_volumes 4 bytes */
    2325                 SIVAL(cur_pdata, 0, shadow_data->num_volumes);
    2326 
    2327                 if (labels) {
    2328                         /* num_labels 4 bytes */
    2329                         SIVAL(cur_pdata, 4, shadow_data->num_volumes);
    2330                 }
    2331 
    2332                 /* needed_data_count 4 bytes */
    2333                 SIVAL(cur_pdata, 8, labels_data_count);
    2334 
    2335                 cur_pdata += 12;
    2336 
    2337                 DEBUG(10,("FSCTL_GET_SHADOW_COPY_DATA: %u volumes for path[%s].\n",
    2338                           shadow_data->num_volumes, fsp_str_dbg(fsp)));
    2339                 if (labels && shadow_data->labels) {
    2340                         for (i=0; i<shadow_data->num_volumes; i++) {
    2341                                 srvstr_push(cur_pdata, req_flags,
    2342                                             cur_pdata, shadow_data->labels[i],
    2343                                             2 * sizeof(SHADOW_COPY_LABEL),
    2344                                             STR_UNICODE|STR_TERMINATE);
    2345                                 cur_pdata += 2 * sizeof(SHADOW_COPY_LABEL);
    2346                                 DEBUGADD(10,("Label[%u]: '%s'\n",i,shadow_data->labels[i]));
    2347                         }
    2348                 }
    2349 
    2350                 TALLOC_FREE(shadow_data);
    2351 
    2352                 return NT_STATUS_OK;
    2353         }
    2354 
    2355         case FSCTL_FIND_FILES_BY_SID:
    2356         {
    2357                 /* pretend this succeeded -
    2358                  *
    2359                  * we have to send back a list with all files owned by this SID
    2360                  *
    2361                  * but I have to check that --metze
    2362                  */
    2363                 struct dom_sid sid;
    2364                 uid_t uid;
    2365                 size_t sid_len;
    2366 
    2367                 DEBUG(10,("FSCTL_FIND_FILES_BY_SID: called on FID[0x%04X]\n", fsp->fnum));
    2368 
    2369                 if (in_len < 8) {
    2370                         /* NT_STATUS_BUFFER_TOO_SMALL maybe? */
    2371                         return NT_STATUS_INVALID_PARAMETER;
    2372                 }
    2373 
    2374                 sid_len = MIN(in_len - 4,SID_MAX_SIZE);
    2375 
    2376                 /* unknown 4 bytes: this is not the length of the sid :-(  */
    2377                 /*unknown = IVAL(pdata,0);*/
    2378 
    2379                 if (!sid_parse(in_data + 4, sid_len, &sid)) {
    2380                         return NT_STATUS_INVALID_PARAMETER;
    2381                 }
    2382                 DEBUGADD(10, ("for SID: %s\n", sid_string_dbg(&sid)));
    2383 
    2384                 if (!sid_to_uid(&sid, &uid)) {
    2385                         DEBUG(0,("sid_to_uid: failed, sid[%s] sid_len[%lu]\n",
    2386                                  sid_string_dbg(&sid),
    2387                                  (unsigned long)sid_len));
    2388                         uid = (-1);
    2389                 }
    2390 
    2391                 /* we can take a look at the find source :-)
    2392                  *
    2393                  * find ./ -uid $uid  -name '*'   is what we need here
    2394                  *
    2395                  *
    2396                  * and send 4bytes len and then NULL terminated unicode strings
    2397                  * for each file
    2398                  *
    2399                  * but I don't know how to deal with the paged results
    2400                  * (maybe we can hang the result anywhere in the fsp struct)
    2401                  *
    2402                  * but I don't know how to deal with the paged results
    2403                  * (maybe we can hang the result anywhere in the fsp struct)
    2404                  *
    2405                  * we don't send all files at once
    2406                  * and at the next we should *not* start from the beginning,
    2407                  * so we have to cache the result
    2408                  *
    2409                  * --metze
    2410                  */
    2411 
    2412                 /* this works for now... */
    2413                 return NT_STATUS_OK;
    2414         }
    2415 
    2416         case FSCTL_QUERY_ALLOCATED_RANGES:
    2417         {
    2418                 /* FIXME: This is just a dummy reply, telling that all of the
    2419                  * file is allocated. MKS cp needs that.
    2420                  * Adding the real allocated ranges via FIEMAP on Linux
    2421                  * and SEEK_DATA/SEEK_HOLE on Solaris is needed to make
    2422                  * this FSCTL correct for sparse files.
    2423                  */
    2424                 NTSTATUS status;
    2425                 uint64_t offset, length;
    2426                 char *out_data_tmp = NULL;
    2427 
    2428                 if (in_len != 16) {
    2429                         DEBUG(0,("FSCTL_QUERY_ALLOCATED_RANGES: data_count(%u) != 16 is invalid!\n",
    2430                                 in_len));
    2431                         return NT_STATUS_INVALID_PARAMETER;
    2432                 }
    2433 
    2434                 if (max_out_len < 16) {
    2435                         DEBUG(0,("FSCTL_QUERY_ALLOCATED_RANGES: max_out_len (%u) < 16 is invalid!\n",
    2436                                 max_out_len));
    2437                         return NT_STATUS_INVALID_PARAMETER;
    2438                 }
    2439 
    2440                 offset = BVAL(in_data,0);
    2441                 length = BVAL(in_data,8);
    2442 
    2443                 if (offset + length < offset) {
    2444                         /* No 64-bit integer wrap. */
    2445                         return NT_STATUS_INVALID_PARAMETER;
    2446                 }
    2447 
    2448                 /* Shouldn't this be SMB_VFS_STAT ... ? */
    2449                 status = vfs_stat_fsp(fsp);
    2450                 if (!NT_STATUS_IS_OK(status)) {
    2451                         return status;
    2452                 }
    2453 
    2454                 *out_len = 16;
    2455                 out_data_tmp = talloc_array(ctx, char, *out_len);
    2456                 if (out_data_tmp == NULL) {
    2457                         DEBUG(10, ("unable to allocate memory for response\n"));
    2458                         return NT_STATUS_NO_MEMORY;
    2459                 }
    2460 
    2461                 if (offset > fsp->fsp_name->st.st_ex_size ||
    2462                                 fsp->fsp_name->st.st_ex_size == 0 ||
    2463                                 length == 0) {
    2464                         memset(out_data_tmp, 0, *out_len);
    2465                 } else {
    2466                         uint64_t end = offset + length;
    2467                         end = MIN(end, fsp->fsp_name->st.st_ex_size);
    2468                         SBVAL(out_data_tmp, 0, 0);
    2469                         SBVAL(out_data_tmp, 8, end);
    2470                 }
    2471 
    2472                 *out_data = out_data_tmp;
    2473 
    2474                 return NT_STATUS_OK;
    2475         }
    2476 
    2477         case FSCTL_IS_VOLUME_DIRTY:
    2478         {
    2479                 DEBUG(10,("FSCTL_IS_VOLUME_DIRTY: called on FID[0x%04X] "
    2480                           "(but not implemented)\n", fsp->fnum));
    2481                 /*
    2482                  * http://msdn.microsoft.com/en-us/library/cc232128%28PROT.10%29.aspx
    2483                  * says we have to respond with NT_STATUS_INVALID_PARAMETER
    2484                  */
    2485                 return NT_STATUS_INVALID_PARAMETER;
    2486         }
    2487 
    2488         default:
    2489                 /*
    2490                  * Only print once ... unfortunately there could be lots of
    2491                  * different FSCTLs that are called.
    2492                  */
    2493                 if (!vfswrap_logged_ioctl_message) {
    2494                         vfswrap_logged_ioctl_message = true;
    2495                         DEBUG(2, ("%s (0x%x): Currently not implemented.\n",
    2496                         __FUNCTION__, function));
    2497                 }
    2498         }
    2499 
    2500         return NT_STATUS_NOT_SUPPORTED;
    2501 }
    2502 
    25032216/****************************************************************************
    25042217 Reply to NT IOCTL
     
    25072220static void call_nt_transact_ioctl(connection_struct *conn,
    25082221                                   struct smb_request *req,
    2509                                    uint16 **ppsetup, uint32 setup_count,
    2510                                    char **ppparams, uint32 parameter_count,
    2511                                    char **ppdata, uint32 data_count,
    2512                                    uint32 max_data_count)
     2222                                   uint16_t **ppsetup, uint32_t setup_count,
     2223                                   char **ppparams, uint32_t parameter_count,
     2224                                   char **ppdata, uint32_t data_count,
     2225                                   uint32_t max_data_count)
    25132226{
    25142227        NTSTATUS status;
    2515         uint32 function;
    2516         uint16 fidnum;
     2228        uint32_t function;
     2229        uint16_t fidnum;
    25172230        files_struct *fsp;
    2518         uint8 isFSctl;
    2519         uint8 compfilter;
     2231        uint8_t isFSctl;
     2232        uint8_t compfilter;
    25202233        char *out_data = NULL;
    2521         uint32 out_data_len = 0;
     2234        uint32_t out_data_len = 0;
    25222235        char *pdata = *ppdata;
    25232236        TALLOC_CTX *ctx = talloc_tos();
     
    25342247        compfilter = CVAL(*ppsetup, 7);
    25352248
    2536         DEBUG(10, ("call_nt_transact_ioctl: function[0x%08X] FID[0x%04X] isFSctl[0x%02X] compfilter[0x%02X]\n",
     2249        DEBUG(10, ("call_nt_transact_ioctl: function[0x%08X] FID[0x%04X] isFSctl[0x%02X] compfilter[0x%02X]\n", 
    25372250                 function, fidnum, isFSctl, compfilter));
    25382251
     
    25542267        }
    25552268
     2269        SMB_PERFCOUNT_SET_IOCTL(&req->pcd, function);
     2270
    25562271        /*
    25572272         * out_data might be allocated by the VFS module, but talloc should be
    25582273         * used, and should be cleaned up when the request ends.
    25592274         */
    2560         status = smb_fsctl(fsp,
     2275        status = SMB_VFS_FSCTL(fsp,
    25612276                               ctx,
    2562                                function,
     2277                               function, 
    25632278                               req->flags2,
    2564                                (uint8_t *)pdata,
    2565                                data_count,
     2279                               (uint8_t *)pdata, 
     2280                               data_count, 
    25662281                               (uint8_t **)&out_data,
    25672282                               max_data_count,
     
    25822297static void call_nt_transact_get_user_quota(connection_struct *conn,
    25832298                                            struct smb_request *req,
    2584                                             uint16 **ppsetup,
    2585                                             uint32 setup_count,
     2299                                            uint16_t **ppsetup,
     2300                                            uint32_t setup_count,
    25862301                                            char **ppparams,
    2587                                             uint32 parameter_count,
     2302                                            uint32_t parameter_count,
    25882303                                            char **ppdata,
    2589                                             uint32 data_count,
    2590                                             uint32 max_data_count)
     2304                                            uint32_t data_count,
     2305                                            uint32_t max_data_count)
    25912306{
    25922307        NTSTATUS nt_status = NT_STATUS_OK;
     
    25982313        int entry_len = 0;
    25992314        files_struct *fsp = NULL;
    2600         uint16 level = 0;
     2315        uint16_t level = 0;
    26012316        size_t sid_len;
    26022317        struct dom_sid sid;
     
    26092324
    26102325        /* access check */
    2611         if (get_current_uid(conn) != 0) {
     2326        if (get_current_uid(conn) != sec_initial_uid()) {
    26122327                DEBUG(1,("get_user_quota: access_denied service [%s] user "
    2613                          "[%s]\n", lp_servicename(SNUM(conn)),
    2614                          conn->session_info->unix_name));
     2328                         "[%s]\n", lp_servicename(talloc_tos(), SNUM(conn)),
     2329                         conn->session_info->unix_info->unix_name));
    26152330                reply_nterror(req, NT_STATUS_ACCESS_DENIED);
    26162331                return;
     
    27382453
    27392454                                /* and now the SID */
    2740                                 sid_linearize(entry+40, sid_len, &tmp_list->quotas->sid);
     2455                                sid_linearize((uint8_t *)(entry+40), sid_len,
     2456                                              &tmp_list->quotas->sid);
    27412457                        }
    27422458
     
    27872503                        }
    27882504
    2789                         if (!sid_parse(pdata+8,sid_len,&sid)) {
     2505                        if (!sid_parse((const uint8_t *)(pdata+8), sid_len,
     2506                                       &sid)) {
    27902507                                reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
    27912508                                return;
     
    28392556
    28402557                        /* and now the SID */
    2841                         sid_linearize(entry+40, sid_len, &sid);
     2558                        sid_linearize((uint8_t *)(entry+40), sid_len, &sid);
    28422559
    28432560                        break;
    28442561
    28452562                default:
    2846                         DEBUG(0,("do_nt_transact_get_user_quota: fnum %d unknown level 0x%04hX\n",fsp->fnum,level));
     2563                        DEBUG(0, ("do_nt_transact_get_user_quota: %s: unknown "
     2564                                  "level 0x%04hX\n",
     2565                                  fsp_fnum_dbg(fsp), level));
    28472566                        reply_nterror(req, NT_STATUS_INVALID_LEVEL);
    28482567                        return;
     
    28602579static void call_nt_transact_set_user_quota(connection_struct *conn,
    28612580                                            struct smb_request *req,
    2862                                             uint16 **ppsetup,
    2863                                             uint32 setup_count,
     2581                                            uint16_t **ppsetup,
     2582                                            uint32_t setup_count,
    28642583                                            char **ppparams,
    2865                                             uint32 parameter_count,
     2584                                            uint32_t parameter_count,
    28662585                                            char **ppdata,
    2867                                             uint32 data_count,
    2868                                             uint32 max_data_count)
     2586                                            uint32_t data_count,
     2587                                            uint32_t max_data_count)
    28692588{
    28702589        char *params = *ppparams;
     
    28812600        if (get_current_uid(conn) != 0) {
    28822601                DEBUG(1,("set_user_quota: access_denied service [%s] user "
    2883                          "[%s]\n", lp_servicename(SNUM(conn)),
    2884                          conn->session_info->unix_name));
     2602                         "[%s]\n", lp_servicename(talloc_tos(), SNUM(conn)),
     2603                         conn->session_info->unix_info->unix_name));
    28852604                reply_nterror(req, NT_STATUS_ACCESS_DENIED);
    28862605                return;
     
    29382657        qt.hardlim = BVAL(pdata,32);
    29392658
    2940         if (!sid_parse(pdata+40,sid_len,&sid)) {
     2659        if (!sid_parse((const uint8_t *)(pdata+40), sid_len, &sid)) {
    29412660                reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
    29422661                return;
     
    29632682        if (get_Protocol() >= PROTOCOL_NT1) {
    29642683                req->flags2 |= 0x40; /* IS_LONG_NAME */
    2965                 SSVAL(req->inbuf,smb_flg2,req->flags2);
     2684                SSVAL(discard_const_p(uint8_t, req->inbuf),smb_flg2,req->flags2);
    29662685        }
    29672686
     
    30992818        uint32_t dscnt;
    31002819        uint32_t dsoff;
    3101         uint16 function_code;
     2820        uint16_t function_code;
    31022821        NTSTATUS result;
    31032822        struct trans_state *state;
     
    31312850        }
    31322851
    3133         if ((state = TALLOC_P(conn, struct trans_state)) == NULL) {
     2852        if ((state = talloc(conn, struct trans_state)) == NULL) {
    31342853                reply_nterror(req, NT_STATUS_NO_MEMORY);
    31352854                END_PROFILE(SMBnttrans);
     
    32482967                }
    32492968
    3250                 state->setup = (uint16 *)TALLOC(state, state->setup_count);
     2969                state->setup = (uint16_t *)TALLOC(state, state->setup_count);
    32512970                if (state->setup == NULL) {
    32522971                        DEBUG(0,("reply_nttrans : Out of memory\n"));
     
    32602979
    32612980                memcpy(state->setup, req->vwv+19, state->setup_count);
    3262                 dump_data(10, (uint8 *)state->setup, state->setup_count);
     2981                dump_data(10, (uint8_t *)state->setup, state->setup_count);
    32632982        }
    32642983
     
    33053024        START_PROFILE(SMBnttranss);
    33063025
    3307         show_msg((char *)req->inbuf);
     3026        show_msg((const char *)req->inbuf);
    33083027
    33093028        /* Windows clients expect all replies to
Note: See TracChangeset for help on using the changeset viewer.