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 */ 213db3f65cSamw /* 2289dc44ceSjose borrego * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 233db3f65cSamw * Use is subject to license terms. 243db3f65cSamw */ 253db3f65cSamw 263db3f65cSamw #ifndef _SMB_SHARE_H 273db3f65cSamw #define _SMB_SHARE_H 283db3f65cSamw 293db3f65cSamw #include <sys/param.h> 303db3f65cSamw #include <smbsrv/string.h> 313db3f65cSamw #include <smbsrv/hash_table.h> 323db3f65cSamw #include <smbsrv/wintypes.h> 333db3f65cSamw #include <smbsrv/lmerr.h> 343db3f65cSamw #include <smbsrv/smb_common_door.h> 353db3f65cSamw 363db3f65cSamw #ifndef _KERNEL 373db3f65cSamw #include <libshare.h> 383db3f65cSamw #else 393db3f65cSamw #include <sys/door.h> 403db3f65cSamw #endif 413db3f65cSamw 423db3f65cSamw #ifdef __cplusplus 433db3f65cSamw extern "C" { 443db3f65cSamw #endif 453db3f65cSamw 463db3f65cSamw /* 4729bd2886SAlan Wright * Share Properties: 4829bd2886SAlan Wright * 4929bd2886SAlan Wright * name Advertised name of the share 5029bd2886SAlan Wright * 5129bd2886SAlan Wright * ad-container Active directory container in which the share 5229bd2886SAlan Wright * will be published 5329bd2886SAlan Wright * 54*e3f2c991SKeyur Desai * abe Determines whether Access Based Enumeration is applied 55*e3f2c991SKeyur Desai * to a share 56*e3f2c991SKeyur Desai * 5729bd2886SAlan Wright * csc Client-side caching (CSC) options applied to this share 5829bd2886SAlan Wright * disabled The client MUST NOT cache any files 5929bd2886SAlan Wright * manual The client should not automatically cache every file 6029bd2886SAlan Wright * that it opens 6129bd2886SAlan Wright * auto The client may cache every file that it opens 6229bd2886SAlan Wright * vdo The client may cache every file that it opens 638d7e4166Sjose borrego * and satisfy file requests from its local cache. 6429bd2886SAlan Wright * 6529bd2886SAlan Wright * catia CATIA character substitution 6629bd2886SAlan Wright * 6729bd2886SAlan Wright * guestok Determines whether guest access is allowed 6829bd2886SAlan Wright * 6929bd2886SAlan Wright * next three properties use access-list a al NFS 7029bd2886SAlan Wright * 7129bd2886SAlan Wright * ro list of hosts that will have read-only access 7229bd2886SAlan Wright * rw list of hosts that will have read/write access 7329bd2886SAlan Wright * none list of hosts that won't be allowed access 743db3f65cSamw */ 758d7e4166Sjose borrego #define SHOPT_AD_CONTAINER "ad-container" 76*e3f2c991SKeyur Desai #define SHOPT_ABE "abe" 7729bd2886SAlan Wright #define SHOPT_NAME "name" 7829bd2886SAlan Wright #define SHOPT_CSC "csc" 7929bd2886SAlan Wright #define SHOPT_CATIA "catia" 8029bd2886SAlan Wright #define SHOPT_GUEST "guestok" 8129bd2886SAlan Wright #define SHOPT_RO "ro" 8229bd2886SAlan Wright #define SHOPT_RW "rw" 8329bd2886SAlan Wright #define SHOPT_NONE "none" 843db3f65cSamw 853db3f65cSamw #define SMB_DEFAULT_SHARE_GROUP "smb" 863db3f65cSamw #define SMB_PROTOCOL_NAME "smb" 873db3f65cSamw 8829bd2886SAlan Wright #define SMB_SHR_MAP 0 8929bd2886SAlan Wright #define SMB_SHR_UNMAP 1 9029bd2886SAlan Wright #define SMB_SHR_DISP_CONT_STR "continue" 9129bd2886SAlan Wright #define SMB_SHR_DISP_TERM_STR "terminate" 9229bd2886SAlan Wright 933db3f65cSamw /* 943db3f65cSamw * RAP protocol share related commands only understand 953db3f65cSamw * share names in OEM format and there is a 13 char size 963db3f65cSamw * limitation 973db3f65cSamw */ 983db3f65cSamw #define SMB_SHARE_OEMNAME_MAX 13 993db3f65cSamw #define SMB_SHARE_CMNT_MAX (64 * MTS_MB_CHAR_MAX) 1003db3f65cSamw 1013db3f65cSamw /* 1023db3f65cSamw * struct SHARE_INFO_1 { 1033db3f65cSamw * char shi1_netname[13] 1043db3f65cSamw * char shi1_pad; 1053db3f65cSamw * unsigned short shi1_type 1063db3f65cSamw * char *shi1_remark; 1073db3f65cSamw * } 1083db3f65cSamw */ 1093db3f65cSamw #define SHARE_INFO_1_SIZE (SMB_SHARE_OEMNAME_MAX + 1 + 2 + 4) 1103db3f65cSamw 1113db3f65cSamw /* 1123db3f65cSamw * Share flags: 1133db3f65cSamw * 1143db3f65cSamw * SMB_SHRF_TRANS Transient share 1153db3f65cSamw * SMB_SHRF_PERM Permanent share 1163db3f65cSamw * SMB_SHRF_AUTOHOME Autohome share. 1173db3f65cSamw * SMB_SHRF_LONGNAME Share name in OEM is longer than 13 chars 1188d7e4166Sjose borrego * SMB_SHRF_CSC_DISABLED Client-side caching is disabled for this share 1198d7e4166Sjose borrego * SMB_SHRF_CSC_MANUAL Manual client-side caching is allowed 1208d7e4166Sjose borrego * SMB_SHRF_CSC_AUTO Automatic client-side caching (CSC) is allowed 1218d7e4166Sjose borrego * SMB_SHRF_CSC_VDO Automatic CSC and local cache lookup is allowed 122b89a8333Snatalie li - Sun Microsystems - Irvine United States * SMB_SHRF_ACC_OPEN No restrictions set 123b89a8333Snatalie li - Sun Microsystems - Irvine United States * SMB_SHRF_ACC_NONE "none" property set 124b89a8333Snatalie li - Sun Microsystems - Irvine United States * SMB_SHRF_ACC_RO "ro" (readonly) property set 125b89a8333Snatalie li - Sun Microsystems - Irvine United States * SMB_SHRF_ACC_RW "rw" (read/write) property set 126b89a8333Snatalie li - Sun Microsystems - Irvine United States * SMB_SHRF_ACC_ALL All of the access bits 1278d7e4166Sjose borrego * SMB_SHRF_ADMIN Admin share 1288b2cc8acSafshin salek ardakani - Sun Microsystems - Irvine United States * SMB_SHRF_CATIA CATIA character translation on/off 12929bd2886SAlan Wright * SMB_SHRF_GUEST_OK Guest access on/off 130*e3f2c991SKeyur Desai * SMB_SHRF_ABE Access Based Enumeration on/off 13129bd2886SAlan Wright * SMB_SHRF_MAP Map command is specified 13229bd2886SAlan Wright * SMB_SHRF_UNMAP Unmap command is specified 13329bd2886SAlan Wright * SMB_SHRF_DISP_TERM Disposition is set to terminate 13429bd2886SAlan Wright * SMB_SHRF_EXEC_MASK All of the exec bits 1353db3f65cSamw * 1363db3f65cSamw * All autohome shares are transient but not all transient shares are autohome. 1373db3f65cSamw * IPC$ and drive letter shares (e.g. d$, e$, etc) are transient but 1383db3f65cSamw * not autohome. 1393db3f65cSamw */ 1403db3f65cSamw #define SMB_SHRF_TRANS 0x0001 1413db3f65cSamw #define SMB_SHRF_PERM 0x0002 1423db3f65cSamw #define SMB_SHRF_AUTOHOME 0x0004 1433db3f65cSamw #define SMB_SHRF_LONGNAME 0x0008 1448d7e4166Sjose borrego 1458d7e4166Sjose borrego #define SMB_SHRF_CSC_MASK 0x00F0 1468d7e4166Sjose borrego #define SMB_SHRF_CSC_DISABLED 0x0010 1478d7e4166Sjose borrego #define SMB_SHRF_CSC_MANUAL 0x0020 1488d7e4166Sjose borrego #define SMB_SHRF_CSC_AUTO 0x0040 1498d7e4166Sjose borrego #define SMB_SHRF_CSC_VDO 0x0080 1503db3f65cSamw 151b89a8333Snatalie li - Sun Microsystems - Irvine United States /* Access Flags */ 152b89a8333Snatalie li - Sun Microsystems - Irvine United States #define SMB_SHRF_ACC_OPEN 0x0000 153b89a8333Snatalie li - Sun Microsystems - Irvine United States #define SMB_SHRF_ACC_NONE 0x0100 154b89a8333Snatalie li - Sun Microsystems - Irvine United States #define SMB_SHRF_ACC_RO 0x0200 155b89a8333Snatalie li - Sun Microsystems - Irvine United States #define SMB_SHRF_ACC_RW 0x0400 156b89a8333Snatalie li - Sun Microsystems - Irvine United States #define SMB_SHRF_ACC_ALL 0x0F00 157b89a8333Snatalie li - Sun Microsystems - Irvine United States 1588d7e4166Sjose borrego #define SMB_SHRF_ADMIN 0x1000 1598b2cc8acSafshin salek ardakani - Sun Microsystems - Irvine United States #define SMB_SHRF_CATIA 0x2000 16029bd2886SAlan Wright #define SMB_SHRF_GUEST_OK 0x4000 161*e3f2c991SKeyur Desai #define SMB_SHRF_ABE 0x8000 1628d7e4166Sjose borrego 16329bd2886SAlan Wright /* Exec Flags */ 16429bd2886SAlan Wright #define SMB_SHRF_MAP 0x10000 16529bd2886SAlan Wright #define SMB_SHRF_UNMAP 0x20000 16629bd2886SAlan Wright #define SMB_SHRF_DISP_TERM 0x40000 16729bd2886SAlan Wright #define SMB_SHRF_EXEC_MASK 0x70000 168b89a8333Snatalie li - Sun Microsystems - Irvine United States 1693db3f65cSamw /* 1703db3f65cSamw * refcnt is currently only used for autohome. autohome needs a refcnt 1713db3f65cSamw * because a user can map his autohome share from more than one client 1723db3f65cSamw * at the same time and the share should only be removed when the last 1733db3f65cSamw * one is disconnected 1743db3f65cSamw */ 1753db3f65cSamw typedef struct smb_share { 1763db3f65cSamw char shr_name[MAXNAMELEN]; 1773db3f65cSamw char shr_path[MAXPATHLEN]; 1783db3f65cSamw char shr_cmnt[SMB_SHARE_CMNT_MAX]; 1793db3f65cSamw char shr_container[MAXPATHLEN]; 1803db3f65cSamw char shr_oemname[SMB_SHARE_OEMNAME_MAX]; 1813db3f65cSamw uint32_t shr_flags; 1823db3f65cSamw uint32_t shr_type; 1833db3f65cSamw uint32_t shr_refcnt; 184b89a8333Snatalie li - Sun Microsystems - Irvine United States uint32_t shr_access_value; /* host return access value */ 185b89a8333Snatalie li - Sun Microsystems - Irvine United States char shr_access_none[MAXPATHLEN]; 186b89a8333Snatalie li - Sun Microsystems - Irvine United States char shr_access_ro[MAXPATHLEN]; 187b89a8333Snatalie li - Sun Microsystems - Irvine United States char shr_access_rw[MAXPATHLEN]; 1883db3f65cSamw } smb_share_t; 1893db3f65cSamw 1903db3f65cSamw typedef struct smb_shriter { 1913db3f65cSamw smb_share_t si_share; 1923db3f65cSamw HT_ITERATOR si_hashiter; 193c8ec8eeaSjose borrego boolean_t si_first; 1943db3f65cSamw } smb_shriter_t; 1953db3f65cSamw 1963db3f65cSamw #define LMSHARES_PER_REQUEST 10 1973db3f65cSamw typedef struct smb_shrlist { 198c8ec8eeaSjose borrego int sl_cnt; 199c8ec8eeaSjose borrego smb_share_t sl_shares[LMSHARES_PER_REQUEST]; 2003db3f65cSamw } smb_shrlist_t; 2013db3f65cSamw 2023db3f65cSamw /* 2033db3f65cSamw * This structure is a helper for building NetShareEnum response 2043db3f65cSamw * in user space and send it back down to kernel. 2053db3f65cSamw * 2063db3f65cSamw * es_username name of the user requesting the shares list which 2073db3f65cSamw * is used to detect if the user has any autohome 2083db3f65cSamw * es_bufsize size of the response buffer 2093db3f65cSamw * es_buf pointer to the response buffer 2103db3f65cSamw * es_ntotal total number of shares exported by server which 2113db3f65cSamw * their OEM names is less then 13 chars 2123db3f65cSamw * es_nsent number of shares that can fit in the specified buffer 2133db3f65cSamw * es_datasize actual data size (share's data) which was encoded 2143db3f65cSamw * in the response buffer 2153db3f65cSamw */ 2163db3f65cSamw typedef struct smb_enumshare_info { 2173db3f65cSamw char *es_username; 2183db3f65cSamw uint16_t es_bufsize; 2193db3f65cSamw char *es_buf; 2203db3f65cSamw uint16_t es_ntotal; 2213db3f65cSamw uint16_t es_nsent; 2223db3f65cSamw uint16_t es_datasize; 2233db3f65cSamw } smb_enumshare_info_t; 2243db3f65cSamw 22529bd2886SAlan Wright typedef struct smb_execsub_info { 22629bd2886SAlan Wright char *e_winname; 22729bd2886SAlan Wright char *e_userdom; 22829bd2886SAlan Wright smb_inaddr_t e_srv_ipaddr; 22929bd2886SAlan Wright smb_inaddr_t e_cli_ipaddr; 23029bd2886SAlan Wright char *e_cli_netbiosname; 23129bd2886SAlan Wright uid_t e_uid; 23229bd2886SAlan Wright } smb_execsub_info_t; 23329bd2886SAlan Wright 2343db3f65cSamw /* 2353db3f65cSamw * LanMan share API (for both SMB kernel module and GUI/CLI sub-system) 2363db3f65cSamw * 2373db3f65cSamw * NOTE: If any error is encounted by either the door server or client, 2383db3f65cSamw * NERR_InternalError will be returned by most functions, smb_share_count 2393db3f65cSamw * will return -1. 2403db3f65cSamw */ 2413db3f65cSamw 2423db3f65cSamw #ifndef _KERNEL 2433db3f65cSamw 2443db3f65cSamw /* 245c8ec8eeaSjose borrego * CIFS share management functions exported by libmlsvc 2463db3f65cSamw */ 2473db3f65cSamw int smb_shr_start(void); 2483db3f65cSamw void smb_shr_stop(void); 2498d7e4166Sjose borrego int smb_shr_load(void); 250c8ec8eeaSjose borrego void smb_shr_iterinit(smb_shriter_t *); 251c8ec8eeaSjose borrego smb_share_t *smb_shr_iterate(smb_shriter_t *); 252c8ec8eeaSjose borrego void smb_shr_list(int, smb_shrlist_t *); 2533db3f65cSamw int smb_shr_count(void); 254b89a8333Snatalie li - Sun Microsystems - Irvine United States uint32_t smb_shr_add(smb_share_t *); 255b89a8333Snatalie li - Sun Microsystems - Irvine United States uint32_t smb_shr_remove(char *); 256c8ec8eeaSjose borrego uint32_t smb_shr_rename(char *, char *); 257c8ec8eeaSjose borrego uint32_t smb_shr_get(char *, smb_share_t *); 258b89a8333Snatalie li - Sun Microsystems - Irvine United States uint32_t smb_shr_modify(smb_share_t *); 259c8ec8eeaSjose borrego uint32_t smb_shr_get_realpath(const char *, char *, int); 2607f667e74Sjose borrego void smb_shr_hostaccess(smb_share_t *, smb_inaddr_t *); 26129bd2886SAlan Wright int smb_shr_exec(char *, smb_execsub_info_t *, int); 2623db3f65cSamw 263c8ec8eeaSjose borrego boolean_t smb_shr_exists(char *); 264c8ec8eeaSjose borrego int smb_shr_is_special(char *); 265c8ec8eeaSjose borrego boolean_t smb_shr_is_restricted(char *); 266c8ec8eeaSjose borrego boolean_t smb_shr_is_admin(char *); 267c8ec8eeaSjose borrego boolean_t smb_shr_chkname(char *); 2683db3f65cSamw 26989dc44ceSjose borrego sa_handle_t smb_shr_sa_enter(void); 27089dc44ceSjose borrego void smb_shr_sa_exit(void); 27189dc44ceSjose borrego void smb_shr_sa_csc_option(const char *, smb_share_t *); 27229bd2886SAlan Wright char *smb_shr_sa_csc_name(const smb_share_t *); 2738b2cc8acSafshin salek ardakani - Sun Microsystems - Irvine United States void smb_shr_sa_catia_option(const char *, smb_share_t *); 274*e3f2c991SKeyur Desai void smb_shr_sa_abe_option(const char *, smb_share_t *); 27589dc44ceSjose borrego 2763db3f65cSamw /* 2773db3f65cSamw * CIFS share management API exported for other processes 2783db3f65cSamw */ 279c8ec8eeaSjose borrego uint32_t smb_share_list(int, smb_shrlist_t *); 2803db3f65cSamw int smb_share_count(void); 281c8ec8eeaSjose borrego uint32_t smb_share_delete(char *); 282c8ec8eeaSjose borrego uint32_t smb_share_rename(char *, char *); 283c8ec8eeaSjose borrego uint32_t smb_share_create(smb_share_t *); 284b89a8333Snatalie li - Sun Microsystems - Irvine United States uint32_t smb_share_modify(smb_share_t *); 2853db3f65cSamw 2863db3f65cSamw #else 2873db3f65cSamw 2883db3f65cSamw door_handle_t smb_kshare_init(int); 2893db3f65cSamw void smb_kshare_fini(door_handle_t); 2907f667e74Sjose borrego uint32_t smb_kshare_getinfo(door_handle_t, char *, smb_share_t *, 2917f667e74Sjose borrego smb_inaddr_t *); 2923db3f65cSamw int smb_kshare_upcall(door_handle_t, void *, boolean_t); 2933db3f65cSamw uint32_t smb_kshare_enum(door_handle_t, smb_enumshare_info_t *); 29429bd2886SAlan Wright uint32_t smb_kshare_exec(door_handle_t, char *, smb_execsub_info_t *, int); 2953db3f65cSamw 2963db3f65cSamw #endif 2973db3f65cSamw 298c8ec8eeaSjose borrego #define SMB_SHARE_DNAME "/var/run/smb_share_door" 2993db3f65cSamw #define SMB_SHARE_DSIZE (65 * 1024) 3003db3f65cSamw 3013db3f65cSamw /* 3023db3f65cSamw * Door interface 3033db3f65cSamw * 3043db3f65cSamw * Define door operations 3053db3f65cSamw */ 3063db3f65cSamw #define SMB_SHROP_NUM_SHARES 1 3073db3f65cSamw #define SMB_SHROP_DELETE 2 3083db3f65cSamw #define SMB_SHROP_RENAME 3 3093db3f65cSamw #define SMB_SHROP_GETINFO 4 3103db3f65cSamw #define SMB_SHROP_ADD 5 311c8ec8eeaSjose borrego #define SMB_SHROP_MODIFY 6 3123db3f65cSamw #define SMB_SHROP_LIST 7 3133db3f65cSamw #define SMB_SHROP_ENUM 8 31429bd2886SAlan Wright #define SMB_SHROP_EXEC 9 3153db3f65cSamw 3163db3f65cSamw /* 3173db3f65cSamw * Door server status 3183db3f65cSamw * 3193db3f65cSamw * SMB_SHARE_DERROR is returned by the door server if there is problem 3203db3f65cSamw * with marshalling/unmarshalling. Otherwise, SMB_SHARE_DSUCCESS is 3213db3f65cSamw * returned. 3223db3f65cSamw * 3233db3f65cSamw */ 3243db3f65cSamw #define SMB_SHARE_DSUCCESS 0 3253db3f65cSamw #define SMB_SHARE_DERROR -1 3263db3f65cSamw 3273db3f65cSamw void smb_dr_get_share(smb_dr_ctx_t *, smb_share_t *); 3283db3f65cSamw void smb_dr_put_share(smb_dr_ctx_t *, smb_share_t *); 3293db3f65cSamw 3308d96b23eSAlan Wright void smb_share_door_clnt_init(void); 3318d96b23eSAlan Wright void smb_share_door_clnt_fini(void); 3323db3f65cSamw 3333db3f65cSamw #ifdef __cplusplus 3343db3f65cSamw } 3353db3f65cSamw #endif 3363db3f65cSamw 3373db3f65cSamw #endif /* _SMB_SHARE_H */ 338