diff options
-rw-r--r-- | source3/include/proto.h | 834 | ||||
-rw-r--r-- | source3/include/vfs.h | 8 | ||||
-rw-r--r-- | source3/lib/substitute.c | 5 | ||||
-rw-r--r-- | source3/smbd/lanman.c | 4 | ||||
-rw-r--r-- | source3/smbd/open.c | 4 | ||||
-rw-r--r-- | source3/smbd/posix_acls.c | 319 | ||||
-rw-r--r-- | source3/smbd/process.c | 6 | ||||
-rw-r--r-- | source3/smbd/reply.c | 6 | ||||
-rw-r--r-- | source3/smbd/service.c | 32 | ||||
-rw-r--r-- | source3/smbd/vfs-wrap.c | 38 | ||||
-rw-r--r-- | source3/smbd/vfs.c | 12 |
11 files changed, 819 insertions, 449 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index 54524d4ead..ead3873c1c 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -214,362 +214,10 @@ void CatchChildLeaveStatus(void); int vslprintf(char *str, int n, char *format, va_list ap); -/*The following definitions come from libsmb/cliconnect.c */ - -BOOL cli_session_setup(struct cli_state *cli, - char *user, - char *pass, int passlen, - char *ntpass, int ntpasslen, - char *workgroup); -BOOL cli_ulogoff(struct cli_state *cli); -BOOL cli_send_tconX(struct cli_state *cli, - char *share, char *dev, char *pass, int passlen); -BOOL cli_tdis(struct cli_state *cli); -void cli_negprot_send(struct cli_state *cli); -BOOL cli_negprot(struct cli_state *cli); -BOOL cli_session_request(struct cli_state *cli, - struct nmb_name *calling, struct nmb_name *called); -BOOL cli_connect(struct cli_state *cli, const char *host, struct in_addr *ip); -BOOL cli_reestablish_connection(struct cli_state *cli); -BOOL cli_establish_connection(struct cli_state *cli, - char *dest_host, struct in_addr *dest_ip, - struct nmb_name *calling, struct nmb_name *called, - char *service, char *service_type, - BOOL do_shutdown, BOOL do_tcon); -BOOL attempt_netbios_session_request(struct cli_state *cli, char *srchost, char *desthost, - struct in_addr *pdest_ip); - -/*The following definitions come from libsmb/clidgram.c */ - -int cli_send_mailslot(BOOL unique, char *mailslot, char *buf, int len, - const char *srcname, int src_type, - const char *dstname, int dest_type, - struct in_addr dest_ip, struct in_addr src_ip, - int dest_port); -int cli_get_response(BOOL unique, char *mailslot, char *buf, int bufsiz); -int cli_get_backup_list(const char *myname, const char *send_to_name); -int cli_get_backup_server(char *my_name, char *target, char *servername, int namesize); - -/*The following definitions come from libsmb/clientgen.c */ - -int cli_set_port(struct cli_state *cli, int port); -BOOL cli_receive_smb(struct cli_state *cli); -BOOL cli_send_smb(struct cli_state *cli); -void cli_setup_packet(struct cli_state *cli); -void cli_init_creds(struct cli_state *cli, const struct ntuser_creds *usr); -struct cli_state *cli_initialise(struct cli_state *cli); -void cli_shutdown(struct cli_state *cli); -void cli_sockopt(struct cli_state *cli, char *options); -uint16 cli_setpid(struct cli_state *cli, uint16 pid); - -/*The following definitions come from libsmb/clierror.c */ - -char *cli_errstr(struct cli_state *cli); -int cli_error(struct cli_state *cli, uint8 *eclass, uint32 *num, uint32 *nt_rpc_error); - -/*The following definitions come from libsmb/clifile.c */ - -BOOL cli_rename(struct cli_state *cli, char *fname_src, char *fname_dst); -BOOL cli_unlink(struct cli_state *cli, char *fname); -BOOL cli_mkdir(struct cli_state *cli, char *dname); -BOOL cli_rmdir(struct cli_state *cli, char *dname); -int cli_nt_create(struct cli_state *cli, char *fname, uint32 DesiredAccess); -int cli_nt_create_uni(struct cli_state *cli, char *fname, uint32 DesiredAccess); -int cli_open(struct cli_state *cli, char *fname, int flags, int share_mode); -BOOL cli_close(struct cli_state *cli, int fnum); -BOOL cli_lock(struct cli_state *cli, int fnum, - uint32 offset, uint32 len, int timeout, enum brl_type lock_type); -BOOL cli_unlock(struct cli_state *cli, int fnum, uint32 offset, uint32 len); -BOOL cli_lock64(struct cli_state *cli, int fnum, - SMB_BIG_UINT offset, SMB_BIG_UINT len, int timeout, enum brl_type lock_type); -BOOL cli_unlock64(struct cli_state *cli, int fnum, SMB_BIG_UINT offset, SMB_BIG_UINT len); -BOOL cli_getattrE(struct cli_state *cli, int fd, - uint16 *attr, size_t *size, - time_t *c_time, time_t *a_time, time_t *m_time); -BOOL cli_getatr(struct cli_state *cli, char *fname, - uint16 *attr, size_t *size, time_t *t); -BOOL cli_setatr(struct cli_state *cli, char *fname, uint16 attr, time_t t); -BOOL cli_chkpath(struct cli_state *cli, char *path); -BOOL cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail); - -/*The following definitions come from libsmb/clilist.c */ - -int cli_list(struct cli_state *cli,const char *Mask,uint16 attribute, - void (*fn)(file_info *, const char *, void *), void *state); -int cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute, - void (*fn)(file_info *, const char *)); - -/*The following definitions come from libsmb/cli_lsarpc.c */ - -struct cli_state *cli_lsa_initialise(struct cli_state *cli, char *system_name, - struct ntuser_creds *creds); -void cli_lsa_shutdown(struct cli_state *cli); -uint32 cli_lsa_open_policy(struct cli_state *cli, BOOL sec_qos, - uint32 des_access, POLICY_HND *pol); -uint32 cli_lsa_close(struct cli_state *cli, POLICY_HND *pol); -uint32 cli_lsa_lookup_sids(struct cli_state *cli, POLICY_HND *pol, - int num_sids, DOM_SID *sids, char ***names, - uint32 **types, int *num_names); -uint32 cli_lsa_lookup_names(struct cli_state *cli, POLICY_HND *pol, - int num_names, char **names, DOM_SID **sids, - uint32 **types, int *num_sids); -uint32 cli_lsa_query_info_policy(struct cli_state *cli, POLICY_HND *pol, - uint16 info_class, fstring domain_name, - DOM_SID * domain_sid); -uint32 cli_lsa_enum_trust_dom(struct cli_state *cli, POLICY_HND *pol, - uint32 *enum_ctx, uint32 *num_domains, - char ***domain_names, DOM_SID **domain_sids); - -/*The following definitions come from libsmb/climessage.c */ - -BOOL cli_message_start(struct cli_state *cli, char *host, char *username, - int *grp); -BOOL cli_message_text(struct cli_state *cli, char *msg, int len, int grp); -BOOL cli_message_end(struct cli_state *cli, int grp); - -/*The following definitions come from libsmb/cliprint.c */ - -int cli_print_queue(struct cli_state *cli, - void (*fn)(struct print_job_info *)); -int cli_printjob_del(struct cli_state *cli, int job); - -/*The following definitions come from libsmb/clirap.c */ - -BOOL cli_api_pipe(struct cli_state *cli, char *pipe_name, int pipe_name_len, - uint16 *setup, uint32 setup_count, uint32 max_setup_count, - char *params, uint32 param_count, uint32 max_param_count, - char *data, uint32 data_count, uint32 max_data_count, - char **rparam, uint32 *rparam_count, - char **rdata, uint32 *rdata_count); -BOOL cli_api(struct cli_state *cli, - char *param, int prcnt, int mprcnt, - char *data, int drcnt, int mdrcnt, - char **rparam, int *rprcnt, - char **rdata, int *rdrcnt); -BOOL cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation); -int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, const char *, void *), void *state); -BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, - void (*fn)(const char *, uint32, const char *, void *), - void *state); -BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char *new_password, - const char *old_password); -BOOL cli_qpathinfo(struct cli_state *cli, const char *fname, - time_t *c_time, time_t *a_time, time_t *m_time, - size_t *size, uint16 *mode); -BOOL cli_qpathinfo2(struct cli_state *cli, const char *fname, - time_t *c_time, time_t *a_time, time_t *m_time, - time_t *w_time, size_t *size, uint16 *mode, - SMB_INO_T *ino); -BOOL cli_qfileinfo(struct cli_state *cli, int fnum, - uint16 *mode, size_t *size, - time_t *c_time, time_t *a_time, time_t *m_time, - time_t *w_time, SMB_INO_T *ino); - -/*The following definitions come from libsmb/clireadwrite.c */ - -size_t cli_read(struct cli_state *cli, int fnum, char *buf, off_t offset, size_t size); -ssize_t cli_write(struct cli_state *cli, - int fnum, uint16 write_mode, - char *buf, off_t offset, size_t size); -ssize_t cli_smbwrite(struct cli_state *cli, - int fnum, char *buf, off_t offset, size_t size1); - -/*The following definitions come from libsmb/cli_samr.c */ - -#if NEW_NTDOMAIN -struct cli_state *cli_samr_initialise(struct cli_state *cli, char *system_name, - struct ntuser_creds *creds); -void cli_samr_shutdown(struct cli_state *cli); -uint32 cli_samr_connect(struct cli_state *cli, char *srv_name, - uint32 access_mask, POLICY_HND *connect_pol); -uint32 cli_samr_close(struct cli_state *cli, POLICY_HND *connect_pol); -uint32 cli_samr_open_domain(struct cli_state *cli, POLICY_HND *connect_pol, - uint32 access_mask, DOM_SID *domain_sid, - POLICY_HND *domain_pol); -uint32 cli_samr_open_user(struct cli_state *cli, POLICY_HND *domain_pol, - uint32 access_mask, uint32 user_rid, - POLICY_HND *user_pol); -uint32 cli_samr_open_group(struct cli_state *cli, POLICY_HND *domain_pol, - uint32 access_mask, uint32 group_rid, - POLICY_HND *group_pol); -uint32 cli_samr_query_userinfo(struct cli_state *cli, POLICY_HND *user_pol, - uint16 switch_value, SAM_USERINFO_CTR *ctr); -uint32 cli_samr_query_groupinfo(struct cli_state *cli, POLICY_HND *group_pol, - uint32 info_level, GROUP_INFO_CTR *ctr); -uint32 cli_samr_query_usergroups(struct cli_state *cli, POLICY_HND *user_pol, - uint32 *num_groups, DOM_GID **gid); -uint32 cli_samr_query_groupmem(struct cli_state *cli, POLICY_HND *group_pol, - uint32 *num_mem, uint32 **rid, uint32 **attr); -#endif - -/*The following definitions come from libsmb/clisecdesc.c */ - -SEC_DESC *cli_query_secdesc(struct cli_state *cli,int fd); -BOOL cli_set_secdesc(struct cli_state *cli,int fd, SEC_DESC *sd); - -/*The following definitions come from libsmb/cli_spoolss.c */ - -struct cli_state *cli_spoolss_initialise(struct cli_state *cli, - char *system_name, - struct ntuser_creds *creds); -void cli_spoolss_shutdown(struct cli_state *cli); -uint32 cli_spoolss_open_printer_ex(struct cli_state *cli, char *printername, - char *datatype, uint32 access_required, - char *station, char *username, - POLICY_HND *pol); -uint32 cli_spoolss_closeprinter(struct cli_state *cli, POLICY_HND *pol); -uint32 cli_spoolss_enum_printers(struct cli_state *cli, uint32 flags, - uint32 level, int *returned, - PRINTER_INFO_CTR *ctr); -uint32 cli_spoolss_enum_ports(struct cli_state *cli, uint32 level, - int *returned, PORT_INFO_CTR *ctr); -uint32 cli_spoolss_getprinter(struct cli_state *cli, POLICY_HND *pol, - uint32 level, PRINTER_INFO_CTR *ctr); - -/*The following definitions come from libsmb/clitrans.c */ - -BOOL cli_send_trans(struct cli_state *cli, int trans, - char *name, int pipe_name_len, - int fid, int flags, - uint16 *setup, int lsetup, int msetup, - char *param, int lparam, int mparam, - char *data, int ldata, int mdata); -BOOL cli_receive_trans(struct cli_state *cli,int trans, - char **param, int *param_len, - char **data, int *data_len); -BOOL cli_send_nt_trans(struct cli_state *cli, - int function, - int flags, - uint16 *setup, int lsetup, int msetup, - char *param, int lparam, int mparam, - char *data, int ldata, int mdata); -BOOL cli_receive_nt_trans(struct cli_state *cli, - char **param, int *param_len, - char **data, int *data_len); - -/*The following definitions come from libsmb/credentials.c */ - -char *credstr(uchar *cred); -void cred_session_key(DOM_CHAL *clnt_chal, DOM_CHAL *srv_chal, char *pass, - uchar session_key[8]); -void cred_create(uchar session_key[8], DOM_CHAL *stor_cred, UTIME timestamp, - DOM_CHAL *cred); -int cred_assert(DOM_CHAL *cred, uchar session_key[8], DOM_CHAL *stored_cred, - UTIME timestamp); -BOOL clnt_deal_with_creds(uchar sess_key[8], - DOM_CRED *sto_clnt_cred, DOM_CRED *rcv_srv_cred); -BOOL deal_with_creds(uchar sess_key[8], - DOM_CRED *sto_clnt_cred, - DOM_CRED *rcv_clnt_cred, DOM_CRED *rtn_srv_cred); - -/*The following definitions come from libsmb/namequery.c */ - -struct node_status *name_status_query(int fd,struct nmb_name *name, - struct in_addr to_ip, int *num_names); -BOOL name_status_find(int type, struct in_addr to_ip, char *name); -struct in_addr *name_query(int fd,const char *name,int name_type, - BOOL bcast,BOOL recurse, - struct in_addr to_ip, int *count); -FILE *startlmhosts(char *fname); -BOOL getlmhostsent( FILE *fp, pstring name, int *name_type, struct in_addr *ipaddr); -void endlmhosts(FILE *fp); -BOOL name_resolve_bcast(const char *name, int name_type, - struct in_addr **return_ip_list, int *return_count); -BOOL is_ip_address(const char *name); -BOOL resolve_name(const char *name, struct in_addr *return_ip, int name_type); -BOOL resolve_srv_name(const char* srv_name, fstring dest_host, - struct in_addr *ip); -BOOL find_master_ip(char *group, struct in_addr *master_ip); -BOOL lookup_pdc_name(const char *srcname, const char *domain, struct in_addr *pdc_ip, char *ret_name); -BOOL get_dc_list(BOOL pdc_only, char *group, struct in_addr **ip_list, int *count); - -/*The following definitions come from libsmb/nmblib.c */ - -void debug_nmb_packet(struct packet_struct *p); -char *nmb_namestr(struct nmb_name *n); -struct packet_struct *copy_packet(struct packet_struct *packet); -void free_packet(struct packet_struct *packet); -struct packet_struct *parse_packet(char *buf,int length, - enum packet_type packet_type); -struct packet_struct *read_packet(int fd,enum packet_type packet_type); -void make_nmb_name( struct nmb_name *n, const char *name, int type); -BOOL nmb_name_equal(struct nmb_name *n1, struct nmb_name *n2); -int build_packet(char *buf, struct packet_struct *p); -BOOL send_packet(struct packet_struct *p); -struct packet_struct *receive_packet(int fd,enum packet_type type,int t); -struct packet_struct *receive_nmb_packet(int fd, int t, int trn_id); -struct packet_struct *receive_dgram_packet(int fd, int t, char *mailslot_name); -BOOL match_mailslot_name(struct packet_struct *p, char *mailslot_name); -void sort_query_replies(char *data, int n, struct in_addr ip); -char *dns_to_netbios_name(char *dns_name); -int name_mangle( char *In, char *Out, char name_type ); -int name_extract(char *buf,int ofs,char *name); -int name_len(char *s1); - -/*The following definitions come from libsmb/nterr.c */ - -BOOL get_safe_nt_error_msg(uint32 nt_code,char *msg, size_t len); -char *get_nt_error_msg(uint32 nt_code); - -/*The following definitions come from libsmb/passchange.c */ - -BOOL remote_password_change(const char *remote_machine, const char *user_name, - const char *old_passwd, const char *new_passwd, - char *err_str, size_t err_str_len); - -/*The following definitions come from libsmb/pwd_cache.c */ - -void pwd_init(struct pwd_info *pwd); -BOOL pwd_is_nullpwd(const struct pwd_info *pwd); -BOOL pwd_compare(struct pwd_info *pwd1, struct pwd_info *pwd2); -void pwd_read(struct pwd_info *pwd, char *passwd_report, BOOL do_encrypt); -void pwd_set_nullpwd(struct pwd_info *pwd); -void pwd_set_cleartext(struct pwd_info *pwd, char *clr); -void pwd_get_cleartext(struct pwd_info *pwd, char *clr); -void pwd_set_lm_nt_16(struct pwd_info *pwd, uchar lm_pwd[16], uchar nt_pwd[16]); -void pwd_get_lm_nt_16(struct pwd_info *pwd, uchar lm_pwd[16], uchar nt_pwd[16]); -void pwd_make_lm_nt_16(struct pwd_info *pwd, char *clr); -void pwd_make_lm_nt_owf(struct pwd_info *pwd, uchar cryptkey[8]); -void pwd_get_lm_nt_owf(struct pwd_info *pwd, uchar lm_owf[24], uchar nt_owf[24]); - /*The following definitions come from lib/smbrun.c */ int smbrun(char *cmd,char *outfile,BOOL shared); -/*The following definitions come from libsmb/smbdes.c */ - -void E_P16(unsigned char *p14,unsigned char *p16); -void E_P24(unsigned char *p21, unsigned char *c8, unsigned char *p24); -void D_P16(unsigned char *p14, unsigned char *in, unsigned char *out); -void E_old_pw_hash( unsigned char *p14, unsigned char *in, unsigned char *out); -void cred_hash1(unsigned char *out,unsigned char *in,unsigned char *key); -void cred_hash2(unsigned char *out,unsigned char *in,unsigned char *key); -void cred_hash3(unsigned char *out,unsigned char *in,unsigned char *key, int forw); -void SamOEMhash( unsigned char *data, unsigned char *key, int val); - -/*The following definitions come from libsmb/smbencrypt.c */ - -void SMBencrypt(uchar *passwd, uchar *c8, uchar *p24); -void E_md4hash(uchar *passwd, uchar *p16); -void nt_lm_owf_gen(char *pwd, uchar nt_p16[16], uchar p16[16]); -void SMBOWFencrypt(uchar passwd[16], uchar *c8, uchar p24[24]); -void NTLMSSPOWFencrypt(uchar passwd[8], uchar *ntlmchalresp, uchar p24[24]); -void SMBNTencrypt(uchar *passwd, uchar *c8, uchar *p24); -BOOL make_oem_passwd_hash(char data[516], const char *passwd, uchar old_pw_hash[16], BOOL unicode); -BOOL decode_pw_buffer(char buffer[516], char *new_pwrd, - int new_pwrd_size, uint32 *new_pw_len); - -/*The following definitions come from libsmb/smberr.c */ - -char *smb_errstr(char *inbuf); - -/*The following definitions come from libsmb/unexpected.c */ - -void unexpected_packet(struct packet_struct *p); -void clear_unexpected(time_t t); -struct packet_struct *receive_unexpected(enum packet_type packet_type, int id, - char *mailslot_name); - /*The following definitions come from lib/snprintf.c */ @@ -707,23 +355,6 @@ BOOL user_in_group_list(char *user,char *gname); BOOL user_in_list(char *user,char *list); struct passwd *smb_getpwnam(char *user, BOOL allow_change); -/*The following definitions come from lib/util_array.c */ - -void free_void_array(uint32 num_entries, void **entries, - void(free_item)(void*)); -void* add_copy_to_array(uint32 *len, void ***array, const void *item, - void*(item_dup)(const void*), BOOL alloc_anyway); -void* add_item_to_array(uint32 *len, void ***array, void *item); -void free_use_info_array(uint32 num_entries, struct use_info **entries); -struct use_info* add_use_info_to_array(uint32 *len, struct use_info ***array, - const struct use_info *name); -void free_char_array(uint32 num_entries, char **entries); -char* add_chars_to_array(uint32 *len, char ***array, const char *name); -void free_uint32_array(uint32 num_entries, uint32 **entries); -uint32* add_uint32s_to_array(uint32 *len, uint32 ***array, const uint32 *name); -void free_sid_array(uint32 num_entries, DOM_SID **entries); -DOM_SID* add_sid_to_array(uint32 *len, DOM_SID ***array, const DOM_SID *sid); - /*The following definitions come from lib/util.c */ char *tmpdir(void); @@ -790,6 +421,23 @@ BOOL ms_has_wild(char *s); BOOL mask_match(char *string, char *pattern, BOOL is_case_sensitive); int _Insure_trap_error(int a1, int a2, int a3, int a4, int a5, int a6); +/*The following definitions come from lib/util_array.c */ + +void free_void_array(uint32 num_entries, void **entries, + void(free_item)(void*)); +void* add_copy_to_array(uint32 *len, void ***array, const void *item, + void*(item_dup)(const void*), BOOL alloc_anyway); +void* add_item_to_array(uint32 *len, void ***array, void *item); +void free_use_info_array(uint32 num_entries, struct use_info **entries); +struct use_info* add_use_info_to_array(uint32 *len, struct use_info ***array, + const struct use_info *name); +void free_char_array(uint32 num_entries, char **entries); +char* add_chars_to_array(uint32 *len, char ***array, const char *name); +void free_uint32_array(uint32 num_entries, uint32 **entries); +uint32* add_uint32s_to_array(uint32 *len, uint32 ***array, const uint32 *name); +void free_sid_array(uint32 num_entries, DOM_SID **entries); +DOM_SID* add_sid_to_array(uint32 *len, DOM_SID ***array, const DOM_SID *sid); + /*The following definitions come from lib/util_file.c */ BOOL do_file_lock(int fd, int waitsecs, int type); @@ -1015,6 +663,358 @@ struct in_addr wins_srv_ip( void ); void wins_srv_died( struct in_addr boothill_ip ); unsigned long wins_srv_count( void ); +/*The following definitions come from libsmb/cli_lsarpc.c */ + +struct cli_state *cli_lsa_initialise(struct cli_state *cli, char *system_name, + struct ntuser_creds *creds); +void cli_lsa_shutdown(struct cli_state *cli); +uint32 cli_lsa_open_policy(struct cli_state *cli, BOOL sec_qos, + uint32 des_access, POLICY_HND *pol); +uint32 cli_lsa_close(struct cli_state *cli, POLICY_HND *pol); +uint32 cli_lsa_lookup_sids(struct cli_state *cli, POLICY_HND *pol, + int num_sids, DOM_SID *sids, char ***names, + uint32 **types, int *num_names); +uint32 cli_lsa_lookup_names(struct cli_state *cli, POLICY_HND *pol, + int num_names, char **names, DOM_SID **sids, + uint32 **types, int *num_sids); +uint32 cli_lsa_query_info_policy(struct cli_state *cli, POLICY_HND *pol, + uint16 info_class, fstring domain_name, + DOM_SID * domain_sid); +uint32 cli_lsa_enum_trust_dom(struct cli_state *cli, POLICY_HND *pol, + uint32 *enum_ctx, uint32 *num_domains, + char ***domain_names, DOM_SID **domain_sids); + +/*The following definitions come from libsmb/cli_samr.c */ + +#if NEW_NTDOMAIN +struct cli_state *cli_samr_initialise(struct cli_state *cli, char *system_name, + struct ntuser_creds *creds); +void cli_samr_shutdown(struct cli_state *cli); +uint32 cli_samr_connect(struct cli_state *cli, char *srv_name, + uint32 access_mask, POLICY_HND *connect_pol); +uint32 cli_samr_close(struct cli_state *cli, POLICY_HND *connect_pol); +uint32 cli_samr_open_domain(struct cli_state *cli, POLICY_HND *connect_pol, + uint32 access_mask, DOM_SID *domain_sid, + POLICY_HND *domain_pol); +uint32 cli_samr_open_user(struct cli_state *cli, POLICY_HND *domain_pol, + uint32 access_mask, uint32 user_rid, + POLICY_HND *user_pol); +uint32 cli_samr_open_group(struct cli_state *cli, POLICY_HND *domain_pol, + uint32 access_mask, uint32 group_rid, + POLICY_HND *group_pol); +uint32 cli_samr_query_userinfo(struct cli_state *cli, POLICY_HND *user_pol, + uint16 switch_value, SAM_USERINFO_CTR *ctr); +uint32 cli_samr_query_groupinfo(struct cli_state *cli, POLICY_HND *group_pol, + uint32 info_level, GROUP_INFO_CTR *ctr); +uint32 cli_samr_query_usergroups(struct cli_state *cli, POLICY_HND *user_pol, + uint32 *num_groups, DOM_GID **gid); +uint32 cli_samr_query_groupmem(struct cli_state *cli, POLICY_HND *group_pol, + uint32 *num_mem, uint32 **rid, uint32 **attr); +#endif + +/*The following definitions come from libsmb/cli_spoolss.c */ + +struct cli_state *cli_spoolss_initialise(struct cli_state *cli, + char *system_name, + struct ntuser_creds *creds); +void cli_spoolss_shutdown(struct cli_state *cli); +uint32 cli_spoolss_open_printer_ex(struct cli_state *cli, char *printername, + char *datatype, uint32 access_required, + char *station, char *username, + POLICY_HND *pol); +uint32 cli_spoolss_closeprinter(struct cli_state *cli, POLICY_HND *pol); +uint32 cli_spoolss_enum_printers(struct cli_state *cli, uint32 flags, + uint32 level, int *returned, + PRINTER_INFO_CTR *ctr); +uint32 cli_spoolss_enum_ports(struct cli_state *cli, uint32 level, + int *returned, PORT_INFO_CTR *ctr); +uint32 cli_spoolss_getprinter(struct cli_state *cli, POLICY_HND *pol, + uint32 level, PRINTER_INFO_CTR *ctr); + +/*The following definitions come from libsmb/cliconnect.c */ + +BOOL cli_session_setup(struct cli_state *cli, + char *user, + char *pass, int passlen, + char *ntpass, int ntpasslen, + char *workgroup); +BOOL cli_ulogoff(struct cli_state *cli); +BOOL cli_send_tconX(struct cli_state *cli, + char *share, char *dev, char *pass, int passlen); +BOOL cli_tdis(struct cli_state *cli); +void cli_negprot_send(struct cli_state *cli); +BOOL cli_negprot(struct cli_state *cli); +BOOL cli_session_request(struct cli_state *cli, + struct nmb_name *calling, struct nmb_name *called); +BOOL cli_connect(struct cli_state *cli, const char *host, struct in_addr *ip); +BOOL cli_reestablish_connection(struct cli_state *cli); +BOOL cli_establish_connection(struct cli_state *cli, + char *dest_host, struct in_addr *dest_ip, + struct nmb_name *calling, struct nmb_name *called, + char *service, char *service_type, + BOOL do_shutdown, BOOL do_tcon); +BOOL attempt_netbios_session_request(struct cli_state *cli, char *srchost, char *desthost, + struct in_addr *pdest_ip); + +/*The following definitions come from libsmb/clidgram.c */ + +int cli_send_mailslot(BOOL unique, char *mailslot, char *buf, int len, + const char *srcname, int src_type, + const char *dstname, int dest_type, + struct in_addr dest_ip, struct in_addr src_ip, + int dest_port); +int cli_get_response(BOOL unique, char *mailslot, char *buf, int bufsiz); +int cli_get_backup_list(const char *myname, const char *send_to_name); +int cli_get_backup_server(char *my_name, char *target, char *servername, int namesize); + +/*The following definitions come from libsmb/clientgen.c */ + +int cli_set_port(struct cli_state *cli, int port); +BOOL cli_receive_smb(struct cli_state *cli); +BOOL cli_send_smb(struct cli_state *cli); +void cli_setup_packet(struct cli_state *cli); +void cli_init_creds(struct cli_state *cli, const struct ntuser_creds *usr); +struct cli_state *cli_initialise(struct cli_state *cli); +void cli_shutdown(struct cli_state *cli); +void cli_sockopt(struct cli_state *cli, char *options); +uint16 cli_setpid(struct cli_state *cli, uint16 pid); + +/*The following definitions come from libsmb/clierror.c */ + +char *cli_errstr(struct cli_state *cli); +int cli_error(struct cli_state *cli, uint8 *eclass, uint32 *num, uint32 *nt_rpc_error); + +/*The following definitions come from libsmb/clifile.c */ + +BOOL cli_rename(struct cli_state *cli, char *fname_src, char *fname_dst); +BOOL cli_unlink(struct cli_state *cli, char *fname); +BOOL cli_mkdir(struct cli_state *cli, char *dname); +BOOL cli_rmdir(struct cli_state *cli, char *dname); +int cli_nt_create(struct cli_state *cli, char *fname, uint32 DesiredAccess); +int cli_nt_create_uni(struct cli_state *cli, char *fname, uint32 DesiredAccess); +int cli_open(struct cli_state *cli, char *fname, int flags, int share_mode); +BOOL cli_close(struct cli_state *cli, int fnum); +BOOL cli_lock(struct cli_state *cli, int fnum, + uint32 offset, uint32 len, int timeout, enum brl_type lock_type); +BOOL cli_unlock(struct cli_state *cli, int fnum, uint32 offset, uint32 len); +BOOL cli_lock64(struct cli_state *cli, int fnum, + SMB_BIG_UINT offset, SMB_BIG_UINT len, int timeout, enum brl_type lock_type); +BOOL cli_unlock64(struct cli_state *cli, int fnum, SMB_BIG_UINT offset, SMB_BIG_UINT len); +BOOL cli_getattrE(struct cli_state *cli, int fd, + uint16 *attr, size_t *size, + time_t *c_time, time_t *a_time, time_t *m_time); +BOOL cli_getatr(struct cli_state *cli, char *fname, + uint16 *attr, size_t *size, time_t *t); +BOOL cli_setatr(struct cli_state *cli, char *fname, uint16 attr, time_t t); +BOOL cli_chkpath(struct cli_state *cli, char *path); +BOOL cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail); + +/*The following definitions come from libsmb/clilist.c */ + +int cli_list(struct cli_state *cli,const char *Mask,uint16 attribute, + void (*fn)(file_info *, const char *, void *), void *state); +int cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute, + void (*fn)(file_info *, const char *)); + +/*The following definitions come from libsmb/climessage.c */ + +BOOL cli_message_start(struct cli_state *cli, char *host, char *username, + int *grp); +BOOL cli_message_text(struct cli_state *cli, char *msg, int len, int grp); +BOOL cli_message_end(struct cli_state *cli, int grp); + +/*The following definitions come from libsmb/cliprint.c */ + +int cli_print_queue(struct cli_state *cli, + void (*fn)(struct print_job_info *)); +int cli_printjob_del(struct cli_state *cli, int job); + +/*The following definitions come from libsmb/clirap.c */ + +BOOL cli_api_pipe(struct cli_state *cli, char *pipe_name, int pipe_name_len, + uint16 *setup, uint32 setup_count, uint32 max_setup_count, + char *params, uint32 param_count, uint32 max_param_count, + char *data, uint32 data_count, uint32 max_data_count, + char **rparam, uint32 *rparam_count, + char **rdata, uint32 *rdata_count); +BOOL cli_api(struct cli_state *cli, + char *param, int prcnt, int mprcnt, + char *data, int drcnt, int mdrcnt, + char **rparam, int *rprcnt, + char **rdata, int *rdrcnt); +BOOL cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation); +int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, const char *, void *), void *state); +BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, + void (*fn)(const char *, uint32, const char *, void *), + void *state); +BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char *new_password, + const char *old_password); +BOOL cli_qpathinfo(struct cli_state *cli, const char *fname, + time_t *c_time, time_t *a_time, time_t *m_time, + size_t *size, uint16 *mode); +BOOL cli_qpathinfo2(struct cli_state *cli, const char *fname, + time_t *c_time, time_t *a_time, time_t *m_time, + time_t *w_time, size_t *size, uint16 *mode, + SMB_INO_T *ino); +BOOL cli_qfileinfo(struct cli_state *cli, int fnum, + uint16 *mode, size_t *size, + time_t *c_time, time_t *a_time, time_t *m_time, + time_t *w_time, SMB_INO_T *ino); + +/*The following definitions come from libsmb/clireadwrite.c */ + +size_t cli_read(struct cli_state *cli, int fnum, char *buf, off_t offset, size_t size); +ssize_t cli_write(struct cli_state *cli, + int fnum, uint16 write_mode, + char *buf, off_t offset, size_t size); +ssize_t cli_smbwrite(struct cli_state *cli, + int fnum, char *buf, off_t offset, size_t size1); + +/*The following definitions come from libsmb/clisecdesc.c */ + +SEC_DESC *cli_query_secdesc(struct cli_state *cli,int fd); +BOOL cli_set_secdesc(struct cli_state *cli,int fd, SEC_DESC *sd); + +/*The following definitions come from libsmb/clitrans.c */ + +BOOL cli_send_trans(struct cli_state *cli, int trans, + char *name, int pipe_name_len, + int fid, int flags, + uint16 *setup, int lsetup, int msetup, + char *param, int lparam, int mparam, + char *data, int ldata, int mdata); +BOOL cli_receive_trans(struct cli_state *cli,int trans, + char **param, int *param_len, + char **data, int *data_len); +BOOL cli_send_nt_trans(struct cli_state *cli, + int function, + int flags, + uint16 *setup, int lsetup, int msetup, + char *param, int lparam, int mparam, + char *data, int ldata, int mdata); +BOOL cli_receive_nt_trans(struct cli_state *cli, + char **param, int *param_len, + char **data, int *data_len); + +/*The following definitions come from libsmb/credentials.c */ + +char *credstr(uchar *cred); +void cred_session_key(DOM_CHAL *clnt_chal, DOM_CHAL *srv_chal, char *pass, + uchar session_key[8]); +void cred_create(uchar session_key[8], DOM_CHAL *stor_cred, UTIME timestamp, + DOM_CHAL *cred); +int cred_assert(DOM_CHAL *cred, uchar session_key[8], DOM_CHAL *stored_cred, + UTIME timestamp); +BOOL clnt_deal_with_creds(uchar sess_key[8], + DOM_CRED *sto_clnt_cred, DOM_CRED *rcv_srv_cred); +BOOL deal_with_creds(uchar sess_key[8], + DOM_CRED *sto_clnt_cred, + DOM_CRED *rcv_clnt_cred, DOM_CRED *rtn_srv_cred); + +/*The following definitions come from libsmb/namequery.c */ + +struct node_status *name_status_query(int fd,struct nmb_name *name, + struct in_addr to_ip, int *num_names); +BOOL name_status_find(int type, struct in_addr to_ip, char *name); +struct in_addr *name_query(int fd,const char *name,int name_type, + BOOL bcast,BOOL recurse, + struct in_addr to_ip, int *count); +FILE *startlmhosts(char *fname); +BOOL getlmhostsent( FILE *fp, pstring name, int *name_type, struct in_addr *ipaddr); +void endlmhosts(FILE *fp); +BOOL name_resolve_bcast(const char *name, int name_type, + struct in_addr **return_ip_list, int *return_count); +BOOL is_ip_address(const char *name); +BOOL resolve_name(const char *name, struct in_addr *return_ip, int name_type); +BOOL resolve_srv_name(const char* srv_name, fstring dest_host, + struct in_addr *ip); +BOOL find_master_ip(char *group, struct in_addr *master_ip); +BOOL lookup_pdc_name(const char *srcname, const char *domain, struct in_addr *pdc_ip, char *ret_name); +BOOL get_dc_list(BOOL pdc_only, char *group, struct in_addr **ip_list, int *count); + +/*The following definitions come from libsmb/nmblib.c */ + +void debug_nmb_packet(struct packet_struct *p); +char *nmb_namestr(struct nmb_name *n); +struct packet_struct *copy_packet(struct packet_struct *packet); +void free_packet(struct packet_struct *packet); +struct packet_struct *parse_packet(char *buf,int length, + enum packet_type packet_type); +struct packet_struct *read_packet(int fd,enum packet_type packet_type); +void make_nmb_name( struct nmb_name *n, const char *name, int type); +BOOL nmb_name_equal(struct nmb_name *n1, struct nmb_name *n2); +int build_packet(char *buf, struct packet_struct *p); +BOOL send_packet(struct packet_struct *p); +struct packet_struct *receive_packet(int fd,enum packet_type type,int t); +struct packet_struct *receive_nmb_packet(int fd, int t, int trn_id); +struct packet_struct *receive_dgram_packet(int fd, int t, char *mailslot_name); +BOOL match_mailslot_name(struct packet_struct *p, char *mailslot_name); +void sort_query_replies(char *data, int n, struct in_addr ip); +char *dns_to_netbios_name(char *dns_name); +int name_mangle( char *In, char *Out, char name_type ); +int name_extract(char *buf,int ofs,char *name); +int name_len(char *s1); + +/*The following definitions come from libsmb/nterr.c */ + +BOOL get_safe_nt_error_msg(uint32 nt_code,char *msg, size_t len); +char *get_nt_error_msg(uint32 nt_code); + +/*The following definitions come from libsmb/passchange.c */ + +BOOL remote_password_change(const char *remote_machine, const char *user_name, + const char *old_passwd, const char *new_passwd, + char *err_str, size_t err_str_len); + +/*The following definitions come from libsmb/pwd_cache.c */ + +void pwd_init(struct pwd_info *pwd); +BOOL pwd_is_nullpwd(const struct pwd_info *pwd); +BOOL pwd_compare(struct pwd_info *pwd1, struct pwd_info *pwd2); +void pwd_read(struct pwd_info *pwd, char *passwd_report, BOOL do_encrypt); +void pwd_set_nullpwd(struct pwd_info *pwd); +void pwd_set_cleartext(struct pwd_info *pwd, char *clr); +void pwd_get_cleartext(struct pwd_info *pwd, char *clr); +void pwd_set_lm_nt_16(struct pwd_info *pwd, uchar lm_pwd[16], uchar nt_pwd[16]); +void pwd_get_lm_nt_16(struct pwd_info *pwd, uchar lm_pwd[16], uchar nt_pwd[16]); +void pwd_make_lm_nt_16(struct pwd_info *pwd, char *clr); +void pwd_make_lm_nt_owf(struct pwd_info *pwd, uchar cryptkey[8]); +void pwd_get_lm_nt_owf(struct pwd_info *pwd, uchar lm_owf[24], uchar nt_owf[24]); + +/*The following definitions come from libsmb/smbdes.c */ + +void E_P16(unsigned char *p14,unsigned char *p16); +void E_P24(unsigned char *p21, unsigned char *c8, unsigned char *p24); +void D_P16(unsigned char *p14, unsigned char *in, unsigned char *out); +void E_old_pw_hash( unsigned char *p14, unsigned char *in, unsigned char *out); +void cred_hash1(unsigned char *out,unsigned char *in,unsigned char *key); +void cred_hash2(unsigned char *out,unsigned char *in,unsigned char *key); +void cred_hash3(unsigned char *out,unsigned char *in,unsigned char *key, int forw); +void SamOEMhash( unsigned char *data, unsigned char *key, int val); + +/*The following definitions come from libsmb/smbencrypt.c */ + +void SMBencrypt(uchar *passwd, uchar *c8, uchar *p24); +void E_md4hash(uchar *passwd, uchar *p16); +void nt_lm_owf_gen(char *pwd, uchar nt_p16[16], uchar p16[16]); +void SMBOWFencrypt(uchar passwd[16], uchar *c8, uchar p24[24]); +void NTLMSSPOWFencrypt(uchar passwd[8], uchar *ntlmchalresp, uchar p24[24]); +void SMBNTencrypt(uchar *passwd, uchar *c8, uchar *p24); +BOOL make_oem_passwd_hash(char data[516], const char *passwd, uchar old_pw_hash[16], BOOL unicode); +BOOL decode_pw_buffer(char buffer[516], char *new_pwrd, + int new_pwrd_size, uint32 *new_pw_len); + +/*The following definitions come from libsmb/smberr.c */ + +char *smb_errstr(char *inbuf); + +/*The following definitions come from libsmb/unexpected.c */ + +void unexpected_packet(struct packet_struct *p); +void clear_unexpected(time_t t); +struct packet_struct *receive_unexpected(enum packet_type packet_type, int id, + char *mailslot_name); + /*The following definitions come from locking/brlock.c */ void brl_init(int read_only); @@ -1101,6 +1101,9 @@ BOOL queue_dns_query(struct packet_struct *p,struct nmb_name *question, struct name_record **n); void kill_async_dns_child(void); +/*The following definitions come from nmbd/nmbd.c */ + + /*The following definitions come from nmbd/nmbd_become_dmb.c */ void add_domain_names(time_t t); @@ -1131,9 +1134,6 @@ void announce_and_sync_with_domain_master_browser( struct subnet_record *subrec, void collect_all_workgroup_names_from_wins_server(time_t t); void sync_all_dmbs(time_t t); -/*The following definitions come from nmbd/nmbd.c */ - - /*The following definitions come from nmbd/nmbd_elections.c */ void check_master_browser_exists(time_t t); @@ -1941,6 +1941,11 @@ void pcap_printer_fn(void (*fn)(char *, char *)); void cups_printer_fn(void (*fn)(char *, char *)); int cups_printername_ok(char *name); +/*The following definitions come from printing/print_svid.c */ + +void sysv_printer_fn(void (*fn)(char *, char *)); +int sysv_printername_ok(char *name); + /*The following definitions come from printing/printfsp.c */ #if OLD_NTDOMAIN @@ -1973,11 +1978,6 @@ BOOL print_queue_resume(struct current_user *user, int snum, int *errcode); BOOL print_queue_purge(struct current_user *user, int snum, int *errcode); #endif -/*The following definitions come from printing/print_svid.c */ - -void sysv_printer_fn(void (*fn)(char *, char *)); -int sysv_printername_ok(char *name); - /*The following definitions come from profile/profile.c */ void profile_message(int msg_type, pid_t src, void *buf, size_t len); @@ -2191,17 +2191,6 @@ BOOL do_wks_query_info(struct cli_state *cli, char *server_name, uint32 switch_value, WKS_INFO_100 *wks100); -/*The following definitions come from rpcclient/cmd_lsarpc.c */ - - -/*The following definitions come from rpcclient/cmd_samr.c */ - -#if NEW_NTDOMAIN -#endif - -/*The following definitions come from rpcclient/cmd_spoolss.c */ - - /*The following definitions come from rpc_client/ncacn_np_use.c */ BOOL ncacn_np_use_del(const char *srv_name, const char *pipe_name, @@ -2215,12 +2204,6 @@ struct ncacn_np *ncacn_np_use_add(const char *pipe_name, const struct ntuser_creds *ntc, BOOL reuse, BOOL *is_new_connection); -/*The following definitions come from rpcclient/rpcclient.c */ - -void fetch_domain_sid(void); -void init_rpcclient_creds(struct ntuser_creds *creds); -void add_command_set(struct cmd_set *cmd_set); - /*The following definitions come from rpc_parse/parse_creds.c */ BOOL make_creds_unix(CREDS_UNIX *r_u, const char* user_name, @@ -3485,6 +3468,23 @@ uint32 lookup_user_rid(char *user_name, uint32 *rid); BOOL api_wkssvc_rpc(pipes_struct *p); #endif +/*The following definitions come from rpcclient/cmd_lsarpc.c */ + + +/*The following definitions come from rpcclient/cmd_samr.c */ + +#if NEW_NTDOMAIN +#endif + +/*The following definitions come from rpcclient/cmd_spoolss.c */ + + +/*The following definitions come from rpcclient/rpcclient.c */ + +void fetch_domain_sid(void); +void init_rpcclient_creds(struct ntuser_creds *creds); +void add_command_set(struct cmd_set *cmd_set); + /*The following definitions come from smbd/blocking.c */ #if OLD_NTDOMAIN @@ -3820,6 +3820,8 @@ int reply_pipe_close(connection_struct *conn, char *inbuf,char *outbuf); #if OLD_NTDOMAIN size_t get_nt_acl(files_struct *fsp, SEC_DESC **ppdesc); BOOL set_nt_acl(files_struct *fsp, uint32 security_info_sent, SEC_DESC *psd); +int chmod_acl(char *name, mode_t mode); +int fchmod_acl(int fd, mode_t mode); #endif /*The following definitions come from smbd/process.c */ @@ -3991,27 +3993,6 @@ BOOL sid_to_uid(DOM_SID *psid, uid_t *puid, enum SID_NAME_USE *sidtype); BOOL sid_to_gid(DOM_SID *psid, gid_t *pgid, enum SID_NAME_USE *sidtype); #endif -/*The following definitions come from smbd/vfs.c */ - -#if OLD_NTDOMAIN -int vfs_init_default(connection_struct *conn); -BOOL vfs_init_custom(connection_struct *conn); -BOOL vfs_directory_exist(connection_struct *conn, char *dname, SMB_STRUCT_STAT *st); -int vfs_mkdir(connection_struct *conn, char *fname, mode_t mode); -char *vfs_getwd(connection_struct *conn, char *unix_path); -BOOL vfs_file_exist(connection_struct *conn,char *fname,SMB_STRUCT_STAT *sbuf); -ssize_t vfs_read_data(files_struct *fsp, char *buf, size_t byte_count); -ssize_t vfs_write_data(files_struct *fsp,char *buffer,size_t N); -int vfs_set_filelen(files_struct *fsp, SMB_OFF_T len); -SMB_OFF_T vfs_transfer_file(int in_fd, files_struct *in_fsp, - int out_fd, files_struct *out_fsp, - SMB_OFF_T n, char *header, int headlen, int align); -char *vfs_readdirname(connection_struct *conn, void *p); -int vfs_ChDir(connection_struct *conn, char *path); -char *vfs_GetWd(connection_struct *conn, char *path); -BOOL reduce_name(connection_struct *conn, char *s,char *dir,BOOL widelinks); -#endif - /*The following definitions come from smbd/vfs-wrap.c */ #if OLD_NTDOMAIN @@ -4046,6 +4027,29 @@ size_t vfswrap_fget_nt_acl(files_struct *fsp, int fd, SEC_DESC **ppdesc); size_t vfswrap_get_nt_acl(files_struct *fsp, char *name, SEC_DESC **ppdesc); BOOL vfswrap_fset_nt_acl(files_struct *fsp, int fd, uint32 security_info_sent, SEC_DESC *psd); BOOL vfswrap_set_nt_acl(files_struct *fsp, char *name, uint32 security_info_sent, SEC_DESC *psd); +int vfswrap_chmod_acl(connection_struct *conn, char *name, mode_t mode); +int vfswrap_fchmod_acl(files_struct *fsp, int fd, mode_t mode); +#endif + +/*The following definitions come from smbd/vfs.c */ + +#if OLD_NTDOMAIN +int vfs_init_default(connection_struct *conn); +BOOL vfs_init_custom(connection_struct *conn); +BOOL vfs_directory_exist(connection_struct *conn, char *dname, SMB_STRUCT_STAT *st); +int vfs_mkdir(connection_struct *conn, char *fname, mode_t mode); +char *vfs_getwd(connection_struct *conn, char *unix_path); +BOOL vfs_file_exist(connection_struct *conn,char *fname,SMB_STRUCT_STAT *sbuf); +ssize_t vfs_read_data(files_struct *fsp, char *buf, size_t byte_count); +ssize_t vfs_write_data(files_struct *fsp,char *buffer,size_t N); +int vfs_set_filelen(files_struct *fsp, SMB_OFF_T len); +SMB_OFF_T vfs_transfer_file(int in_fd, files_struct *in_fsp, + int out_fd, files_struct *out_fsp, + SMB_OFF_T n, char *header, int headlen, int align); +char *vfs_readdirname(connection_struct *conn, void *p); +int vfs_ChDir(connection_struct *conn, char *path); +char *vfs_GetWd(connection_struct *conn, char *path); +BOOL reduce_name(connection_struct *conn, char *s,char *dir,BOOL widelinks); #endif /*The following definitions come from smbwrapper/realcalls.c */ diff --git a/source3/include/vfs.h b/source3/include/vfs.h index 3696178a75..9ca4bde0c5 100644 --- a/source3/include/vfs.h +++ b/source3/include/vfs.h @@ -85,10 +85,18 @@ struct vfs_ops { int (*ftruncate)(struct files_struct *fsp, int fd, SMB_OFF_T offset); BOOL (*lock)(struct files_struct *fsp, int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type); + /* NT ACL operations. */ + size_t (*fget_nt_acl)(struct files_struct *fsp, int fd, struct security_descriptor_info **ppdesc); size_t (*get_nt_acl)(struct files_struct *fsp, char *name, struct security_descriptor_info **ppdesc); BOOL (*fset_nt_acl)(struct files_struct *fsp, int fd, uint32 security_info_sent, struct security_descriptor_info *psd); BOOL (*set_nt_acl)(struct files_struct *fsp, char *name, uint32 security_info_sent, struct security_descriptor_info *psd); + + /* POSIX ACL operations. */ + + int (*chmod_acl)(struct connection_struct *conn, char *name, mode_t mode); + int (*fchmod_acl)(struct files_struct *fsp, int fd, mode_t mode); + }; struct vfs_options { diff --git a/source3/lib/substitute.c b/source3/lib/substitute.c index 0212147161..09a60cf3f1 100644 --- a/source3/lib/substitute.c +++ b/source3/lib/substitute.c @@ -26,7 +26,7 @@ extern int DEBUGLEVEL; fstring local_machine=""; fstring remote_arch="UNKNOWN"; -pstring sesssetup_user=""; +userdom_struct current_user_info; pstring samlogon_user=""; BOOL sam_logon_in_ssb = False; fstring remote_proto="UNKNOWN"; @@ -206,7 +206,7 @@ void standard_sub_advanced(int snum, char *user, char *connectpath, gid_t gid, c int l = sizeof(pstring) - (int)(p-str); switch (*(p+1)) { - case 'U' : string_sub(p,"%U",sam_logon_in_ssb?samlogon_user:sesssetup_user,l); break; + case 'U' : string_sub(p,"%U",sam_logon_in_ssb?samlogon_user:current_user_info.smb_name,l); break; case 'G' : if ((pass = Get_Pwnam(user,False))!=NULL) { string_sub(p,"%G",gidtoname(pass->pw_gid),l); @@ -214,6 +214,7 @@ void standard_sub_advanced(int snum, char *user, char *connectpath, gid_t gid, c p += 2; } break; + case 'D' : string_sub(p,"%D", current_user_info.domain,l); break; case 'N' : string_sub(p,"%N", automount_server(user),l); break; case 'H': if ((home = get_user_home_dir(user))) { diff --git a/source3/smbd/lanman.c b/source3/smbd/lanman.c index fd59f4603a..33da479361 100644 --- a/source3/smbd/lanman.c +++ b/source3/smbd/lanman.c @@ -2187,7 +2187,7 @@ static BOOL api_NetWkstaGetInfo(connection_struct *conn,uint16 vuid, char *param char *str2 = skip_string(str1,1); char *p = skip_string(str2,1); char *p2; - extern pstring sesssetup_user; + extern userdom_struct current_user_info; int level = SVAL(p,0); DEBUG(4,("NetWkstaGetInfo level %d\n",level)); @@ -2216,7 +2216,7 @@ static BOOL api_NetWkstaGetInfo(connection_struct *conn,uint16 vuid, char *param p += 4; SIVAL(p,0,PTR_DIFF(p2,*rdata)); - pstrcpy(p2,sesssetup_user); + pstrcpy(p2,current_user_info.smb_name); p2 = skip_string(p2,1); p += 4; diff --git a/source3/smbd/open.c b/source3/smbd/open.c index b23da55542..77962562e3 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -25,7 +25,7 @@ extern int DEBUGLEVEL; -extern pstring sesssetup_user; +extern userdom_struct current_user_info; extern uint16 global_oplock_port; extern BOOL global_client_failed_oplock_break; @@ -188,7 +188,7 @@ static BOOL open_file(files_struct *fsp,connection_struct *conn, fsp->wcp = NULL; /* Write cache pointer. */ DEBUG(2,("%s opened file %s read=%s write=%s (numopen=%d)\n", - *sesssetup_user ? sesssetup_user : conn->user,fsp->fsp_name, + *current_user_info.smb_name ? current_user_info.smb_name : conn->user,fsp->fsp_name, BOOLSTR(fsp->can_read), BOOLSTR(fsp->can_write), conn->num_files_open + 1)); diff --git a/source3/smbd/posix_acls.c b/source3/smbd/posix_acls.c index 0071f8786d..2bd0065d58 100644 --- a/source3/smbd/posix_acls.c +++ b/source3/smbd/posix_acls.c @@ -42,6 +42,22 @@ typedef struct canon_ace { static void free_canon_ace_list( canon_ace *list_head ); /**************************************************************************** + Function to duplicate a canon_ace entry. +****************************************************************************/ + +static canon_ace *dup_canon_ace( canon_ace *src_ace) +{ + canon_ace *dst_ace = (canon_ace *)malloc(sizeof(canon_ace)); + + if (dst_ace == NULL) + return NULL; + + *dst_ace = *src_ace; + dst_ace->prev = dst_ace->next = NULL; + return dst_ace; +} + +/**************************************************************************** Function to create owner and group SIDs from a SMB_STRUCT_STAT. ****************************************************************************/ @@ -254,11 +270,120 @@ static BOOL merge_aces( canon_ace *list_head, canon_ace *p_ace) } /**************************************************************************** + Create a default mode for a directory default ACE. +****************************************************************************/ + +static mode_t get_default_ace_mode(files_struct *fsp, int type) +{ + mode_t force_mode = lp_force_dir_security_mode(SNUM(fsp->conn)); + mode_t mode = 0; + + switch(type) { + case S_IRUSR: + mode |= (force_mode & S_IRUSR) ? S_IRUSR : 0; + mode |= (force_mode & S_IWUSR) ? S_IWUSR : 0; + mode |= (force_mode & S_IXUSR) ? S_IXUSR : 0; + break; + case S_IRGRP: + mode |= (force_mode & S_IRGRP) ? S_IRUSR : 0; + mode |= (force_mode & S_IWGRP) ? S_IWUSR : 0; + mode |= (force_mode & S_IXGRP) ? S_IXUSR : 0; + break; + case S_IROTH: + mode |= (force_mode & S_IROTH) ? S_IRUSR : 0; + mode |= (force_mode & S_IWOTH) ? S_IWUSR : 0; + mode |= (force_mode & S_IXOTH) ? S_IXUSR : 0; + break; + } + + return mode; +} + +/**************************************************************************** + A well formed POSIX file or default ACL has at least 3 entries, a + SMB_ACL_USER_OBJ, SMB_ACL_GROUP_OBJ, SMB_ACL_OTHER_OBJ. +****************************************************************************/ + +static BOOL ensure_canon_entry_valid(canon_ace **pp_ace, + files_struct *fsp, + DOM_SID *pfile_owner_sid, + DOM_SID *pfile_grp_sid, + SMB_STRUCT_STAT *pst, + BOOL default_acl) +{ + extern DOM_SID global_sid_World; + canon_ace *pace; + BOOL got_user = False; + BOOL got_grp = False; + BOOL got_other = False; + + for (pace = *pp_ace; pace; pace = pace->next) { + if (pace->type == SMB_ACL_USER_OBJ) + got_user = True; + else if (pace->type == SMB_ACL_GROUP_OBJ) + got_grp = True; + else if (pace->type == SMB_ACL_OTHER) + got_other = True; + } + + if (!got_user) { + if ((pace = (canon_ace *)malloc(sizeof(canon_ace))) == NULL) { + DEBUG(0,("ensure_canon_entry_valid: malloc fail.\n")); + return False; + } + + ZERO_STRUCTP(pace); + pace->type = SMB_ACL_USER_OBJ; + pace->owner_type = UID_ACE; + pace->unix_ug.uid = pst->st_uid; + pace->sid = *pfile_owner_sid; + pace->perms = default_acl ? get_default_ace_mode(fsp, S_IRUSR): 0; + + DLIST_ADD(*pp_ace, pace); + } + + if (!got_grp) { + if ((pace = (canon_ace *)malloc(sizeof(canon_ace))) == NULL) { + DEBUG(0,("ensure_canon_entry_valid: malloc fail.\n")); + return False; + } + + ZERO_STRUCTP(pace); + pace->type = SMB_ACL_GROUP_OBJ; + pace->owner_type = GID_ACE; + pace->unix_ug.uid = pst->st_gid; + pace->sid = *pfile_grp_sid; + pace->perms = default_acl ? get_default_ace_mode(fsp, S_IRGRP): 0; + + DLIST_ADD(*pp_ace, pace); + } + + if (!got_other) { + if ((pace = (canon_ace *)malloc(sizeof(canon_ace))) == NULL) { + DEBUG(0,("ensure_canon_entry_valid: malloc fail.\n")); + return False; + } + + ZERO_STRUCTP(pace); + pace->type = SMB_ACL_OTHER; + pace->owner_type = WORLD_ACE; + pace->unix_ug.world = -1; + pace->sid = global_sid_World; + pace->perms = default_acl ? get_default_ace_mode(fsp, S_IROTH): 0; + + DLIST_ADD(*pp_ace, pace); + } + + return True; +} + +/**************************************************************************** Unpack a SEC_DESC into two canonical ace lists. We don't depend on this succeeding. ****************************************************************************/ static BOOL unpack_canon_ace(files_struct *fsp, + SMB_STRUCT_STAT *pst, DOM_SID *pfile_owner_sid, DOM_SID *pfile_grp_sid, canon_ace **ppfile_ace, canon_ace **ppdir_ace, @@ -383,7 +508,8 @@ static BOOL unpack_canon_ace(files_struct *fsp, current_ace->type = (current_ace->owner_type == UID_ACE) ? SMB_ACL_USER : SMB_ACL_GROUP; } - if (fsp->is_directory && (psa->flags & SEC_ACE_FLAG_INHERIT_ONLY)) { + if (fsp->is_directory) { + /* * We can only add to the default POSIX ACE list if the ACE is * designed to be inherited by both files and directories. @@ -391,14 +517,45 @@ static BOOL unpack_canon_ace(files_struct *fsp, if ((psa->flags & (SEC_ACE_FLAG_OBJECT_INHERIT|SEC_ACE_FLAG_CONTAINER_INHERIT)) == (SEC_ACE_FLAG_OBJECT_INHERIT|SEC_ACE_FLAG_CONTAINER_INHERIT)) { DLIST_ADD(dir_ace, current_ace); - } else { - DEBUG(0,("unpack_canon_ace: unable to use a non-generic default ACE.\n")); - free(current_ace); + + /* + * If this is not an inherit only ACE we need to add a duplicate + * to the file acl. + */ + + if (!(psa->flags & SEC_ACE_FLAG_INHERIT_ONLY)) { + canon_ace *dup_ace = dup_canon_ace(current_ace); + + if (!dup_ace) { + DEBUG(0,("unpack_canon_ace: malloc fail !\n")); + free_canon_ace_list(file_ace); + free_canon_ace_list(dir_ace); + return False; + } + + current_ace = dup_ace; + } else { + current_ace = NULL; + } } - } else { + } + + /* + * Only add to the file ACL if not inherit only. + */ + + if (!(psa->flags & SEC_ACE_FLAG_INHERIT_ONLY)) { DLIST_ADD(file_ace, current_ace); all_aces_are_inherit_only = False; + current_ace = NULL; } + + /* + * Free if ACE was not addedd. + */ + + if (current_ace) + free(current_ace); } if (fsp->is_directory && all_aces_are_inherit_only) { @@ -431,6 +588,36 @@ static BOOL unpack_canon_ace(files_struct *fsp, goto again_dir; } + /* + * A well formed POSIX file or default ACL has at least 3 entries, a + * SMB_ACL_USER_OBJ, SMB_ACL_GROUP_OBJ, SMB_ACL_OTHER_OBJ + * and optionally a mask entry. Ensure this is the case. + */ + + if (!ensure_canon_entry_valid(&file_ace, fsp, pfile_owner_sid, pfile_grp_sid, pst, False)) { + free_canon_ace_list(file_ace); + free_canon_ace_list(dir_ace); + return False; + } + + if (!ensure_canon_entry_valid(&dir_ace, fsp, pfile_owner_sid, pfile_grp_sid, pst, True)) { + free_canon_ace_list(file_ace); + free_canon_ace_list(dir_ace); + return False; + } + + if( DEBUGLVL( 10 )) { + dbgtext("unpack_canon_ace: File ACL:\n"); + for (i = 0, current_ace = file_ace; current_ace; current_ace = current_ace->next, i++ ) { + print_canon_ace( current_ace, i); + } + + dbgtext("unpack_canon_ace: Directory ACL:\n"); + for (i = 0, current_ace = dir_ace; current_ace; current_ace = current_ace->next, i++ ) { + print_canon_ace( current_ace, i); + } + } + *ppfile_ace = file_ace; *ppdir_ace = dir_ace; return True; @@ -914,7 +1101,7 @@ static canon_ace *canonicalise_acl( SMB_ACL_T posix_acl, SMB_STRUCT_STAT *psbuf) Attempt to apply an ACL to a file or directory. ****************************************************************************/ -static BOOL set_canon_ace_list(files_struct *fsp, canon_ace *the_ace, BOOL default_ace) +static BOOL set_canon_ace_list(files_struct *fsp, canon_ace *the_ace, BOOL default_ace, BOOL *pacl_set_support) { BOOL ret = False; SMB_ACL_T the_acl = sys_acl_init((int)count_canon_ace_list(the_ace) + 1); @@ -933,6 +1120,7 @@ static BOOL set_canon_ace_list(files_struct *fsp, canon_ace *the_ace, BOOL defau DEBUG(0,("set_canon_ace_list: Unable to init %s ACL. (%s)\n", default_ace ? "default" : "file", strerror(errno) )); #endif + *pacl_set_support = False; return False; } @@ -951,6 +1139,13 @@ static BOOL set_canon_ace_list(files_struct *fsp, canon_ace *the_ace, BOOL defau } /* + * Ok - we now know the ACL calls should be working, don't + * allow fallback to chmod. + */ + + *pacl_set_support = True; + + /* * Initialise the entry from the canon_ace. */ @@ -1041,7 +1236,9 @@ static BOOL set_canon_ace_list(files_struct *fsp, canon_ace *the_ace, BOOL defau */ if (sys_acl_valid(the_acl) == -1) { - DEBUG(0,("set_canon_ace_list: ACL is invalid for set (%s).\n", strerror(errno) )); + DEBUG(0,("set_canon_ace_list: ACL type (%s) is invalid for set (%s).\n", + the_acl_type == SMB_ACL_TYPE_DEFAULT ? "directory default" : "file", + strerror(errno) )); goto done; } @@ -1051,7 +1248,8 @@ static BOOL set_canon_ace_list(files_struct *fsp, canon_ace *the_ace, BOOL defau if(default_ace || fsp->is_directory || fsp->fd == -1) { if (sys_acl_set_file(fsp->fsp_name, the_acl_type, the_acl) == -1) { - DEBUG(0,("set_canon_ace_list: sys_acl_set_file failed for file %s (%s).\n", + DEBUG(0,("set_canon_ace_list: sys_acl_set_file type %s failed for file %s (%s).\n", + the_acl_type == SMB_ACL_TYPE_DEFAULT ? "directory default" : "file", fsp->fsp_name, strerror(errno) )); goto done; } @@ -1150,7 +1348,7 @@ size_t get_nt_acl(files_struct *fsp, SEC_DESC **ppdesc) num_acls = count_canon_ace_list(file_ace); if (fsp->is_directory) { - if (dir_ace) + if (dir_acl) dir_ace = canonicalise_acl( dir_acl, &sbuf); else dir_ace = unix_canonicalise_acl(fsp, &sbuf, &owner_sid, &group_sid); @@ -1302,7 +1500,7 @@ BOOL set_nt_acl(files_struct *fsp, uint32 security_info_sent, SEC_DESC *psd) create_file_sids(&sbuf, &file_owner_sid, &file_grp_sid); - acl_perms = unpack_canon_ace( fsp, &file_owner_sid, &file_grp_sid, + acl_perms = unpack_canon_ace( fsp, &sbuf, &file_owner_sid, &file_grp_sid, &file_ace_list, &dir_ace_list, security_info_sent, psd); posix_perms = unpack_posix_permissions( fsp, &sbuf, &perms, security_info_sent, psd, acl_perms); @@ -1324,17 +1522,31 @@ BOOL set_nt_acl(files_struct *fsp, uint32 security_info_sent, SEC_DESC *psd) if((security_info_sent & DACL_SECURITY_INFORMATION) && (psd->dacl != NULL)) { BOOL acl_set_support = False; + BOOL ret = False; /* * Try using the POSIX ACL set first. All back to chmod if * we have no ACL support on this filesystem. */ - if (acl_perms && file_ace_list && set_canon_ace_list(fsp, file_ace_list, False)) - acl_set_support = True; + if (acl_perms && file_ace_list) { + ret = set_canon_ace_list(fsp, file_ace_list, False, &acl_set_support); + if (acl_set_support && ret == False) { + DEBUG(3,("set_nt_acl: failed to set file acl on file %s (%s).\n", fsp->fsp_name, strerror(errno) )); + free_canon_ace_list(file_ace_list); + free_canon_ace_list(dir_ace_list); + return False; + } + } - if (acl_perms && acl_set_support && fsp->is_directory && dir_ace_list) - set_canon_ace_list(fsp, dir_ace_list, True); + if (acl_perms && acl_set_support && fsp->is_directory && dir_ace_list) { + if (!set_canon_ace_list(fsp, dir_ace_list, True, &acl_set_support)) { + DEBUG(3,("set_nt_acl: failed to set default acl on directory %s (%s).\n", fsp->fsp_name, strerror(errno) )); + free_canon_ace_list(file_ace_list); + free_canon_ace_list(dir_ace_list); + return False; + } + } /* * If we cannot set using POSIX ACLs we fall back to checking if we need to chmod. @@ -1347,7 +1559,7 @@ BOOL set_nt_acl(files_struct *fsp, uint32 security_info_sent, SEC_DESC *psd) file_ace_list = NULL; dir_ace_list = NULL; - DEBUG(3,("call_nt_transact_set_security_desc: chmod %s. perms = 0%o.\n", + DEBUG(3,("set_nt_acl: chmod %s. perms = 0%o.\n", fsp->fsp_name, (unsigned int)perms )); if(conn->vfs_ops.chmod(conn,dos_to_unix(fsp->fsp_name, False), perms) == -1) { @@ -1363,4 +1575,81 @@ BOOL set_nt_acl(files_struct *fsp, uint32 security_info_sent, SEC_DESC *psd) return True; } + +/**************************************************************************** + Do a chmod by setting the ACL USER_OBJ, GROUP_OBJ and OTHER bits in an ACL + and set the mask to rwx. Needed to preserve complex ACLs set by NT. +****************************************************************************/ + +static int chmod_acl_internals( SMB_ACL_T posix_acl, mode_t mode) +{ + int entry_id = SMB_ACL_FIRST_ENTRY; + SMB_ACL_ENTRY_T entry; + int num_entries = 0; + +#if 1 + return -1; +#else + while ( sys_acl_get_entry(posix_acl, entry_id, &entry) == 1) { + SMB_ACL_TAG_T tagtype; + SMB_ACL_PERMSET_T permset; + + if (sys_acl_get_tag_type(entry, &tagtype) == -1) + return -1; + + if (sys_acl_get_permset(entry, &permset) == -1) + return -1; + + num_entries++; + + switch(tagtype) { + case SMB_ACL_USER_OBJ: + break; + case SMB_ACL_USER: + break; + case SMB_ACL_GROUP_OBJ: + break; + case SMB_ACL_GROUP: + break; + case SMB_ACL_MASK: + break; + case SMB_ACL_OTHER: + break; + } + + } +#endif +} + +/**************************************************************************** + Do a chmod by setting the ACL USER_OBJ, GROUP_OBJ and OTHER bits in an ACL + and set the mask to rwx. Needed to preserve complex ACLs set by NT. + Note that name is in UNIX character set. +****************************************************************************/ + +int chmod_acl(char *name, mode_t mode) +{ + SMB_ACL_T posix_acl = NULL; + + if ((posix_acl = sys_acl_get_file(name, SMB_ACL_TYPE_ACCESS)) == NULL) + return -1; + + return chmod_acl_internals(posix_acl, mode); +} + +/**************************************************************************** + Do an fchmod by setting the ACL USER_OBJ, GROUP_OBJ and OTHER bits in an ACL + and set the mask to rwx. Needed to preserve complex ACLs set by NT. +****************************************************************************/ + +int fchmod_acl(int fd, mode_t mode) +{ + SMB_ACL_T posix_acl = NULL; + + if ((posix_acl = sys_acl_get_fd(fd)) == NULL) + return -1; + + return chmod_acl_internals(posix_acl, mode); +} + #undef OLD_NTDOMAIN diff --git a/source3/smbd/process.c b/source3/smbd/process.c index ea0309599f..0916dc5b7e 100644 --- a/source3/smbd/process.c +++ b/source3/smbd/process.c @@ -44,7 +44,7 @@ int max_recv = BUFFER_SIZE; extern int last_message; extern int global_oplock_break; -extern pstring sesssetup_user; +extern userdom_struct current_user_info; extern char *last_inbuf; extern char *InBuffer; extern char *OutBuffer; @@ -524,7 +524,7 @@ static int switch_message(int type,char *inbuf,char *outbuf,int size,int bufsize SSVAL(inbuf,smb_uid,session_tag); /* - * Ensure the correct username is in sesssetup_user. + * Ensure the correct username is in current_user_info. * This is a really ugly bugfix for problems with * multiple session_setup_and_X's being done and * allowing %U and %G substitutions to work correctly. @@ -539,7 +539,7 @@ static int switch_message(int type,char *inbuf,char *outbuf,int size,int bufsize if(session_tag != UID_FIELD_INVALID) vuser = get_valid_user_struct(session_tag); if(vuser != NULL) - pstrcpy( sesssetup_user, vuser->user.smb_name); + current_user_info = vuser->user; } /* does this protocol need to be run as root? */ diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 7738f2594f..624dc59084 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -36,7 +36,7 @@ extern char magic_char; extern BOOL case_sensitive; extern BOOL case_preserve; extern BOOL short_case_preserve; -extern pstring sesssetup_user; +extern userdom_struct current_user_info; extern pstring global_myname; extern fstring global_myworkgroup; extern int global_oplock_break; @@ -879,7 +879,7 @@ int reply_sesssetup_and_X(connection_struct *conn, char *inbuf,char *outbuf,int guest = True; } - pstrcpy(sesssetup_user,user); + pstrcpy(current_user_info.smb_name,user); reload_services(True); @@ -1042,7 +1042,7 @@ int reply_sesssetup_and_X(connection_struct *conn, char *inbuf,char *outbuf,int /* register the name and uid as being validated, so further connections to a uid can get through without a password, on the same VC */ - sess_vuid = register_vuid(uid,gid,user,sesssetup_user,domain,guest); + sess_vuid = register_vuid(uid,gid,user,current_user_info.smb_name,domain,guest); SSVAL(outbuf,smb_uid,sess_vuid); SSVAL(inbuf,smb_uid,sess_vuid); diff --git a/source3/smbd/service.c b/source3/smbd/service.c index 1db5dc4a5f..a6e66965c3 100644 --- a/source3/smbd/service.c +++ b/source3/smbd/service.c @@ -33,7 +33,7 @@ extern BOOL case_mangle; extern BOOL case_sensitive; extern BOOL use_mangled_map; extern fstring remote_machine; -extern pstring sesssetup_user; +extern userdom_struct current_user_info; extern fstring remote_machine; @@ -113,8 +113,28 @@ int find_service(char *service) int iHomeService; if ((iHomeService = lp_servicenumber(HOMES_NAME)) >= 0) { - lp_add_home(service,iHomeService,phome_dir); - iService = lp_servicenumber(service); + /* + * If this is a winbindd provided username, remove + * the domain component before adding the service. + * Log a warning if the "path=" parameter does not + * include any macros. + */ + + fstring new_service; + char *usr_p = NULL; + + fstrcpy(new_service, service); + + if ((usr_p = strchr(service,*lp_winbind_separator())) != NULL) + fstrcpy(new_service, usr_p+1); + + lp_add_home(new_service,iHomeService,phome_dir); + iService = lp_servicenumber(new_service); + + if (usr_p && (strchr(lp_pathname(iService),'%') == NULL)) + DEBUG(0,("find_service: Service %s added for user %s - contains non-local (Domain) user \ +with non parameterised path (%s). This may be cause the wrong directory to be seen.\n", + new_service, service, lp_pathname(iService) )); } } } @@ -234,11 +254,11 @@ connection_struct *make_connection(char *service,char *user,char *password, int return(make_connection(dos_username,user,password,pwlen,dev,vuid,ecode)); } } else { - /* Security = share. Try with sesssetup_user + /* Security = share. Try with current_user_info.smb_name * as the username. */ - if(*sesssetup_user) { + if(*current_user_info.smb_name) { fstring dos_username; - fstrcpy(user,sesssetup_user); + fstrcpy(user,current_user_info.smb_name); fstrcpy(dos_username, user); unix_to_dos(dos_username, True); return(make_connection(dos_username,user,password,pwlen,dev,vuid,ecode)); diff --git a/source3/smbd/vfs-wrap.c b/source3/smbd/vfs-wrap.c index a9d8a32430..ad4d4ddbef 100644 --- a/source3/smbd/vfs-wrap.c +++ b/source3/smbd/vfs-wrap.c @@ -107,6 +107,20 @@ int vfswrap_mkdir(connection_struct *conn, char *path, mode_t mode) #endif result = mkdir(path, mode); + + if (result == 0) { + /* + * We need to do this as the default behavior of POSIX ACLs + * is to set the mask to be the requested group permission + * bits, not the group permission bits to be the requested + * group permission bits. This is not what we want, as it will + * mess up any inherited ACL bits that were set. JRA. + */ + if (conn->vfs_ops.chmod_acl != NULL) { + conn->vfs_ops.chmod_acl(conn, path, mode); + } + } + END_PROFILE(syscall_mkdir); return result; } @@ -332,6 +346,19 @@ int vfswrap_chmod(connection_struct *conn, char *path, mode_t mode) } #endif + /* + * We need to do this due to the fact that the default POSIX ACL + * chmod modifies the ACL *mask* for the group owner, not the + * group owner bits directly. JRA. + */ + + if (conn->vfs_ops.chmod_acl != NULL) { + if ((result = conn->vfs_ops.chmod_acl(conn, path, mode)) == 0) { + END_PROFILE(syscall_chmod); + return result; + } + } + result = chmod(path, mode); END_PROFILE(syscall_chmod); return result; @@ -506,4 +533,15 @@ BOOL vfswrap_set_nt_acl(files_struct *fsp, char *name, uint32 security_info_sent { return set_nt_acl(fsp, security_info_sent, psd); } + +int vfswrap_chmod_acl(connection_struct *conn, char *name, mode_t mode) +{ + return chmod_acl(name, mode); +} + +int vfswrap_fchmod_acl(files_struct *fsp, int fd, mode_t mode) +{ + return fchmod_acl(fd, mode); +} + #undef OLD_NTDOMAIN diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index cbd1fd6825..2cd83c37f3 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -74,7 +74,10 @@ struct vfs_ops default_vfs_ops = { vfswrap_fget_nt_acl, vfswrap_get_nt_acl, vfswrap_fset_nt_acl, - vfswrap_set_nt_acl + vfswrap_set_nt_acl, + + vfswrap_chmod_acl, + vfswrap_fchmod_acl }; /**************************************************************************** @@ -257,6 +260,13 @@ BOOL vfs_init_custom(connection_struct *conn) conn->vfs_ops.set_nt_acl = default_vfs_ops.set_nt_acl; } + if (conn->vfs_ops.chmod_acl == NULL) { + conn->vfs_ops.chmod_acl = default_vfs_ops.chmod_acl; + } + + if (conn->vfs_ops.fchmod_acl == NULL) { + conn->vfs_ops.fchmod_acl = default_vfs_ops.fchmod_acl; + } return True; } #endif |