1 /* 2 * CDDL HEADER START 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 2008 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 /* 27 * Structures and type definitions for the SMB module. 28 */ 29 30 #ifndef _SMBSRV_SMB_KTYPES_H 31 #define _SMBSRV_SMB_KTYPES_H 32 33 #ifdef __cplusplus 34 extern "C" { 35 #endif 36 37 #include <sys/note.h> 38 #include <sys/systm.h> 39 #include <sys/param.h> 40 #include <sys/types.h> 41 #include <sys/synch.h> 42 #include <sys/taskq.h> 43 #include <sys/socket.h> 44 #include <sys/acl.h> 45 #include <sys/sdt.h> 46 #include <sys/stat.h> 47 #include <sys/vnode.h> 48 #include <sys/cred.h> 49 #include <sys/fem.h> 50 #include <sys/door.h> 51 #include <smbsrv/smb.h> 52 #include <smbsrv/smbinfo.h> 53 #include <smbsrv/mbuf.h> 54 #include <smbsrv/smb_sid.h> 55 #include <smbsrv/smb_xdr.h> 56 #include <smbsrv/netbios.h> 57 #include <smbsrv/smb_vops.h> 58 #include <smbsrv/mlsvc.h> 59 60 struct smb_request; 61 struct smb_server; 62 struct smb_sd; 63 64 int smb_noop(void *, size_t, int); 65 66 #define SMB_AUDIT_STACK_DEPTH 16 67 #define SMB_AUDIT_BUF_MAX_REC 16 68 #define SMB_AUDIT_NODE 0x00000001 69 70 /* 71 * Maximum number of records returned in SMBsearch, SMBfind 72 * and SMBfindunique response. Value set to 10 for compatibility 73 * with Windows. 74 */ 75 #define SMB_MAX_SEARCH 10 76 77 #define SMB_SEARCH_HIDDEN(sattr) ((sattr) & FILE_ATTRIBUTE_HIDDEN) 78 #define SMB_SEARCH_SYSTEM(sattr) ((sattr) & FILE_ATTRIBUTE_SYSTEM) 79 #define SMB_SEARCH_DIRECTORY(sattr) ((sattr) & FILE_ATTRIBUTE_DIRECTORY) 80 81 82 extern uint32_t smb_audit_flags; 83 84 typedef struct { 85 uint32_t anr_refcnt; 86 int anr_depth; 87 pc_t anr_stack[SMB_AUDIT_STACK_DEPTH]; 88 } smb_audit_record_node_t; 89 90 typedef struct { 91 int anb_index; 92 int anb_max_index; 93 smb_audit_record_node_t anb_records[SMB_AUDIT_BUF_MAX_REC]; 94 } smb_audit_buf_node_t; 95 96 #define SMB_WORKER_PRIORITY 99 97 /* 98 * Thread State Machine 99 * -------------------- 100 * 101 * T5 T0 102 * smb_thread_destroy() <-------+ +------- smb_thread_init() 103 * | | 104 * | v 105 * +-----------------------------+ 106 * | SMB_THREAD_STATE_EXITED |<---+ 107 * +-----------------------------+ | 108 * | T1 | 109 * v | 110 * +-----------------------------+ | 111 * | SMB_THREAD_STATE_STARTING | | 112 * +-----------------------------+ | 113 * | T2 | T4 114 * v | 115 * +-----------------------------+ | 116 * | SMB_THREAD_STATE_RUNNING | | 117 * +-----------------------------+ | 118 * | T3 | 119 * v | 120 * +-----------------------------+ | 121 * | SMB_THREAD_STATE_EXITING |----+ 122 * +-----------------------------+ 123 * 124 * Transition T0 125 * 126 * This transition is executed in smb_thread_init(). 127 * 128 * Transition T1 129 * 130 * This transition is executed in smb_thread_start(). 131 * 132 * Transition T2 133 * 134 * This transition is executed by the thread itself when it starts running. 135 * 136 * Transition T3 137 * 138 * This transition is executed by the thread itself in 139 * smb_thread_entry_point() just before calling thread_exit(). 140 * 141 * 142 * Transition T4 143 * 144 * This transition is executed in smb_thread_stop(). 145 * 146 * Transition T5 147 * 148 * This transition is executed in smb_thread_destroy(). 149 * 150 * Comments 151 * -------- 152 * 153 * The field smb_thread_aw_t contains a function pointer that knows how to 154 * awake the thread. It is a temporary solution to work around the fact that 155 * kernel threads (not part of a userspace process) cannot be signaled. 156 */ 157 typedef enum smb_thread_state { 158 SMB_THREAD_STATE_STARTING = 0, 159 SMB_THREAD_STATE_RUNNING, 160 SMB_THREAD_STATE_EXITING, 161 SMB_THREAD_STATE_EXITED 162 } smb_thread_state_t; 163 164 struct _smb_thread; 165 166 typedef void (*smb_thread_ep_t)(struct _smb_thread *, void *ep_arg); 167 typedef void (*smb_thread_aw_t)(struct _smb_thread *, void *aw_arg); 168 169 #define SMB_THREAD_MAGIC 0x534D4254 /* SMBT */ 170 171 typedef struct _smb_thread { 172 uint32_t sth_magic; 173 char sth_name[16]; 174 smb_thread_state_t sth_state; 175 kthread_t *sth_th; 176 kt_did_t sth_did; 177 smb_thread_ep_t sth_ep; 178 void *sth_ep_arg; 179 smb_thread_aw_t sth_aw; 180 void *sth_aw_arg; 181 boolean_t sth_kill; 182 kmutex_t sth_mtx; 183 kcondvar_t sth_cv; 184 } smb_thread_t; 185 186 /* 187 * Pool of IDs 188 * ----------- 189 * 190 * A pool of IDs is a pool of 16 bit numbers. It is implemented as a bitmap. 191 * A bit set to '1' indicates that that particular value has been allocated. 192 * The allocation process is done shifting a bit through the whole bitmap. 193 * The current position of that index bit is kept in the smb_idpool_t 194 * structure and represented by a byte index (0 to buffer size minus 1) and 195 * a bit index (0 to 7). 196 * 197 * The pools start with a size of 8 bytes or 64 IDs. Each time the pool runs 198 * out of IDs its current size is doubled until it reaches its maximum size 199 * (8192 bytes or 65536 IDs). The IDs 0 and 65535 are never given out which 200 * means that a pool can have a maximum number of 65534 IDs available. 201 */ 202 #define SMB_IDPOOL_MAGIC 0x4944504C /* IDPL */ 203 #define SMB_IDPOOL_MIN_SIZE 64 /* Number of IDs to begin with */ 204 #define SMB_IDPOOL_MAX_SIZE 64 * 1024 205 206 typedef struct smb_idpool { 207 uint32_t id_magic; 208 kmutex_t id_mutex; 209 uint8_t *id_pool; 210 uint32_t id_size; 211 uint8_t id_bit; 212 uint8_t id_bit_idx; 213 uint32_t id_idx; 214 uint32_t id_idx_msk; 215 uint32_t id_free_counter; 216 uint32_t id_max_free_counter; 217 } smb_idpool_t; 218 219 /* 220 * Maximum size of a Transport Data Unit 221 * 4 --> NBT/TCP Transport Header. 222 * 32 --> SMB Header 223 * 1 --> Word Count byte 224 * 510 --> Maximum Number of bytes of the Word Table (2 * 255) 225 * 2 --> Byte count of the data 226 * 65535 --> Maximum size of the data 227 * ----- 228 * 66084 229 */ 230 #define SMB_REQ_MAX_SIZE 66080 231 #define SMB_XPRT_MAX_SIZE (SMB_REQ_MAX_SIZE + NETBIOS_HDR_SZ) 232 233 #define SMB_TXREQ_MAGIC 0X54524251 /* 'TREQ' */ 234 typedef struct { 235 uint32_t tr_magic; 236 list_node_t tr_lnd; 237 int tr_len; 238 uint8_t tr_buf[SMB_XPRT_MAX_SIZE]; 239 } smb_txreq_t; 240 241 #define SMB_TXLST_MAGIC 0X544C5354 /* 'TLST' */ 242 typedef struct { 243 uint32_t tl_magic; 244 kmutex_t tl_mutex; 245 boolean_t tl_active; 246 list_t tl_list; 247 } smb_txlst_t; 248 249 /* 250 * Maximum buffer size for NT is 37KB. If all clients are Windows 2000, this 251 * can be changed to 64KB. 37KB must be used with a mix of NT/Windows 2000 252 * clients because NT loses directory entries when values greater than 37KB are 253 * used. 254 * 255 * Note: NBT_MAXBUF will be subtracted from the specified max buffer size to 256 * account for the NBT header. 257 */ 258 #define NBT_MAXBUF 8 259 #define SMB_NT_MAXBUF (37 * 1024) 260 261 #define OUTBUFSIZE (65 * 1024) 262 #define SMBHEADERSIZE 32 263 #define SMBND_HASH_MASK (0xFF) 264 #define MAX_IOVEC 512 265 #define MAX_READREF (8 * 1024) 266 267 #define SMB_WORKER_MIN 4 268 #define SMB_WORKER_DEFAULT 64 269 #define SMB_WORKER_MAX 1024 270 271 /* 272 * Fix align a pointer or offset appropriately so that fields will not 273 * cross word boundaries. 274 */ 275 #define PTRALIGN(x) \ 276 (((uintptr_t)(x) + (uintptr_t)(_POINTER_ALIGNMENT) - 1l) & \ 277 ~((uintptr_t)(_POINTER_ALIGNMENT) - 1l)) 278 279 /* 280 * native os types are defined in win32/smbinfo.h 281 */ 282 283 /* 284 * All 4 different time / date formats that will bee seen in SMB 285 */ 286 typedef struct { 287 uint16_t Day : 5; 288 uint16_t Month : 4; 289 uint16_t Year : 7; 290 } SMB_DATE; 291 292 typedef struct { 293 uint16_t TwoSeconds : 5; 294 uint16_t Minutes : 6; 295 uint16_t Hours : 5; 296 } SMB_TIME; 297 298 299 typedef uint32_t UTIME; /* seconds since Jan 1 1970 */ 300 301 typedef struct smb_malloc_list { 302 struct smb_malloc_list *forw; 303 struct smb_malloc_list *back; 304 } smb_malloc_list; 305 306 typedef struct smb_llist { 307 krwlock_t ll_lock; 308 list_t ll_list; 309 uint32_t ll_count; 310 uint64_t ll_wrop; 311 } smb_llist_t; 312 313 typedef struct smb_slist { 314 kmutex_t sl_mutex; 315 kcondvar_t sl_cv; 316 list_t sl_list; 317 uint32_t sl_count; 318 boolean_t sl_waiting; 319 } smb_slist_t; 320 321 typedef struct smb_session_list { 322 krwlock_t se_lock; 323 uint64_t se_wrop; 324 struct { 325 list_t lst; 326 uint32_t count; 327 } se_rdy; 328 struct { 329 list_t lst; 330 uint32_t count; 331 } se_act; 332 } smb_session_list_t; 333 334 typedef struct { 335 kcondvar_t rwx_cv; 336 kmutex_t rwx_mutex; 337 krwlock_t rwx_lock; 338 boolean_t rwx_waiting; 339 } smb_rwx_t; 340 341 /* NOTIFY CHANGE */ 342 343 typedef struct smb_notify_change_req { 344 list_node_t nc_lnd; 345 struct smb_node *nc_node; 346 uint32_t nc_reply_type; 347 uint32_t nc_flags; 348 } smb_notify_change_req_t; 349 350 /* 351 * SMB operates over a NetBIOS-over-TCP transport (NBT) or directly 352 * over TCP, which is also known as direct hosted NetBIOS-less SMB 353 * or SMB-over-TCP. 354 * 355 * NBT messages have a 4-byte header that defines the message type 356 * (8-bits), a 7-bit flags field and a 17-bit length. 357 * 358 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 359 * | TYPE | FLAGS |E| LENGTH | 360 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 361 * 362 * 8-bit type Defined in RFC 1002 363 * 7-bit flags Bits 0-6 reserved (must be 0) 364 * Bit 7: Length extension bit (E) 365 * 17-bit length Includes bit 7 of the flags byte 366 * 367 * 368 * SMB-over-TCP is defined to use a modified version of the NBT header 369 * containing an 8-bit message type and 24-bit message length. 370 * 371 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 372 * | TYPE | LENGTH | 373 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 374 * 375 * 8-bit type Must be 0 376 * 24-bit length 377 * 378 * The following structure is used to represent a generic, in-memory 379 * SMB transport header; it is not intended to map directly to either 380 * of the over-the-wire formats. 381 */ 382 typedef struct { 383 uint8_t xh_type; 384 uint32_t xh_length; 385 } smb_xprt_t; 386 387 int MBC_LENGTH(struct mbuf_chain *); 388 int MBC_MAXBYTES(struct mbuf_chain *); 389 void MBC_SETUP(struct mbuf_chain *, uint32_t); 390 void MBC_INIT(struct mbuf_chain *, uint32_t); 391 void MBC_FLUSH(struct mbuf_chain *); 392 void MBC_ATTACH_MBUF(struct mbuf_chain *, struct mbuf *); 393 void MBC_APPEND_MBUF(struct mbuf_chain *, struct mbuf *); 394 void MBC_ATTACH_BUF(struct mbuf_chain *MBC, unsigned char *BUF, int LEN); 395 int MBC_SHADOW_CHAIN(struct mbuf_chain *SUBMBC, struct mbuf_chain *MBC, 396 int OFF, int LEN); 397 398 #define MBC_ROOM_FOR(b, n) (((b)->chain_offset + (n)) <= (b)->max_bytes) 399 400 typedef struct smb_oplock { 401 struct smb_ofile *op_ofile; 402 uint32_t op_flags; 403 uint32_t op_ipaddr; 404 uint64_t op_kid; 405 } smb_oplock_t; 406 407 #define OPLOCK_FLAG_BREAKING 1 408 409 #define OPLOCK_RELEASE_LOCK_RELEASED 0 410 #define OPLOCK_RELEASE_FILE_CLOSED 1 411 412 #define DOS_ATTR_VALID 0x80000000 413 414 #define SMB_VFS_MAGIC 0x534D4256 /* 'SMBV' */ 415 416 typedef struct smb_vfs { 417 uint32_t sv_magic; 418 list_node_t sv_lnd; 419 uint32_t sv_refcnt; 420 vfs_t *sv_vfsp; 421 vnode_t *sv_rootvp; 422 } smb_vfs_t; 423 424 typedef struct smb_unexport { 425 list_node_t ux_lnd; 426 char ux_sharename[MAXNAMELEN]; 427 } smb_unexport_t; 428 429 #define SMB_NODE_MAGIC 0x4E4F4445 /* 'NODE' */ 430 431 typedef enum { 432 SMB_NODE_STATE_AVAILABLE = 0, 433 SMB_NODE_STATE_DESTROYING 434 } smb_node_state_t; 435 436 typedef struct smb_node { 437 uint32_t n_magic; 438 smb_rwx_t n_lock; 439 krwlock_t n_share_lock; 440 list_node_t n_lnd; 441 smb_node_state_t n_state; 442 uint32_t n_refcnt; 443 uint32_t n_hashkey; 444 struct smb_request *n_sr; 445 kmem_cache_t *n_cache; 446 smb_llist_t *n_hash_bucket; 447 uint64_t n_orig_session_id; 448 uint32_t n_orig_uid; 449 smb_llist_t n_ofile_list; 450 smb_llist_t n_lock_list; 451 struct smb_ofile *readonly_creator; 452 volatile int flags; /* FILE_NOTIFY_CHANGE_* */ 453 volatile int waiting_event; /* # of clients requesting FCN */ 454 smb_attr_t attr; 455 unsigned int what; 456 u_offset_t n_size; 457 smb_oplock_t n_oplock; 458 struct smb_node *dir_snode; /* Directory of node */ 459 struct smb_node *unnamed_stream_node; /* set in stream nodes */ 460 /* Credentials for delayed delete */ 461 cred_t *delete_on_close_cred; 462 char od_name[MAXNAMELEN]; 463 vnode_t *vp; 464 smb_audit_buf_node_t *n_audit_buf; 465 } smb_node_t; 466 467 #define NODE_FLAGS_NOTIFY_CHANGE 0x10000fff 468 #define NODE_OPLOCKS_IN_FORCE 0x0000f000 469 #define NODE_OPLOCK_NONE 0x00000000 470 #define NODE_EXCLUSIVE_OPLOCK 0x00001000 471 #define NODE_BATCH_OPLOCK 0x00002000 472 #define NODE_LEVEL_II_OPLOCK 0x00003000 473 #define NODE_CAP_LEVEL_II 0x00010000 474 #define NODE_PROTOCOL_LOCK 0x00020000 475 #define NODE_FLAGS_WRITE_THROUGH 0x00100000 476 #define NODE_FLAGS_SYNCATIME 0x00200000 477 #define NODE_FLAGS_LOCKED 0x00400000 478 #define NODE_FLAGS_ATTR_VALID 0x00800000 479 #define NODE_XATTR_DIR 0x01000000 480 #define NODE_FLAGS_CREATED 0x04000000 481 #define NODE_FLAGS_CHANGED 0x08000000 482 #define NODE_FLAGS_WATCH_TREE 0x10000000 483 #define NODE_FLAGS_SET_SIZE 0x20000000 484 #define NODE_FLAGS_DELETE_ON_CLOSE 0x40000000 485 #define NODE_FLAGS_EXECUTABLE 0x80000000 486 487 #define OPLOCK_TYPE(n) ((n)->flags & NODE_OPLOCKS_IN_FORCE) 488 #define OPLOCKS_IN_FORCE(n) (OPLOCK_TYPE(n) != NODE_OPLOCK_NONE) 489 #define EXCLUSIVE_OPLOCK_IN_FORCE(n) \ 490 (OPLOCK_TYPE(n) == NODE_EXCLUSIVE_OPLOCK) 491 #define BATCH_OPLOCK_IN_FORCE(n) (OPLOCK_TYPE(n) == NODE_BATCH_OPLOCK) 492 #define LEVEL_II_OPLOCK_IN_FORCE(n) (OPLOCK_TYPE(n) == NODE_LEVEL_II_OPLOCK) 493 494 #define SMB_NODE_VFS(node) ((node)->vp->v_vfsp) 495 #define SMB_NODE_FSID(node) ((node)->vp->v_vfsp->vfs_fsid) 496 497 /* 498 * Based on section 2.6.1.2 (Connection Management) of the June 13, 499 * 1996 CIFS spec, a server may terminate the transport connection 500 * due to inactivity. The client software is expected to be able to 501 * automatically reconnect to the server if this happens. Like much 502 * of the useful background information, this section appears to 503 * have been dropped from later revisions of the document. 504 * 505 * Each session has an activity timestamp that's updated whenever a 506 * request is dispatched. If the session is idle, i.e. receives no 507 * requests, for SMB_SESSION_INACTIVITY_TIMEOUT minutes it will be 508 * closed. 509 * 510 * Each session has an I/O semaphore to serialize communication with 511 * the client. For example, after receiving a raw-read request, the 512 * server is not allowed to send an oplock break to the client until 513 * after it has sent the raw-read data. 514 */ 515 #define SMB_SESSION_INACTIVITY_TIMEOUT (15 * 60) 516 517 #define SMB_SESSION_OFILE_MAX (16 * 1024) 518 519 /* 520 * When a connection is set up we need to remember both the client 521 * (peer) IP address and the local IP address used to establish the 522 * connection. When a client connects with a vc number of zero, we 523 * are supposed to abort any existing connections with that client 524 * (see notes in smb_negotiate.c and smb_session_setup_andx.c). For 525 * servers with multiple network interfaces or IP aliases, however, 526 * each interface has to be managed independently since the client 527 * is not aware of the server configuration. We have to allow the 528 * client to establish a connection on each interface with a vc 529 * number of zero without aborting the other connections. 530 * 531 * ipaddr: the client (peer) IP address for the session. 532 * local_ipaddr: the local IP address used to connect to the server. 533 */ 534 535 #define SMB_MAC_KEYSZ 512 536 537 struct smb_sign { 538 unsigned int seqnum; 539 unsigned int mackey_len; 540 unsigned int flags; 541 unsigned char mackey[SMB_MAC_KEYSZ]; 542 }; 543 544 #define SMB_SIGNING_ENABLED 1 545 #define SMB_SIGNING_CHECK 2 546 547 /* 548 * Session State Machine 549 * --------------------- 550 * 551 * +-----------------------------+ +------------------------------+ 552 * | SMB_SESSION_STATE_CONNECTED | | SMB_SESSION_STATE_TERMINATED | 553 * +-----------------------------+ +------------------------------+ 554 * T0| ^ 555 * +--------------------+ |T13 556 * v |T14 | 557 * +-------------------------------+ | +--------------------------------+ 558 * | SMB_SESSION_STATE_ESTABLISHED |---+--->| SMB_SESSION_STATE_DISCONNECTED | 559 * +-------------------------------+ +--------------------------------+ 560 * T1| ^ ^ ^ ^ 561 * +----------+ |T9 | | | 562 * v | | | | 563 * +------------------------------+ | | | 564 * | SMB_SESSION_STATE_NEGOTIATED | | | | 565 * +------------------------------+ | | | 566 * ^| ^| | ^ | | | 567 * +----------------+| || | | | | | 568 * |+----------------+ || T7| |T8 | | | 569 * || || | | | | | 570 * || +----------------+| | | | | | 571 * || |+----------------+ | | | | | 572 * || || v | | | | 573 * || || +-----------------------------------+ T10| | | 574 * || || | SMB_SESSION_STATE_OPLOCK_BREAKING |----+ | | 575 * || || +-----------------------------------+ | | 576 * || ||T5 | | 577 * || |+-->+-----------------------------------+ T11| | 578 * || |T6 | SMB_SESSION_STATE_READ_RAW_ACTIVE |------+ | 579 * || +----+-----------------------------------+ | 580 * ||T3 | 581 * |+------->+------------------------------------+ T12| 582 * |T4 | SMB_SESSION_STATE_WRITE_RAW_ACTIVE |-------+ 583 * +---------+------------------------------------+ 584 * 585 * Transition T0 586 * 587 * 588 * 589 * Transition T1 590 * 591 * 592 * 593 * Transition T2 594 * 595 * 596 * 597 * Transition T3 598 * 599 * 600 * 601 * Transition T4 602 * 603 * 604 * 605 * Transition T5 606 * 607 * 608 * 609 * Transition T6 610 * 611 * 612 * 613 * Transition T7 614 * 615 * 616 * 617 * Transition T8 618 * 619 * 620 * 621 * Transition T9 622 * 623 * 624 * 625 * Transition T10 626 * 627 * 628 * 629 * Transition T11 630 * 631 * 632 * 633 * Transition T12 634 * 635 * 636 * 637 * Transition T13 638 * 639 * 640 * 641 * Transition T14 642 * 643 * 644 * 645 */ 646 #define SMB_SESSION_MAGIC 0x53455353 /* 'SESS' */ 647 648 typedef enum { 649 SMB_SESSION_STATE_INITIALIZED = 0, 650 SMB_SESSION_STATE_DISCONNECTED, 651 SMB_SESSION_STATE_CONNECTED, 652 SMB_SESSION_STATE_ESTABLISHED, 653 SMB_SESSION_STATE_NEGOTIATED, 654 SMB_SESSION_STATE_OPLOCK_BREAKING, 655 SMB_SESSION_STATE_WRITE_RAW_ACTIVE, 656 SMB_SESSION_STATE_TERMINATED, 657 SMB_SESSION_STATE_SENTINEL 658 } smb_session_state_t; 659 660 typedef struct smb_session { 661 uint32_t s_magic; 662 smb_rwx_t s_lock; 663 list_node_t s_lnd; 664 uint64_t s_kid; 665 smb_session_state_t s_state; 666 uint32_t s_flags; 667 int s_write_raw_status; 668 kthread_t *s_thread; 669 kt_did_t s_ktdid; 670 smb_kmod_cfg_t s_cfg; 671 kmem_cache_t *s_cache; 672 kmem_cache_t *s_cache_request; 673 struct smb_server *s_server; 674 int32_t s_gmtoff; 675 uint32_t keep_alive; 676 uint64_t opentime; 677 uint16_t vcnumber; 678 uint16_t s_local_port; 679 uint32_t ipaddr; 680 uint32_t local_ipaddr; 681 char workstation[SMB_PI_MAX_HOST]; 682 int dialect; 683 int native_os; 684 uint32_t capabilities; 685 struct smb_sign signing; 686 687 struct sonode *sock; 688 689 smb_slist_t s_req_list; 690 smb_llist_t s_xa_list; 691 smb_llist_t s_user_list; 692 smb_idpool_t s_uid_pool; 693 smb_txlst_t s_txlst; 694 695 volatile uint32_t s_tree_cnt; 696 volatile uint32_t s_file_cnt; 697 volatile uint32_t s_dir_cnt; 698 699 uint16_t secmode; 700 uint32_t sesskey; 701 uint32_t challenge_len; 702 unsigned char challenge_key[8]; 703 unsigned char MAC_key[44]; 704 int64_t activity_timestamp; 705 /* 706 * Maximum negotiated buffer size between SMB client and server 707 * in SMB_SESSION_SETUP_ANDX 708 */ 709 uint16_t smb_msg_size; 710 uchar_t *outpipe_data; 711 int outpipe_datalen; 712 int outpipe_cookie; 713 } smb_session_t; 714 715 #define SMB_USER_MAGIC 0x55534552 /* 'USER' */ 716 717 #define SMB_USER_FLAG_GUEST SMB_ATF_GUEST 718 #define SMB_USER_FLAG_IPC SMB_ATF_ANON 719 #define SMB_USER_FLAG_ADMIN SMB_ATF_ADMIN 720 #define SMB_USER_FLAG_POWER_USER SMB_ATF_POWERUSER 721 #define SMB_USER_FLAG_BACKUP_OPERATOR SMB_ATF_BACKUPOP 722 723 #define SMB_USER_PRIV_TAKE_OWNERSHIP 0x00000001 724 #define SMB_USER_PRIV_BACKUP 0x00000002 725 #define SMB_USER_PRIV_RESTORE 0x00000004 726 #define SMB_USER_PRIV_SECURITY 0x00000008 727 728 729 typedef enum { 730 SMB_USER_STATE_LOGGED_IN = 0, 731 SMB_USER_STATE_LOGGING_OFF, 732 SMB_USER_STATE_LOGGED_OFF, 733 SMB_USER_STATE_SENTINEL 734 } smb_user_state_t; 735 736 typedef struct smb_user { 737 uint32_t u_magic; 738 list_node_t u_lnd; 739 kmutex_t u_mutex; 740 smb_user_state_t u_state; 741 742 struct smb_server *u_server; 743 smb_session_t *u_session; 744 uint16_t u_name_len; 745 char *u_name; 746 uint16_t u_domain_len; 747 char *u_domain; 748 time_t u_logon_time; 749 cred_t *u_cred; 750 751 smb_llist_t u_tree_list; 752 smb_idpool_t u_tid_pool; 753 754 uint32_t u_refcnt; 755 uint32_t u_flags; 756 uint32_t u_privileges; 757 uint16_t u_uid; 758 uint32_t u_audit_sid; 759 } smb_user_t; 760 761 #define SMB_TREE_MAGIC 0x54524545 /* 'TREE' */ 762 763 #define SMB_TYPENAMELEN _ST_FSTYPSZ 764 #define SMB_VOLNAMELEN 32 765 766 #define SMB_TREE_READONLY 0x00000001 767 #define SMB_TREE_SUPPORTS_ACLS 0x00000002 768 #define SMB_TREE_STREAMS 0x00000004 769 #define SMB_TREE_CASEINSENSITIVE 0x00000008 770 #define SMB_TREE_NO_CASESENSITIVE 0x00000010 771 #define SMB_TREE_NO_EXPORT 0x00000020 772 #define SMB_TREE_NO_OPLOCKS 0x00000040 773 #define SMB_TREE_NO_ATIME 0x00000080 774 #define SMB_TREE_XVATTR 0x00000100 775 #define SMB_TREE_DIRENTFLAGS 0x00000200 776 #define SMB_TREE_ACLONCREATE 0x00000400 777 #define SMB_TREE_ACEMASKONACCESS 0x00000800 778 #define SMB_TREE_NFS_MOUNTED 0x00001000 779 780 /* 781 * Currently, the VFSFT_XVATTR feature is defined for file systems 782 * which understand the xvattr_t interface as well as for file systems 783 * which do not, but which understand the system attribute "view" interface. 784 * Since we need to be able to differentiate between these two for UFS, 785 * for now we use SMB_TREE_UFS so that we do the right thing. 786 */ 787 788 #define SMB_TREE_UFS 0x00002000 789 790 typedef enum { 791 SMB_TREE_STATE_CONNECTED = 0, 792 SMB_TREE_STATE_DISCONNECTING, 793 SMB_TREE_STATE_DISCONNECTED, 794 SMB_TREE_STATE_SENTINEL 795 } smb_tree_state_t; 796 797 typedef struct smb_tree { 798 uint32_t t_magic; 799 kmutex_t t_mutex; 800 list_node_t t_lnd; 801 smb_tree_state_t t_state; 802 803 struct smb_server *t_server; 804 smb_session_t *t_session; 805 smb_user_t *t_user; 806 smb_node_t *t_snode; 807 808 smb_llist_t t_ofile_list; 809 smb_idpool_t t_fid_pool; 810 811 smb_llist_t t_odir_list; 812 smb_idpool_t t_sid_pool; 813 814 uint32_t t_refcnt; 815 uint32_t t_flags; 816 int32_t t_res_type; 817 uint16_t t_tid; 818 uint16_t t_umask; 819 char t_sharename[MAXNAMELEN]; 820 char t_resource[MAXPATHLEN]; 821 char t_typename[SMB_TYPENAMELEN]; 822 char t_volume[SMB_VOLNAMELEN]; 823 acl_type_t t_acltype; 824 } smb_tree_t; 825 826 #define SMB_TREE_VFS(tree) ((tree)->t_snode->vp->v_vfsp) 827 #define SMB_TREE_FSID(tree) ((tree)->t_snode->vp->v_vfsp->vfs_fsid) 828 829 #define SMB_TREE_IS_READONLY(sr) \ 830 (((sr) && (sr)->tid_tree) ? \ 831 smb_tree_has_feature((sr)->tid_tree, SMB_TREE_READONLY) : 0) 832 833 #define SMB_TREE_IS_CASEINSENSITIVE(sr) \ 834 (((sr) && (sr)->tid_tree) ? \ 835 smb_tree_has_feature((sr)->tid_tree, SMB_TREE_CASEINSENSITIVE) : 0) 836 837 /* 838 * SMB_TREE_CONTAINS_NODE is used to check that a node is in the same 839 * file system as the tree. 840 */ 841 #define SMB_TREE_CONTAINS_NODE(sr, node) \ 842 (((sr) && (sr)->tid_tree) ? \ 843 (SMB_TREE_VFS((sr)->tid_tree) == SMB_NODE_VFS(node)) : 1) 844 845 /* 846 * SMB_NODE_IS_READONLY(node) 847 * 848 * This macro indicates whether the DOS readonly bit is set in the node's 849 * attribute cache. The cache reflects what is on-disk. 850 */ 851 852 #define SMB_NODE_IS_READONLY(node) \ 853 ((node) && (node)->attr.sa_dosattr & FILE_ATTRIBUTE_READONLY) 854 855 /* 856 * SMB_OFILE_IS_READONLY reflects whether an ofile is readonly or not. 857 * The macro takes into account 858 * - the tree readonly state 859 * - the node readonly state 860 * - whether the specified ofile is the readonly creator 861 * The readonly creator has write permission until the ofile is closed. 862 */ 863 864 #define SMB_OFILE_IS_READONLY(of) \ 865 (((of)->f_flags & SMB_OFLAGS_READONLY) || \ 866 SMB_NODE_IS_READONLY((of)->f_node) || \ 867 (((of)->f_node->readonly_creator) && \ 868 ((of)->f_node->readonly_creator != (of)))) 869 870 /* 871 * SMB_PATHFILE_IS_READONLY indicates whether or not a file is 872 * readonly when the caller has a path rather than an ofile. Unlike 873 * SMB_OFILE_IS_READONLY, the caller cannot be the readonly creator, 874 * since that requires an ofile. 875 */ 876 877 #define SMB_PATHFILE_IS_READONLY(sr, node) \ 878 (SMB_TREE_IS_READONLY((sr)) || \ 879 SMB_NODE_IS_READONLY((node)) || \ 880 ((node)->readonly_creator)) 881 882 #define PIPE_STATE_AUTH_VERIFY 0x00000001 883 884 /* 885 * Data structure for SMB_FTYPE_MESG_PIPE ofiles, which is used 886 * at the interface between SMB and NDR RPC. 887 */ 888 typedef struct smb_opipe { 889 kmutex_t p_mutex; 890 kcondvar_t p_cv; 891 char *p_name; 892 uint32_t p_busy; 893 smb_opipe_hdr_t p_hdr; 894 smb_opipe_context_t p_context; 895 uint8_t *p_doorbuf; 896 uint8_t *p_data; 897 } smb_opipe_t; 898 899 /* 900 * The of_ftype of an open file should contain the SMB_FTYPE value 901 * (cifs.h) returned when the file/pipe was opened. The following 902 * assumptions are currently made: 903 * 904 * File Type Node PipeInfo 905 * --------- -------- -------- 906 * SMB_FTYPE_DISK Valid Null 907 * SMB_FTYPE_BYTE_PIPE Undefined Undefined 908 * SMB_FTYPE_MESG_PIPE Null Valid 909 * SMB_FTYPE_PRINTER Undefined Undefined 910 * SMB_FTYPE_UNKNOWN Undefined Undefined 911 */ 912 913 /* 914 * Some flags for ofile structure 915 * 916 * SMB_OFLAGS_SET_DELETE_ON_CLOSE 917 * Set this flag when the corresponding open operation whose 918 * DELETE_ON_CLOSE bit of the CreateOptions is set. If any 919 * open file instance has this bit set, the NODE_FLAGS_DELETE_ON_CLOSE 920 * will be set for the file node upon close. 921 */ 922 923 #define SMB_OFLAGS_READONLY 0x0001 924 #define SMB_OFLAGS_SET_DELETE_ON_CLOSE 0x0004 925 #define SMB_OFLAGS_LLF_POS_VALID 0x0008 926 927 #define SMB_OFILE_MAGIC 0x4F464C45 /* 'OFLE' */ 928 929 typedef enum { 930 SMB_OFILE_STATE_OPEN = 0, 931 SMB_OFILE_STATE_CLOSING, 932 SMB_OFILE_STATE_CLOSED, 933 SMB_OFILE_STATE_SENTINEL 934 } smb_ofile_state_t; 935 936 typedef struct smb_ofile { 937 uint32_t f_magic; 938 kmutex_t f_mutex; 939 list_node_t f_lnd; 940 list_node_t f_nnd; 941 smb_ofile_state_t f_state; 942 943 struct smb_server *f_server; 944 smb_session_t *f_session; 945 smb_user_t *f_user; 946 smb_tree_t *f_tree; 947 smb_node_t *f_node; 948 smb_opipe_t *f_pipe; 949 950 uint32_t f_uniqid; 951 uint32_t f_refcnt; 952 uint64_t f_seek_pos; 953 uint32_t f_flags; 954 uint32_t f_granted_access; 955 uint32_t f_share_access; 956 uint32_t f_create_options; 957 uint16_t f_fid; 958 uint16_t f_opened_by_pid; 959 uint16_t f_ftype; 960 uint64_t f_llf_pos; 961 int f_mode; 962 cred_t *f_cr; 963 pid_t f_pid; 964 } smb_ofile_t; 965 966 /* odir flags bits */ 967 #define SMB_DIR_FLAG_OPEN 0x0001 968 #define SMB_DIR_FLAG_CLOSE 0x0002 969 #define SMB_DIR_CLOSED(dir) ((dir)->d_flags & SMB_DIR_FLAG_CLOSE) 970 971 #define SMB_ODIR_MAGIC 0x4F444952 /* 'ODIR' */ 972 973 typedef enum { 974 SMB_ODIR_STATE_OPEN = 0, 975 SMB_ODIR_STATE_CLOSING, 976 SMB_ODIR_STATE_CLOSED, 977 SMB_ODIR_STATE_SENTINEL 978 } smb_odir_state_t; 979 980 typedef struct smb_odir { 981 uint32_t d_magic; 982 kmutex_t d_mutex; 983 list_node_t d_lnd; 984 smb_odir_state_t d_state; 985 986 smb_session_t *d_session; 987 smb_user_t *d_user; 988 smb_tree_t *d_tree; 989 990 uint32_t d_refcnt; 991 uint32_t d_cookie; 992 uint32_t d_cookies[SMB_MAX_SEARCH]; 993 uint16_t d_sid; 994 uint16_t d_opened_by_pid; 995 uint16_t d_sattr; 996 char d_pattern[MAXNAMELEN]; 997 struct smb_node *d_dir_snode; 998 unsigned int d_wildcards; 999 } smb_odir_t; 1000 1001 typedef struct smb_odir_context { 1002 uint32_t dc_cookie; 1003 uint16_t dc_dattr; 1004 char dc_name[MAXNAMELEN]; /* Real 'Xxxx.yyy.xx' */ 1005 char dc_name83[SMB_SHORTNAMELEN]; /* w/ dot 'XXXX .XX ' */ 1006 char dc_shortname[SMB_SHORTNAMELEN]; /* w/ dot 'XXXX.XX' */ 1007 smb_attr_t dc_attr; 1008 } smb_odir_context_t; 1009 1010 #define SMB_LOCK_MAGIC 0x4C4F434B /* 'LOCK' */ 1011 1012 typedef struct smb_lock { 1013 uint32_t l_magic; 1014 kmutex_t l_mutex; 1015 list_node_t l_lnd; 1016 kcondvar_t l_cv; 1017 1018 list_node_t l_conflict_lnd; 1019 smb_slist_t l_conflict_list; 1020 1021 smb_session_t *l_session; 1022 smb_ofile_t *l_file; 1023 struct smb_request *l_sr; 1024 1025 uint32_t l_flags; 1026 uint64_t l_session_kid; 1027 struct smb_lock *l_blocked_by; /* Debug info only */ 1028 1029 uint16_t l_pid; 1030 uint16_t l_uid; 1031 uint32_t l_type; 1032 uint64_t l_start; 1033 uint64_t l_length; 1034 clock_t l_end_time; 1035 } smb_lock_t; 1036 1037 #define SMB_LOCK_FLAG_INDEFINITE 0x0004 1038 #define SMB_LOCK_INDEFINITE_WAIT(lock) \ 1039 ((lock)->l_flags & SMB_LOCK_FLAG_INDEFINITE) 1040 1041 #define SMB_LOCK_TYPE_READWRITE 101 1042 #define SMB_LOCK_TYPE_READONLY 102 1043 1044 typedef struct vardata_block { 1045 uint8_t tag; 1046 uint16_t len; 1047 struct uio uio; 1048 struct iovec iovec[MAX_IOVEC]; 1049 } smb_vdb_t; 1050 1051 #define SMB_RW_MAGIC 0x52445257 /* 'RDRW' */ 1052 1053 typedef struct smb_rw_param { 1054 uint32_t rw_magic; 1055 smb_vdb_t rw_vdb; 1056 uint64_t rw_offset; 1057 uint32_t rw_last_write; 1058 uint16_t rw_mode; 1059 uint16_t rw_count; 1060 uint16_t rw_mincnt; 1061 uint16_t rw_dsoff; /* SMB data offset */ 1062 uint8_t rw_andx; /* SMB secondary andx command */ 1063 } smb_rw_param_t; 1064 1065 struct smb_fqi { /* fs_query_info */ 1066 char *path; 1067 uint16_t srch_attr; 1068 struct smb_node *dir_snode; 1069 smb_attr_t dir_attr; 1070 char last_comp[MAXNAMELEN]; 1071 int last_comp_was_found; 1072 char last_comp_od[MAXNAMELEN]; 1073 struct smb_node *last_snode; 1074 smb_attr_t last_attr; 1075 }; 1076 1077 #define SMB_NULL_FQI_NODES(fqi) \ 1078 (fqi).last_snode = NULL; \ 1079 (fqi).dir_snode = NULL; 1080 1081 #define FQM_DIR_MUST_EXIST 1 1082 #define FQM_PATH_MUST_EXIST 2 1083 #define FQM_PATH_MUST_NOT_EXIST 3 1084 1085 #define MYF_OPLOCK_MASK 0x000000F0 1086 #define MYF_OPLOCK_NONE 0x00000000 1087 #define MYF_EXCLUSIVE_OPLOCK 0x00000010 1088 #define MYF_BATCH_OPLOCK 0x00000020 1089 #define MYF_LEVEL_II_OPLOCK 0x00000030 1090 #define MYF_MUST_BE_DIRECTORY 0x00000100 1091 1092 #define MYF_OPLOCK_TYPE(o) ((o) & MYF_OPLOCK_MASK) 1093 #define MYF_OPLOCKS_REQUEST(o) (MYF_OPLOCK_TYPE(o) != MYF_OPLOCK_NONE) 1094 #define MYF_IS_EXCLUSIVE_OPLOCK(o) (MYF_OPLOCK_TYPE(o) == MYF_EXCLUSIVE_OPLOCK) 1095 #define MYF_IS_BATCH_OPLOCK(o) (MYF_OPLOCK_TYPE(o) == MYF_BATCH_OPLOCK) 1096 #define MYF_IS_LEVEL_II_OPLOCK(o) (MYF_OPLOCK_TYPE(o) == MYF_LEVEL_II_OPLOCK) 1097 1098 #define OPLOCK_MIN_TIMEOUT (5 * 1000) 1099 #define OPLOCK_STD_TIMEOUT (15 * 1000) 1100 #define OPLOCK_RETRIES 2 1101 1102 typedef struct { 1103 uint32_t severity; 1104 uint32_t status; 1105 uint16_t errcls; 1106 uint16_t errcode; 1107 } smb_error_t; 1108 1109 /* 1110 * SMB Request State Machine 1111 * ------------------------- 1112 * 1113 * T4 +------+ T0 1114 * +--------------------------->| FREE |---------------------------+ 1115 * | +------+ | 1116 * +-----------+ | 1117 * | COMPLETED | | 1118 * +-----------+ 1119 * ^ | 1120 * | T15 +----------+ v 1121 * +------------+ T6 | | +--------------+ 1122 * | CLEANED_UP |<-----------------| CANCELED | | INITIALIZING | 1123 * +------------+ | | +--------------+ 1124 * | ^ +----------+ | 1125 * | | ^ ^ ^ ^ | 1126 * | | +-------------+ | | | | 1127 * | | T3 | | | | T13 | T1 1128 * | +-------------------------+ | | +----------------------+ | 1129 * +----------------------------+ | | | | | 1130 * T16 | | | | +-----------+ | | 1131 * | \/ | | T5 | | v 1132 * +-----------------+ | T12 +--------+ | T2 +-----------+ 1133 * | EVENT_OCCURRED |------------->| ACTIVE |<--------------------| SUBMITTED | 1134 * +-----------------+ | +--------+ | +-----------+ 1135 * ^ | | ^ | | 1136 * | | T8 | | | T7 | 1137 * | T10 T9 | +----------+ | +-------+ | T11 1138 * | | | +-------+ | | 1139 * | | | T14 | | | 1140 * | | v | v | 1141 * +----------------------+ +--------------+ 1142 * | WAITING_EVENT | | WAITING_LOCK | 1143 * +----------------------+ +--------------+ 1144 * 1145 * 1146 * 1147 * 1148 * 1149 * Transition T0 1150 * 1151 * This transition occurs when the request is allocated and is still under the 1152 * control of the session thread. 1153 * 1154 * Transition T1 1155 * 1156 * This transition occurs when the session thread dispatches a task to treat the 1157 * request. 1158 * 1159 * Transition T2 1160 * 1161 * 1162 * 1163 * Transition T3 1164 * 1165 * A request completes and smbsr_cleanup is called to release resources 1166 * associated with the request (but not the smb_request_t itself). This 1167 * includes references on smb_ofile_t, smb_node_t, and other structures. 1168 * CLEANED_UP state exists to detect if we attempt to cleanup a request 1169 * multiple times and to allow us to detect that we are accessing a 1170 * request that has already been cleaned up. 1171 * 1172 * Transition T4 1173 * 1174 * 1175 * 1176 * Transition T5 1177 * 1178 * 1179 * 1180 * Transition T6 1181 * 1182 * 1183 * 1184 * Transition T7 1185 * 1186 * 1187 * 1188 * Transition T8 1189 * 1190 * 1191 * 1192 * Transition T9 1193 * 1194 * 1195 * 1196 * Transition T10 1197 * 1198 * 1199 * 1200 * Transition T11 1201 * 1202 * 1203 * 1204 * Transition T12 1205 * 1206 * 1207 * 1208 * Transition T13 1209 * 1210 * 1211 * 1212 * Transition T14 1213 * 1214 * 1215 * 1216 * Transition T15 1217 * 1218 * Request processing is completed (control returns from smb_dispatch) 1219 * 1220 * Transition T16 1221 * 1222 * Multipart (andx) request was cleaned up with smbsr_cleanup but more "andx" 1223 * sections remain to be processed. 1224 * 1225 */ 1226 1227 #define SMB_REQ_MAGIC 0x534D4252 /* 'SMBR' */ 1228 1229 typedef enum smb_req_state { 1230 SMB_REQ_STATE_FREE = 0, 1231 SMB_REQ_STATE_INITIALIZING, 1232 SMB_REQ_STATE_SUBMITTED, 1233 SMB_REQ_STATE_ACTIVE, 1234 SMB_REQ_STATE_WAITING_EVENT, 1235 SMB_REQ_STATE_EVENT_OCCURRED, 1236 SMB_REQ_STATE_WAITING_LOCK, 1237 SMB_REQ_STATE_COMPLETED, 1238 SMB_REQ_STATE_CANCELED, 1239 SMB_REQ_STATE_CLEANED_UP, 1240 SMB_REQ_STATE_SENTINEL 1241 } smb_req_state_t; 1242 1243 typedef struct smb_request { 1244 uint32_t sr_magic; 1245 kmutex_t sr_mutex; 1246 list_node_t sr_session_lnd; 1247 smb_req_state_t sr_state; 1248 boolean_t sr_keep; 1249 kmem_cache_t *sr_cache; 1250 struct smb_server *sr_server; 1251 pid_t *sr_pid; 1252 int32_t sr_gmtoff; 1253 smb_session_t *session; 1254 smb_kmod_cfg_t *sr_cfg; 1255 smb_notify_change_req_t sr_ncr; 1256 1257 /* Info from session service header */ 1258 uint32_t sr_req_length; /* Excluding NBT header */ 1259 1260 /* Request buffer excluding NBT header */ 1261 void *sr_request_buf; 1262 1263 /* Fields for raw writes */ 1264 uint32_t sr_raw_data_length; 1265 void *sr_raw_data_buf; 1266 1267 smb_lock_t *sr_awaiting; 1268 struct mbuf_chain command; 1269 struct mbuf_chain reply; 1270 struct mbuf_chain raw_data; 1271 smb_malloc_list request_storage; 1272 struct smb_xa *r_xa; 1273 int andx_prev_wct; 1274 int cur_reply_offset; 1275 int orig_request_hdr; 1276 unsigned int reply_seqnum; /* reply sequence number */ 1277 unsigned char first_smb_com; /* command code */ 1278 unsigned char smb_com; /* command code */ 1279 1280 uint8_t smb_rcls; /* error code class */ 1281 uint8_t smb_reh; /* rsvd (AH DOS INT-24 ERR) */ 1282 uint16_t smb_err; /* error code */ 1283 smb_error_t smb_error; 1284 1285 uint8_t smb_flg; /* flags */ 1286 uint16_t smb_flg2; /* flags */ 1287 uint16_t smb_pid_high; /* high part of pid */ 1288 unsigned char smb_sig[8]; /* signiture */ 1289 uint16_t smb_tid; /* tree id # */ 1290 uint16_t smb_pid; /* caller's process id # */ 1291 uint16_t smb_uid; /* user id # */ 1292 uint16_t smb_mid; /* mutiplex id # */ 1293 unsigned char smb_wct; /* count of parameter words */ 1294 uint16_t smb_bcc; /* data byte count */ 1295 1296 /* Parameters */ 1297 struct mbuf_chain smb_vwv; /* variable width value */ 1298 1299 /* Data */ 1300 struct mbuf_chain smb_data; 1301 1302 uint16_t smb_fid; /* not in hdr, but common */ 1303 uint16_t smb_sid; /* not in hdr, but common */ 1304 1305 unsigned char andx_com; 1306 uint16_t andx_off; 1307 1308 struct smb_tree *tid_tree; 1309 struct smb_ofile *fid_ofile; 1310 struct smb_odir *sid_odir; 1311 smb_user_t *uid_user; 1312 1313 union { 1314 struct tcon { 1315 char *path; 1316 char *service; 1317 int pwdlen; 1318 char *password; 1319 uint16_t flags; 1320 } tcon; 1321 1322 struct open_param { 1323 struct smb_fqi fqi; 1324 uint16_t omode; 1325 uint16_t oflags; 1326 uint16_t ofun; 1327 uint32_t my_flags; 1328 uint32_t timeo; 1329 uint32_t dattr; 1330 timestruc_t crtime; 1331 timestruc_t mtime; 1332 uint64_t dsize; 1333 uint32_t desired_access; 1334 uint32_t share_access; 1335 uint32_t create_options; 1336 uint32_t create_disposition; 1337 boolean_t created_readonly; 1338 uint32_t ftype, devstate; 1339 uint32_t action_taken; 1340 uint64_t fileid; 1341 uint32_t rootdirfid; 1342 /* This is only set by NTTransactCreate */ 1343 struct smb_sd *sd; 1344 } open; 1345 1346 struct dirop { 1347 struct smb_fqi fqi; 1348 struct smb_fqi dst_fqi; 1349 } dirop; 1350 1351 smb_rw_param_t *rw; 1352 uint32_t timestamp; 1353 } arg; 1354 1355 cred_t *user_cr; 1356 } smb_request_t; 1357 1358 #define SMB_READ_PROTOCOL(smb_nh_ptr) \ 1359 LE_IN32(((smb_nethdr_t *)(smb_nh_ptr))->sh_protocol) 1360 1361 #define SMB_PROTOCOL_MAGIC_INVALID(rd_sr) \ 1362 (SMB_READ_PROTOCOL((rd_sr)->sr_request_buf) != SMB_PROTOCOL_MAGIC) 1363 1364 #define SMB_READ_COMMAND(smb_nh_ptr) \ 1365 (((smb_nethdr_t *)(smb_nh_ptr))->sh_command) 1366 1367 #define SMB_IS_WRITERAW(rd_sr) \ 1368 (SMB_READ_COMMAND((rd_sr)->sr_request_buf) == SMB_COM_WRITE_RAW) 1369 1370 1371 #define SR_FLG_OFFSET 9 1372 1373 #define MAX_TRANS_NAME 64 1374 1375 #define SMB_XA_FLAG_OPEN 0x0001 1376 #define SMB_XA_FLAG_CLOSE 0x0002 1377 #define SMB_XA_FLAG_COMPLETE 0x0004 1378 #define SMB_XA_CLOSED(xa) (!((xa)->xa_flags & SMB_XA_FLAG_OPEN)) 1379 1380 #define SMB_XA_MAGIC 0x534D4258 /* 'SMBX' */ 1381 1382 typedef struct smb_xa { 1383 uint32_t xa_magic; 1384 kmutex_t xa_mutex; 1385 list_node_t xa_lnd; 1386 1387 uint32_t xa_refcnt; 1388 uint32_t xa_flags; 1389 1390 struct smb_session *xa_session; 1391 1392 unsigned char smb_com; /* which TRANS type */ 1393 unsigned char smb_flg; /* flags */ 1394 uint16_t smb_flg2; /* flags */ 1395 uint16_t smb_tid; /* tree id number */ 1396 uint16_t smb_pid; /* caller's process id number */ 1397 uint16_t smb_uid; /* user id number */ 1398 uint32_t smb_func; /* NT_TRANS function */ 1399 1400 uint16_t xa_smb_mid; /* mutiplex id number */ 1401 uint16_t xa_smb_fid; /* TRANS2 secondary */ 1402 1403 unsigned int reply_seqnum; /* reply sequence number */ 1404 1405 uint32_t smb_tpscnt; /* total parameter bytes being sent */ 1406 uint32_t smb_tdscnt; /* total data bytes being sent */ 1407 uint32_t smb_mprcnt; /* max parameter bytes to return */ 1408 uint32_t smb_mdrcnt; /* max data bytes to return */ 1409 uint32_t smb_msrcnt; /* max setup words to return */ 1410 uint32_t smb_flags; /* additional information: */ 1411 /* bit 0 - if set, disconnect TID in smb_tid */ 1412 /* bit 1 - if set, transaction is one way */ 1413 /* (no final response) */ 1414 int32_t smb_timeout; /* number of milliseconds to await completion */ 1415 uint32_t smb_suwcnt; /* set up word count */ 1416 1417 1418 char *xa_smb_trans_name; 1419 1420 int req_disp_param; 1421 int req_disp_data; 1422 1423 struct mbuf_chain req_setup_mb; 1424 struct mbuf_chain req_param_mb; 1425 struct mbuf_chain req_data_mb; 1426 1427 struct mbuf_chain rep_setup_mb; 1428 struct mbuf_chain rep_param_mb; 1429 struct mbuf_chain rep_data_mb; 1430 } smb_xa_t; 1431 1432 1433 #define SDDF_NO_FLAGS 0 1434 #define SDDF_SUPPRESS_TID 0x0001 1435 #define SDDF_SUPPRESS_UID 0x0002 1436 1437 /* 1438 * SMB dispatch return codes. 1439 */ 1440 typedef enum { 1441 SDRC_SUCCESS = 0, 1442 SDRC_ERROR, 1443 SDRC_DROP_VC, 1444 SDRC_NO_REPLY, 1445 SDRC_NOT_IMPLEMENTED 1446 } smb_sdrc_t; 1447 1448 #define VAR_BCC ((short)-1) 1449 1450 #define SMB_SERVER_MAGIC 0x53534552 /* 'SSER' */ 1451 1452 typedef struct { 1453 kstat_named_t open_files; 1454 kstat_named_t open_trees; 1455 kstat_named_t open_users; 1456 } smb_server_stats_t; 1457 1458 typedef struct { 1459 kthread_t *ld_kth; 1460 kt_did_t ld_ktdid; 1461 struct sonode *ld_so; 1462 struct sockaddr_in ld_sin; 1463 smb_session_list_t ld_session_list; 1464 } smb_listener_daemon_t; 1465 1466 typedef enum smb_server_state { 1467 SMB_SERVER_STATE_CREATED = 0, 1468 SMB_SERVER_STATE_CONFIGURED, 1469 SMB_SERVER_STATE_RUNNING, 1470 SMB_SERVER_STATE_DELETING, 1471 SMB_SERVER_STATE_SENTINEL 1472 } smb_server_state_t; 1473 1474 typedef struct smb_server { 1475 uint32_t sv_magic; 1476 kcondvar_t sv_cv; 1477 kmutex_t sv_mutex; 1478 list_node_t sv_lnd; 1479 smb_server_state_t sv_state; 1480 uint32_t sv_refcnt; 1481 pid_t sv_pid; 1482 zoneid_t sv_zid; 1483 smb_listener_daemon_t sv_nbt_daemon; 1484 smb_listener_daemon_t sv_tcp_daemon; 1485 krwlock_t sv_cfg_lock; 1486 smb_kmod_cfg_t sv_cfg; 1487 smb_session_t *sv_session; 1488 1489 kstat_t *sv_ksp; 1490 kmutex_t sv_ksp_mutex; 1491 char sv_ksp_name[KSTAT_STRLEN]; 1492 smb_server_stats_t sv_ks_data; 1493 1494 door_handle_t sv_lmshrd; 1495 1496 int32_t si_gmtoff; 1497 1498 smb_thread_t si_thread_timers; 1499 smb_thread_t si_thread_unexport; 1500 1501 taskq_t *sv_thread_pool; 1502 1503 kmem_cache_t *si_cache_unexport; 1504 kmem_cache_t *si_cache_vfs; 1505 kmem_cache_t *si_cache_request; 1506 kmem_cache_t *si_cache_session; 1507 kmem_cache_t *si_cache_user; 1508 kmem_cache_t *si_cache_tree; 1509 kmem_cache_t *si_cache_ofile; 1510 kmem_cache_t *si_cache_odir; 1511 kmem_cache_t *si_cache_node; 1512 1513 volatile uint32_t sv_open_trees; 1514 volatile uint32_t sv_open_files; 1515 volatile uint32_t sv_open_users; 1516 1517 smb_node_t *si_root_smb_node; 1518 smb_llist_t sv_vfs_list; 1519 smb_slist_t sv_unexport_list; 1520 } smb_server_t; 1521 1522 #define SMB_INFO_NETBIOS_SESSION_SVC_RUNNING 0x0001 1523 #define SMB_INFO_NETBIOS_SESSION_SVC_FAILED 0x0002 1524 #define SMB_INFO_USER_LEVEL_SECURITY 0x40000000 1525 #define SMB_INFO_ENCRYPT_PASSWORDS 0x80000000 1526 1527 #define SMB_NEW_KID() atomic_inc_64_nv(&smb_kids) 1528 #define SMB_UNIQ_FID() atomic_inc_32_nv(&smb_fids) 1529 1530 /* 1531 * This is to be used by Trans2SetFileInfo 1532 * and Trans2SetPathInfo 1533 */ 1534 typedef struct smb_trans2_setinfo { 1535 uint16_t level; 1536 struct smb_xa *ts_xa; 1537 struct smb_node *node; 1538 char *path; 1539 char name[MAXNAMELEN]; 1540 } smb_trans2_setinfo_t; 1541 1542 #define SMB_IS_STREAM(node) ((node)->unnamed_stream_node) 1543 1544 #ifdef DEBUG 1545 extern uint_t smb_tsd_key; 1546 #endif 1547 1548 typedef struct smb_tsd { 1549 void (*proc)(); 1550 void *arg; 1551 char name[100]; 1552 } smb_tsd_t; 1553 1554 #define SMB_INVALID_AMASK -1 1555 #define SMB_INVALID_SHAREMODE -1 1556 #define SMB_INVALID_CRDISPOSITION -1 1557 1558 typedef struct smb_dispatch_table { 1559 smb_sdrc_t (*sdt_pre_op)(smb_request_t *); 1560 smb_sdrc_t (*sdt_function)(smb_request_t *); 1561 void (*sdt_post_op)(smb_request_t *); 1562 char sdt_dialect; 1563 unsigned char sdt_flags; 1564 krw_t sdt_slock_mode; 1565 kstat_named_t sdt_dispatch_stats; /* invocations */ 1566 } smb_dispatch_table_t; 1567 1568 /* 1569 * Discretionary Access Control List (DACL) 1570 * 1571 * A Discretionary Access Control List (DACL), often abbreviated to 1572 * ACL, is a list of access controls which either allow or deny access 1573 * for users or groups to a resource. There is a list header followed 1574 * by a list of access control entries (ACE). Each ACE specifies the 1575 * access allowed or denied to a single user or group (identified by 1576 * a SID). 1577 * 1578 * There is another access control list object called a System Access 1579 * Control List (SACL), which is used to control auditing, but no 1580 * support is provideed for SACLs at this time. 1581 * 1582 * ACL header format: 1583 * 1584 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1585 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 1586 * +-------------------------------+---------------+---------------+ 1587 * | AclSize | Sbz1 | AclRevision | 1588 * +-------------------------------+---------------+---------------+ 1589 * | Sbz2 | AceCount | 1590 * +-------------------------------+-------------------------------+ 1591 * 1592 * AclRevision specifies the revision level of the ACL. This value should 1593 * be ACL_REVISION, unless the ACL contains an object-specific ACE, in which 1594 * case this value must be ACL_REVISION_DS. All ACEs in an ACL must be at the 1595 * same revision level. 1596 * 1597 * ACE header format: 1598 * 1599 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1600 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 1601 * +---------------+-------+-------+---------------+---------------+ 1602 * | AceSize | AceFlags | AceType | 1603 * +---------------+-------+-------+---------------+---------------+ 1604 * 1605 * Access mask format: 1606 * 1607 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1608 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 1609 * +---------------+---------------+-------------------------------+ 1610 * |G|G|G|G|Res'd|A| StandardRights| SpecificRights | 1611 * |R|W|E|A| |S| | | 1612 * +-+-------------+---------------+-------------------------------+ 1613 * 1614 * typedef struct ACCESS_MASK { 1615 * WORD SpecificRights; 1616 * BYTE StandardRights; 1617 * BYTE AccessSystemAcl : 1; 1618 * BYTE Reserved : 3; 1619 * BYTE GenericAll : 1; 1620 * BYTE GenericExecute : 1; 1621 * BYTE GenericWrite : 1; 1622 * BYTE GenericRead : 1; 1623 * } ACCESS_MASK; 1624 * 1625 */ 1626 1627 #define ACL_REVISION1 1 1628 #define ACL_REVISION2 2 1629 #define MIN_ACL_REVISION2 ACL_REVISION2 1630 #define ACL_REVISION3 3 1631 #define ACL_REVISION4 4 1632 #define MAX_ACL_REVISION ACL_REVISION4 1633 1634 /* 1635 * Current ACE and ACL revision Levels 1636 */ 1637 #define ACE_REVISION 1 1638 #define ACL_REVISION ACL_REVISION2 1639 #define ACL_REVISION_DS ACL_REVISION4 1640 1641 1642 #define ACCESS_ALLOWED_ACE_TYPE 0 1643 #define ACCESS_DENIED_ACE_TYPE 1 1644 #define SYSTEM_AUDIT_ACE_TYPE 2 1645 #define SYSTEM_ALARM_ACE_TYPE 3 1646 1647 /* 1648 * se_flags 1649 * ---------- 1650 * Specifies a set of ACE type-specific control flags. This member can be a 1651 * combination of the following values. 1652 * 1653 * CONTAINER_INHERIT_ACE: Child objects that are containers, such as 1654 * directories, inherit the ACE as an effective ACE. The inherited 1655 * ACE is inheritable unless the NO_PROPAGATE_INHERIT_ACE bit flag 1656 * is also set. 1657 * 1658 * INHERIT_ONLY_ACE: Indicates an inherit-only ACE which does not control 1659 * access to the object to which it is attached. 1660 * If this flag is not set, 1661 * the ACE is an effective ACE which controls access to the object 1662 * to which it is attached. 1663 * Both effective and inherit-only ACEs can be inherited 1664 * depending on the state of the other inheritance flags. 1665 * 1666 * INHERITED_ACE: Windows 2000/XP: Indicates that the ACE was inherited. 1667 * The system sets this bit when it propagates an 1668 * inherited ACE to a child object. 1669 * 1670 * NO_PROPAGATE_INHERIT_ACE: If the ACE is inherited by a child object, the 1671 * system clears the OBJECT_INHERIT_ACE and CONTAINER_INHERIT_ACE 1672 * flags in the inherited ACE. 1673 * This prevents the ACE from being inherited by 1674 * subsequent generations of objects. 1675 * 1676 * OBJECT_INHERIT_ACE: Noncontainer child objects inherit the ACE as an 1677 * effective ACE. For child objects that are containers, 1678 * the ACE is inherited as an inherit-only ACE unless the 1679 * NO_PROPAGATE_INHERIT_ACE bit flag is also set. 1680 */ 1681 #define OBJECT_INHERIT_ACE 0x01 1682 #define CONTAINER_INHERIT_ACE 0x02 1683 #define NO_PROPOGATE_INHERIT_ACE 0x04 1684 #define INHERIT_ONLY_ACE 0x08 1685 #define INHERITED_ACE 0x10 1686 #define INHERIT_MASK_ACE 0x1F 1687 1688 1689 /* 1690 * These flags are only used in system audit or alarm ACEs to 1691 * indicate when an audit message should be generated, i.e. 1692 * on successful access or on unsuccessful access. 1693 */ 1694 #define SUCCESSFUL_ACCESS_ACE_FLAG 0x40 1695 #define FAILED_ACCESS_ACE_FLAG 0x80 1696 1697 /* 1698 * se_bsize is the size, in bytes, of ACE as it appears on the wire. 1699 * se_sln is used to sort the ACL when it's required. 1700 */ 1701 typedef struct smb_acehdr { 1702 uint8_t se_type; 1703 uint8_t se_flags; 1704 uint16_t se_bsize; 1705 } smb_acehdr_t; 1706 1707 typedef struct smb_ace { 1708 smb_acehdr_t se_hdr; 1709 uint32_t se_mask; 1710 list_node_t se_sln; 1711 smb_sid_t *se_sid; 1712 } smb_ace_t; 1713 1714 /* 1715 * sl_bsize is the size of ACL in bytes as it appears on the wire. 1716 */ 1717 typedef struct smb_acl { 1718 uint8_t sl_revision; 1719 uint16_t sl_bsize; 1720 uint16_t sl_acecnt; 1721 smb_ace_t *sl_aces; 1722 list_t sl_sorted; 1723 } smb_acl_t; 1724 1725 /* 1726 * ACE/ACL header size, in byte, as it appears on the wire 1727 */ 1728 #define SMB_ACE_HDRSIZE 4 1729 #define SMB_ACL_HDRSIZE 8 1730 1731 /* 1732 * Security Descriptor (SD) 1733 * 1734 * Security descriptors provide protection for objects, for example 1735 * files and directories. It identifies the owner and primary group 1736 * (SIDs) and contains an access control list. When a user tries to 1737 * access an object his SID is compared to the permissions in the 1738 * DACL to determine if access should be allowed or denied. Note that 1739 * this is a simplification because there are other factors, such as 1740 * default behavior and privileges to be taken into account (see also 1741 * access tokens). 1742 * 1743 * The boolean flags have the following meanings when set: 1744 * 1745 * SE_OWNER_DEFAULTED indicates that the SID pointed to by the Owner 1746 * field was provided by a defaulting mechanism rather than explicitly 1747 * provided by the original provider of the security descriptor. This 1748 * may affect the treatment of the SID with respect to inheritance of 1749 * an owner. 1750 * 1751 * SE_GROUP_DEFAULTED indicates that the SID in the Group field was 1752 * provided by a defaulting mechanism rather than explicitly provided 1753 * by the original provider of the security descriptor. This may 1754 * affect the treatment of the SID with respect to inheritance of a 1755 * primary group. 1756 * 1757 * SE_DACL_PRESENT indicates that the security descriptor contains a 1758 * discretionary ACL. If this flag is set and the Dacl field of the 1759 * SECURITY_DESCRIPTOR is null, then a null ACL is explicitly being 1760 * specified. 1761 * 1762 * SE_DACL_DEFAULTED indicates that the ACL pointed to by the Dacl 1763 * field was provided by a defaulting mechanism rather than explicitly 1764 * provided by the original provider of the security descriptor. This 1765 * may affect the treatment of the ACL with respect to inheritance of 1766 * an ACL. This flag is ignored if the DaclPresent flag is not set. 1767 * 1768 * SE_SACL_PRESENT indicates that the security descriptor contains a 1769 * system ACL pointed to by the Sacl field. If this flag is set and 1770 * the Sacl field of the SECURITY_DESCRIPTOR is null, then an empty 1771 * (but present) ACL is being specified. 1772 * 1773 * SE_SACL_DEFAULTED indicates that the ACL pointed to by the Sacl 1774 * field was provided by a defaulting mechanism rather than explicitly 1775 * provided by the original provider of the security descriptor. This 1776 * may affect the treatment of the ACL with respect to inheritance of 1777 * an ACL. This flag is ignored if the SaclPresent flag is not set. 1778 * 1779 * SE_DACL_PROTECTED Prevents ACEs set on the DACL of the parent container 1780 * (and any objects above the parent container in the directory hierarchy) 1781 * from being applied to the object's DACL. 1782 * 1783 * SE_SACL_PROTECTED Prevents ACEs set on the SACL of the parent container 1784 * (and any objects above the parent container in the directory hierarchy) 1785 * from being applied to the object's SACL. 1786 * 1787 * Note that the SE_DACL_PRESENT flag needs to be present to set 1788 * SE_DACL_PROTECTED and SE_SACL_PRESENT needs to be present to set 1789 * SE_SACL_PROTECTED. 1790 * 1791 * SE_SELF_RELATIVE indicates that the security descriptor is in self- 1792 * relative form. In this form, all fields of the security descriptor 1793 * are contiguous in memory and all pointer fields are expressed as 1794 * offsets from the beginning of the security descriptor. 1795 * 1796 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1797 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 1798 * +---------------------------------------------------------------+ 1799 * | Control |Reserved1 (SBZ)| Revision | 1800 * +---------------------------------------------------------------+ 1801 * | Owner | 1802 * +---------------------------------------------------------------+ 1803 * | Group | 1804 * +---------------------------------------------------------------+ 1805 * | Sacl | 1806 * +---------------------------------------------------------------+ 1807 * | Dacl | 1808 * +---------------------------------------------------------------+ 1809 * 1810 */ 1811 1812 #define SMB_OWNER_SECINFO 0x0001 1813 #define SMB_GROUP_SECINFO 0x0002 1814 #define SMB_DACL_SECINFO 0x0004 1815 #define SMB_SACL_SECINFO 0x0008 1816 #define SMB_ALL_SECINFO 0x000F 1817 #define SMB_ACL_SECINFO (SMB_DACL_SECINFO | SMB_SACL_SECINFO) 1818 1819 #define SECURITY_DESCRIPTOR_REVISION 1 1820 1821 1822 #define SE_OWNER_DEFAULTED 0x0001 1823 #define SE_GROUP_DEFAULTED 0x0002 1824 #define SE_DACL_PRESENT 0x0004 1825 #define SE_DACL_DEFAULTED 0x0008 1826 #define SE_SACL_PRESENT 0x0010 1827 #define SE_SACL_DEFAULTED 0x0020 1828 #define SE_DACL_AUTO_INHERIT_REQ 0x0100 1829 #define SE_SACL_AUTO_INHERIT_REQ 0x0200 1830 #define SE_DACL_AUTO_INHERITED 0x0400 1831 #define SE_SACL_AUTO_INHERITED 0x0800 1832 #define SE_DACL_PROTECTED 0x1000 1833 #define SE_SACL_PROTECTED 0x2000 1834 #define SE_SELF_RELATIVE 0x8000 1835 1836 #define SE_DACL_INHERITANCE_MASK 0x1500 1837 #define SE_SACL_INHERITANCE_MASK 0x2A00 1838 1839 /* 1840 * Security descriptor structures: 1841 * 1842 * smb_sd_t SD in SMB pointer form 1843 * smb_fssd_t SD in filesystem form 1844 * 1845 * Filesystems (e.g. ZFS/UFS) don't have something equivalent 1846 * to SD. The items comprising a SMB SD are kept separately in 1847 * filesystem. smb_fssd_t is introduced as a helper to provide 1848 * the required abstraction for CIFS code. 1849 */ 1850 1851 typedef struct smb_sd { 1852 uint8_t sd_revision; 1853 uint16_t sd_control; 1854 smb_sid_t *sd_owner; /* SID file owner */ 1855 smb_sid_t *sd_group; /* SID group (for POSIX) */ 1856 smb_acl_t *sd_sacl; /* ACL System (audits) */ 1857 smb_acl_t *sd_dacl; /* ACL Discretionary (perm) */ 1858 } smb_sd_t; 1859 1860 /* 1861 * SD header size as it appears on the wire 1862 */ 1863 #define SMB_SD_HDRSIZE 20 1864 1865 /* 1866 * values for smb_fssd.sd_flags 1867 */ 1868 #define SMB_FSSD_FLAGS_DIR 0x01 1869 1870 typedef struct smb_fssd { 1871 uint32_t sd_secinfo; 1872 uint32_t sd_flags; 1873 uid_t sd_uid; 1874 gid_t sd_gid; 1875 acl_t *sd_zdacl; 1876 acl_t *sd_zsacl; 1877 } smb_fssd_t; 1878 1879 #ifdef __cplusplus 1880 } 1881 #endif 1882 1883 #endif /* _SMBSRV_SMB_KTYPES_H */ 1884