Print this page
NEX-19057 All zfs/nfs/smb threads in door calls to idle idmap
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Roman Strashkin <roman.strashkin@nexenta.com>
1575 untangle libmlrpc from SMB server
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Toomas Soome <tsoome@me.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
NEX-16159 Time spent sharing SMB filesystems could be reduced by optimizing smb_getdataset for default mount points (build fix)
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
NEX-16159 Time spent sharing SMB filesystems could be reduced by optimizing smb_getdataset for default mount points
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Reviewed by: Matt Barden <matt.barden@nexenta.com>
NEX-15558 SMB logon fails during 1st second after service start
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
NEX-15558 SMB logon fails during 1st second after service start
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
NEX-15052 Need a way to add appliance local user/group ACE from Windows
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
NEX-15041 method to delete local SMB users
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
NEX-15052 Need a way to add appliance local user/group ACE from Windows
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
NEX-15041 method to delete local SMB users
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
NEX-9497 SMB should bypass ACL traverse checking
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Roman Strashkin <roman.strashkin@nexenta.com>
NEX-10019 SMB server min_protocol setting
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
NEX-5273 SMB 3 Encryption
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Roman Strashkin <roman.strashkin@nexenta.com>
NEX-4083 Upstream changes from illumos 5917 and 5995
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Kevin Crowe <kevin.crowe@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
NEX-3611 CLONE NEX-3550 Replace smb2_enable with max_protocol
Reviewed by: Yuri Pankov <Yuri.Pankov@nexenta.com>
NEX-2667 Wrong error when join domain with wrong password
Reviewed by: Kevin Crowe <kevin.crowe@nexenta.com>
Reviewed by: Bayard Bell <bayard.bell@nexenta.com>
NEX-2225 Unable to join NexentaStor to 2008 AD
NEX-2346 SMB server debug logging cleanup after NEX-2314
NEX-2314 SMB server debug logging needs improvement
NEX-2286 smbadm join error messages are uninformative
NEX-1404 fixed malformed entries in zone_sun.tab
NEX-1799 Failure to authenticate domain account from Win2003 with NTLM(v1)
NEX-1638 Updated DC Locator
Includes work by: matt.barden@nexenta.com, kevin.crowe@nexenta.com
SMB-126 Unable to map share from win2003/win2003R2 client ...
SMB-107 Unable to map network drive in workgroup mode using Windows XP...
SMB-68 NTLM(v1) inbound with Extended Session Security
NEX-1050 enable_smb2 should be smb2_enable
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)
SMB-70 Hang during boot after SMB-50
SMB-56 extended security NTLMSSP, inbound
SMB-50 User-mode SMB server
Includes work by these authors:
Thomas Keiser <thomas.keiser@nexenta.com>
Albert Lee <trisk@nexenta.com>
SFR-56 Identity Management for UNIX (IDMU) authentication support
re #12435 rb3958 r10 is added 2 times to panic info
re #12393 rb3935 Kerberos and smbd disagree about who is our AD server
re #6813 rb1757 port 2976 Child folder visibility through shares
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/lib/smbsrv/libsmb/common/libsmb.h
+++ new/usr/src/lib/smbsrv/libsmb/common/libsmb.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
|
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24 - * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
24 + * Copyright 2019 Nexenta Systems, Inc. All rights reserved.
25 25 */
26 26
27 27 #ifndef _LIBSMB_H
28 28 #define _LIBSMB_H
29 29
30 30 #ifdef __cplusplus
31 31 extern "C" {
32 32 #endif
33 33
34 34 #include <sys/types.h>
35 +#include <sys/inttypes.h>
35 36 #include <sys/list.h>
36 37 #include <sys/avl.h>
37 38 #include <arpa/inet.h>
38 39 #include <net/if.h> /* LIFNAMSIZ */
39 40 #include <netdb.h>
40 41 #include <stdlib.h>
41 42 #include <libscf.h>
42 43 #include <libshare.h>
43 44 #include <uuid/uuid.h>
44 45 #include <synch.h>
45 46 #include <stdarg.h>
46 47
48 +#include <smb/nterror.h>
49 +#include <smb/ntstatus.h>
50 +#include <smb/wintypes.h>
51 +
47 52 #include <smbsrv/string.h>
48 53 #include <smbsrv/smb_idmap.h>
49 54 #include <smbsrv/netbios.h>
50 55 #include <smbsrv/smb_share.h>
51 -#include <smb/nterror.h>
52 -#include <smb/ntstatus.h>
53 56 #include <smbsrv/smb_door.h>
54 57 #include <smbsrv/alloc.h>
55 58 #include <smbsrv/hash_table.h>
56 59 #include <smbsrv/msgbuf.h>
57 -#include <smbsrv/wintypes.h>
58 60 #include <smbsrv/smb_xdr.h>
59 61 #include <smbsrv/smbinfo.h>
60 62 #include <smbsrv/ntifs.h>
61 63
62 64 #define SMB_VARSMB_DIR "/var/smb"
63 65 #define SMB_VARRUN_DIR "/var/run/smb"
64 66 #define SMB_CCACHE_FILE "ccache"
65 67 #define SMB_CCACHE_PATH SMB_VARRUN_DIR "/" SMB_CCACHE_FILE
66 68
67 69
68 70 /* Max value length of all SMB properties */
69 71 #define MAX_VALUE_BUFLEN 512
70 72
71 73 #define SMBD_FMRI_PREFIX "network/smb/server"
72 74 #define SMBD_DEFAULT_INSTANCE_FMRI "svc:/network/smb/server:default"
73 75 #define SMBD_PG_NAME "smbd"
74 76 #define SMBD_PROTECTED_PG_NAME "read"
75 77 #define SMBD_EXEC_PG_NAME "exec"
76 78
77 79 #define SMBD_SMF_OK 0
78 80 #define SMBD_SMF_NO_MEMORY 1 /* no memory for data structures */
79 81 #define SMBD_SMF_SYSTEM_ERR 2 /* system error, use errno */
80 82 #define SMBD_SMF_NO_PERMISSION 3 /* no permission for operation */
81 83 #define SMBD_SMF_INVALID_ARG 4
82 84
83 85 #define SCH_STATE_UNINIT 0
84 86 #define SCH_STATE_INITIALIZING 1
85 87 #define SCH_STATE_INIT 2
86 88
87 89 typedef struct smb_scfhandle {
88 90 scf_handle_t *scf_handle;
89 91 int scf_state;
90 92 scf_service_t *scf_service;
91 93 scf_scope_t *scf_scope;
92 94 scf_transaction_t *scf_trans;
93 95 scf_transaction_entry_t *scf_entry;
94 96 scf_propertygroup_t *scf_pg;
95 97 scf_instance_t *scf_instance;
96 98 scf_iter_t *scf_inst_iter;
97 99 scf_iter_t *scf_pg_iter;
98 100 } smb_scfhandle_t;
99 101
100 102 /*
101 103 * CIFS Configuration Management
102 104 */
103 105 typedef enum {
104 106 SMB_CI_VERSION = 0,
105 107 SMB_CI_OPLOCK_ENABLE,
106 108
107 109 SMB_CI_AUTOHOME_MAP,
108 110
109 111 SMB_CI_DOMAIN_SID,
110 112 SMB_CI_DOMAIN_MEMB,
111 113 SMB_CI_DOMAIN_NAME,
112 114 SMB_CI_DOMAIN_FQDN,
113 115 SMB_CI_DOMAIN_FOREST,
114 116 SMB_CI_DOMAIN_GUID,
115 117 SMB_CI_DOMAIN_SRV,
116 118
117 119 SMB_CI_WINS_SRV1,
118 120 SMB_CI_WINS_SRV2,
119 121 SMB_CI_WINS_EXCL,
120 122
121 123 SMB_CI_MAX_WORKERS,
122 124 SMB_CI_MAX_CONNECTIONS,
123 125 SMB_CI_KEEPALIVE,
124 126 SMB_CI_RESTRICT_ANON,
125 127
126 128 SMB_CI_SIGNING_ENABLE,
127 129 SMB_CI_SIGNING_REQD,
128 130
129 131 SMB_CI_SYNC_ENABLE,
130 132
131 133 SMB_CI_SECURITY,
132 134 SMB_CI_NETBIOS_ENABLE,
133 135 SMB_CI_NBSCOPE,
134 136 SMB_CI_SYS_CMNT,
135 137 SMB_CI_LM_LEVEL,
136 138
137 139 SMB_CI_ADS_SITE,
138 140
139 141 SMB_CI_DYNDNS_ENABLE,
140 142
141 143 SMB_CI_MACHINE_PASSWD,
142 144 SMB_CI_MACHINE_UUID,
143 145 SMB_CI_KPASSWD_SRV,
144 146 SMB_CI_KPASSWD_DOMAIN,
145 147 SMB_CI_KPASSWD_SEQNUM,
146 148 SMB_CI_NETLOGON_SEQNUM,
147 149 SMB_CI_IPV6_ENABLE,
|
↓ open down ↓ |
80 lines elided |
↑ open up ↑ |
148 150 SMB_CI_PRINT_ENABLE,
149 151 SMB_CI_MAP,
150 152 SMB_CI_UNMAP,
151 153 SMB_CI_DISPOSITION,
152 154 SMB_CI_DFS_STDROOT_NUM,
153 155 SMB_CI_TRAVERSE_MOUNTS,
154 156 SMB_CI_SMB2_ENABLE_OLD, /* obsolete */
155 157 SMB_CI_INITIAL_CREDITS,
156 158 SMB_CI_MAXIMUM_CREDITS,
157 159 SMB_CI_MAX_PROTOCOL,
160 + SMB_CI_ENCRYPT,
161 + SMB_CI_MIN_PROTOCOL,
162 + SMB_CI_BYPASS_TRAVERSE_CHECKING,
158 163
159 164 SMB_CI_MAX
160 165 } smb_cfg_id_t;
161 166
162 167 /* SMF helper functions */
163 168 extern smb_scfhandle_t *smb_smf_scf_init(char *);
164 169 extern void smb_smf_scf_fini(smb_scfhandle_t *);
165 170 extern int smb_smf_start_transaction(smb_scfhandle_t *);
166 171 extern int smb_smf_end_transaction(smb_scfhandle_t *);
167 172 extern int smb_smf_set_string_property(smb_scfhandle_t *, char *, char *);
168 173 extern int smb_smf_get_string_property(smb_scfhandle_t *, char *,
169 174 char *, size_t);
170 175 extern int smb_smf_set_integer_property(smb_scfhandle_t *, char *, int64_t);
171 176 extern int smb_smf_get_integer_property(smb_scfhandle_t *, char *, int64_t *);
172 177 extern int smb_smf_set_boolean_property(smb_scfhandle_t *, char *, uint8_t);
173 178 extern int smb_smf_get_boolean_property(smb_scfhandle_t *, char *, uint8_t *);
|
↓ open down ↓ |
6 lines elided |
↑ open up ↑ |
174 179 extern int smb_smf_set_opaque_property(smb_scfhandle_t *, char *,
175 180 void *, size_t);
176 181 extern int smb_smf_get_opaque_property(smb_scfhandle_t *, char *,
177 182 void *, size_t);
178 183 extern int smb_smf_create_service_pgroup(smb_scfhandle_t *, char *);
179 184 extern int smb_smf_delete_property(smb_scfhandle_t *, char *);
180 185 extern int smb_smf_restart_service(void);
181 186 extern int smb_smf_maintenance_mode(void);
182 187
183 188 /* ZFS interface */
184 -int smb_getdataset(const char *, char *, size_t);
189 +struct libzfs_handle;
190 +int smb_getdataset(struct libzfs_handle *, const char *, char *, size_t);
185 191
186 192 /* Configuration management functions */
187 193 extern int smb_config_get(smb_cfg_id_t, char *, int);
188 194 extern char *smb_config_getname(smb_cfg_id_t);
189 195 extern int smb_config_getstr(smb_cfg_id_t, char *, int);
190 196 extern int smb_config_getnum(smb_cfg_id_t, int64_t *);
191 197 extern boolean_t smb_config_getbool(smb_cfg_id_t);
192 198
193 199 extern int smb_config_set(smb_cfg_id_t, char *);
194 200 extern int smb_config_setstr(smb_cfg_id_t, char *);
195 201 extern int smb_config_setnum(smb_cfg_id_t, int64_t);
196 202 extern int smb_config_setbool(smb_cfg_id_t, boolean_t);
197 203
198 204 extern boolean_t smb_config_get_ads_enable(void);
199 205 extern int smb_config_get_debug(void);
200 206 extern uint8_t smb_config_get_fg_flag(void);
201 207 extern char *smb_config_get_localsid(void);
202 208 extern int smb_config_get_localuuid(uuid_t);
203 209 extern int smb_config_secmode_fromstr(char *);
204 210 extern char *smb_config_secmode_tostr(int);
205 211 extern int smb_config_get_secmode(void);
|
↓ open down ↓ |
11 lines elided |
↑ open up ↑ |
206 212 extern int smb_config_set_secmode(int);
207 213 extern int smb_config_set_idmap_domain(char *);
208 214 extern int smb_config_refresh_idmap(void);
209 215 extern int smb_config_getip(smb_cfg_id_t, smb_inaddr_t *);
210 216 extern void smb_config_get_version(smb_version_t *);
211 217 uint32_t smb_config_get_execinfo(char *, char *, size_t);
212 218 extern void smb_config_get_negtok(uchar_t *, uint32_t *);
213 219
214 220 extern int smb_config_check_protocol(char *);
215 221 extern uint32_t smb_config_get_max_protocol(void);
222 +extern uint32_t smb_config_get_min_protocol(void);
216 223 extern void smb_config_upgrade(void);
217 224
225 +extern smb_cfg_val_t smb_config_get_require(smb_cfg_id_t);
226 +
218 227 extern void smb_load_kconfig(smb_kmod_cfg_t *kcfg);
219 228 extern uint32_t smb_crc_gen(uint8_t *, size_t);
220 229
221 230 extern boolean_t smb_match_netlogon_seqnum(void);
222 231 extern int smb_setdomainprops(char *, char *, char *);
223 232 extern void smb_update_netlogon_seqnum(void);
224 233
225 234 /* maximum password length on Windows 2000 and above */
226 235 #define SMB_PASSWD_MAXLEN 127
227 236 #define SMB_USERNAME_MAXLEN 40
228 237
229 238 /* See also: smb_joininfo_xdr() */
230 239 typedef struct smb_joininfo {
231 240 char domain_name[MAXHOSTNAMELEN];
232 241 char domain_username[SMB_USERNAME_MAXLEN + 1];
233 242 char domain_passwd[SMB_PASSWD_MAXLEN + 1];
234 243 uint32_t mode;
235 244 } smb_joininfo_t;
236 245
237 246 /* See also: smb_joinres_xdr() */
238 247 typedef struct smb_joinres {
239 248 uint32_t status;
240 249 int join_err;
241 250 char dc_name[MAXHOSTNAMELEN];
242 251 } smb_joinres_t;
243 252
244 253 /* APIs to communicate with SMB daemon via door calls */
245 254 int smb_join(smb_joininfo_t *, smb_joinres_t *info);
246 255 bool_t smb_joininfo_xdr(XDR *, smb_joininfo_t *);
247 256 bool_t smb_joinres_xdr(XDR *, smb_joinres_t *);
248 257 boolean_t smb_find_ads_server(char *, char *, int);
249 258 void smb_notify_dc_changed(void);
250 259
251 260 extern void smb_config_getdomaininfo(char *, char *, char *, char *, char *);
252 261 extern void smb_config_setdomaininfo(char *, char *, char *, char *, char *);
253 262 extern uint32_t smb_get_dcinfo(char *, uint32_t, smb_inaddr_t *);
254 263
255 264 /*
256 265 * buffer context structure. This is used to keep track of the buffer
257 266 * context.
258 267 *
259 268 * basep: points to the beginning of the buffer
260 269 * curp: points to the current offset
261 270 * endp: points to the limit of the buffer
262 271 */
263 272 typedef struct {
264 273 unsigned char *basep;
265 274 unsigned char *curp;
266 275 unsigned char *endp;
267 276 } smb_ctxbuf_t;
268 277
269 278 extern int smb_ctxbuf_init(smb_ctxbuf_t *ctx, unsigned char *buf,
270 279 size_t buflen);
271 280 extern int smb_ctxbuf_len(smb_ctxbuf_t *ctx);
272 281 extern int smb_ctxbuf_printf(smb_ctxbuf_t *ctx, const char *fmt, ...);
273 282
274 283 void smb_idmap_check(const char *, idmap_stat);
275 284
276 285 /* Miscellaneous functions */
277 286 extern void hexdump(unsigned char *, int);
278 287 extern size_t bintohex(const char *, size_t, char *, size_t);
279 288 extern size_t hextobin(const char *, size_t, char *, size_t);
280 289 extern char *strstrip(char *, const char *);
281 290 extern char *strtrim(char *, const char *);
282 291 extern char *trim_whitespace(char *);
283 292 extern void randomize(char *, unsigned);
284 293 extern void rand_hash(unsigned char *, size_t, unsigned char *, size_t);
285 294
286 295 extern int smb_getdomainname(char *, size_t);
287 296 extern int smb_getfqdomainname(char *, size_t);
288 297
289 298 typedef enum smb_caseconv {
290 299 SMB_CASE_PRESERVE = 0,
291 300 SMB_CASE_UPPER,
292 301 SMB_CASE_LOWER
293 302 } smb_caseconv_t;
294 303
295 304 extern int smb_gethostname(char *, size_t, smb_caseconv_t);
296 305 extern int smb_getfqhostname(char *, size_t);
297 306 extern int smb_getnetbiosname(char *, size_t);
298 307 extern struct hostent *smb_gethostbyname(const char *, int *);
299 308 extern struct hostent *smb_gethostbyaddr(const char *, int, int, int *);
300 309
301 310 #define SMB_SAMACCT_MAXLEN (NETBIOS_NAME_SZ + 1)
302 311 extern int smb_getsamaccount(char *, size_t);
303 312
304 313 extern int smb_get_nameservers(smb_inaddr_t *, int);
305 314 extern void smb_tonetbiosname(char *, char *, char);
306 315
307 316 extern int smb_chk_hostaccess(smb_inaddr_t *, char *);
308 317
309 318 extern int smb_getnameinfo(smb_inaddr_t *, char *, int, int);
310 319
311 320 void smb_trace(const char *s);
312 321 void smb_tracef(const char *fmt, ...);
313 322
314 323 const char *xlate_nt_status(unsigned int);
315 324
316 325 void libsmb_redirect_syslog(__FILE_TAG *fp, int priority);
317 326
318 327 /*
319 328 * Authentication
320 329 */
321 330
322 331 #define SMBAUTH_LM_MAGIC_STR "KGS!@#$%"
323 332
324 333 #define SMBAUTH_HASH_SZ 16 /* also LM/NTLM/NTLMv2 Hash size */
325 334 #define SMBAUTH_LM_RESP_SZ 24 /* also NTLM Response size */
326 335 #define SMBAUTH_LM_PWD_SZ 14 /* LM password size */
327 336 #define SMBAUTH_CHAL_SZ 8 /* both LMv2 and NTLMv2 */
328 337 #define SMBAUTH_SESSION_KEY_SZ SMBAUTH_HASH_SZ
329 338 #define SMBAUTH_HEXHASH_SZ (SMBAUTH_HASH_SZ * 2)
330 339
331 340 #define SMBAUTH_FAILURE 1
332 341 #define SMBAUTH_SUCCESS 0
333 342 #define MD_DIGEST_LEN 16
334 343
335 344 /*
336 345 * Name Types
337 346 *
338 347 * The list of names near the end of the data blob (i.e. the ndb_names
339 348 * field of the smb_auth_data_blob_t data structure) can be classify into
340 349 * the following types:
341 350 *
342 351 * 0x0000 Indicates the end of the list.
343 352 * 0x0001 The name is a NetBIOS machine name (e.g. server name)
344 353 * 0x0002 The name is an NT Domain NetBIOS name.
345 354 * 0x0003 The name is the server's DNS hostname.
346 355 * 0x0004 The name is a W2K Domain name (a DNS name).
347 356 */
348 357 #define SMBAUTH_NAME_TYPE_LIST_END 0x0000
349 358 #define SMBAUTH_NAME_TYPE_SERVER_NETBIOS 0x0001
350 359 #define SMBAUTH_NAME_TYPE_DOMAIN_NETBIOS 0x0002
351 360 #define SMBAUTH_NAME_TYPE_SERVER_DNS 0x0003
352 361 #define SMBAUTH_NAME_TYPE_DOMAIN_DNS 0x0004
353 362
354 363 /*
355 364 * smb_auth_name_entry_t
356 365 *
357 366 * Each name entry in the data blob consists of the following 3 fields:
358 367 *
359 368 * nne_type - name type
360 369 * nne_len - the length of the name
361 370 * nne_name - the name, in uppercase UCS-2LE Unicode format
362 371 */
363 372 typedef struct smb_auth_name_entry {
364 373 unsigned short nne_type;
365 374 unsigned short nne_len;
366 375 smb_wchar_t nne_name[SMB_PI_MAX_DOMAIN * 2];
367 376 } smb_auth_name_entry_t;
368 377
369 378 /*
370 379 * smb_auth_data_blob
371 380 *
372 381 * The format of this NTLMv2 data blob structure is as follow:
373 382 *
374 383 * - Blob Signature 0x01010000 (4 bytes)
375 384 * - Reserved (0x00000000) (4 bytes)
376 385 * - Timestamp Little-endian, 64-bit signed value representing
377 386 * the number of tenths of a microsecond since January 1, 1601.
378 387 * (8 bytes)
379 388 * - Client Challenge (8 bytes)
380 389 * - Unknown1 (4 bytes)
381 390 * - List of Target Information (variable length)
382 391 * - Unknown2 (4 bytes)
383 392 */
384 393 typedef struct smb_auth_data_blob {
385 394 unsigned char ndb_signature[4];
386 395 unsigned char ndb_reserved[4];
387 396 uint64_t ndb_timestamp;
388 397 unsigned char ndb_clnt_challenge[SMBAUTH_CHAL_SZ];
389 398 unsigned char ndb_unknown[4];
390 399 smb_auth_name_entry_t ndb_names[2];
391 400 unsigned char ndb_unknown2[4];
392 401 } smb_auth_data_blob_t;
393 402
394 403 #define SMBAUTH_BLOB_MAXLEN (sizeof (smb_auth_data_blob_t))
395 404 #define SMBAUTH_CI_MAXLEN SMBAUTH_LM_RESP_SZ
396 405 #define SMBAUTH_CS_MAXLEN (SMBAUTH_BLOB_MAXLEN + SMBAUTH_HASH_SZ)
397 406
398 407 /*
399 408 * smb_auth_info_t
400 409 *
401 410 * The structure contains all the authentication information
402 411 * needed for the preparaton of the SMBSessionSetupAndx request
403 412 * and the user session key.
404 413 *
405 414 * hash - NTLM hash
406 415 * hash_v2 - NTLMv2 hash
407 416 * ci_len - the length of the case-insensitive password
408 417 * ci - case-insensitive password
409 418 * (If NTLMv2 authentication mechanism is used, it
410 419 * represents the LMv2 response. Otherwise, it
411 420 * is empty.)
412 421 * cs_len - the length of the case-sensitive password
413 422 * cs - case-sensitive password
414 423 * (If NTLMv2 authentication mechanism is used, it
415 424 * represents the NTLMv2 response. Otherwise, it
416 425 * represents the NTLM response.)
417 426 * data_blob - NTLMv2 data blob
418 427 */
419 428 typedef struct smb_auth_info {
420 429 unsigned char hash[SMBAUTH_HASH_SZ];
421 430 unsigned char hash_v2[SMBAUTH_HASH_SZ];
422 431 unsigned short ci_len;
423 432 unsigned char ci[SMBAUTH_CI_MAXLEN];
424 433 unsigned short cs_len;
425 434 unsigned char cs[SMBAUTH_CS_MAXLEN];
426 435 int lmcompatibility_lvl;
427 436 smb_auth_data_blob_t data_blob;
428 437 } smb_auth_info_t;
429 438
430 439 /*
431 440 * SMB password management
432 441 */
433 442
434 443 #define SMB_PWF_LM 0x01 /* LM hash is present */
435 444 #define SMB_PWF_NT 0x02 /* NT hash is present */
436 445 #define SMB_PWF_DISABLE 0x04 /* Account is disabled */
437 446
438 447 typedef struct smb_passwd {
439 448 uid_t pw_uid;
440 449 uint32_t pw_flags;
441 450 char pw_name[SMB_USERNAME_MAXLEN];
|
↓ open down ↓ |
214 lines elided |
↑ open up ↑ |
442 451 uint8_t pw_lmhash[SMBAUTH_HASH_SZ];
443 452 uint8_t pw_nthash[SMBAUTH_HASH_SZ];
444 453 } smb_passwd_t;
445 454
446 455 /*
447 456 * Control flags passed to smb_pwd_setcntl
448 457 */
449 458 #define SMB_PWC_DISABLE 0x01
450 459 #define SMB_PWC_ENABLE 0x02
451 460 #define SMB_PWC_NOLM 0x04
461 +#define SMB_PWC_DELETE 0x08
452 462
453 463 #define SMB_PWE_SUCCESS 0
454 464 #define SMB_PWE_USER_UNKNOWN 1
455 465 #define SMB_PWE_USER_DISABLE 2
456 466 #define SMB_PWE_CLOSE_FAILED 3
457 467 #define SMB_PWE_OPEN_FAILED 4
458 468 #define SMB_PWE_WRITE_FAILED 6
459 469 #define SMB_PWE_UPDATE_FAILED 7
460 470 #define SMB_PWE_STAT_FAILED 8
461 471 #define SMB_PWE_BUSY 9
462 472 #define SMB_PWE_DENIED 10
463 473 #define SMB_PWE_SYSTEM_ERROR 11
464 474 #define SMB_PWE_INVALID_PARAM 12
465 475 #define SMB_PWE_NO_MEMORY 13
466 476 #define SMB_PWE_MAX 14
467 477
468 478 typedef struct smb_pwditer {
469 479 void *spi_next;
470 480 } smb_pwditer_t;
471 481
472 482 typedef struct smb_luser {
473 483 char *su_name;
474 484 char *su_fullname;
475 485 char *su_desc;
476 486 uint32_t su_rid;
477 487 uint32_t su_ctrl;
478 488 } smb_luser_t;
479 489
480 490 extern void smb_pwd_init(boolean_t);
481 491 extern void smb_pwd_fini(void);
482 492 extern smb_passwd_t *smb_pwd_getpwnam(const char *, smb_passwd_t *);
483 493 extern smb_passwd_t *smb_pwd_getpwuid(uid_t, smb_passwd_t *);
484 494 extern int smb_pwd_setpasswd(const char *, const char *);
485 495 extern int smb_pwd_setcntl(const char *, int);
486 496
487 497 extern int smb_pwd_iteropen(smb_pwditer_t *);
488 498 extern smb_luser_t *smb_pwd_iterate(smb_pwditer_t *);
489 499 extern void smb_pwd_iterclose(smb_pwditer_t *);
490 500
491 501 extern int smb_auth_qnd_unicode(smb_wchar_t *, const char *, int);
492 502 extern int smb_auth_hmac_md5(unsigned char *, int, unsigned char *, int,
493 503 unsigned char *);
494 504
495 505 /*
496 506 * A variation on HMAC-MD5 known as HMACT64 is used by Windows systems.
497 507 * The HMACT64() function is the same as the HMAC-MD5() except that
498 508 * it truncates the input key to 64 bytes rather than hashing it down
499 509 * to 16 bytes using the MD5() function.
500 510 */
501 511 #define SMBAUTH_HMACT64(D, Ds, K, Ks, digest) \
502 512 smb_auth_hmac_md5(D, Ds, K, (Ks > 64) ? 64 : Ks, digest)
503 513
504 514 extern int smb_auth_DES(unsigned char *, int, unsigned char *, int,
505 515 unsigned char *, int);
506 516 extern int smb_auth_RC4(unsigned char *, int, unsigned char *, int,
507 517 unsigned char *, int);
508 518
509 519 extern int smb_auth_md4(unsigned char *, unsigned char *, int);
510 520 extern int smb_auth_lm_hash(const char *, unsigned char *);
511 521 extern int smb_auth_ntlm_hash(const char *, unsigned char *);
512 522 extern void smb_auth_ntlm2_mkchallenge(char *, const char *, const char *);
513 523 extern void smb_auth_ntlm2_kxkey(unsigned char *, const char *, const char *,
514 524 unsigned char *);
515 525
516 526 extern int smb_auth_set_info(char *, char *,
517 527 unsigned char *, char *, unsigned char *,
518 528 int, int, smb_auth_info_t *);
519 529
520 530 extern int smb_auth_ntlmv2_hash(unsigned char *,
521 531 char *, char *, unsigned char *);
522 532
523 533 boolean_t smb_auth_validate(smb_passwd_t *, char *, char *,
524 534 uchar_t *, uint_t, uchar_t *, uint_t, uchar_t *, uint_t, uchar_t *);
525 535
526 536 int smb_gen_random_passwd(char *passwd, size_t bufsz);
527 537
528 538 /*
529 539 * SMB authenticated IPC
530 540 */
531 541 extern void smb_ipc_commit(void);
532 542 extern void smb_ipc_get_user(char *, size_t);
533 543 extern void smb_ipc_get_passwd(uint8_t *, size_t);
534 544 extern void smb_ipc_init(void);
535 545 extern void smb_ipc_rollback(void);
536 546 extern void smb_ipc_set(char *, uint8_t *);
537 547
538 548 /*
539 549 * Signing flags:
540 550 *
541 551 * SMB_SCF_ENABLE Signing is enabled.
542 552 *
543 553 * SMB_SCF_REQUIRED Signing is enabled and required.
544 554 * This flag shouldn't be set if
545 555 * SMB_SCF_ENABLE isn't set.
546 556 *
547 557 * SMB_SCF_STARTED Signing will start after receiving
548 558 * the first non-anonymous SessionSetup
549 559 * request.
550 560 *
551 561 * SMB_SCF_KEY_ISSET_THIS_LOGON Indicates whether the MAC key has just
552 562 * been set for this logon. (prior to
553 563 * sending the SMBSessionSetup request)
554 564 *
555 565 */
556 566 #define SMB_SCF_ENABLE 0x01
557 567 #define SMB_SCF_REQUIRED 0x02
558 568 #define SMB_SCF_STARTED 0x04
559 569 #define SMB_SCF_KEY_ISSET_THIS_LOGON 0x08
560 570
561 571 /*
562 572 * Each domain is categorized using the enum values below.
563 573 * The local domain refers to the local machine and is named
564 574 * after the local hostname. The primary domain is the domain
565 575 * that the system joined. All other domains are either
566 576 * trusted or untrusted, as defined by the primary domain PDC.
567 577 */
568 578 typedef enum smb_domain_type {
569 579 SMB_DOMAIN_NULL,
570 580 SMB_DOMAIN_BUILTIN,
571 581 SMB_DOMAIN_LOCAL,
572 582 SMB_DOMAIN_PRIMARY,
573 583 SMB_DOMAIN_ACCOUNT,
574 584 SMB_DOMAIN_TRUSTED,
575 585 SMB_DOMAIN_UNTRUSTED,
576 586 SMB_DOMAIN_NUM_TYPES
577 587 } smb_domain_type_t;
578 588
579 589 /*
580 590 * Information specific to trusted domains
581 591 */
582 592 typedef struct smb_domain_trust {
583 593 uint32_t dti_trust_direction;
584 594 uint32_t dti_trust_type;
585 595 uint32_t dti_trust_attrs;
586 596 } smb_domain_trust_t;
587 597
588 598 /*
589 599 * DNS information for domain types that this info is
590 600 * obtained/available. Currently this is only obtained
591 601 * for the primary domain.
592 602 */
593 603 typedef struct smb_domain_dns {
594 604 char ddi_forest[MAXHOSTNAMELEN];
595 605 char ddi_guid[UUID_PRINTABLE_STRING_LENGTH];
596 606 } smb_domain_dns_t;
597 607
598 608 /*
599 609 * This is the information that is held about each domain.
600 610 */
601 611 typedef struct smb_domain {
602 612 list_node_t di_lnd;
603 613 smb_domain_type_t di_type;
604 614 char di_sid[SMB_SID_STRSZ];
605 615 char di_nbname[NETBIOS_NAME_SZ];
606 616 char di_fqname[MAXHOSTNAMELEN];
607 617 smb_sid_t *di_binsid;
608 618 union {
609 619 smb_domain_dns_t di_dns;
610 620 smb_domain_trust_t di_trust;
611 621 } di_u;
612 622 } smb_domain_t;
613 623
614 624 typedef struct smb_trusted_domains {
615 625 uint32_t td_num;
616 626 smb_domain_t *td_domains;
617 627 } smb_trusted_domains_t;
618 628
619 629 #define SMB_DOMAIN_SUCCESS 0
620 630 #define SMB_DOMAIN_NOMACHINE_SID 1
621 631 #define SMB_DOMAIN_NODOMAIN_SID 2
622 632 #define SMB_DOMAIN_NODOMAIN_NAME 3
623 633 #define SMB_DOMAIN_INTERNAL_ERR 4
624 634 #define SMB_DOMAIN_INVALID_ARG 5
625 635 #define SMB_DOMAIN_NO_MEMORY 6
626 636 #define SMB_DOMAIN_NO_CACHE 7
627 637
628 638 typedef struct smb_dcinfo {
629 639 char dc_name[MAXHOSTNAMELEN];
630 640 smb_inaddr_t dc_addr;
631 641 } smb_dcinfo_t;
632 642
633 643 /*
634 644 * This structure could contain information about
635 645 * the primary domain the name of selected domain controller
636 646 * for the primary domain and a list of trusted domains if
637 647 * any. The "ex" in the structure name stands for extended.
638 648 * This is to differentiate this structure from smb_domain_t
639 649 * which only contains information about a single domain.
640 650 */
641 651 typedef struct smb_domainex {
642 652 smb_dcinfo_t d_dci;
643 653 smb_domain_t d_primary;
644 654 smb_trusted_domains_t d_trusted;
645 655 } smb_domainex_t;
646 656
647 657 int smb_domain_init(uint32_t);
648 658 void smb_domain_fini(void);
649 659 void smb_domain_show(void);
650 660 void smb_domain_save(void);
651 661 boolean_t smb_domain_lookup_name(char *, smb_domain_t *);
652 662 boolean_t smb_domain_lookup_sid(smb_sid_t *, smb_domain_t *);
653 663 boolean_t smb_domain_lookup_type(smb_domain_type_t, smb_domain_t *);
|
↓ open down ↓ |
192 lines elided |
↑ open up ↑ |
654 664 boolean_t smb_domain_getinfo(smb_domainex_t *);
655 665 void smb_domain_update(smb_domainex_t *);
656 666 uint32_t smb_domain_start_update(void);
657 667 void smb_domain_end_update(void);
658 668 void smb_domain_set_basic_info(char *, char *, char *, smb_domain_t *);
659 669 void smb_domain_set_dns_info(char *, char *, char *, char *, char *,
660 670 smb_domain_t *);
661 671 void smb_domain_set_trust_info(char *, char *, char *,
662 672 uint32_t, uint32_t, uint32_t, smb_domain_t *);
663 673 void smb_domain_current_dc(smb_dcinfo_t *);
674 +void smb_domain_bad_dc(void);
664 675
665 676 typedef struct smb_gsid {
666 677 smb_sid_t *gs_sid;
667 678 uint16_t gs_type;
668 679 } smb_gsid_t;
669 680
670 681 struct sqlite_vm;
671 682 struct sqlite;
672 683
673 684 typedef struct smb_giter {
674 685 struct sqlite_vm *sgi_vm;
675 686 struct sqlite *sgi_db;
676 687 uint32_t sgi_nerr;
677 688 } smb_giter_t;
678 689
679 690 typedef struct smb_group {
680 691 char *sg_name;
681 692 char *sg_cmnt;
682 693 uint32_t sg_attr;
683 694 uint32_t sg_rid;
684 695 smb_gsid_t sg_id;
685 696 smb_domain_type_t sg_domain;
686 697 smb_privset_t *sg_privs;
687 698 uint32_t sg_nmembers;
688 699 smb_gsid_t *sg_members;
689 700 } smb_group_t;
690 701
691 702 int smb_lgrp_start(void);
692 703 void smb_lgrp_stop(void);
693 704 int smb_lgrp_add(char *, char *);
694 705 int smb_lgrp_rename(char *, char *);
695 706 int smb_lgrp_delete(char *);
696 707 int smb_lgrp_setcmnt(char *, char *);
697 708 int smb_lgrp_getcmnt(char *, char **);
698 709 int smb_lgrp_getpriv(char *, uint8_t, boolean_t *);
699 710 int smb_lgrp_setpriv(char *, uint8_t, boolean_t);
700 711 int smb_lgrp_add_member(char *, smb_sid_t *, uint16_t);
701 712 int smb_lgrp_del_member(char *, smb_sid_t *, uint16_t);
702 713 int smb_lgrp_getbyname(char *, smb_group_t *);
703 714 int smb_lgrp_getbyrid(uint32_t, smb_domain_type_t, smb_group_t *);
|
↓ open down ↓ |
30 lines elided |
↑ open up ↑ |
704 715 void smb_lgrp_free(smb_group_t *);
705 716 uint32_t smb_lgrp_err_to_ntstatus(uint32_t);
706 717 boolean_t smb_lgrp_is_member(smb_group_t *, smb_sid_t *);
707 718 char *smb_lgrp_strerror(int);
708 719 int smb_lgrp_iteropen(smb_giter_t *);
709 720 void smb_lgrp_iterclose(smb_giter_t *);
710 721 boolean_t smb_lgrp_itererror(smb_giter_t *);
711 722 int smb_lgrp_iterate(smb_giter_t *, smb_group_t *);
712 723
713 724 int smb_lookup_sid(const char *, lsa_account_t *);
725 +int smb_lookup_lsid(const char *, lsa_account_t *);
714 726 int smb_lookup_name(const char *, sid_type_t, lsa_account_t *);
727 +int smb_lookup_lname(const char *, sid_type_t, lsa_account_t *);
715 728
716 729 #define SMB_LGRP_SUCCESS 0
717 730 #define SMB_LGRP_INVALID_ARG 1
718 731 #define SMB_LGRP_INVALID_MEMBER 2
719 732 #define SMB_LGRP_INVALID_NAME 3
720 733 #define SMB_LGRP_NOT_FOUND 4
721 734 #define SMB_LGRP_EXISTS 5
722 735 #define SMB_LGRP_NO_SID 6
723 736 #define SMB_LGRP_NO_LOCAL_SID 7
724 737 #define SMB_LGRP_SID_NOTLOCAL 8
725 738 #define SMB_LGRP_WKSID 9
726 739 #define SMB_LGRP_NO_MEMORY 10
727 740 #define SMB_LGRP_DB_ERROR 11
728 741 #define SMB_LGRP_DBINIT_ERROR 12
729 742 #define SMB_LGRP_INTERNAL_ERROR 13
730 743 #define SMB_LGRP_MEMBER_IN_GROUP 14
731 744 #define SMB_LGRP_MEMBER_NOT_IN_GROUP 15
732 745 #define SMB_LGRP_NO_SUCH_PRIV 16
733 746 #define SMB_LGRP_NO_SUCH_DOMAIN 17
734 747 #define SMB_LGRP_PRIV_HELD 18
735 748 #define SMB_LGRP_PRIV_NOT_HELD 19
736 749 #define SMB_LGRP_BAD_DATA 20
737 750 #define SMB_LGRP_NO_MORE 21
738 751 #define SMB_LGRP_DBOPEN_FAILED 22
739 752 #define SMB_LGRP_DBEXEC_FAILED 23
740 753 #define SMB_LGRP_DBINIT_FAILED 24
741 754 #define SMB_LGRP_DOMLKP_FAILED 25
742 755 #define SMB_LGRP_DOMINS_FAILED 26
743 756 #define SMB_LGRP_INSERT_FAILED 27
744 757 #define SMB_LGRP_DELETE_FAILED 28
745 758 #define SMB_LGRP_UPDATE_FAILED 29
746 759 #define SMB_LGRP_LOOKUP_FAILED 30
747 760 #define SMB_LGRP_NOT_SUPPORTED 31
748 761 #define SMB_LGRP_OFFLINE 32
749 762 #define SMB_LGRP_POSIXCREATE_FAILED 33
750 763
751 764 #define SMB_LGRP_COMMENT_MAX 256
752 765
753 766 /*
754 767 * values for smb_nic_t.smbflags
755 768 */
756 769 #define SMB_NICF_NBEXCL 0x01 /* Excluded from Netbios activities */
757 770 #define SMB_NICF_ALIAS 0x02 /* This is an alias */
758 771
759 772 /*
760 773 * smb_nic_t
761 774 * nic_host actual host name
762 775 * nic_nbname 16-byte NetBIOS host name
763 776 */
764 777 typedef struct {
765 778 char nic_host[MAXHOSTNAMELEN];
766 779 char nic_nbname[NETBIOS_NAME_SZ];
767 780 char nic_cmnt[SMB_PI_MAX_COMMENT];
768 781 char nic_ifname[LIFNAMSIZ];
769 782 smb_inaddr_t nic_ip;
770 783 uint32_t nic_mask;
771 784 uint32_t nic_bcast;
772 785 uint32_t nic_smbflags;
773 786 uint64_t nic_sysflags;
774 787 } smb_nic_t;
775 788
776 789 typedef struct smb_niciter {
777 790 smb_nic_t ni_nic;
778 791 int ni_cookie;
779 792 int ni_seqnum;
780 793 } smb_niciter_t;
781 794
782 795 /* NIC config functions */
783 796 int smb_nic_init(void);
784 797 void smb_nic_fini(void);
785 798 int smb_nic_getnum(char *);
786 799 int smb_nic_addhost(const char *, const char *, int, const char **);
787 800 int smb_nic_delhost(const char *);
788 801 int smb_nic_getfirst(smb_niciter_t *);
789 802 int smb_nic_getnext(smb_niciter_t *);
790 803 boolean_t smb_nic_is_local(smb_inaddr_t *);
791 804 boolean_t smb_nic_is_same_subnet(smb_inaddr_t *);
792 805
793 806 #define SMB_NIC_SUCCESS 0
794 807 #define SMB_NIC_INVALID_ARG 1
795 808 #define SMB_NIC_NOT_FOUND 2
796 809 #define SMB_NIC_NO_HOST 3
797 810 #define SMB_NIC_NO_MEMORY 4
798 811 #define SMB_NIC_DB_ERROR 5
799 812 #define SMB_NIC_DBINIT_ERROR 6
800 813 #define SMB_NIC_BAD_DATA 7
801 814 #define SMB_NIC_NO_MORE 8
802 815 #define SMB_NIC_DBOPEN_FAILED 9
803 816 #define SMB_NIC_DBEXEC_FAILED 10
804 817 #define SMB_NIC_DBINIT_FAILED 11
805 818 #define SMB_NIC_INSERT_FAILED 12
806 819 #define SMB_NIC_DELETE_FAILED 13
807 820 #define SMB_NIC_SOCK 14
808 821 #define SMB_NIC_IOCTL 15
809 822 #define SMB_NIC_CHANGED 16
810 823
811 824 /*
812 825 * Well-known account structure
813 826 *
814 827 * A security identifier (SID) is a unique value of variable length that
815 828 * is used to identify a security principal or security group in
816 829 * Windows. Well-known SIDs are a group of SIDs that identify generic
817 830 * users or generic groups. Their values remain constant across all
818 831 * operating systems.
819 832 *
820 833 * This structure is defined to store these SIDs and other related
821 834 * information about them (e.g. account and domain names) in a
822 835 * predefined table.
823 836 */
824 837 typedef struct smb_wka {
825 838 uint8_t wka_domidx;
826 839 char *wka_sid;
827 840 char *wka_name;
828 841 uint16_t wka_type;
829 842 uint16_t wka_flags;
830 843 char *wka_desc;
831 844 smb_sid_t *wka_binsid;
832 845 } smb_wka_t;
833 846
834 847 /*
835 848 * Defined values for smb_wka.wka_flags
836 849 *
837 850 * SMB_WKAFLG_LGRP_ENABLE Can be added as local group
838 851 */
839 852 #define SMB_WKAFLG_LGRP_ENABLE 0x1
840 853
841 854 /*
842 855 * Well-known account interfaces
843 856 */
844 857 smb_wka_t *smb_wka_lookup_builtin(const char *);
845 858 smb_wka_t *smb_wka_lookup_name(const char *);
846 859 smb_wka_t *smb_wka_lookup_sid(smb_sid_t *);
847 860 smb_sid_t *smb_wka_get_sid(const char *);
848 861 char *smb_wka_get_domain(int);
849 862 uint32_t smb_wka_token_groups(uint32_t, smb_ids_t *);
850 863
|
↓ open down ↓ |
126 lines elided |
↑ open up ↑ |
851 864 /*
852 865 * In memory account representation
853 866 */
854 867 typedef struct smb_account {
855 868 char *a_name;
856 869 char *a_domain;
857 870 uint16_t a_type;
858 871 smb_sid_t *a_sid;
859 872 smb_sid_t *a_domsid;
860 873 uint32_t a_rid;
874 + uint32_t a_flags;
861 875 } smb_account_t;
862 876
863 877 uint32_t smb_sam_lookup_name(char *, char *, uint16_t, smb_account_t *);
864 878 uint32_t smb_sam_lookup_sid(smb_sid_t *, smb_account_t *);
865 879 int smb_sam_usr_cnt(void);
866 880 uint32_t smb_sam_usr_groups(smb_sid_t *, smb_ids_t *);
867 881 int smb_sam_grp_cnt(smb_domain_type_t);
868 882 void smb_account_free(smb_account_t *);
869 883 boolean_t smb_account_validate(smb_account_t *);
870 884
871 885 /*
872 886 * Security Descriptor functions.
873 887 */
874 888 uint32_t smb_sd_read(char *path, smb_sd_t *, uint32_t);
875 889 uint32_t smb_sd_write(char *path, smb_sd_t *, uint32_t);
876 890 uint32_t smb_sd_fromfs(smb_fssd_t *, smb_sd_t *);
877 891
878 892 /* Kernel Module Interface */
879 893 int smb_kmod_bind(void);
880 894 boolean_t smb_kmod_isbound(void);
881 895 int smb_kmod_setcfg(smb_kmod_cfg_t *);
882 896 int smb_kmod_setgmtoff(int32_t);
883 897 int smb_kmod_start(int, int, int);
884 898 void smb_kmod_stop(void);
885 899 int smb_kmod_event_notify(uint32_t);
886 900 void smb_kmod_unbind(void);
887 901 int smb_kmod_share(nvlist_t *);
888 902 int smb_kmod_unshare(nvlist_t *);
889 903 int smb_kmod_shareinfo(char *, boolean_t *);
890 904 int smb_kmod_get_open_num(smb_opennum_t *);
891 905 int smb_kmod_enum(smb_netsvc_t *);
892 906 smb_netsvc_t *smb_kmod_enum_init(smb_svcenum_t *);
893 907 void smb_kmod_enum_fini(smb_netsvc_t *);
894 908 int smb_kmod_session_close(const char *, const char *);
895 909 int smb_kmod_file_close(uint32_t);
896 910 int smb_kmod_get_spool_doc(uint32_t *, char *, char *, smb_inaddr_t *);
897 911
898 912 void smb_name_parse(char *, char **, char **);
899 913 uint32_t smb_name_validate_share(const char *);
900 914 uint32_t smb_name_validate_account(const char *);
901 915 uint32_t smb_name_validate_domain(const char *);
902 916 uint32_t smb_name_validate_nbdomain(const char *);
903 917 uint32_t smb_name_validate_workgroup(const char *);
904 918 uint32_t smb_name_validate_rpath(const char *);
905 919
906 920 /*
907 921 * Interposer library validation
908 922 */
909 923 #define SMBEX_VERSION 1
910 924 #define SMBEX_KEY "82273fdc-e32a-18c3-3f78-827929dc23ea"
911 925 typedef struct smbex_version {
912 926 uint32_t v_version;
913 927 uuid_t v_uuid;
914 928 } smbex_version_t;
915 929 void *smb_dlopen(void);
916 930 void smb_dlclose(void *);
917 931
918 932 /*
919 933 * General purpose multi-thread safe cache based on
920 934 * AVL tree
921 935 */
922 936 typedef struct smb_cache {
923 937 avl_tree_t ch_cache;
924 938 rwlock_t ch_cache_lck;
925 939 uint32_t ch_state;
926 940 uint32_t ch_nops;
927 941 uint32_t ch_wait;
928 942 uint32_t ch_sequence;
929 943 size_t ch_datasz;
930 944 mutex_t ch_mtx;
931 945 cond_t ch_cv;
932 946 void (*ch_free)(void *);
933 947 void (*ch_copy)(const void *, void *, size_t);
934 948 } smb_cache_t;
935 949
936 950 typedef struct smb_cache_node {
937 951 avl_node_t cn_link;
938 952 void *cn_data;
939 953 } smb_cache_node_t;
940 954
941 955 typedef struct smb_cache_cursor {
942 956 void *cc_next;
943 957 uint32_t cc_sequence;
944 958 } smb_cache_cursor_t;
945 959
946 960 /*
947 961 * flags used with smb_cache_add()
948 962 *
949 963 * SMB_CACHE_ADD If object doesn't exist add, otherwise fail
950 964 * SMB_CACHE_REPLACE If object doesn't exist add, otherwise replace
951 965 */
952 966 #define SMB_CACHE_ADD 1
953 967 #define SMB_CACHE_REPLACE 2
954 968
955 969 void smb_cache_create(smb_cache_t *, uint32_t,
956 970 int (*cmpfn) (const void *, const void *), void (*freefn)(void *),
957 971 void (*copyfn)(const void *, void *, size_t), size_t);
958 972 void smb_cache_destroy(smb_cache_t *);
959 973 void smb_cache_flush(smb_cache_t *);
960 974 uint32_t smb_cache_num(smb_cache_t *);
961 975 int smb_cache_refreshing(smb_cache_t *);
962 976 void smb_cache_ready(smb_cache_t *);
963 977 int smb_cache_add(smb_cache_t *, const void *, int);
964 978 void smb_cache_remove(smb_cache_t *, const void *);
965 979 void smb_cache_iterinit(smb_cache_t *, smb_cache_cursor_t *);
966 980 boolean_t smb_cache_iterate(smb_cache_t *, smb_cache_cursor_t *, void *);
967 981
968 982 /*
969 983 * Values returned by smb_reparse_stat()
970 984 */
971 985 #define SMB_REPARSE_NOTFOUND 1 /* object does not exist */
972 986 #define SMB_REPARSE_NOTREPARSE 2 /* object is NOT a reparse point */
973 987 #define SMB_REPARSE_ISREPARSE 3 /* object is a reparse point */
974 988
975 989 /*
976 990 * Reparse Point API
977 991 */
978 992 int smb_reparse_stat(const char *, uint32_t *);
979 993 int smb_reparse_svcadd(const char *, const char *, const char *);
980 994 int smb_reparse_svcdel(const char *, const char *);
981 995 int smb_reparse_svcget(const char *, const char *, char **);
982 996
983 997 uint32_t smb_get_txid(void);
984 998
985 999 void smb_syslog(int, const char *, ...);
986 1000 void smb_vsyslog(int, const char *, va_list ap);
987 1001 char *smb_syslog_fmt_m(char *, int, const char *, int);
988 1002
989 1003 #ifdef __cplusplus
990 1004 }
991 1005 #endif
992 1006
993 1007 #endif /* _LIBSMB_H */
|
↓ open down ↓ |
123 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX