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)
NEX-16824 SMB client connection setup rework
NEX-17232 SMB client reconnect failures
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Matt Barden <matt.barden@nexenta.com>
and: (improve debug)
NEX-16818 Add fksmbcl development tool
NEX-17264 SMB client test tp_smbutil_013 fails after NEX-14666
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Matt Barden <matt.barden@nexenta.com>
and: (fix ref leaks)
SUP-513 Unable to join AD domain (with NtlmMinSeverSec set in the registry)
 Implement "Extended Session Security" and "Key Exchange" in NTLMSSP


  17  *    may be used to endorse or promote products derived from this software
  18  *    without specific prior written permission.
  19  *
  20  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30  * SUCH DAMAGE.
  31  *
  32  * $Id: smb_lib.h,v 1.21.82.2 2005/06/02 00:55:39 lindak Exp $
  33  */
  34 
  35 /*
  36  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  37  * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
  38  */
  39 
  40 #ifndef _NETSMB_SMB_LIB_H_
  41 #define _NETSMB_SMB_LIB_H_
  42 
  43 /*
  44  * Internal interface exported to our commands in:
  45  *      usr/src/cmd/fs.d/smbclnt/
  46  */
  47 
  48 #include <sys/types.h>
  49 #include <sys/socket.h>
  50 #include <netinet/in.h>
  51 #include <arpa/inet.h>
  52 #include <sys/byteorder.h>
  53 
  54 #include <netsmb/smbfs_api.h>
  55 #include <netsmb/smb_dev.h>
  56 
  57 extern const char smbutil_std_opts[];


  86 };
  87 typedef struct smb_iod_ssn smb_iod_ssn_t;
  88 
  89 
  90 /*
  91  * SMB work context. Used to store all values which are necessary
  92  * to establish connection to an SMB server.
  93  */
  94 struct smb_ctx {
  95         int             ct_flags;       /* SMBCF_ */
  96         int             ct_dev_fd;      /* device handle */
  97         int             ct_door_fd;     /* to smbiod */
  98         int             ct_parsedlevel;
  99         int             ct_minlevel;
 100         int             ct_maxlevel;
 101         char            *ct_fullserver; /* orig. server name from cmd line */
 102         char            *ct_srvaddr_s;  /* hostname or IP address of server */
 103         struct addrinfo *ct_addrinfo;   /* IP addresses of the server */
 104         struct nb_ctx   *ct_nb;         /* NetBIOS info. */
 105         char            *ct_locname;    /* local (machine) name */
 106         smb_iod_ssn_t   ct_iod_ssn;
 107         /* smbioc_oshare_t      ct_sh; XXX */
 108         int             ct_minauth;
 109         int             ct_shtype_req;  /* share type wanted */
 110         char            *ct_origshare;
 111         char            *ct_home;
 112         char            *ct_rpath;      /* remote file name */
 113 
 114         /* Connection setup SMB stuff. */
 115         /* Strings from the SMB negotiate response. */
 116         char            *ct_srv_OS;
 117         char            *ct_srv_LM;
 118         uint32_t        ct_clnt_caps;
 119 
 120         /* NTLM auth. stuff */
 121         uchar_t         ct_clnonce[NTLM_CHAL_SZ];
 122         uchar_t         ct_srv_chal[NTLM_CHAL_SZ];
 123         char            ct_password[SMBIOC_MAX_NAME];
 124 
 125         /* See ssp.c */
 126         void            *ct_ssp_ctx;
 127         smbioc_ssn_work_t ct_work;
 128 };
 129 
 130 
 131 /*
 132  * Short-hand for some of the substruct fields above
 133  */
 134 #define ct_ssn          ct_iod_ssn.iod_ossn
 135 #define ct_vopt         ct_iod_ssn.iod_ossn.ssn_vopt


 136 #define ct_owner        ct_iod_ssn.iod_ossn.ssn_owner
 137 #define ct_srvaddr      ct_iod_ssn.iod_ossn.ssn_srvaddr
 138 #define ct_domain       ct_iod_ssn.iod_ossn.ssn_domain
 139 #define ct_user         ct_iod_ssn.iod_ossn.ssn_user
 140 #define ct_srvname      ct_iod_ssn.iod_ossn.ssn_srvname
 141 #define ct_authflags    ct_iod_ssn.iod_authflags
 142 #define ct_nthash       ct_iod_ssn.iod_nthash
 143 #define ct_lmhash       ct_iod_ssn.iod_lmhash
 144 
 145 #define ct_sopt         ct_work.wk_sopt
 146 #define ct_iods         ct_work.wk_iods
 147 #define ct_tran_fd      ct_work.wk_iods.is_tran_fd
 148 #define ct_hflags       ct_work.wk_iods.is_hflags
 149 #define ct_hflags2      ct_work.wk_iods.is_hflags2
 150 #define ct_vcflags      ct_work.wk_iods.is_vcflags
 151 #define ct_ssn_key      ct_work.wk_iods.is_ssn_key
 152 #define ct_mac_seqno    ct_work.wk_iods.is_next_seq
 153 #define ct_mackeylen    ct_work.wk_iods.is_u_maclen
 154 #define ct_mackey       ct_work.wk_iods.is_u_mackey.lp_ptr
 155 
 156 
 157 /*
 158  * Bits in smb_ctx_t.ct_flags
 159  */
 160 #define SMBCF_NOPWD                 0x0001 /* don't ask for a password */
 161 #define SMBCF_SRIGHTS               0x0002 /* share access rights supplied */
 162 #define SMBCF_LOCALE                0x0004 /* use current locale */
 163 #define SMBCF_CMD_DOM               0x0010 /* CMD specified domain */
 164 #define SMBCF_CMD_USR               0x0020 /* CMD specified user */
 165 #define SMBCF_CMD_PW                0x0040 /* CMD specified password */
 166 #define SMBCF_RESOLVED              0x8000 /* structure has been verified */
 167 #define SMBCF_KCBAD             0x00080000 /* keychain password failed */
 168 #define SMBCF_KCFOUND           0x00100000 /* password is from keychain */
 169 #define SMBCF_BROWSEOK          0x00200000 /* browser dialogue may be used */
 170 #define SMBCF_AUTHREQ           0x00400000 /* auth. dialog requested */
 171 #define SMBCF_KCSAVE            0x00800000 /* add to keychain requested */
 172 #define SMBCF_XXX               0x01000000 /* mount-all, a very bad thing */
 173 #define SMBCF_SSNACTIVE         0x02000000 /* session setup succeeded */
 174 #define SMBCF_KCDOMAIN          0x04000000 /* use domain in KC lookup */
 175 
 176 
 177 /*
 178  * Context management
 179  */
 180 
 181 int  smb_ctx_init(struct smb_ctx *);
 182 void smb_ctx_done(struct smb_ctx *);
 183 int  smb_open_driver(void);


 184 
 185 int  smb_ctx_gethandle(struct smb_ctx *);
 186 int  smb_ctx_findvc(struct smb_ctx *);
 187 int  smb_ctx_newvc(struct smb_ctx *);
 188 
 189 /*
 190  * I/O daemon stuff
 191  */
 192 
 193 #define SMBIOD_RUNDIR   "/var/run/smbiod"
 194 #define SMBIOD_SVC_DOOR SMBIOD_RUNDIR "/.svc"
 195 #define SMBIOD_USR_DOOR SMBIOD_RUNDIR "/%d"
 196 #define SMBIOD_START    1
 197 
 198 int  smb_iod_cl_newvc(smb_ctx_t *ctx);
 199 char *smb_iod_door_path(void);
 200 int smb_iod_open_door(int *);
 201 int smb_iod_connect(struct smb_ctx *);
 202 int smb_iod_work(struct smb_ctx *);
 203 
 204 /*
 205  * Other stuff
 206  */
 207 
 208 int  smb_open_rcfile(char *);
 209 void smb_close_rcfile(void);
 210 



 211 void smb_simplecrypt(char *dst, const char *src);
 212 int  smb_simpledecrypt(char *dst, const char *src);
 213 
 214 int     nls_setrecode(const char *, const char *);
 215 int     nls_setlocale(const char *);
 216 char    *nls_str_toext(char *, const char *);
 217 char    *nls_str_toloc(char *, const char *);
 218 void    *nls_mem_toext(void *, const void *, int);
 219 void    *nls_mem_toloc(void *, const void *, int);
 220 char    *nls_str_upper(char *, const char *);
 221 char    *nls_str_lower(char *, const char *);
 222 
 223 char *smb_getprogname();
 224 #define __progname smb_getprogname()
 225 
 226 #endif /* _NETSMB_SMB_LIB_H_ */


  17  *    may be used to endorse or promote products derived from this software
  18  *    without specific prior written permission.
  19  *
  20  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30  * SUCH DAMAGE.
  31  *
  32  * $Id: smb_lib.h,v 1.21.82.2 2005/06/02 00:55:39 lindak Exp $
  33  */
  34 
  35 /*
  36  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  37  * Copyright 2018 Nexenta Systems, Inc.  All rights reserved.
  38  */
  39 
  40 #ifndef _NETSMB_SMB_LIB_H_
  41 #define _NETSMB_SMB_LIB_H_
  42 
  43 /*
  44  * Internal interface exported to our commands in:
  45  *      usr/src/cmd/fs.d/smbclnt/
  46  */
  47 
  48 #include <sys/types.h>
  49 #include <sys/socket.h>
  50 #include <netinet/in.h>
  51 #include <arpa/inet.h>
  52 #include <sys/byteorder.h>
  53 
  54 #include <netsmb/smbfs_api.h>
  55 #include <netsmb/smb_dev.h>
  56 
  57 extern const char smbutil_std_opts[];


  86 };
  87 typedef struct smb_iod_ssn smb_iod_ssn_t;
  88 
  89 
  90 /*
  91  * SMB work context. Used to store all values which are necessary
  92  * to establish connection to an SMB server.
  93  */
  94 struct smb_ctx {
  95         int             ct_flags;       /* SMBCF_ */
  96         int             ct_dev_fd;      /* device handle */
  97         int             ct_door_fd;     /* to smbiod */
  98         int             ct_parsedlevel;
  99         int             ct_minlevel;
 100         int             ct_maxlevel;
 101         char            *ct_fullserver; /* orig. server name from cmd line */
 102         char            *ct_srvaddr_s;  /* hostname or IP address of server */
 103         struct addrinfo *ct_addrinfo;   /* IP addresses of the server */
 104         struct nb_ctx   *ct_nb;         /* NetBIOS info. */
 105         char            *ct_locname;    /* local (machine) name */


 106         int             ct_minauth;
 107         int             ct_shtype_req;  /* share type wanted */
 108         char            *ct_origshare;
 109         char            *ct_home;
 110         char            *ct_rpath;      /* remote file name */
 111 
 112         /* See ssp.c */
 113         void            *ct_ssp_ctx;
 114         smbioc_ssn_work_t ct_work;
 115         smb_iod_ssn_t   ct_iod_ssn;

 116 
 117         /* NTLM auth. stuff */
 118         uchar_t         ct_clnonce[NTLM_CHAL_SZ];
 119         uchar_t         ct_srv_chal[NTLM_CHAL_SZ];
 120         char            ct_password[SMBIOC_MAX_NAME];




 121 };
 122 
 123 
 124 /*
 125  * Short-hand for some of the substruct fields above
 126  */
 127 #define ct_ssn          ct_iod_ssn.iod_ossn
 128 #define ct_vopt         ct_iod_ssn.iod_ossn.ssn_vopt
 129 #define ct_minver       ct_iod_ssn.iod_ossn.ssn_minver
 130 #define ct_maxver       ct_iod_ssn.iod_ossn.ssn_maxver
 131 #define ct_owner        ct_iod_ssn.iod_ossn.ssn_owner
 132 #define ct_srvaddr      ct_iod_ssn.iod_ossn.ssn_srvaddr
 133 #define ct_domain       ct_iod_ssn.iod_ossn.ssn_domain
 134 #define ct_user         ct_iod_ssn.iod_ossn.ssn_user
 135 #define ct_srvname      ct_iod_ssn.iod_ossn.ssn_srvname
 136 #define ct_authflags    ct_iod_ssn.iod_authflags
 137 #define ct_nthash       ct_iod_ssn.iod_nthash
 138 #define ct_lmhash       ct_iod_ssn.iod_lmhash
 139 
 140 #define ct_vcflags      ct_work.wk_vcflags
 141 #define ct_ssnkey_len   ct_work.wk_u_ssnkey_len
 142 #define ct_ssnkey_buf   ct_work.wk_u_ssnkey_buf.lp_ptr







 143 
 144 
 145 /*
 146  * Bits in smb_ctx_t.ct_flags
 147  */
 148 #define SMBCF_NOPWD                 0x0001 /* don't ask for a password */
 149 #define SMBCF_SRIGHTS               0x0002 /* share access rights supplied */
 150 #define SMBCF_LOCALE                0x0004 /* use current locale */
 151 #define SMBCF_CMD_DOM               0x0010 /* CMD specified domain */
 152 #define SMBCF_CMD_USR               0x0020 /* CMD specified user */
 153 #define SMBCF_CMD_PW                0x0040 /* CMD specified password */
 154 #define SMBCF_RESOLVED              0x8000 /* structure has been verified */
 155 #define SMBCF_KCBAD             0x00080000 /* keychain password failed */
 156 #define SMBCF_KCFOUND           0x00100000 /* password is from keychain */
 157 #define SMBCF_BROWSEOK          0x00200000 /* browser dialogue may be used */
 158 #define SMBCF_AUTHREQ           0x00400000 /* auth. dialog requested */
 159 #define SMBCF_KCSAVE            0x00800000 /* add to keychain requested */
 160 #define SMBCF_KCDOMAIN          0x01000000 /* use domain in KC lookup */


 161 
 162 
 163 /*
 164  * Context management
 165  */
 166 
 167 int  smb_ctx_init(struct smb_ctx *);
 168 void smb_ctx_done(struct smb_ctx *);
 169 int  smb_open_driver(void);
 170 int  nsmb_ioctl(int, int, void *);
 171 int  nsmb_close(int);
 172 
 173 int  smb_ctx_gethandle(struct smb_ctx *);
 174 int  smb_ctx_findvc(struct smb_ctx *);
 175 int  smb_ctx_newvc(struct smb_ctx *);
 176 
 177 /*
 178  * I/O daemon stuff
 179  */
 180 
 181 #define SMBIOD_RUNDIR   "/var/run/smbiod"
 182 #define SMBIOD_SVC_DOOR SMBIOD_RUNDIR "/.svc"
 183 #define SMBIOD_USR_DOOR SMBIOD_RUNDIR "/%d"
 184 #define SMBIOD_START    1
 185 
 186 int  smb_iod_cl_newvc(smb_ctx_t *ctx);
 187 char *smb_iod_door_path(void);
 188 int smb_iod_open_door(int *);
 189 int smb_iod_connect(struct smb_ctx *);
 190 int smb_iod_work(struct smb_ctx *);
 191 
 192 /*
 193  * Other stuff
 194  */
 195 
 196 int  smb_open_rcfile(char *);
 197 void smb_close_rcfile(void);
 198 
 199 int smb_cf_minauth_from_str(char *);
 200 int smb_cf_version_from_str(char *);
 201 
 202 void smb_simplecrypt(char *dst, const char *src);
 203 int  smb_simpledecrypt(char *dst, const char *src);
 204 
 205 int     nls_setrecode(const char *, const char *);
 206 int     nls_setlocale(const char *);
 207 char    *nls_str_toext(char *, const char *);
 208 char    *nls_str_toloc(char *, const char *);
 209 void    *nls_mem_toext(void *, const void *, int);
 210 void    *nls_mem_toloc(void *, const void *, int);
 211 char    *nls_str_upper(char *, const char *);
 212 char    *nls_str_lower(char *, const char *);
 213 
 214 char *smb_getprogname();
 215 #define __progname smb_getprogname()
 216 
 217 #endif /* _NETSMB_SMB_LIB_H_ */