13db3f65cSamw /* 23db3f65cSamw * CDDL HEADER START 33db3f65cSamw * 43db3f65cSamw * The contents of this file are subject to the terms of the 53db3f65cSamw * Common Development and Distribution License (the "License"). 63db3f65cSamw * You may not use this file except in compliance with the License. 73db3f65cSamw * 83db3f65cSamw * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 93db3f65cSamw * or http://www.opensolaris.org/os/licensing. 103db3f65cSamw * See the License for the specific language governing permissions 113db3f65cSamw * and limitations under the License. 123db3f65cSamw * 133db3f65cSamw * When distributing Covered Code, include this CDDL HEADER in each 143db3f65cSamw * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 153db3f65cSamw * If applicable, add the following below this CDDL HEADER, with the 163db3f65cSamw * fields enclosed by brackets "[]" replaced with your own identifying 173db3f65cSamw * information: Portions Copyright [yyyy] [name of copyright owner] 183db3f65cSamw * 193db3f65cSamw * CDDL HEADER END 203db3f65cSamw */ 21148c5f43SAlan Wright 223db3f65cSamw /* 23148c5f43SAlan Wright * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 247206bf49SGordon Ross * Copyright 2013 Nexenta Systems, Inc. All rights reserved. 253db3f65cSamw */ 263db3f65cSamw 273db3f65cSamw #ifndef _SMB_SHARE_H 283db3f65cSamw #define _SMB_SHARE_H 293db3f65cSamw 303db3f65cSamw #include <sys/param.h> 313db3f65cSamw #include <smbsrv/string.h> 329fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States #include <smbsrv/smb_inet.h> 333db3f65cSamw #include <smbsrv/hash_table.h> 343db3f65cSamw #include <smbsrv/wintypes.h> 35148c5f43SAlan Wright #include <smb/lmerr.h> 363db3f65cSamw 377206bf49SGordon Ross #if !defined(_KERNEL) && !defined(_FAKE_KERNEL) 383db3f65cSamw #include <libshare.h> 393db3f65cSamw #endif 403db3f65cSamw 413db3f65cSamw #ifdef __cplusplus 423db3f65cSamw extern "C" { 433db3f65cSamw #endif 443db3f65cSamw 45148c5f43SAlan Wright #define SMB_CVOL "/var/smb/cvol" 46148c5f43SAlan Wright #define SMB_SYSROOT SMB_CVOL "/windows" 47148c5f43SAlan Wright #define SMB_SYSTEM32 SMB_SYSROOT "/system32" 48148c5f43SAlan Wright #define SMB_VSS SMB_SYSTEM32 "/vss" 49148c5f43SAlan Wright 50*cf115f36SGordon Ross /* Exported named pipes are in... */ 51*cf115f36SGordon Ross #define SMB_PIPE_DIR "/var/smb/pipe" 52*cf115f36SGordon Ross 533db3f65cSamw /* 5429bd2886SAlan Wright * Share Properties: 5529bd2886SAlan Wright * 5629bd2886SAlan Wright * name Advertised name of the share 5729bd2886SAlan Wright * 5829bd2886SAlan Wright * ad-container Active directory container in which the share 5929bd2886SAlan Wright * will be published 6029bd2886SAlan Wright * 61e3f2c991SKeyur Desai * abe Determines whether Access Based Enumeration is applied 62e3f2c991SKeyur Desai * to a share 63e3f2c991SKeyur Desai * 6429bd2886SAlan Wright * csc Client-side caching (CSC) options applied to this share 6529bd2886SAlan Wright * disabled The client MUST NOT cache any files 6629bd2886SAlan Wright * manual The client should not automatically cache every file 6729bd2886SAlan Wright * that it opens 6829bd2886SAlan Wright * auto The client may cache every file that it opens 6929bd2886SAlan Wright * vdo The client may cache every file that it opens 708d7e4166Sjose borrego * and satisfy file requests from its local cache. 7129bd2886SAlan Wright * 7229bd2886SAlan Wright * catia CATIA character substitution 7329bd2886SAlan Wright * 7429bd2886SAlan Wright * guestok Determines whether guest access is allowed 7529bd2886SAlan Wright * 7629bd2886SAlan Wright * next three properties use access-list a al NFS 7729bd2886SAlan Wright * 7829bd2886SAlan Wright * ro list of hosts that will have read-only access 7929bd2886SAlan Wright * rw list of hosts that will have read/write access 8029bd2886SAlan Wright * none list of hosts that won't be allowed access 813db3f65cSamw */ 828d7e4166Sjose borrego #define SHOPT_AD_CONTAINER "ad-container" 83e3f2c991SKeyur Desai #define SHOPT_ABE "abe" 8429bd2886SAlan Wright #define SHOPT_NAME "name" 8529bd2886SAlan Wright #define SHOPT_CSC "csc" 8629bd2886SAlan Wright #define SHOPT_CATIA "catia" 8729bd2886SAlan Wright #define SHOPT_GUEST "guestok" 8829bd2886SAlan Wright #define SHOPT_RO "ro" 8929bd2886SAlan Wright #define SHOPT_RW "rw" 9029bd2886SAlan Wright #define SHOPT_NONE "none" 919fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States #define SHOPT_DFSROOT "dfsroot" 92148c5f43SAlan Wright #define SHOPT_DESCRIPTION "description" 933db3f65cSamw 943db3f65cSamw #define SMB_DEFAULT_SHARE_GROUP "smb" 953db3f65cSamw #define SMB_PROTOCOL_NAME "smb" 963db3f65cSamw 973db3f65cSamw /* 983db3f65cSamw * RAP protocol share related commands only understand 993db3f65cSamw * share names in OEM format and there is a 13 char size 1003db3f65cSamw * limitation 1013db3f65cSamw */ 1023db3f65cSamw #define SMB_SHARE_OEMNAME_MAX 13 103fe1c642dSBill Krier #define SMB_SHARE_NTNAME_MAX 81 1043db3f65cSamw #define SMB_SHARE_CMNT_MAX (64 * MTS_MB_CHAR_MAX) 1053db3f65cSamw 1063db3f65cSamw /* 1073db3f65cSamw * struct SHARE_INFO_1 { 1083db3f65cSamw * char shi1_netname[13] 1093db3f65cSamw * char shi1_pad; 1103db3f65cSamw * unsigned short shi1_type 1113db3f65cSamw * char *shi1_remark; 1123db3f65cSamw * } 1133db3f65cSamw */ 1143db3f65cSamw #define SHARE_INFO_1_SIZE (SMB_SHARE_OEMNAME_MAX + 1 + 2 + 4) 1153db3f65cSamw 1163db3f65cSamw /* 1173db3f65cSamw * Share flags: 1183db3f65cSamw * 1199fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * There are two types of flags: 1209fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * 1219fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * - flags that represent a share property 1229fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * - other flags set at runtime 1239fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * 1249fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Property flags: 1259fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * 1268d7e4166Sjose borrego * SMB_SHRF_CSC_DISABLED Client-side caching is disabled for this share 1278d7e4166Sjose borrego * SMB_SHRF_CSC_MANUAL Manual client-side caching is allowed 1288d7e4166Sjose borrego * SMB_SHRF_CSC_AUTO Automatic client-side caching (CSC) is allowed 1298d7e4166Sjose borrego * SMB_SHRF_CSC_VDO Automatic CSC and local cache lookup is allowed 130b89a8333Snatalie li - Sun Microsystems - Irvine United States * SMB_SHRF_ACC_OPEN No restrictions set 131b89a8333Snatalie li - Sun Microsystems - Irvine United States * SMB_SHRF_ACC_NONE "none" property set 132b89a8333Snatalie li - Sun Microsystems - Irvine United States * SMB_SHRF_ACC_RO "ro" (readonly) property set 133b89a8333Snatalie li - Sun Microsystems - Irvine United States * SMB_SHRF_ACC_RW "rw" (read/write) property set 134b89a8333Snatalie li - Sun Microsystems - Irvine United States * SMB_SHRF_ACC_ALL All of the access bits 1358b2cc8acSafshin salek ardakani - Sun Microsystems - Irvine United States * SMB_SHRF_CATIA CATIA character translation on/off 13629bd2886SAlan Wright * SMB_SHRF_GUEST_OK Guest access on/off 137e3f2c991SKeyur Desai * SMB_SHRF_ABE Access Based Enumeration on/off 1389fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * SMB_SHRF_DFSROOT Share is a standalone DFS root 1399fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * 1409fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Runtime flags: 1419fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * 1429fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * SMB_SHRF_TRANS Transient share 1439fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * SMB_SHRF_PERM Permanent share 1449fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * SMB_SHRF_AUTOHOME Autohome share. 1459fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * SMB_SHRF_ADMIN Admin share 1463db3f65cSamw * 1473db3f65cSamw * All autohome shares are transient but not all transient shares are autohome. 1483db3f65cSamw * IPC$ and drive letter shares (e.g. d$, e$, etc) are transient but 1493db3f65cSamw * not autohome. 1503db3f65cSamw */ 1518d7e4166Sjose borrego 1529fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* 1539fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Property flags 1549fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States */ 1559fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States #define SMB_SHRF_DFSROOT 0x0001 1569fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States #define SMB_SHRF_CATIA 0x0002 1579fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States #define SMB_SHRF_GUEST_OK 0x0004 1589fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States #define SMB_SHRF_ABE 0x0008 1599fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 1608d7e4166Sjose borrego #define SMB_SHRF_CSC_DISABLED 0x0010 1618d7e4166Sjose borrego #define SMB_SHRF_CSC_MANUAL 0x0020 1628d7e4166Sjose borrego #define SMB_SHRF_CSC_AUTO 0x0040 1638d7e4166Sjose borrego #define SMB_SHRF_CSC_VDO 0x0080 1649fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States #define SMB_SHRF_CSC_MASK 0x00F0 1653db3f65cSamw 166b89a8333Snatalie li - Sun Microsystems - Irvine United States #define SMB_SHRF_ACC_OPEN 0x0000 167b89a8333Snatalie li - Sun Microsystems - Irvine United States #define SMB_SHRF_ACC_NONE 0x0100 168b89a8333Snatalie li - Sun Microsystems - Irvine United States #define SMB_SHRF_ACC_RO 0x0200 169b89a8333Snatalie li - Sun Microsystems - Irvine United States #define SMB_SHRF_ACC_RW 0x0400 170b89a8333Snatalie li - Sun Microsystems - Irvine United States #define SMB_SHRF_ACC_ALL 0x0F00 171b89a8333Snatalie li - Sun Microsystems - Irvine United States 1729fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* 1739fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Runtime flags 1749fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States */ 1759fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States #define SMB_SHRF_ADMIN 0x01000000 1769fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States #define SMB_SHRF_TRANS 0x10000000 1779fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States #define SMB_SHRF_PERM 0x20000000 1789fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States #define SMB_SHRF_AUTOHOME 0x40000000 179b89a8333Snatalie li - Sun Microsystems - Irvine United States 180cb174861Sjoyce mcintosh #define SMB_SHARE_PRINT "print$" 181cb174861Sjoyce mcintosh #define SMB_SHARE_PRINT_LEN 6 1823db3f65cSamw /* 1833db3f65cSamw * refcnt is currently only used for autohome. autohome needs a refcnt 1843db3f65cSamw * because a user can map his autohome share from more than one client 1853db3f65cSamw * at the same time and the share should only be removed when the last 1863db3f65cSamw * one is disconnected 1873db3f65cSamw */ 1883db3f65cSamw typedef struct smb_share { 1893db3f65cSamw char shr_name[MAXNAMELEN]; 1903db3f65cSamw char shr_path[MAXPATHLEN]; 1913db3f65cSamw char shr_cmnt[SMB_SHARE_CMNT_MAX]; 1923db3f65cSamw char shr_container[MAXPATHLEN]; 1933db3f65cSamw uint32_t shr_flags; 1943db3f65cSamw uint32_t shr_type; 1953db3f65cSamw uint32_t shr_refcnt; 196b89a8333Snatalie li - Sun Microsystems - Irvine United States uint32_t shr_access_value; /* host return access value */ 197fe1c642dSBill Krier uid_t shr_uid; /* autohome only */ 198fe1c642dSBill Krier gid_t shr_gid; /* autohome only */ 199b89a8333Snatalie li - Sun Microsystems - Irvine United States char shr_access_none[MAXPATHLEN]; 200b89a8333Snatalie li - Sun Microsystems - Irvine United States char shr_access_ro[MAXPATHLEN]; 201b89a8333Snatalie li - Sun Microsystems - Irvine United States char shr_access_rw[MAXPATHLEN]; 2023db3f65cSamw } smb_share_t; 2033db3f65cSamw 2043db3f65cSamw typedef struct smb_shriter { 2053db3f65cSamw smb_share_t si_share; 2063db3f65cSamw HT_ITERATOR si_hashiter; 207c8ec8eeaSjose borrego boolean_t si_first; 2083db3f65cSamw } smb_shriter_t; 2093db3f65cSamw 2103db3f65cSamw #define LMSHARES_PER_REQUEST 10 2113db3f65cSamw typedef struct smb_shrlist { 212c8ec8eeaSjose borrego int sl_cnt; 213c8ec8eeaSjose borrego smb_share_t sl_shares[LMSHARES_PER_REQUEST]; 2143db3f65cSamw } smb_shrlist_t; 2153db3f65cSamw 216148c5f43SAlan Wright typedef struct smb_shr_execinfo { 217148c5f43SAlan Wright char *e_sharename; 21829bd2886SAlan Wright char *e_winname; 21929bd2886SAlan Wright char *e_userdom; 22029bd2886SAlan Wright smb_inaddr_t e_srv_ipaddr; 22129bd2886SAlan Wright smb_inaddr_t e_cli_ipaddr; 22229bd2886SAlan Wright char *e_cli_netbiosname; 22329bd2886SAlan Wright uid_t e_uid; 224148c5f43SAlan Wright int e_type; 225148c5f43SAlan Wright } smb_shr_execinfo_t; 22629bd2886SAlan Wright 2273db3f65cSamw /* 2283db3f65cSamw * LanMan share API (for both SMB kernel module and GUI/CLI sub-system) 2293db3f65cSamw * 2303db3f65cSamw * NOTE: If any error is encounted by either the door server or client, 2313db3f65cSamw * NERR_InternalError will be returned by most functions, smb_share_count 2323db3f65cSamw * will return -1. 2333db3f65cSamw */ 2343db3f65cSamw 2357206bf49SGordon Ross #if !defined(_KERNEL) && !defined(_FAKE_KERNEL) 2363db3f65cSamw 2373db3f65cSamw /* 238c8ec8eeaSjose borrego * CIFS share management functions exported by libmlsvc 2393db3f65cSamw */ 2403db3f65cSamw int smb_shr_start(void); 2413db3f65cSamw void smb_shr_stop(void); 242fd9ee8b5Sjoyce mcintosh void *smb_shr_load(void *); 243c8ec8eeaSjose borrego void smb_shr_iterinit(smb_shriter_t *); 244c8ec8eeaSjose borrego smb_share_t *smb_shr_iterate(smb_shriter_t *); 245c8ec8eeaSjose borrego void smb_shr_list(int, smb_shrlist_t *); 2463db3f65cSamw int smb_shr_count(void); 247b89a8333Snatalie li - Sun Microsystems - Irvine United States uint32_t smb_shr_add(smb_share_t *); 248b89a8333Snatalie li - Sun Microsystems - Irvine United States uint32_t smb_shr_remove(char *); 249c8ec8eeaSjose borrego uint32_t smb_shr_rename(char *, char *); 250c8ec8eeaSjose borrego uint32_t smb_shr_get(char *, smb_share_t *); 251b89a8333Snatalie li - Sun Microsystems - Irvine United States uint32_t smb_shr_modify(smb_share_t *); 252c8ec8eeaSjose borrego uint32_t smb_shr_get_realpath(const char *, char *, int); 253148c5f43SAlan Wright uint32_t smb_shr_hostaccess(smb_inaddr_t *, char *, char *, char *, uint32_t); 254148c5f43SAlan Wright int smb_shr_exec(smb_shr_execinfo_t *); 2553db3f65cSamw 256c8ec8eeaSjose borrego boolean_t smb_shr_exists(char *); 257c8ec8eeaSjose borrego int smb_shr_is_special(char *); 258c8ec8eeaSjose borrego boolean_t smb_shr_is_restricted(char *); 259c8ec8eeaSjose borrego boolean_t smb_shr_is_admin(char *); 260c5866007SKeyur Desai char smb_shr_drive_letter(const char *); 2613db3f65cSamw 26289dc44ceSjose borrego sa_handle_t smb_shr_sa_enter(void); 26389dc44ceSjose borrego void smb_shr_sa_exit(void); 26489dc44ceSjose borrego void smb_shr_sa_csc_option(const char *, smb_share_t *); 26529bd2886SAlan Wright char *smb_shr_sa_csc_name(const smb_share_t *); 2669fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States void smb_shr_sa_setflag(const char *, smb_share_t *, uint32_t); 26789dc44ceSjose borrego 2683db3f65cSamw /* 2693db3f65cSamw * CIFS share management API exported for other processes 2703db3f65cSamw */ 271c8ec8eeaSjose borrego uint32_t smb_share_list(int, smb_shrlist_t *); 2723db3f65cSamw int smb_share_count(void); 273c8ec8eeaSjose borrego uint32_t smb_share_delete(char *); 274c8ec8eeaSjose borrego uint32_t smb_share_rename(char *, char *); 275c8ec8eeaSjose borrego uint32_t smb_share_create(smb_share_t *); 276b89a8333Snatalie li - Sun Microsystems - Irvine United States uint32_t smb_share_modify(smb_share_t *); 2773db3f65cSamw 2787206bf49SGordon Ross #endif /* _KERNEL */ 2793db3f65cSamw 2803db3f65cSamw #ifdef __cplusplus 2813db3f65cSamw } 2823db3f65cSamw #endif 2833db3f65cSamw 2843db3f65cSamw #endif /* _SMB_SHARE_H */ 285