Print this page
NEX-14666 Need to provide SMB 2.1 Client
NEX-17187 panic in smbfs_acl_store
NEX-17231 smbfs create xattr files finds wrong file
NEX-17224 smbfs lookup EINVAL should be ENOENT
NEX-17260 SMB1 client fails to list directory after NEX-14666
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Rick McNeal <rick.mcneal@nexenta.com>
Reviewed by: Saso Kiselkov <saso.kiselkov@nexenta.com>
Reviewed by: Joyce McIntosh <joyce.mcintosh@nexenta.com>
and: (cleanup)
4295 libshare sa_get_proto_status sometimes returns unallocated strings
Reviewed by: Marcel Telka <marcel@telka.sk>
Approved by: Garrett D'Amore <garrett@damore.org>


   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 /*
  23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.


  25  */
  26 
  27 /*
  28  * SMB specific functions
  29  */
  30 #include <stdio.h>
  31 #include <string.h>
  32 #include <ctype.h>
  33 #include <stdlib.h>
  34 #include <unistd.h>
  35 #include <zone.h>
  36 #include <errno.h>
  37 #include <locale.h>
  38 #include <signal.h>
  39 #include <fcntl.h>
  40 #include <sys/types.h>
  41 #include <sys/stat.h>
  42 #include <syslog.h>
  43 #include "libshare.h"
  44 #include "libshare_impl.h"


  53 #include <netsmb/smb_lib.h>
  54 
  55 #define SMBFS_PROTOCOL_NAME     "smbfs"
  56 
  57 /* internal functions */
  58 static uint64_t smbfs_features();
  59 static int smbfs_init();
  60 static void smbfs_fini();
  61 static int smbfs_set_proto_prop(sa_property_t);
  62 static sa_protocol_properties_t smbfs_get_proto_set();
  63 static char *smbfs_get_status();
  64 static int smbfs_delete_section(char *);
  65 static int smbfs_delete_property_group(char *);
  66 
  67 static int range_check_validator(int, char *, char *);
  68 static int string_length_check_validator(int, char *, char *);
  69 static int yes_no_validator(int, char *, char *);
  70 static int ip_address_validator(int, char *, char *);
  71 static int minauth_validator(int, char *, char *);
  72 static int password_validator(int, char *, char *);

  73 static int signing_validator(int, char *, char *);
  74 
  75 int propset_changed = 0;
  76 
  77 /*
  78  * ops vector that provides the protocol specific info and operations
  79  * for share management.
  80  */
  81 
  82 struct sa_plugin_ops sa_plugin_ops = {
  83         SA_PLUGIN_VERSION,
  84         SMBFS_PROTOCOL_NAME,
  85         smbfs_init,
  86         smbfs_fini,
  87         NULL,   /* share */
  88         NULL,   /* unshare */
  89         NULL,   /* valid_prop */
  90         NULL,   /* valid_space */
  91         NULL,   /* security_prop */
  92         NULL,   /* legacy_opts */


 165             0, 0, MAX_VALUE_BUFLEN,
 166             ip_address_validator},
 167         { "password", NULL, PROTO_OPT_PASSWORD,
 168             0, 0, MAX_VALUE_BUFLEN,
 169             password_validator},
 170         { "timeout", NULL, PROTO_OPT_TIMEOUT,
 171             0, 0, 60,
 172             range_check_validator},
 173         { "user", NULL, PROTO_OPT_USER,
 174             0, 0, MAX_VALUE_BUFLEN,
 175             string_length_check_validator},
 176         { "domain", NULL, PROTO_OPT_DOMAIN,
 177             0, 0, MAX_VALUE_BUFLEN,
 178             string_length_check_validator},
 179         { "workgroup", NULL, PROTO_OPT_WORKGROUP,
 180             0, 0, MAX_VALUE_BUFLEN,
 181             string_length_check_validator},
 182         { "signing", NULL, PROTO_OPT_SIGNING,
 183             0, 0, MAX_VALUE_BUFLEN,
 184             signing_validator},






 185         {NULL}
 186 };
 187 
 188 /*
 189  * Check the range of value as int range.
 190  */
 191 /*ARGSUSED*/
 192 static int
 193 range_check_validator(int index, char *section, char *value)
 194 {
 195         int ret = SA_OK;
 196 
 197         if (value == NULL)
 198                 return (SA_BAD_VALUE);
 199         if (strlen(value) == 0)
 200                 return (SA_OK);
 201         if (!is_a_number(value)) {
 202                 ret = SA_BAD_VALUE;
 203         } else {
 204                 int val;


 253 /*ARGSUSED*/
 254 static int
 255 ip_address_validator(int index, char *section, char *value)
 256 {
 257         int len;
 258 
 259         if (value == NULL)
 260                 return (SA_BAD_VALUE);
 261         len = strlen(value);
 262         if (len == 0)
 263                 return (SA_OK);
 264         if (len > MAX_VALUE_BUFLEN)
 265                 return (SA_BAD_VALUE);
 266         return (SA_OK);
 267 }
 268 
 269 /*ARGSUSED*/
 270 static int
 271 minauth_validator(int index, char *section, char *value)
 272 {


 273         if (value == NULL)
 274                 return (SA_BAD_VALUE);
 275         if (strlen(value) == 0)



 276                 return (SA_OK);
 277         if (strcmp(value, "kerberos") == 0 ||
 278             strcmp(value, "ntlmv2") == 0 ||
 279             strcmp(value, "ntlm") == 0 ||
 280             strcmp(value, "lm") == 0 ||
 281             strcmp(value, "none") == 0)
 282                 return (SA_OK);
 283         else


 284                 return (SA_BAD_VALUE);





 285 }
 286 
 287 /*ARGSUSED*/
 288 static int
 289 signing_validator(int index, char *section, char *value)
 290 {
 291         if (value == NULL)
 292                 return (SA_BAD_VALUE);
 293         if (strlen(value) == 0)
 294                 return (SA_OK);
 295         if (strcmp(value, "disabled") == 0 ||
 296             strcmp(value, "enabled") == 0 ||
 297             strcmp(value, "required") == 0)
 298                 return (SA_OK);
 299         else
 300                 return (SA_BAD_VALUE);
 301 }
 302 
 303 /*ARGSUSED*/
 304 static int




   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 /*
  23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  *
  26  * Copyright 2018 Nexenta Systems, Inc.  All rights reserved.
  27  */
  28 
  29 /*
  30  * SMB specific functions
  31  */
  32 #include <stdio.h>
  33 #include <string.h>
  34 #include <ctype.h>
  35 #include <stdlib.h>
  36 #include <unistd.h>
  37 #include <zone.h>
  38 #include <errno.h>
  39 #include <locale.h>
  40 #include <signal.h>
  41 #include <fcntl.h>
  42 #include <sys/types.h>
  43 #include <sys/stat.h>
  44 #include <syslog.h>
  45 #include "libshare.h"
  46 #include "libshare_impl.h"


  55 #include <netsmb/smb_lib.h>
  56 
  57 #define SMBFS_PROTOCOL_NAME     "smbfs"
  58 
  59 /* internal functions */
  60 static uint64_t smbfs_features();
  61 static int smbfs_init();
  62 static void smbfs_fini();
  63 static int smbfs_set_proto_prop(sa_property_t);
  64 static sa_protocol_properties_t smbfs_get_proto_set();
  65 static char *smbfs_get_status();
  66 static int smbfs_delete_section(char *);
  67 static int smbfs_delete_property_group(char *);
  68 
  69 static int range_check_validator(int, char *, char *);
  70 static int string_length_check_validator(int, char *, char *);
  71 static int yes_no_validator(int, char *, char *);
  72 static int ip_address_validator(int, char *, char *);
  73 static int minauth_validator(int, char *, char *);
  74 static int password_validator(int, char *, char *);
  75 static int protocol_validator(int, char *, char *);
  76 static int signing_validator(int, char *, char *);
  77 
  78 int propset_changed = 0;
  79 
  80 /*
  81  * ops vector that provides the protocol specific info and operations
  82  * for share management.
  83  */
  84 
  85 struct sa_plugin_ops sa_plugin_ops = {
  86         SA_PLUGIN_VERSION,
  87         SMBFS_PROTOCOL_NAME,
  88         smbfs_init,
  89         smbfs_fini,
  90         NULL,   /* share */
  91         NULL,   /* unshare */
  92         NULL,   /* valid_prop */
  93         NULL,   /* valid_space */
  94         NULL,   /* security_prop */
  95         NULL,   /* legacy_opts */


 168             0, 0, MAX_VALUE_BUFLEN,
 169             ip_address_validator},
 170         { "password", NULL, PROTO_OPT_PASSWORD,
 171             0, 0, MAX_VALUE_BUFLEN,
 172             password_validator},
 173         { "timeout", NULL, PROTO_OPT_TIMEOUT,
 174             0, 0, 60,
 175             range_check_validator},
 176         { "user", NULL, PROTO_OPT_USER,
 177             0, 0, MAX_VALUE_BUFLEN,
 178             string_length_check_validator},
 179         { "domain", NULL, PROTO_OPT_DOMAIN,
 180             0, 0, MAX_VALUE_BUFLEN,
 181             string_length_check_validator},
 182         { "workgroup", NULL, PROTO_OPT_WORKGROUP,
 183             0, 0, MAX_VALUE_BUFLEN,
 184             string_length_check_validator},
 185         { "signing", NULL, PROTO_OPT_SIGNING,
 186             0, 0, MAX_VALUE_BUFLEN,
 187             signing_validator},
 188         { "min_protocol", NULL, PROTO_OPT_MIN_PROTOCOL,
 189             0, 0, MAX_VALUE_BUFLEN,
 190             protocol_validator},
 191         { "max_protocol", NULL, PROTO_OPT_MAX_PROTOCOL,
 192             0, 0, MAX_VALUE_BUFLEN,
 193             protocol_validator},
 194         {NULL}
 195 };
 196 
 197 /*
 198  * Check the range of value as int range.
 199  */
 200 /*ARGSUSED*/
 201 static int
 202 range_check_validator(int index, char *section, char *value)
 203 {
 204         int ret = SA_OK;
 205 
 206         if (value == NULL)
 207                 return (SA_BAD_VALUE);
 208         if (strlen(value) == 0)
 209                 return (SA_OK);
 210         if (!is_a_number(value)) {
 211                 ret = SA_BAD_VALUE;
 212         } else {
 213                 int val;


 262 /*ARGSUSED*/
 263 static int
 264 ip_address_validator(int index, char *section, char *value)
 265 {
 266         int len;
 267 
 268         if (value == NULL)
 269                 return (SA_BAD_VALUE);
 270         len = strlen(value);
 271         if (len == 0)
 272                 return (SA_OK);
 273         if (len > MAX_VALUE_BUFLEN)
 274                 return (SA_BAD_VALUE);
 275         return (SA_OK);
 276 }
 277 
 278 /*ARGSUSED*/
 279 static int
 280 minauth_validator(int index, char *section, char *value)
 281 {
 282         int ival;
 283 
 284         if (value == NULL)
 285                 return (SA_BAD_VALUE);
 286         ival = smb_cf_minauth_from_str(value);
 287         if (ival == -1)
 288                 return (SA_BAD_VALUE);
 289 
 290         return (SA_OK);
 291 }
 292 
 293 /*ARGSUSED*/
 294 static int
 295 protocol_validator(int index, char *section, char *value)
 296 {
 297         int ival;
 298 
 299         if (value == NULL)
 300                 return (SA_BAD_VALUE);
 301         ival = smb_cf_version_from_str(value);
 302         if (ival == -1)
 303                 return (SA_BAD_VALUE);
 304 
 305         return (SA_OK);
 306 }
 307 
 308 /*ARGSUSED*/
 309 static int
 310 signing_validator(int index, char *section, char *value)
 311 {
 312         if (value == NULL)
 313                 return (SA_BAD_VALUE);
 314         if (strlen(value) == 0)
 315                 return (SA_OK);
 316         if (strcmp(value, "disabled") == 0 ||
 317             strcmp(value, "enabled") == 0 ||
 318             strcmp(value, "required") == 0)
 319                 return (SA_OK);
 320         else
 321                 return (SA_BAD_VALUE);
 322 }
 323 
 324 /*ARGSUSED*/
 325 static int