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 /* 303db3f65cSamw * This file defines the LanMan (CIFS/SMB) resource share interface. 313db3f65cSamw */ 323db3f65cSamw 333db3f65cSamw #include <sys/param.h> 343db3f65cSamw #include <smbsrv/string.h> 353db3f65cSamw #include <smbsrv/hash_table.h> 363db3f65cSamw #include <smbsrv/wintypes.h> 373db3f65cSamw #include <smbsrv/lmerr.h> 383db3f65cSamw #include <smbsrv/smb_common_door.h> 39b89a8333Snatalie li - Sun Microsystems - Irvine United States #include <netinet/in.h> 403db3f65cSamw 413db3f65cSamw #ifndef _KERNEL 423db3f65cSamw #include <libshare.h> 433db3f65cSamw #else 443db3f65cSamw #include <sys/door.h> 453db3f65cSamw #endif 463db3f65cSamw 473db3f65cSamw #ifdef __cplusplus 483db3f65cSamw extern "C" { 493db3f65cSamw #endif 503db3f65cSamw 513db3f65cSamw /* 528d7e4166Sjose borrego * Share-specific client-side caching (CSC) options: 538d7e4166Sjose borrego * disabled The client MUST NOT cache any files from this share. 548d7e4166Sjose borrego * manual The client should not automatically cache every file that it 558d7e4166Sjose borrego * opens from this share. 568d7e4166Sjose borrego * auto The client may cache every file that it opens from this share. 578d7e4166Sjose borrego * vdo The client may cache every file that it opens from this share 588d7e4166Sjose borrego * and satisfy file requests from its local cache. 593db3f65cSamw */ 608d7e4166Sjose borrego #define SHOPT_AD_CONTAINER "ad-container" 618d7e4166Sjose borrego #define SHOPT_NAME "name" /* name is a pseudo property */ 628d7e4166Sjose borrego #define SHOPT_CSC "csc" /* client-side caching (CSC) options */ 63*8b2cc8acSafshin salek ardakani - Sun Microsystems - Irvine United States #define SHOPT_CATIA "catia" /* CATIA character substitution */ 64b89a8333Snatalie li - Sun Microsystems - Irvine United States /* next three properties use access-list a al NFS */ 65b89a8333Snatalie li - Sun Microsystems - Irvine United States #define SHOPT_RO "ro" /* share is read-only */ 66b89a8333Snatalie li - Sun Microsystems - Irvine United States #define SHOPT_RW "rw" /* share defaults to read-write */ 67b89a8333Snatalie li - Sun Microsystems - Irvine United States #define SHOPT_NONE "none" /* share doesn't allow access */ 683db3f65cSamw 693db3f65cSamw #define SMB_DEFAULT_SHARE_GROUP "smb" 703db3f65cSamw #define SMB_PROTOCOL_NAME "smb" 713db3f65cSamw 723db3f65cSamw /* 733db3f65cSamw * RAP protocol share related commands only understand 743db3f65cSamw * share names in OEM format and there is a 13 char size 753db3f65cSamw * limitation 763db3f65cSamw */ 773db3f65cSamw #define SMB_SHARE_OEMNAME_MAX 13 783db3f65cSamw #define SMB_SHARE_CMNT_MAX (64 * MTS_MB_CHAR_MAX) 793db3f65cSamw 803db3f65cSamw /* 813db3f65cSamw * struct SHARE_INFO_1 { 823db3f65cSamw * char shi1_netname[13] 833db3f65cSamw * char shi1_pad; 843db3f65cSamw * unsigned short shi1_type 853db3f65cSamw * char *shi1_remark; 863db3f65cSamw * } 873db3f65cSamw */ 883db3f65cSamw #define SHARE_INFO_1_SIZE (SMB_SHARE_OEMNAME_MAX + 1 + 2 + 4) 893db3f65cSamw 903db3f65cSamw /* 913db3f65cSamw * Share flags: 923db3f65cSamw * 933db3f65cSamw * SMB_SHRF_TRANS Transient share 943db3f65cSamw * SMB_SHRF_PERM Permanent share 953db3f65cSamw * SMB_SHRF_AUTOHOME Autohome share. 963db3f65cSamw * SMB_SHRF_LONGNAME Share name in OEM is longer than 13 chars 978d7e4166Sjose borrego * SMB_SHRF_CSC_DISABLED Client-side caching is disabled for this share 988d7e4166Sjose borrego * SMB_SHRF_CSC_MANUAL Manual client-side caching is allowed 998d7e4166Sjose borrego * SMB_SHRF_CSC_AUTO Automatic client-side caching (CSC) is allowed 1008d7e4166Sjose borrego * SMB_SHRF_CSC_VDO Automatic CSC and local cache lookup is allowed 101b89a8333Snatalie li - Sun Microsystems - Irvine United States * SMB_SHRF_ACC_OPEN No restrictions set 102b89a8333Snatalie li - Sun Microsystems - Irvine United States * SMB_SHRF_ACC_NONE "none" property set 103b89a8333Snatalie li - Sun Microsystems - Irvine United States * SMB_SHRF_ACC_RO "ro" (readonly) property set 104b89a8333Snatalie li - Sun Microsystems - Irvine United States * SMB_SHRF_ACC_RW "rw" (read/write) property set 105b89a8333Snatalie li - Sun Microsystems - Irvine United States * SMB_SHRF_ACC_ALL All of the access bits 1068d7e4166Sjose borrego * SMB_SHRF_ADMIN Admin share 107*8b2cc8acSafshin salek ardakani - Sun Microsystems - Irvine United States * SMB_SHRF_CATIA CATIA character translation on/off 1083db3f65cSamw * 1093db3f65cSamw * All autohome shares are transient but not all transient shares are autohome. 1103db3f65cSamw * IPC$ and drive letter shares (e.g. d$, e$, etc) are transient but 1113db3f65cSamw * not autohome. 1123db3f65cSamw */ 1133db3f65cSamw #define SMB_SHRF_TRANS 0x0001 1143db3f65cSamw #define SMB_SHRF_PERM 0x0002 1153db3f65cSamw #define SMB_SHRF_AUTOHOME 0x0004 1163db3f65cSamw #define SMB_SHRF_LONGNAME 0x0008 1178d7e4166Sjose borrego 1188d7e4166Sjose borrego #define SMB_SHRF_CSC_MASK 0x00F0 1198d7e4166Sjose borrego #define SMB_SHRF_CSC_DISABLED 0x0010 1208d7e4166Sjose borrego #define SMB_SHRF_CSC_MANUAL 0x0020 1218d7e4166Sjose borrego #define SMB_SHRF_CSC_AUTO 0x0040 1228d7e4166Sjose borrego #define SMB_SHRF_CSC_VDO 0x0080 1233db3f65cSamw 124b89a8333Snatalie li - Sun Microsystems - Irvine United States /* Access Flags */ 125b89a8333Snatalie li - Sun Microsystems - Irvine United States #define SMB_SHRF_ACC_OPEN 0x0000 126b89a8333Snatalie li - Sun Microsystems - Irvine United States #define SMB_SHRF_ACC_NONE 0x0100 127b89a8333Snatalie li - Sun Microsystems - Irvine United States #define SMB_SHRF_ACC_RO 0x0200 128b89a8333Snatalie li - Sun Microsystems - Irvine United States #define SMB_SHRF_ACC_RW 0x0400 129b89a8333Snatalie li - Sun Microsystems - Irvine United States #define SMB_SHRF_ACC_ALL 0x0F00 130b89a8333Snatalie li - Sun Microsystems - Irvine United States 1318d7e4166Sjose borrego #define SMB_SHRF_ADMIN 0x1000 132*8b2cc8acSafshin salek ardakani - Sun Microsystems - Irvine United States #define SMB_SHRF_CATIA 0x2000 1338d7e4166Sjose borrego 134b89a8333Snatalie li - Sun Microsystems - Irvine United States 1353db3f65cSamw /* 1363db3f65cSamw * refcnt is currently only used for autohome. autohome needs a refcnt 1373db3f65cSamw * because a user can map his autohome share from more than one client 1383db3f65cSamw * at the same time and the share should only be removed when the last 1393db3f65cSamw * one is disconnected 1403db3f65cSamw */ 1413db3f65cSamw typedef struct smb_share { 1423db3f65cSamw char shr_name[MAXNAMELEN]; 1433db3f65cSamw char shr_path[MAXPATHLEN]; 1443db3f65cSamw char shr_cmnt[SMB_SHARE_CMNT_MAX]; 1453db3f65cSamw char shr_container[MAXPATHLEN]; 1463db3f65cSamw char shr_oemname[SMB_SHARE_OEMNAME_MAX]; 1473db3f65cSamw uint32_t shr_flags; 1483db3f65cSamw uint32_t shr_type; 1493db3f65cSamw uint32_t shr_refcnt; 150b89a8333Snatalie li - Sun Microsystems - Irvine United States uint32_t shr_access_value; /* host return access value */ 151b89a8333Snatalie li - Sun Microsystems - Irvine United States char shr_access_none[MAXPATHLEN]; 152b89a8333Snatalie li - Sun Microsystems - Irvine United States char shr_access_ro[MAXPATHLEN]; 153b89a8333Snatalie li - Sun Microsystems - Irvine United States char shr_access_rw[MAXPATHLEN]; 1543db3f65cSamw } smb_share_t; 1553db3f65cSamw 1563db3f65cSamw typedef struct smb_shriter { 1573db3f65cSamw smb_share_t si_share; 1583db3f65cSamw HT_ITERATOR si_hashiter; 159c8ec8eeaSjose borrego boolean_t si_first; 1603db3f65cSamw } smb_shriter_t; 1613db3f65cSamw 1623db3f65cSamw #define LMSHARES_PER_REQUEST 10 1633db3f65cSamw typedef struct smb_shrlist { 164c8ec8eeaSjose borrego int sl_cnt; 165c8ec8eeaSjose borrego smb_share_t sl_shares[LMSHARES_PER_REQUEST]; 1663db3f65cSamw } smb_shrlist_t; 1673db3f65cSamw 1683db3f65cSamw /* 1693db3f65cSamw * This structure is a helper for building NetShareEnum response 1703db3f65cSamw * in user space and send it back down to kernel. 1713db3f65cSamw * 1723db3f65cSamw * es_username name of the user requesting the shares list which 1733db3f65cSamw * is used to detect if the user has any autohome 1743db3f65cSamw * es_bufsize size of the response buffer 1753db3f65cSamw * es_buf pointer to the response buffer 1763db3f65cSamw * es_ntotal total number of shares exported by server which 1773db3f65cSamw * their OEM names is less then 13 chars 1783db3f65cSamw * es_nsent number of shares that can fit in the specified buffer 1793db3f65cSamw * es_datasize actual data size (share's data) which was encoded 1803db3f65cSamw * in the response buffer 1813db3f65cSamw */ 1823db3f65cSamw typedef struct smb_enumshare_info { 1833db3f65cSamw char *es_username; 1843db3f65cSamw uint16_t es_bufsize; 1853db3f65cSamw char *es_buf; 1863db3f65cSamw uint16_t es_ntotal; 1873db3f65cSamw uint16_t es_nsent; 1883db3f65cSamw uint16_t es_datasize; 1893db3f65cSamw } smb_enumshare_info_t; 1903db3f65cSamw 1913db3f65cSamw /* 1923db3f65cSamw * LanMan share API (for both SMB kernel module and GUI/CLI sub-system) 1933db3f65cSamw * 1943db3f65cSamw * NOTE: If any error is encounted by either the door server or client, 1953db3f65cSamw * NERR_InternalError will be returned by most functions, smb_share_count 1963db3f65cSamw * will return -1. 1973db3f65cSamw */ 1983db3f65cSamw 1993db3f65cSamw #ifndef _KERNEL 2003db3f65cSamw 2013db3f65cSamw /* 202c8ec8eeaSjose borrego * CIFS share management functions exported by libmlsvc 2033db3f65cSamw */ 2043db3f65cSamw int smb_shr_start(void); 2053db3f65cSamw void smb_shr_stop(void); 2068d7e4166Sjose borrego int smb_shr_load(void); 207c8ec8eeaSjose borrego void smb_shr_iterinit(smb_shriter_t *); 208c8ec8eeaSjose borrego smb_share_t *smb_shr_iterate(smb_shriter_t *); 209c8ec8eeaSjose borrego void smb_shr_list(int, smb_shrlist_t *); 2103db3f65cSamw int smb_shr_count(void); 211b89a8333Snatalie li - Sun Microsystems - Irvine United States uint32_t smb_shr_add(smb_share_t *); 212b89a8333Snatalie li - Sun Microsystems - Irvine United States uint32_t smb_shr_remove(char *); 213c8ec8eeaSjose borrego uint32_t smb_shr_rename(char *, char *); 214c8ec8eeaSjose borrego uint32_t smb_shr_get(char *, smb_share_t *); 215b89a8333Snatalie li - Sun Microsystems - Irvine United States uint32_t smb_shr_modify(smb_share_t *); 216c8ec8eeaSjose borrego uint32_t smb_shr_get_realpath(const char *, char *, int); 2177f667e74Sjose borrego void smb_shr_hostaccess(smb_share_t *, smb_inaddr_t *); 2183db3f65cSamw 219c8ec8eeaSjose borrego boolean_t smb_shr_exists(char *); 220c8ec8eeaSjose borrego int smb_shr_is_special(char *); 221c8ec8eeaSjose borrego boolean_t smb_shr_is_restricted(char *); 222c8ec8eeaSjose borrego boolean_t smb_shr_is_admin(char *); 223c8ec8eeaSjose borrego boolean_t smb_shr_chkname(char *); 2243db3f65cSamw 22589dc44ceSjose borrego sa_handle_t smb_shr_sa_enter(void); 22689dc44ceSjose borrego void smb_shr_sa_exit(void); 22789dc44ceSjose borrego void smb_shr_sa_csc_option(const char *, smb_share_t *); 228*8b2cc8acSafshin salek ardakani - Sun Microsystems - Irvine United States void smb_shr_sa_catia_option(const char *, smb_share_t *); 22989dc44ceSjose borrego 2303db3f65cSamw /* 2313db3f65cSamw * CIFS share management API exported for other processes 2323db3f65cSamw */ 233c8ec8eeaSjose borrego uint32_t smb_share_list(int, smb_shrlist_t *); 2343db3f65cSamw int smb_share_count(void); 235c8ec8eeaSjose borrego uint32_t smb_share_delete(char *); 236c8ec8eeaSjose borrego uint32_t smb_share_rename(char *, char *); 237c8ec8eeaSjose borrego uint32_t smb_share_create(smb_share_t *); 238b89a8333Snatalie li - Sun Microsystems - Irvine United States uint32_t smb_share_modify(smb_share_t *); 2393db3f65cSamw 2403db3f65cSamw #else 2413db3f65cSamw 2423db3f65cSamw door_handle_t smb_kshare_init(int); 2433db3f65cSamw void smb_kshare_fini(door_handle_t); 2447f667e74Sjose borrego uint32_t smb_kshare_getinfo(door_handle_t, char *, smb_share_t *, 2457f667e74Sjose borrego smb_inaddr_t *); 2463db3f65cSamw int smb_kshare_upcall(door_handle_t, void *, boolean_t); 2473db3f65cSamw uint32_t smb_kshare_enum(door_handle_t, smb_enumshare_info_t *); 2483db3f65cSamw 2493db3f65cSamw #endif 2503db3f65cSamw 251c8ec8eeaSjose borrego #define SMB_SHARE_DNAME "/var/run/smb_share_door" 2523db3f65cSamw #define SMB_SHARE_DSIZE (65 * 1024) 2533db3f65cSamw 2543db3f65cSamw /* 2553db3f65cSamw * Door interface 2563db3f65cSamw * 2573db3f65cSamw * Define door operations 2583db3f65cSamw */ 2593db3f65cSamw #define SMB_SHROP_NUM_SHARES 1 2603db3f65cSamw #define SMB_SHROP_DELETE 2 2613db3f65cSamw #define SMB_SHROP_RENAME 3 2623db3f65cSamw #define SMB_SHROP_GETINFO 4 2633db3f65cSamw #define SMB_SHROP_ADD 5 264c8ec8eeaSjose borrego #define SMB_SHROP_MODIFY 6 2653db3f65cSamw #define SMB_SHROP_LIST 7 2663db3f65cSamw #define SMB_SHROP_ENUM 8 2673db3f65cSamw 2683db3f65cSamw /* 2693db3f65cSamw * Door server status 2703db3f65cSamw * 2713db3f65cSamw * SMB_SHARE_DERROR is returned by the door server if there is problem 2723db3f65cSamw * with marshalling/unmarshalling. Otherwise, SMB_SHARE_DSUCCESS is 2733db3f65cSamw * returned. 2743db3f65cSamw * 2753db3f65cSamw */ 2763db3f65cSamw #define SMB_SHARE_DSUCCESS 0 2773db3f65cSamw #define SMB_SHARE_DERROR -1 2783db3f65cSamw 2793db3f65cSamw void smb_dr_get_share(smb_dr_ctx_t *, smb_share_t *); 2803db3f65cSamw void smb_dr_put_share(smb_dr_ctx_t *, smb_share_t *); 2813db3f65cSamw 2828d96b23eSAlan Wright void smb_share_door_clnt_init(void); 2838d96b23eSAlan Wright void smb_share_door_clnt_fini(void); 2843db3f65cSamw 2853db3f65cSamw #ifdef __cplusplus 2863db3f65cSamw } 2873db3f65cSamw #endif 2883db3f65cSamw 2893db3f65cSamw #endif /* _SMB_SHARE_H */ 290