smb_share.h revision 11963:061945695ce1
125184Sjkh/* 225184Sjkh * CDDL HEADER START 341185Smsmith * 425184Sjkh * The contents of this file are subject to the terms of the 525184Sjkh * Common Development and Distribution License (the "License"). 625184Sjkh * You may not use this file except in compliance with the License. 725184Sjkh * 825184Sjkh * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 925184Sjkh * or http://www.opensolaris.org/os/licensing. 1025184Sjkh * See the License for the specific language governing permissions 1125184Sjkh * and limitations under the License. 1225184Sjkh * 1325184Sjkh * When distributing Covered Code, include this CDDL HEADER in each 1425184Sjkh * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 1525184Sjkh * If applicable, add the following below this CDDL HEADER, with the 1625184Sjkh * fields enclosed by brackets "[]" replaced with your own identifying 1725184Sjkh * information: Portions Copyright [yyyy] [name of copyright owner] 1825184Sjkh * 1925184Sjkh * CDDL HEADER END 2025184Sjkh */ 2125184Sjkh/* 2225184Sjkh * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 2325184Sjkh * Use is subject to license terms. 2425184Sjkh */ 2525184Sjkh 2625184Sjkh#ifndef _SMB_SHARE_H 2725184Sjkh#define _SMB_SHARE_H 2840006Sphk 2940006Sphk#include <sys/param.h> 3040006Sphk#include <smbsrv/string.h> 3140006Sphk#include <smbsrv/smb_inet.h> 3240006Sphk#include <smbsrv/hash_table.h> 3340006Sphk#include <smbsrv/wintypes.h> 3425184Sjkh#include <smbsrv/lmerr.h> 3525184Sjkh#include <smbsrv/smb_door.h> 3625184Sjkh 3733682Sbrian#ifndef _KERNEL 3825184Sjkh#include <libshare.h> 3925184Sjkh#else 4025184Sjkh#include <sys/door.h> 4125184Sjkh#endif 4225184Sjkh 4325184Sjkh#ifdef __cplusplus 4425184Sjkhextern "C" { 4525184Sjkh#endif 4625184Sjkh 4725184Sjkh/* 4825184Sjkh * Share Properties: 4925184Sjkh * 5025184Sjkh * name Advertised name of the share 5125184Sjkh * 5225184Sjkh * ad-container Active directory container in which the share 5325184Sjkh * will be published 5425184Sjkh * 5525184Sjkh * abe Determines whether Access Based Enumeration is applied 5625184Sjkh * to a share 5725184Sjkh * 5825184Sjkh * csc Client-side caching (CSC) options applied to this share 5925184Sjkh * disabled The client MUST NOT cache any files 6025184Sjkh * manual The client should not automatically cache every file 6125184Sjkh * that it opens 6225184Sjkh * auto The client may cache every file that it opens 6329300Sdanny * vdo The client may cache every file that it opens 6429300Sdanny * and satisfy file requests from its local cache. 6529300Sdanny * 6629300Sdanny * catia CATIA character substitution 6732382Salex * 6832382Salex * guestok Determines whether guest access is allowed 6932382Salex * 7029300Sdanny * next three properties use access-list a al NFS 7129300Sdanny * 7229300Sdanny * ro list of hosts that will have read-only access 7329300Sdanny * rw list of hosts that will have read/write access 7441077Speter * none list of hosts that won't be allowed access 7529300Sdanny */ 7629300Sdanny#define SHOPT_AD_CONTAINER "ad-container" 7729300Sdanny#define SHOPT_ABE "abe" 7829300Sdanny#define SHOPT_NAME "name" 7929300Sdanny#define SHOPT_CSC "csc" 8029300Sdanny#define SHOPT_CATIA "catia" 8129300Sdanny#define SHOPT_GUEST "guestok" 8229300Sdanny#define SHOPT_RO "ro" 8329300Sdanny#define SHOPT_RW "rw" 8429300Sdanny#define SHOPT_NONE "none" 8529300Sdanny#define SHOPT_DFSROOT "dfsroot" 8625364Sjkh 8729300Sdanny#define SMB_DEFAULT_SHARE_GROUP "smb" 8829300Sdanny#define SMB_PROTOCOL_NAME "smb" 8933337Salex 9033337Salex#define SMB_SHR_MAP 0 9133149Salex#define SMB_SHR_UNMAP 1 9233149Salex#define SMB_SHR_DISP_CONT_STR "continue" 9333149Salex#define SMB_SHR_DISP_TERM_STR "terminate" 9433149Salex 9529300Sdanny/* 9625184Sjkh * RAP protocol share related commands only understand 9725184Sjkh * share names in OEM format and there is a 13 char size 9840006Sphk * limitation 9940006Sphk */ 10040006Sphk#define SMB_SHARE_OEMNAME_MAX 13 10140006Sphk#define SMB_SHARE_NTNAME_MAX 81 10240006Sphk#define SMB_SHARE_CMNT_MAX (64 * MTS_MB_CHAR_MAX) 10329300Sdanny 10429300Sdanny/* 10525184Sjkh * struct SHARE_INFO_1 { 10625184Sjkh * char shi1_netname[13] 10725184Sjkh * char shi1_pad; 10825184Sjkh * unsigned short shi1_type 10925184Sjkh * char *shi1_remark; 11025184Sjkh * } 11125184Sjkh */ 11225184Sjkh#define SHARE_INFO_1_SIZE (SMB_SHARE_OEMNAME_MAX + 1 + 2 + 4) 11325184Sjkh 11425184Sjkh/* 11525184Sjkh * Share flags: 11625184Sjkh * 11725184Sjkh * There are two types of flags: 11825184Sjkh * 11927218Spst * - flags that represent a share property 12027218Spst * - other flags set at runtime 12127218Spst * 12227218Spst * Property flags: 12327218Spst * 12439267Sjkoshy * SMB_SHRF_CSC_DISABLED Client-side caching is disabled for this share 12539267Sjkoshy * SMB_SHRF_CSC_MANUAL Manual client-side caching is allowed 12639267Sjkoshy * SMB_SHRF_CSC_AUTO Automatic client-side caching (CSC) is allowed 12739267Sjkoshy * SMB_SHRF_CSC_VDO Automatic CSC and local cache lookup is allowed 12839267Sjkoshy * SMB_SHRF_ACC_OPEN No restrictions set 12925184Sjkh * SMB_SHRF_ACC_NONE "none" property set 13025365Sjkh * SMB_SHRF_ACC_RO "ro" (readonly) property set 13125184Sjkh * SMB_SHRF_ACC_RW "rw" (read/write) property set 13225184Sjkh * SMB_SHRF_ACC_ALL All of the access bits 13325184Sjkh * SMB_SHRF_CATIA CATIA character translation on/off 13433439Sguido * SMB_SHRF_GUEST_OK Guest access on/off 13533439Sguido * SMB_SHRF_ABE Access Based Enumeration on/off 13633439Sguido * SMB_SHRF_DFSROOT Share is a standalone DFS root 13733439Sguido * 13833439Sguido * Runtime flags: 13933439Sguido * 14033439Sguido * SMB_SHRF_TRANS Transient share 14133439Sguido * SMB_SHRF_PERM Permanent share 14233439Sguido * SMB_SHRF_AUTOHOME Autohome share. 14333439Sguido * SMB_SHRF_LONGNAME Share name in OEM is longer than 13 chars 14425184Sjkh * SMB_SHRF_ADMIN Admin share 14525365Sjkh * SMB_SHRF_MAP Map command is specified 14625184Sjkh * SMB_SHRF_UNMAP Unmap command is specified 14725184Sjkh * SMB_SHRF_DISP_TERM Disposition is set to terminate 14825184Sjkh * SMB_SHRF_EXEC_MASK All of the exec bits 14936174Sjkh * 15036174Sjkh * All autohome shares are transient but not all transient shares are autohome. 15136174Sjkh * IPC$ and drive letter shares (e.g. d$, e$, etc) are transient but 15236174Sjkh * not autohome. 15336174Sjkh */ 15436174Sjkh 15536174Sjkh/* 15636174Sjkh * Property flags 15736174Sjkh */ 15836174Sjkh#define SMB_SHRF_DFSROOT 0x0001 15936174Sjkh#define SMB_SHRF_CATIA 0x0002 16025184Sjkh#define SMB_SHRF_GUEST_OK 0x0004 16136174Sjkh#define SMB_SHRF_ABE 0x0008 16225184Sjkh 16325184Sjkh#define SMB_SHRF_CSC_DISABLED 0x0010 16425765Sjkh#define SMB_SHRF_CSC_MANUAL 0x0020 16536174Sjkh#define SMB_SHRF_CSC_AUTO 0x0040 16636174Sjkh#define SMB_SHRF_CSC_VDO 0x0080 16725765Sjkh#define SMB_SHRF_CSC_MASK 0x00F0 16836174Sjkh 16934395Sjkh#define SMB_SHRF_ACC_OPEN 0x0000 17034395Sjkh#define SMB_SHRF_ACC_NONE 0x0100 17134395Sjkh#define SMB_SHRF_ACC_RO 0x0200 17225184Sjkh#define SMB_SHRF_ACC_RW 0x0400 17325184Sjkh#define SMB_SHRF_ACC_ALL 0x0F00 17425184Sjkh 17525184Sjkh/* 17625184Sjkh * Runtime flags 17725184Sjkh */ 17825184Sjkh#define SMB_SHRF_MAP 0x00010000 17932949Swollman#define SMB_SHRF_UNMAP 0x00020000 18025184Sjkh#define SMB_SHRF_DISP_TERM 0x00040000 18125184Sjkh#define SMB_SHRF_EXEC_MASK 0x00070000 18231472Sobrien 18335787Sandreas#define SMB_SHRF_ADMIN 0x01000000 18431472Sobrien#define SMB_SHRF_TRANS 0x10000000 18525184Sjkh#define SMB_SHRF_PERM 0x20000000 18631472Sobrien#define SMB_SHRF_AUTOHOME 0x40000000 18735787Sandreas#define SMB_SHRF_LONGNAME 0x80000000 18825184Sjkh 18925184Sjkh/* 19025184Sjkh * refcnt is currently only used for autohome. autohome needs a refcnt 19125184Sjkh * because a user can map his autohome share from more than one client 19225184Sjkh * at the same time and the share should only be removed when the last 19325184Sjkh * one is disconnected 19425184Sjkh */ 19525184Sjkhtypedef struct smb_share { 19625184Sjkh char shr_name[MAXNAMELEN]; 19725184Sjkh char shr_path[MAXPATHLEN]; 19825184Sjkh char shr_cmnt[SMB_SHARE_CMNT_MAX]; 19925184Sjkh char shr_container[MAXPATHLEN]; 20025184Sjkh char shr_oemname[SMB_SHARE_OEMNAME_MAX]; 20125184Sjkh uint32_t shr_flags; 20225184Sjkh uint32_t shr_type; 20325184Sjkh uint32_t shr_refcnt; 20425184Sjkh uint32_t shr_access_value; /* host return access value */ 20525184Sjkh uid_t shr_uid; /* autohome only */ 20625184Sjkh gid_t shr_gid; /* autohome only */ 20725184Sjkh char shr_access_none[MAXPATHLEN]; 20825184Sjkh char shr_access_ro[MAXPATHLEN]; 20925184Sjkh char shr_access_rw[MAXPATHLEN]; 21025184Sjkh} smb_share_t; 21125184Sjkh 21225184Sjkhtypedef struct smb_shriter { 21325184Sjkh smb_share_t si_share; 21425184Sjkh HT_ITERATOR si_hashiter; 21525184Sjkh boolean_t si_first; 21625184Sjkh} smb_shriter_t; 21725184Sjkh 21825184Sjkh#define LMSHARES_PER_REQUEST 10 21925184Sjkhtypedef struct smb_shrlist { 22035149Smarkm int sl_cnt; 22135149Smarkm smb_share_t sl_shares[LMSHARES_PER_REQUEST]; 22235149Smarkm} smb_shrlist_t; 22335149Smarkm 22435149Smarkm/* 22535149Smarkm * This structure is a helper for building NetShareEnum response 22635149Smarkm * in user space and send it back down to kernel. 22735149Smarkm * 22835149Smarkm * es_username name of the user requesting the shares list which 22940006Sphk * is used to detect if the user has any autohome 23040006Sphk * es_bufsize size of the response buffer 23140006Sphk * es_buf pointer to the response buffer 23240006Sphk * es_ntotal total number of shares exported by server which 23340006Sphk * their OEM names is less then 13 chars 23425184Sjkh * es_nsent number of shares that can fit in the specified buffer 23525184Sjkh * es_datasize actual data size (share's data) which was encoded 23625184Sjkh * in the response buffer 23725184Sjkh */ 23825184Sjkhtypedef struct smb_enumshare_info { 23925184Sjkh char *es_username; 24025184Sjkh uint16_t es_bufsize; 24125184Sjkh char *es_buf; 24225184Sjkh uint16_t es_ntotal; 24325184Sjkh uint16_t es_nsent; 24425184Sjkh uint16_t es_datasize; 24525184Sjkh} smb_enumshare_info_t; 24625184Sjkh 24725184Sjkhtypedef struct smb_execsub_info { 24825184Sjkh char *e_winname; 24925184Sjkh char *e_userdom; 25025916Sjkh smb_inaddr_t e_srv_ipaddr; 25125184Sjkh smb_inaddr_t e_cli_ipaddr; 25225184Sjkh char *e_cli_netbiosname; 25325184Sjkh uid_t e_uid; 25425184Sjkh} smb_execsub_info_t; 25525184Sjkh 25625184Sjkh/* 25725184Sjkh * LanMan share API (for both SMB kernel module and GUI/CLI sub-system) 25825184Sjkh * 25925184Sjkh * NOTE: If any error is encounted by either the door server or client, 26025916Sjkh * NERR_InternalError will be returned by most functions, smb_share_count 26141185Smsmith * will return -1. 26241185Smsmith */ 26341185Smsmith 26425184Sjkh#ifndef _KERNEL 26525184Sjkh 26625184Sjkh/* 26725184Sjkh * CIFS share management functions exported by libmlsvc 26835459Sphk */ 26939380Scracauerint smb_shr_start(void); 27035459Sphkvoid smb_shr_stop(void); 27125184Sjkhint smb_shr_load(void); 27225184Sjkhvoid smb_shr_iterinit(smb_shriter_t *); 27325184Sjkhsmb_share_t *smb_shr_iterate(smb_shriter_t *); 27425184Sjkhvoid smb_shr_list(int, smb_shrlist_t *); 27525184Sjkhint smb_shr_count(void); 27625184Sjkhuint32_t smb_shr_add(smb_share_t *); 27725184Sjkhuint32_t smb_shr_remove(char *); 27825184Sjkhuint32_t smb_shr_rename(char *, char *); 27925184Sjkhuint32_t smb_shr_get(char *, smb_share_t *); 28031033Ssefuint32_t smb_shr_modify(smb_share_t *); 28131033Ssefuint32_t smb_shr_get_realpath(const char *, char *, int); 28231033Ssefvoid smb_shr_hostaccess(smb_share_t *, smb_inaddr_t *); 28331033Ssefint smb_shr_exec(char *, smb_execsub_info_t *, int); 28431033Ssef 28531033Ssefboolean_t smb_shr_exists(char *); 28638316Sphkint smb_shr_is_special(char *); 28731033Ssefboolean_t smb_shr_is_restricted(char *); 28831033Ssefboolean_t smb_shr_is_admin(char *); 28938316Sphk 29031033Ssefsa_handle_t smb_shr_sa_enter(void); 29131033Ssefvoid smb_shr_sa_exit(void); 29225184Sjkhvoid smb_shr_sa_csc_option(const char *, smb_share_t *); 29325184Sjkhchar *smb_shr_sa_csc_name(const smb_share_t *); 29435267Sbrianvoid smb_shr_sa_setflag(const char *, smb_share_t *, uint32_t); 29537514Snectar 29637514Snectar/* 29737514Snectar * CIFS share management API exported for other processes 29837514Snectar */ 29937514Snectaruint32_t smb_share_list(int, smb_shrlist_t *); 30037514Snectarint smb_share_count(void); 30137514Snectaruint32_t smb_share_delete(char *); 30237514Snectaruint32_t smb_share_rename(char *, char *); 30337514Snectaruint32_t smb_share_create(smb_share_t *); 30437514Snectaruint32_t smb_share_modify(smb_share_t *); 30535267Sbrian 30625184Sjkh#else 30725184Sjkh 30825184Sjkhdoor_handle_t smb_kshare_init(int); 309void smb_kshare_fini(door_handle_t); 310uint32_t smb_kshare_getinfo(door_handle_t, char *, smb_share_t *, 311 smb_inaddr_t *); 312int smb_kshare_upcall(door_handle_t, void *, boolean_t); 313uint32_t smb_kshare_enum(door_handle_t, smb_enumshare_info_t *); 314uint32_t smb_kshare_exec(door_handle_t, char *, smb_execsub_info_t *, int); 315 316#endif 317 318#define SMB_SHARE_DNAME "/var/run/smb_share_door" 319#define SMB_SHARE_DSIZE (65 * 1024) 320 321/* 322 * Door interface 323 * 324 * Define door operations 325 */ 326#define SMB_SHROP_NUM_SHARES 1 327#define SMB_SHROP_DELETE 2 328#define SMB_SHROP_RENAME 3 329#define SMB_SHROP_GETINFO 4 330#define SMB_SHROP_ADD 5 331#define SMB_SHROP_MODIFY 6 332#define SMB_SHROP_LIST 7 333#define SMB_SHROP_ENUM 8 334#define SMB_SHROP_EXEC 9 335 336/* 337 * Door server status 338 * 339 * SMB_SHARE_DERROR is returned by the door server if there is problem 340 * with marshalling/unmarshalling. Otherwise, SMB_SHARE_DSUCCESS is 341 * returned. 342 * 343 */ 344#define SMB_SHARE_DSUCCESS 0 345#define SMB_SHARE_DERROR -1 346 347void smb_dr_get_share(smb_dr_ctx_t *, smb_share_t *); 348void smb_dr_put_share(smb_dr_ctx_t *, smb_share_t *); 349 350void smb_share_door_clnt_init(void); 351void smb_share_door_clnt_fini(void); 352 353#ifdef __cplusplus 354} 355#endif 356 357#endif /* _SMB_SHARE_H */ 358