Print this page
NEX-15069 smtorture smb2.create.blob is failed
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
NEX-15069 smtorture smb2.create.blob is failed
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
NEX-1643 dtrace provider for smbsrv
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Matt Barden <matt.barden@nexenta.com>
NEX-4540 SMB server declines EA support incorrectly
Reviewed by: Bayard Bell <bayard.bell@nexenta.com>
Reviewed by: Matt Barden <Matt.Barden@nexenta.com>
NEX-2442 regression with smbtorture test raw.sfileinfo.rename
NEX-946 smb_set_by_fid should return zero on success
SMB-11 SMB2 message parse & dispatch
SMB-12 SMB2 Negotiate Protocol
SMB-13 SMB2 Session Setup
SMB-14 SMB2 Logoff
SMB-15 SMB2 Tree Connect
SMB-16 SMB2 Tree Disconnect
SMB-17 SMB2 Create
SMB-18 SMB2 Close
SMB-19 SMB2 Flush
SMB-20 SMB2 Read
SMB-21 SMB2 Write
SMB-22 SMB2 Lock/Unlock
SMB-23 SMB2 Ioctl
SMB-24 SMB2 Cancel
SMB-25 SMB2 Echo
SMB-26 SMB2 Query Dir
SMB-27 SMB2 Change Notify
SMB-28 SMB2 Query Info
SMB-29 SMB2 Set Info
SMB-30 SMB2 Oplocks
SMB-53 SMB2 Create Context options
(SMB2 code review cleanup 1, 2, 3)


   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
  24  */
  25 
  26 /*
  27  * Trans2 Set File/Path Information Levels:
  28  *
  29  * SMB_INFO_STANDARD
  30  * SMB_INFO_SET_EAS
  31  * SMB_SET_FILE_BASIC_INFO
  32  * SMB_SET_FILE_DISPOSITION_INFO
  33  * SMB_SET_FILE_END_OF_FILE_INFO
  34  * SMB_SET_FILE_ALLOCATION_INFO
  35  *
  36  * Handled Passthrough levels:
  37  * SMB_FILE_BASIC_INFORMATION
  38  * SMB_FILE_RENAME_INFORMATION
  39  * SMB_FILE_LINK_INFORMATION
  40  * SMB_FILE_DISPOSITION_INFORMATION
  41  * SMB_FILE_END_OF_FILE_INFORMATION
  42  * SMB_FILE_ALLOCATION_INFORMATION
  43  *


 110                     ERRDOS, ERROR_INVALID_FUNCTION);
 111                 return (SDRC_ERROR);
 112         }
 113 
 114         if (smb_mbc_decodef(&xa->req_param_mb, "%w4.u",
 115             sr, &infolev, &fqi->fq_path.pn_path) != 0)
 116                 return (SDRC_ERROR);
 117 
 118         if (smb_set_by_path(sr, xa, infolev) != 0)
 119                 return (SDRC_ERROR);
 120 
 121         return (SDRC_SUCCESS);
 122 }
 123 
 124 /*
 125  * smb_com_set_information (aka setattr)
 126  */
 127 smb_sdrc_t
 128 smb_pre_set_information(smb_request_t *sr)
 129 {
 130         DTRACE_SMB_1(op__SetInformation__start, smb_request_t *, sr);
 131         return (SDRC_SUCCESS);
 132 }
 133 
 134 void
 135 smb_post_set_information(smb_request_t *sr)
 136 {
 137         DTRACE_SMB_1(op__SetInformation__done, smb_request_t *, sr);
 138 }
 139 
 140 smb_sdrc_t
 141 smb_com_set_information(smb_request_t *sr)
 142 {
 143         uint16_t        infolev = SMB_SET_INFORMATION;
 144         smb_fqi_t       *fqi = &sr->arg.dirop.fqi;
 145 
 146         if (STYPE_ISIPC(sr->tid_tree->t_res_type)) {
 147                 smbsr_error(sr, NT_STATUS_ACCESS_DENIED,
 148                     ERRDOS, ERROR_ACCESS_DENIED);
 149                 return (SDRC_ERROR);
 150         }
 151 
 152         if (smbsr_decode_data(sr, "%S", sr, &fqi->fq_path.pn_path) != 0)
 153                 return (SDRC_ERROR);
 154 
 155         if (smb_set_by_path(sr, NULL, infolev) != 0)
 156                 return (SDRC_ERROR);
 157 
 158         if (smbsr_encode_empty_result(sr) != 0)
 159                 return (SDRC_ERROR);
 160 
 161         return (SDRC_SUCCESS);
 162 }
 163 
 164 /*
 165  * smb_com_set_information2 (aka setattre)
 166  */
 167 smb_sdrc_t
 168 smb_pre_set_information2(smb_request_t *sr)
 169 {
 170         DTRACE_SMB_1(op__SetInformation2__start, smb_request_t *, sr);
 171         return (SDRC_SUCCESS);
 172 }
 173 
 174 void
 175 smb_post_set_information2(smb_request_t *sr)
 176 {
 177         DTRACE_SMB_1(op__SetInformation2__done, smb_request_t *, sr);
 178 }
 179 
 180 smb_sdrc_t
 181 smb_com_set_information2(smb_request_t *sr)
 182 {
 183         uint16_t infolev = SMB_SET_INFORMATION2;
 184 
 185         if (smbsr_decode_vwv(sr, "w", &sr->smb_fid) != 0)
 186                 return (SDRC_ERROR);
 187 
 188         if (smb_set_by_fid(sr, NULL, infolev) != 0)
 189                 return (SDRC_ERROR);
 190 
 191         if (smbsr_encode_empty_result(sr) != 0)
 192                 return (SDRC_ERROR);
 193 
 194         return (SDRC_SUCCESS);
 195 }
 196 
 197 /*


 276                     ERRDOS, ERROR_ACCESS_DENIED);
 277                 return (-1);
 278         }
 279 
 280         pn = &sr->arg.dirop.fqi.fq_path;
 281         smb_pathname_init(sr, pn, pn->pn_path);
 282         if (!smb_pathname_validate(sr, pn))
 283                 return (-1);
 284 
 285         name = kmem_alloc(MAXNAMELEN, KM_SLEEP);
 286         rc = smb_pathname_reduce(sr, sr->user_cr, pn->pn_path,
 287             sr->tid_tree->t_snode, sr->tid_tree->t_snode, &dnode, name);
 288         if (rc == 0) {
 289                 rc = smb_fsop_lookup_name(sr, sr->user_cr, SMB_FOLLOW_LINKS,
 290                     sr->tid_tree->t_snode, dnode, name, &node);
 291                 smb_node_release(dnode);
 292         }
 293         kmem_free(name, MAXNAMELEN);
 294 
 295         if (rc != 0) {
 296                 if (rc == ENOENT) {
 297                         smbsr_error(sr, NT_STATUS_OBJECT_NAME_NOT_FOUND,
 298                             ERRDOS, ERROR_FILE_NOT_FOUND);
 299                 } else {
 300                         smbsr_errno(sr, rc);
 301                 }
 302                 return (-1);
 303         }
 304 
 305         bzero(&sinfo, sizeof (sinfo));
 306         sinfo.si_node = node;
 307         if (xa != NULL)
 308                 sinfo.si_data = xa->req_data_mb;
 309         status = smb_set_fileinfo(sr, &sinfo, infolev);
 310         if (status != 0) {
 311                 smbsr_error(sr, status, 0, 0);
 312                 rc = -1;
 313         }
 314 
 315         smb_node_release(node);
 316         return (rc);
 317 }
 318 
 319 /*
 320  * smb_set_fileinfo
 321  *


 324  */
 325 static uint32_t
 326 smb_set_fileinfo(smb_request_t *sr, smb_setinfo_t *sinfo, int infolev)
 327 {
 328         uint32_t status;
 329 
 330         switch (infolev) {
 331         case SMB_SET_INFORMATION:
 332                 status = smb_set_information(sr, sinfo);
 333                 break;
 334 
 335         case SMB_SET_INFORMATION2:
 336                 status = smb_set_information2(sr, sinfo);
 337                 break;
 338 
 339         case SMB_INFO_STANDARD:
 340                 status = smb_set_standard_info(sr, sinfo);
 341                 break;
 342 
 343         case SMB_INFO_SET_EAS:
 344                 /* EAs not supported */
 345                 status = 0;
 346                 break;
 347 
 348         case SMB_SET_FILE_BASIC_INFO:
 349         case SMB_FILE_BASIC_INFORMATION:
 350                 status = smb_set_basic_info(sr, sinfo);
 351                 break;
 352 
 353         case SMB_SET_FILE_DISPOSITION_INFO:
 354         case SMB_FILE_DISPOSITION_INFORMATION:
 355                 status = smb_set_disposition_info(sr, sinfo);
 356                 break;
 357 
 358         case SMB_SET_FILE_END_OF_FILE_INFO:
 359         case SMB_FILE_END_OF_FILE_INFORMATION:
 360                 status = smb_set_eof_info(sr, sinfo);
 361                 break;
 362 
 363         case SMB_SET_FILE_ALLOCATION_INFO:
 364         case SMB_FILE_ALLOCATION_INFORMATION:
 365                 status = smb_set_alloc_info(sr, sinfo);




   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright 2017 Nexenta Systems, Inc.  All rights reserved.
  24  */
  25 
  26 /*
  27  * Trans2 Set File/Path Information Levels:
  28  *
  29  * SMB_INFO_STANDARD
  30  * SMB_INFO_SET_EAS
  31  * SMB_SET_FILE_BASIC_INFO
  32  * SMB_SET_FILE_DISPOSITION_INFO
  33  * SMB_SET_FILE_END_OF_FILE_INFO
  34  * SMB_SET_FILE_ALLOCATION_INFO
  35  *
  36  * Handled Passthrough levels:
  37  * SMB_FILE_BASIC_INFORMATION
  38  * SMB_FILE_RENAME_INFORMATION
  39  * SMB_FILE_LINK_INFORMATION
  40  * SMB_FILE_DISPOSITION_INFORMATION
  41  * SMB_FILE_END_OF_FILE_INFORMATION
  42  * SMB_FILE_ALLOCATION_INFORMATION
  43  *


 110                     ERRDOS, ERROR_INVALID_FUNCTION);
 111                 return (SDRC_ERROR);
 112         }
 113 
 114         if (smb_mbc_decodef(&xa->req_param_mb, "%w4.u",
 115             sr, &infolev, &fqi->fq_path.pn_path) != 0)
 116                 return (SDRC_ERROR);
 117 
 118         if (smb_set_by_path(sr, xa, infolev) != 0)
 119                 return (SDRC_ERROR);
 120 
 121         return (SDRC_SUCCESS);
 122 }
 123 
 124 /*
 125  * smb_com_set_information (aka setattr)
 126  */
 127 smb_sdrc_t
 128 smb_pre_set_information(smb_request_t *sr)
 129 {
 130         DTRACE_SMB_START(op__SetInformation, smb_request_t *, sr);
 131         return (SDRC_SUCCESS);
 132 }
 133 
 134 void
 135 smb_post_set_information(smb_request_t *sr)
 136 {
 137         DTRACE_SMB_DONE(op__SetInformation, smb_request_t *, sr);
 138 }
 139 
 140 smb_sdrc_t
 141 smb_com_set_information(smb_request_t *sr)
 142 {
 143         uint16_t        infolev = SMB_SET_INFORMATION;
 144         smb_fqi_t       *fqi = &sr->arg.dirop.fqi;
 145 
 146         if (STYPE_ISIPC(sr->tid_tree->t_res_type)) {
 147                 smbsr_error(sr, NT_STATUS_ACCESS_DENIED,
 148                     ERRDOS, ERROR_ACCESS_DENIED);
 149                 return (SDRC_ERROR);
 150         }
 151 
 152         if (smbsr_decode_data(sr, "%S", sr, &fqi->fq_path.pn_path) != 0)
 153                 return (SDRC_ERROR);
 154 
 155         if (smb_set_by_path(sr, NULL, infolev) != 0)
 156                 return (SDRC_ERROR);
 157 
 158         if (smbsr_encode_empty_result(sr) != 0)
 159                 return (SDRC_ERROR);
 160 
 161         return (SDRC_SUCCESS);
 162 }
 163 
 164 /*
 165  * smb_com_set_information2 (aka setattre)
 166  */
 167 smb_sdrc_t
 168 smb_pre_set_information2(smb_request_t *sr)
 169 {
 170         DTRACE_SMB_START(op__SetInformation2, smb_request_t *, sr);
 171         return (SDRC_SUCCESS);
 172 }
 173 
 174 void
 175 smb_post_set_information2(smb_request_t *sr)
 176 {
 177         DTRACE_SMB_DONE(op__SetInformation2, smb_request_t *, sr);
 178 }
 179 
 180 smb_sdrc_t
 181 smb_com_set_information2(smb_request_t *sr)
 182 {
 183         uint16_t infolev = SMB_SET_INFORMATION2;
 184 
 185         if (smbsr_decode_vwv(sr, "w", &sr->smb_fid) != 0)
 186                 return (SDRC_ERROR);
 187 
 188         if (smb_set_by_fid(sr, NULL, infolev) != 0)
 189                 return (SDRC_ERROR);
 190 
 191         if (smbsr_encode_empty_result(sr) != 0)
 192                 return (SDRC_ERROR);
 193 
 194         return (SDRC_SUCCESS);
 195 }
 196 
 197 /*


 276                     ERRDOS, ERROR_ACCESS_DENIED);
 277                 return (-1);
 278         }
 279 
 280         pn = &sr->arg.dirop.fqi.fq_path;
 281         smb_pathname_init(sr, pn, pn->pn_path);
 282         if (!smb_pathname_validate(sr, pn))
 283                 return (-1);
 284 
 285         name = kmem_alloc(MAXNAMELEN, KM_SLEEP);
 286         rc = smb_pathname_reduce(sr, sr->user_cr, pn->pn_path,
 287             sr->tid_tree->t_snode, sr->tid_tree->t_snode, &dnode, name);
 288         if (rc == 0) {
 289                 rc = smb_fsop_lookup_name(sr, sr->user_cr, SMB_FOLLOW_LINKS,
 290                     sr->tid_tree->t_snode, dnode, name, &node);
 291                 smb_node_release(dnode);
 292         }
 293         kmem_free(name, MAXNAMELEN);
 294 
 295         if (rc != 0) {




 296                 smbsr_errno(sr, rc);

 297                 return (-1);
 298         }
 299 
 300         bzero(&sinfo, sizeof (sinfo));
 301         sinfo.si_node = node;
 302         if (xa != NULL)
 303                 sinfo.si_data = xa->req_data_mb;
 304         status = smb_set_fileinfo(sr, &sinfo, infolev);
 305         if (status != 0) {
 306                 smbsr_error(sr, status, 0, 0);
 307                 rc = -1;
 308         }
 309 
 310         smb_node_release(node);
 311         return (rc);
 312 }
 313 
 314 /*
 315  * smb_set_fileinfo
 316  *


 319  */
 320 static uint32_t
 321 smb_set_fileinfo(smb_request_t *sr, smb_setinfo_t *sinfo, int infolev)
 322 {
 323         uint32_t status;
 324 
 325         switch (infolev) {
 326         case SMB_SET_INFORMATION:
 327                 status = smb_set_information(sr, sinfo);
 328                 break;
 329 
 330         case SMB_SET_INFORMATION2:
 331                 status = smb_set_information2(sr, sinfo);
 332                 break;
 333 
 334         case SMB_INFO_STANDARD:
 335                 status = smb_set_standard_info(sr, sinfo);
 336                 break;
 337 
 338         case SMB_INFO_SET_EAS:
 339                 status = NT_STATUS_EAS_NOT_SUPPORTED;

 340                 break;
 341 
 342         case SMB_SET_FILE_BASIC_INFO:
 343         case SMB_FILE_BASIC_INFORMATION:
 344                 status = smb_set_basic_info(sr, sinfo);
 345                 break;
 346 
 347         case SMB_SET_FILE_DISPOSITION_INFO:
 348         case SMB_FILE_DISPOSITION_INFORMATION:
 349                 status = smb_set_disposition_info(sr, sinfo);
 350                 break;
 351 
 352         case SMB_SET_FILE_END_OF_FILE_INFO:
 353         case SMB_FILE_END_OF_FILE_INFORMATION:
 354                 status = smb_set_eof_info(sr, sinfo);
 355                 break;
 356 
 357         case SMB_SET_FILE_ALLOCATION_INFO:
 358         case SMB_FILE_ALLOCATION_INFORMATION:
 359                 status = smb_set_alloc_info(sr, sinfo);