s3: smbd: Change open_streams_for_delete() to take a struct smb_filename *.
[samba.git] / source3 / smbd / nttrans.c
index 57c41597dceba40e85f259b4fa4c87c660f3b97a..c6ad095919b21a5ffea5abf280430e8ee9917305 100644 (file)
@@ -67,8 +67,7 @@ static void send_nt_replies(connection_struct *conn,
        int params_sent_thistime, data_sent_thistime, total_sent_thistime;
        int alignment_offset = 1;
        int data_alignment_offset = 0;
-       struct smbd_server_connection *sconn = req->sconn;
-       struct smbXsrv_connection *xconn = sconn->conn;
+       struct smbXsrv_connection *xconn = req->xconn;
        int max_send = xconn->smb1.sessions.max_send;
 
        /*
@@ -84,7 +83,7 @@ static void send_nt_replies(connection_struct *conn,
                                         __LINE__,__FILE__);
                }
                show_msg((char *)req->outbuf);
-               if (!srv_send_smb(sconn,
+               if (!srv_send_smb(xconn,
                                (char *)req->outbuf,
                                true, req->seqnum+1,
                                IS_CONN_ENCRYPTED(conn),
@@ -248,7 +247,7 @@ static void send_nt_replies(connection_struct *conn,
 
                /* Send the packet */
                show_msg((char *)req->outbuf);
-               if (!srv_send_smb(sconn,
+               if (!srv_send_smb(xconn,
                                (char *)req->outbuf,
                                true, req->seqnum+1,
                                IS_CONN_ENCRYPTED(conn),
@@ -318,7 +317,7 @@ static void do_ntcreate_pipe_open(connection_struct *conn,
        char *fname = NULL;
        uint16_t pnum = FNUM_FIELD_INVALID;
        char *p = NULL;
-       uint32 flags = IVAL(req->vwv+3, 1);
+       uint32_t flags = IVAL(req->vwv+3, 1);
        TALLOC_CTX *ctx = talloc_tos();
 
        srvstr_pull_req_talloc(ctx, req, &fname, req->buf, STR_TERMINATE);
@@ -439,17 +438,17 @@ void reply_ntcreate_and_X(struct smb_request *req)
        connection_struct *conn = req->conn;
        struct smb_filename *smb_fname = NULL;
        char *fname = NULL;
-       uint32 flags;
-       uint32 access_mask;
-       uint32 file_attributes;
-       uint32 share_access;
-       uint32 create_disposition;
-       uint32 create_options;
-       uint16 root_dir_fid;
+       uint32_t flags;
+       uint32_t access_mask;
+       uint32_t file_attributes;
+       uint32_t share_access;
+       uint32_t create_disposition;
+       uint32_t create_options;
+       uint16_t root_dir_fid;
        uint64_t allocation_size;
        /* Breakout the oplock request bits so we can set the
           reply bits separately. */
-       uint32 fattr=0;
+       uint32_t fattr=0;
        off_t file_len = 0;
        int info = 0;
        files_struct *fsp = NULL;
@@ -462,6 +461,8 @@ void reply_ntcreate_and_X(struct smb_request *req)
        int oplock_request;
        uint8_t oplock_granted = NO_OPLOCK_RETURN;
        struct case_semantics_state *case_state = NULL;
+       uint32_t ucf_flags = UCF_PREP_CREATEFILE |
+                       (req->posix_pathnames ? UCF_POSIX_PATHNAMES : 0);
        TALLOC_CTX *ctx = talloc_tos();
 
        START_PROFILE(SMBntcreateX);
@@ -477,7 +478,7 @@ void reply_ntcreate_and_X(struct smb_request *req)
        share_access = IVAL(req->vwv+15, 1);
        create_disposition = IVAL(req->vwv+17, 1);
        create_options = IVAL(req->vwv+19, 1);
-       root_dir_fid = (uint16)IVAL(req->vwv+5, 1);
+       root_dir_fid = (uint16_t)IVAL(req->vwv+5, 1);
 
        allocation_size = BVAL(req->vwv+9, 1);
 
@@ -539,7 +540,7 @@ void reply_ntcreate_and_X(struct smb_request *req)
                                conn,
                                req->flags2 & FLAGS2_DFS_PATHNAMES,
                                fname,
-                               UCF_PREP_CREATEFILE,
+                               ucf_flags,
                                NULL,
                                &smb_fname);
 
@@ -574,15 +575,17 @@ void reply_ntcreate_and_X(struct smb_request *req)
                create_options,                         /* create_options */
                file_attributes,                        /* file_attributes */
                oplock_request,                         /* oplock_request */
+               NULL,                                   /* lease */
                allocation_size,                        /* allocation_size */
                0,                                      /* private_flags */
                NULL,                                   /* sd */
                NULL,                                   /* ea_list */
                &fsp,                                   /* result */
-               &info);                                 /* pinfo */
+               &info,                                  /* pinfo */
+               NULL, NULL);                            /* create context */
 
        if (!NT_STATUS_IS_OK(status)) {
-               if (open_was_deferred(req->sconn, req->mid)) {
+               if (open_was_deferred(req->xconn, req->mid)) {
                        /* We have re-scheduled this call, no error. */
                        goto out;
                }
@@ -695,7 +698,7 @@ void reply_ntcreate_and_X(struct smb_request *req)
                if (NT_STATUS_IS_OK(status) && num_names) {
                        file_status &= ~NO_EAS;
                }
-               status = vfs_streaminfo(conn, NULL, smb_fname->base_name, ctx,
+               status = vfs_streaminfo(conn, NULL, smb_fname, ctx,
                        &num_streams, &streams);
                /* There is always one stream, ::$DATA. */
                if (NT_STATUS_IS_OK(status) && num_streams > 1) {
@@ -708,7 +711,7 @@ void reply_ntcreate_and_X(struct smb_request *req)
        SCVAL(p,0,fsp->is_directory ? 1 : 0);
 
        if (flags & EXTENDED_RESPONSE_REQUIRED) {
-               uint32 perms = 0;
+               uint32_t perms = 0;
                p += 25;
                if (fsp->is_directory ||
                    fsp->can_write ||
@@ -734,9 +737,9 @@ void reply_ntcreate_and_X(struct smb_request *req)
 
 static void do_nt_transact_create_pipe(connection_struct *conn,
                                       struct smb_request *req,
-                                      uint16 **ppsetup, uint32 setup_count,
-                                      char **ppparams, uint32 parameter_count,
-                                      char **ppdata, uint32 data_count)
+                                      uint16_t **ppsetup, uint32_t setup_count,
+                                      char **ppparams, uint32_t parameter_count,
+                                      char **ppdata, uint32_t data_count)
 {
        char *fname = NULL;
        char *params = *ppparams;
@@ -744,7 +747,7 @@ static void do_nt_transact_create_pipe(connection_struct *conn,
        char *p = NULL;
        NTSTATUS status;
        size_t param_len;
-       uint32 flags;
+       uint32_t flags;
        TALLOC_CTX *ctx = talloc_tos();
 
        /*
@@ -759,9 +762,25 @@ static void do_nt_transact_create_pipe(connection_struct *conn,
 
        flags = IVAL(params,0);
 
-       srvstr_get_path(ctx, params, req->flags2, &fname, params+53,
-                       parameter_count-53, STR_TERMINATE,
+       if (req->posix_pathnames) {
+               srvstr_get_path_posix(ctx,
+                       params,
+                       req->flags2,
+                       &fname,
+                       params+53,
+                       parameter_count-53,
+                       STR_TERMINATE,
+                       &status);
+       } else {
+               srvstr_get_path(ctx,
+                       params,
+                       req->flags2,
+                       &fname,
+                       params+53,
+                       parameter_count-53,
+                       STR_TERMINATE,
                        &status);
+       }
        if (!NT_STATUS_IS_OK(status)) {
                reply_nterror(req, status);
                return;
@@ -963,31 +982,31 @@ NTSTATUS set_sd_blob(files_struct *fsp, uint8_t *data, uint32_t sd_len,
 
 static void call_nt_transact_create(connection_struct *conn,
                                    struct smb_request *req,
-                                   uint16 **ppsetup, uint32 setup_count,
-                                   char **ppparams, uint32 parameter_count,
-                                   char **ppdata, uint32 data_count,
-                                   uint32 max_data_count)
+                                   uint16_t **ppsetup, uint32_t setup_count,
+                                   char **ppparams, uint32_t parameter_count,
+                                   char **ppdata, uint32_t data_count,
+                                   uint32_t max_data_count)
 {
        struct smb_filename *smb_fname = NULL;
        char *fname = NULL;
        char *params = *ppparams;
        char *data = *ppdata;
        /* Breakout the oplock request bits so we can set the reply bits separately. */
-       uint32 fattr=0;
+       uint32_t fattr=0;
        off_t file_len = 0;
        int info = 0;
        files_struct *fsp = NULL;
        char *p = NULL;
-       uint32 flags;
-       uint32 access_mask;
-       uint32 file_attributes;
-       uint32 share_access;
-       uint32 create_disposition;
-       uint32 create_options;
-       uint32 sd_len;
+       uint32_t flags;
+       uint32_t access_mask;
+       uint32_t file_attributes;
+       uint32_t share_access;
+       uint32_t create_disposition;
+       uint32_t create_options;
+       uint32_t sd_len;
        struct security_descriptor *sd = NULL;
-       uint32 ea_len;
-       uint16 root_dir_fid;
+       uint32_t ea_len;
+       uint16_t root_dir_fid;
        struct timespec create_timespec;
        struct timespec c_timespec;
        struct timespec a_timespec;
@@ -999,6 +1018,8 @@ static void call_nt_transact_create(connection_struct *conn,
        int oplock_request;
        uint8_t oplock_granted;
        struct case_semantics_state *case_state = NULL;
+       uint32_t ucf_flags = UCF_PREP_CREATEFILE |
+                       (req->posix_pathnames ? UCF_POSIX_PATHNAMES : 0);
        TALLOC_CTX *ctx = talloc_tos();
 
        DEBUG(5,("call_nt_transact_create\n"));
@@ -1038,7 +1059,7 @@ static void call_nt_transact_create(connection_struct *conn,
        create_options = IVAL(params,32);
        sd_len = IVAL(params,36);
        ea_len = IVAL(params,40);
-       root_dir_fid = (uint16)IVAL(params,4);
+       root_dir_fid = (uint16_t)IVAL(params,4);
        allocation_size = BVAL(params,12);
 
        /*
@@ -1047,9 +1068,25 @@ static void call_nt_transact_create(connection_struct *conn,
         */
        create_options &= ~NTCREATEX_OPTIONS_MUST_IGNORE_MASK;
 
-       srvstr_get_path(ctx, params, req->flags2, &fname,
-                       params+53, parameter_count-53,
-                       STR_TERMINATE, &status);
+       if (req->posix_pathnames) {
+               srvstr_get_path_posix(ctx,
+                       params,
+                       req->flags2,
+                       &fname,
+                       params+53,
+                       parameter_count-53,
+                       STR_TERMINATE,
+                       &status);
+       } else {
+               srvstr_get_path(ctx,
+                       params,
+                       req->flags2,
+                       &fname,
+                       params+53,
+                       parameter_count-53,
+                       STR_TERMINATE,
+                       &status);
+       }
        if (!NT_STATUS_IS_OK(status)) {
                reply_nterror(req, status);
                goto out;
@@ -1067,7 +1104,7 @@ static void call_nt_transact_create(connection_struct *conn,
                                conn,
                                req->flags2 & FLAGS2_DFS_PATHNAMES,
                                fname,
-                               UCF_PREP_CREATEFILE,
+                               ucf_flags,
                                NULL,
                                &smb_fname);
 
@@ -1180,15 +1217,17 @@ static void call_nt_transact_create(connection_struct *conn,
                create_options,                         /* create_options */
                file_attributes,                        /* file_attributes */
                oplock_request,                         /* oplock_request */
+               NULL,                                   /* lease */
                allocation_size,                        /* allocation_size */
                0,                                      /* private_flags */
                sd,                                     /* sd */
                ea_list,                                /* ea_list */
                &fsp,                                   /* result */
-               &info);                                 /* pinfo */
+               &info,                                  /* pinfo */
+               NULL, NULL);                            /* create context */
 
        if(!NT_STATUS_IS_OK(status)) {
-               if (open_was_deferred(req->sconn, req->mid)) {
+               if (open_was_deferred(req->xconn, req->mid)) {
                        /* We have re-scheduled this call, no error. */
                        return;
                }
@@ -1298,7 +1337,7 @@ static void call_nt_transact_create(connection_struct *conn,
                if (NT_STATUS_IS_OK(status) && num_names) {
                        file_status &= ~NO_EAS;
                }
-               status = vfs_streaminfo(conn, NULL, smb_fname->base_name, ctx,
+               status = vfs_streaminfo(conn, NULL, smb_fname, ctx,
                        &num_streams, &streams);
                /* There is always one stream, ::$DATA. */
                if (NT_STATUS_IS_OK(status) && num_streams > 1) {
@@ -1311,7 +1350,7 @@ static void call_nt_transact_create(connection_struct *conn,
        SCVAL(p,0,fsp->is_directory ? 1 : 0);
 
        if (flags & EXTENDED_RESPONSE_REQUIRED) {
-               uint32 perms = 0;
+               uint32_t perms = 0;
                p += 25;
                if (fsp->is_directory ||
                    fsp->can_write ||
@@ -1339,7 +1378,8 @@ static void call_nt_transact_create(connection_struct *conn,
 
 void reply_ntcancel(struct smb_request *req)
 {
-       struct smbXsrv_connection *xconn = req->sconn->conn;
+       struct smbXsrv_connection *xconn = req->xconn;
+       struct smbd_server_connection *sconn = req->sconn;
 
        /*
         * Go through and cancel any pending change notifies.
@@ -1347,8 +1387,8 @@ void reply_ntcancel(struct smb_request *req)
 
        START_PROFILE(SMBntcancel);
        srv_cancel_sign_response(xconn);
-       remove_pending_change_notify_requests_by_mid(req->sconn, req->mid);
-       remove_pending_lock_requests_by_mid_smb1(req->sconn, req->mid);
+       remove_pending_change_notify_requests_by_mid(sconn, req->mid);
+       remove_pending_lock_requests_by_mid_smb1(sconn, req->mid);
 
        DEBUG(3,("reply_ntcancel: cancel called on mid = %llu.\n",
                (unsigned long long)req->mid));
@@ -1366,10 +1406,10 @@ static NTSTATUS copy_internals(TALLOC_CTX *ctx,
                                struct smb_request *req,
                                struct smb_filename *smb_fname_src,
                                struct smb_filename *smb_fname_dst,
-                               uint32 attrs)
+                               uint32_t attrs)
 {
        files_struct *fsp1,*fsp2;
-       uint32 fattr;
+       uint32_t fattr;
        int info;
        off_t ret=-1;
        NTSTATUS status = NT_STATUS_OK;
@@ -1422,12 +1462,14 @@ static NTSTATUS copy_internals(TALLOC_CTX *ctx,
                0,                                      /* create_options */
                FILE_ATTRIBUTE_NORMAL,                  /* file_attributes */
                NO_OPLOCK,                              /* oplock_request */
+               NULL,                                   /* lease */
                0,                                      /* allocation_size */
                0,                                      /* private_flags */
                NULL,                                   /* sd */
                NULL,                                   /* ea_list */
                &fsp1,                                  /* result */
-               &info);                                 /* pinfo */
+               &info,                                  /* pinfo */
+               NULL, NULL);                            /* create context */
 
        if (!NT_STATUS_IS_OK(status)) {
                goto out;
@@ -1446,12 +1488,14 @@ static NTSTATUS copy_internals(TALLOC_CTX *ctx,
                0,                                      /* create_options */
                fattr,                                  /* file_attributes */
                NO_OPLOCK,                              /* oplock_request */
+               NULL,                                   /* lease */
                0,                                      /* allocation_size */
                0,                                      /* private_flags */
                NULL,                                   /* sd */
                NULL,                                   /* ea_list */
                &fsp2,                                  /* result */
-               &info);                                 /* pinfo */
+               &info,                                  /* pinfo */
+               NULL, NULL);                            /* create context */
 
        if (!NT_STATUS_IS_OK(status)) {
                close_file(NULL, fsp1, ERROR_CLOSE);
@@ -1515,10 +1559,10 @@ void reply_ntrename(struct smb_request *req)
        NTSTATUS status;
        bool src_has_wcard = False;
        bool dest_has_wcard = False;
-       uint32 attrs;
-       uint32_t ucf_flags_src = 0;
-       uint32_t ucf_flags_dst = 0;
-       uint16 rename_type;
+       uint32_t attrs;
+       uint32_t ucf_flags_src = (req->posix_pathnames ? UCF_POSIX_PATHNAMES : 0);
+       uint32_t ucf_flags_dst = (req->posix_pathnames ? UCF_POSIX_PATHNAMES : 0);
+       uint16_t rename_type;
        TALLOC_CTX *ctx = talloc_tos();
        bool stream_rename = false;
 
@@ -1540,7 +1584,7 @@ void reply_ntrename(struct smb_request *req)
                goto out;
        }
 
-       if (ms_has_wild(oldname)) {
+       if (!req->posix_pathnames && ms_has_wild(oldname)) {
                reply_nterror(req, NT_STATUS_OBJECT_PATH_SYNTAX_BAD);
                goto out;
        }
@@ -1553,7 +1597,7 @@ void reply_ntrename(struct smb_request *req)
                goto out;
        }
 
-       if (!lp_posix_pathnames()) {
+       if (!req->posix_pathnames) {
                /* The newname must begin with a ':' if the
                   oldname contains a ':'. */
                if (strchr_m(oldname, ':')) {
@@ -1666,7 +1710,7 @@ void reply_ntrename(struct smb_request *req)
        }
 
        if (!NT_STATUS_IS_OK(status)) {
-               if (open_was_deferred(req->sconn, req->mid)) {
+               if (open_was_deferred(req->xconn, req->mid)) {
                        /* We have re-scheduled this call. */
                        goto out;
                }
@@ -1695,17 +1739,17 @@ static void smbd_smb1_notify_reply(struct smb_request *req,
 
 static void call_nt_transact_notify_change(connection_struct *conn,
                                           struct smb_request *req,
-                                          uint16 **ppsetup,
-                                          uint32 setup_count,
+                                          uint16_t **ppsetup,
+                                          uint32_t setup_count,
                                           char **ppparams,
-                                          uint32 parameter_count,
-                                          char **ppdata, uint32 data_count,
-                                          uint32 max_data_count,
-                                          uint32 max_param_count)
+                                          uint32_t parameter_count,
+                                          char **ppdata, uint32_t data_count,
+                                          uint32_t max_data_count,
+                                          uint32_t max_param_count)
 {
-       uint16 *setup = *ppsetup;
+       uint16_t *setup = *ppsetup;
        files_struct *fsp;
-       uint32 filter;
+       uint32_t filter;
        NTSTATUS status;
        bool recursive;
 
@@ -1802,10 +1846,10 @@ static void call_nt_transact_notify_change(connection_struct *conn,
 
 static void call_nt_transact_rename(connection_struct *conn,
                                    struct smb_request *req,
-                                   uint16 **ppsetup, uint32 setup_count,
-                                   char **ppparams, uint32 parameter_count,
-                                   char **ppdata, uint32 data_count,
-                                   uint32 max_data_count)
+                                   uint16_t **ppsetup, uint32_t setup_count,
+                                   char **ppparams, uint32_t parameter_count,
+                                   char **ppdata, uint32_t data_count,
+                                   uint32_t max_data_count)
 {
        char *params = *ppparams;
        char *new_name = NULL;
@@ -1823,9 +1867,28 @@ static void call_nt_transact_rename(connection_struct *conn,
        if (!check_fsp(conn, req, fsp)) {
                return;
        }
-       srvstr_get_path_wcard(ctx, params, req->flags2, &new_name, params+4,
-                             parameter_count - 4,
-                             STR_TERMINATE, &status, &dest_has_wcard);
+       if (req->posix_pathnames) {
+               srvstr_get_path_wcard_posix(ctx,
+                               params,
+                               req->flags2,
+                               &new_name,
+                               params+4,
+                               parameter_count - 4,
+                               STR_TERMINATE,
+                               &status,
+                               &dest_has_wcard);
+       } else {
+               srvstr_get_path_wcard(ctx,
+                               params,
+                               req->flags2,
+                               &new_name,
+                               params+4,
+                               parameter_count - 4,
+                               STR_TERMINATE,
+                               &status,
+                               &dest_has_wcard);
+       }
+
        if (!NT_STATUS_IS_OK(status)) {
                reply_nterror(req, status);
                return;
@@ -1862,7 +1925,7 @@ static NTSTATUS get_null_nt_acl(TALLOC_CTX *mem_ctx, struct security_descriptor
 
 /****************************************************************************
  Reply to query a security descriptor.
- Callable from SMB2 and SMB2.
+ Callable from SMB1 and SMB2.
  If it returns NT_STATUS_BUFFER_TOO_SMALL, pdata_size is initialized with
  the required size.
 ****************************************************************************/
@@ -1985,18 +2048,18 @@ NTSTATUS smbd_do_query_security_desc(connection_struct *conn,
 
 static void call_nt_transact_query_security_desc(connection_struct *conn,
                                                 struct smb_request *req,
-                                                uint16 **ppsetup,
-                                                uint32 setup_count,
+                                                uint16_t **ppsetup,
+                                                uint32_t setup_count,
                                                 char **ppparams,
-                                                uint32 parameter_count,
+                                                uint32_t parameter_count,
                                                 char **ppdata,
-                                                uint32 data_count,
-                                                uint32 max_data_count)
+                                                uint32_t data_count,
+                                                uint32_t max_data_count)
 {
        char *params = *ppparams;
        char *data = *ppdata;
        size_t sd_size = 0;
-       uint32 security_info_wanted;
+       uint32_t security_info_wanted;
        files_struct *fsp = NULL;
        NTSTATUS status;
        uint8_t *marshalled_sd = NULL;
@@ -2031,7 +2094,8 @@ static void call_nt_transact_query_security_desc(connection_struct *conn,
        status = smbd_do_query_security_desc(conn,
                                        talloc_tos(),
                                        fsp,
-                                       security_info_wanted,
+                                       security_info_wanted &
+                                       SMB_SUPPORTED_SECINFO_FLAGS,
                                        max_data_count,
                                        &marshalled_sd,
                                        &sd_size);
@@ -2081,18 +2145,18 @@ static void call_nt_transact_query_security_desc(connection_struct *conn,
 
 static void call_nt_transact_set_security_desc(connection_struct *conn,
                                               struct smb_request *req,
-                                              uint16 **ppsetup,
-                                              uint32 setup_count,
+                                              uint16_t **ppsetup,
+                                              uint32_t setup_count,
                                               char **ppparams,
-                                              uint32 parameter_count,
+                                              uint32_t parameter_count,
                                               char **ppdata,
-                                              uint32 data_count,
-                                              uint32 max_data_count)
+                                              uint32_t data_count,
+                                              uint32_t max_data_count)
 {
        char *params= *ppparams;
        char *data = *ppdata;
        files_struct *fsp = NULL;
-       uint32 security_info_sent = 0;
+       uint32_t security_info_sent = 0;
        NTSTATUS status;
 
        if(parameter_count < 8) {
@@ -2124,8 +2188,8 @@ static void call_nt_transact_set_security_desc(connection_struct *conn,
                return;
        }
 
-       status = set_sd_blob(fsp, (uint8 *)data, data_count, security_info_sent);
-
+       status = set_sd_blob(fsp, (uint8_t *)data, data_count,
+                            security_info_sent & SMB_SUPPORTED_SECINFO_FLAGS);
        if (!NT_STATUS_IS_OK(status)) {
                reply_nterror(req, status);
                return;
@@ -2142,19 +2206,19 @@ static void call_nt_transact_set_security_desc(connection_struct *conn,
 
 static void call_nt_transact_ioctl(connection_struct *conn,
                                   struct smb_request *req,
-                                  uint16 **ppsetup, uint32 setup_count,
-                                  char **ppparams, uint32 parameter_count,
-                                  char **ppdata, uint32 data_count,
-                                  uint32 max_data_count)
+                                  uint16_t **ppsetup, uint32_t setup_count,
+                                  char **ppparams, uint32_t parameter_count,
+                                  char **ppdata, uint32_t data_count,
+                                  uint32_t max_data_count)
 {
        NTSTATUS status;
-       uint32 function;
-       uint16 fidnum;
+       uint32_t function;
+       uint16_t fidnum;
        files_struct *fsp;
-       uint8 isFSctl;
-       uint8 compfilter;
+       uint8_t isFSctl;
+       uint8_t compfilter;
        char *out_data = NULL;
-       uint32 out_data_len = 0;
+       uint32_t out_data_len = 0;
        char *pdata = *ppdata;
        TALLOC_CTX *ctx = talloc_tos();
 
@@ -2219,13 +2283,13 @@ static void call_nt_transact_ioctl(connection_struct *conn,
 
 static void call_nt_transact_get_user_quota(connection_struct *conn,
                                            struct smb_request *req,
-                                           uint16 **ppsetup,
-                                           uint32 setup_count,
+                                           uint16_t **ppsetup,
+                                           uint32_t setup_count,
                                            char **ppparams,
-                                           uint32 parameter_count,
+                                           uint32_t parameter_count,
                                            char **ppdata,
-                                           uint32 data_count,
-                                           uint32 max_data_count)
+                                           uint32_t data_count,
+                                           uint32_t max_data_count)
 {
        NTSTATUS nt_status = NT_STATUS_OK;
        char *params = *ppparams;
@@ -2235,7 +2299,7 @@ static void call_nt_transact_get_user_quota(connection_struct *conn,
        int qt_len=0;
        int entry_len = 0;
        files_struct *fsp = NULL;
-       uint16 level = 0;
+       uint16_t level = 0;
        size_t sid_len;
        struct dom_sid sid;
        bool start_enum = True;
@@ -2246,7 +2310,7 @@ static void call_nt_transact_get_user_quota(connection_struct *conn,
        ZERO_STRUCT(qt);
 
        /* access check */
-       if (get_current_uid(conn) != 0) {
+       if (get_current_uid(conn) != sec_initial_uid()) {
                DEBUG(1,("get_user_quota: access_denied service [%s] user "
                         "[%s]\n", lp_servicename(talloc_tos(), SNUM(conn)),
                         conn->session_info->unix_info->unix_name));
@@ -2375,7 +2439,8 @@ static void call_nt_transact_get_user_quota(connection_struct *conn,
                                SBIG_UINT(entry,32,tmp_list->quotas->hardlim);
 
                                /* and now the SID */
-                               sid_linearize(entry+40, sid_len, &tmp_list->quotas->sid);
+                               sid_linearize((uint8_t *)(entry+40), sid_len,
+                                             &tmp_list->quotas->sid);
                        }
 
                        qt_handle->tmp_list = tmp_list;
@@ -2424,7 +2489,8 @@ static void call_nt_transact_get_user_quota(connection_struct *conn,
                                break;
                        }
 
-                       if (!sid_parse(pdata+8,sid_len,&sid)) {
+                       if (!sid_parse((const uint8_t *)(pdata+8), sid_len,
+                                      &sid)) {
                                reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
                                return;
                        }
@@ -2476,7 +2542,7 @@ static void call_nt_transact_get_user_quota(connection_struct *conn,
                        SBIG_UINT(entry,32,qt.hardlim);
 
                        /* and now the SID */
-                       sid_linearize(entry+40, sid_len, &sid);
+                       sid_linearize((uint8_t *)(entry+40), sid_len, &sid);
 
                        break;
 
@@ -2499,13 +2565,13 @@ static void call_nt_transact_get_user_quota(connection_struct *conn,
 
 static void call_nt_transact_set_user_quota(connection_struct *conn,
                                            struct smb_request *req,
-                                           uint16 **ppsetup,
-                                           uint32 setup_count,
+                                           uint16_t **ppsetup,
+                                           uint32_t setup_count,
                                            char **ppparams,
-                                           uint32 parameter_count,
+                                           uint32_t parameter_count,
                                            char **ppdata,
-                                           uint32 data_count,
-                                           uint32 max_data_count)
+                                           uint32_t data_count,
+                                           uint32_t max_data_count)
 {
        char *params = *ppparams;
        char *pdata = *ppdata;
@@ -2577,7 +2643,7 @@ static void call_nt_transact_set_user_quota(connection_struct *conn,
        /* the hard quotas 8 bytes (uint64_t)*/
        qt.hardlim = BVAL(pdata,32);
 
-       if (!sid_parse(pdata+40,sid_len,&sid)) {
+       if (!sid_parse((const uint8_t *)(pdata+40), sid_len, &sid)) {
                reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
                return;
        }
@@ -2738,7 +2804,7 @@ void reply_nttrans(struct smb_request *req)
        uint32_t psoff;
        uint32_t dscnt;
        uint32_t dsoff;
-       uint16 function_code;
+       uint16_t function_code;
        NTSTATUS result;
        struct trans_state *state;
 
@@ -2887,7 +2953,7 @@ void reply_nttrans(struct smb_request *req)
                        goto bad_param;
                }
 
-               state->setup = (uint16 *)TALLOC(state, state->setup_count);
+               state->setup = (uint16_t *)TALLOC(state, state->setup_count);
                if (state->setup == NULL) {
                        DEBUG(0,("reply_nttrans : Out of memory\n"));
                        SAFE_FREE(state->data);
@@ -2899,7 +2965,7 @@ void reply_nttrans(struct smb_request *req)
                }
 
                memcpy(state->setup, req->vwv+19, state->setup_count);
-               dump_data(10, (uint8 *)state->setup, state->setup_count);
+               dump_data(10, (uint8_t *)state->setup, state->setup_count);
        }
 
        if ((state->received_data == state->total_data) &&