diff options
author | Shirish Kalele <kalele@samba.org> | 2000-03-17 20:17:51 +0000 |
---|---|---|
committer | Shirish Kalele <kalele@samba.org> | 2000-03-17 20:17:51 +0000 |
commit | d3a5901f4117372ab227c057556190bbcc036ec9 (patch) | |
tree | 064a95925bd7d37803166f04cae695e1aae44cd9 | |
parent | 19ab1efaf6eac4b41b616ad5440ab47489221279 (diff) | |
download | samba-d3a5901f4117372ab227c057556190bbcc036ec9.tar.gz samba-d3a5901f4117372ab227c057556190bbcc036ec9.tar.xz samba-d3a5901f4117372ab227c057556190bbcc036ec9.zip |
Added Dfs commands to rpcclient
-rw-r--r-- | source/Makefile.in | 8 | ||||
-rw-r--r-- | source/include/lib_smb_proto.h | 136 | ||||
-rw-r--r-- | source/include/ntdomain.h | 1 | ||||
-rw-r--r-- | source/include/proto.h | 1293 | ||||
-rw-r--r-- | source/include/rpc_client_proto.h | 7 | ||||
-rw-r--r-- | source/include/rpc_dfs.h | 144 | ||||
-rw-r--r-- | source/include/rpc_parse_proto.h | 23 | ||||
-rw-r--r-- | source/include/smb.h | 1 | ||||
-rw-r--r-- | source/include/winbindd_proto.h | 554 | ||||
-rw-r--r-- | source/rpc_client/cli_connect.c | 13 | ||||
-rw-r--r-- | source/rpc_client/cli_dfs.c | 191 | ||||
-rw-r--r-- | source/rpc_parse/parse_dfs.c | 345 | ||||
-rw-r--r-- | source/rpc_parse/parse_rpc.c | 19 | ||||
-rw-r--r-- | source/rpcclient/cmd_dfs.c | 244 | ||||
-rw-r--r-- | source/rpcclient/dfs_cmds.c | 64 | ||||
-rw-r--r-- | source/rpcclient/rpcclient.c | 1 |
16 files changed, 2047 insertions, 997 deletions
diff --git a/source/Makefile.in b/source/Makefile.in index 1c0ea4fed73..dd2708df812 100644 --- a/source/Makefile.in +++ b/source/Makefile.in @@ -198,7 +198,8 @@ RPC_PARSE_OBJ1 = rpc_parse/parse_lsa.o \ rpc_parse/parse_at.o \ rpc_parse/parse_spoolss.o \ rpc_parse/parse_eventlog.o \ - rpc_parse/parse_brs.o + rpc_parse/parse_brs.o \ + rpc_parse/parse_dfs.o RPC_PARSE_OBJ2 = rpc_parse/parse_rpc.o \ rpc_parse/parse_misc.o \ @@ -231,7 +232,8 @@ RPC_CLIENT_OBJ = \ rpc_client/msrpc_netlogon.o \ rpc_client/msrpc_lsarpc.o \ rpc_client/cli_atsvc.o \ - rpc_client/cli_eventlog.o + rpc_client/cli_eventlog.o \ + rpc_client/cli_dfs.o LOCKING_OBJ = locking/locking.o @@ -576,6 +578,7 @@ RPCCLIENT_OBJ = lib/cmd_interp.o \ rpcclient/netlogon_cmds.o \ rpcclient/cmdat_cmds.o \ rpcclient/spoolss_cmds.o \ + rpcclient/dfs_cmds.o \ rpcclient/display_at.o \ rpcclient/display_event.o \ rpcclient/display_reg.o \ @@ -596,6 +599,7 @@ RPCCLIENT_OBJ = lib/cmd_interp.o \ rpcclient/cmd_atsvc.o \ rpcclient/cmd_spoolss.o \ rpcclient/cmd_eventlog.o \ + rpcclient/cmd_dfs.o \ $(SIDDB_OBJ) \ $(STUB_UID_OBJ) RPCCLIENT_LIBS = $(SAMBA_LIBS) $(UBIQXLIB) diff --git a/source/include/lib_smb_proto.h b/source/include/lib_smb_proto.h index ed94d1e16f3..cef7fe043b6 100644 --- a/source/include/lib_smb_proto.h +++ b/source/include/lib_smb_proto.h @@ -23,6 +23,74 @@ void MD5Update(struct MD5Context *ctx, uchar const *buf, unsigned len); void MD5Final(uchar digest[16], struct MD5Context *ctx); void MD5Transform(uint32 buf[4], const uchar inext[64]); +/*The following definitions come from lib/util_hnd.c */ + +struct policy_cache *get_global_hnd_cache(void); +struct policy_cache *init_policy_cache(int num_pol_hnds); +void free_policy_cache(struct policy_cache *cache); +BOOL policy_hnd_set_name(struct policy_cache *cache, + POLICY_HND *hnd, const char *name); +const char *policy_hnd_get_name(struct policy_cache *cache, + const POLICY_HND *hnd); +BOOL dup_policy_hnd(struct policy_cache *cache, + POLICY_HND *hnd, + const POLICY_HND *from); +BOOL register_policy_hnd(struct policy_cache *cache, + const vuser_key *key, + POLICY_HND *hnd, + uint32 access_mask); +BOOL open_policy_hnd(struct policy_cache *cache, + const vuser_key *key, + POLICY_HND *hnd, + uint32 access_mask); +BOOL open_policy_hnd_link(struct policy_cache *cache, + const POLICY_HND *parent_hnd, + POLICY_HND *hnd, + uint32 access_mask); +int find_policy_by_hnd(struct policy_cache *cache, const POLICY_HND *hnd); +BOOL set_policy_state(struct policy_cache *cache, POLICY_HND *hnd, + void(*fn)(void*), void *dev); +void *get_policy_state_info(struct policy_cache *cache, const POLICY_HND *hnd); +BOOL policy_hnd_set_state_type(struct policy_cache *cache, + POLICY_HND *hnd, int type); +int policy_hnd_get_state_type(struct policy_cache *cache, + const POLICY_HND *hnd); +BOOL policy_hnd_check_state_type(struct policy_cache *cache, + const POLICY_HND *hnd, int type); +BOOL close_policy_hnd(struct policy_cache *cache, POLICY_HND *hnd); +BOOL policy_link_key(struct policy_cache *cache, const POLICY_HND *hnd, + POLICY_HND *to); +const vuser_key *get_policy_vuser_key(struct policy_cache *cache, + const POLICY_HND *hnd); +BOOL pol_get_usr_sesskey(struct policy_cache *cache, const POLICY_HND *hnd, + uchar usr_sess_key[16]); + +/*The following definitions come from lib/vuser.c */ + +BOOL is_valid_user_struct(const vuser_key * key); +user_struct *get_valid_user_struct(const vuser_key * key); +void invalidate_vuid(vuser_key * key); +BOOL validated_username(vuser_key * key, char *name, size_t len); +uint16 create_vuid(pid_t pid, + uid_t uid, gid_t gid, + int n_groups, gid_t * groups, + const char *unix_name, + const char *requested_name, + const char *real_name, + BOOL guest, const NET_USER_INFO_3 * info3); +uint16 register_vuid(pid_t pid, uid_t uid, gid_t gid, + const char *unix_name, + const char *requested_name, + BOOL guest, const NET_USER_INFO_3 * info3); +BOOL check_vuser_ok(struct uid_cache *cache, user_struct * vuser, int snum); + +/*The following definitions come from lib/vuser_db.c */ + +BOOL tdb_delete_vuid( const vuser_key *uk); +BOOL tdb_lookup_vuid( const vuser_key *uk, user_struct **usr); +BOOL tdb_store_vuid( const vuser_key *uk, user_struct *usr); +BOOL vuid_init_db(void); + /*The following definitions come from libsmb/clientgen.c */ int cli_set_port(struct cli_state *cli, int port); @@ -240,74 +308,6 @@ BOOL smb_safe_err_msg(uint8 class, uint32 num, char *ret, size_t len); BOOL smb_safe_errstr(char *inbuf, char *msg, size_t len); char *smb_errstr(char *inbuf); -/*The following definitions come from lib/util_hnd.c */ - -struct policy_cache *get_global_hnd_cache(void); -struct policy_cache *init_policy_cache(int num_pol_hnds); -void free_policy_cache(struct policy_cache *cache); -BOOL policy_hnd_set_name(struct policy_cache *cache, - POLICY_HND *hnd, const char *name); -const char *policy_hnd_get_name(struct policy_cache *cache, - const POLICY_HND *hnd); -BOOL dup_policy_hnd(struct policy_cache *cache, - POLICY_HND *hnd, - const POLICY_HND *from); -BOOL register_policy_hnd(struct policy_cache *cache, - const vuser_key *key, - POLICY_HND *hnd, - uint32 access_mask); -BOOL open_policy_hnd(struct policy_cache *cache, - const vuser_key *key, - POLICY_HND *hnd, - uint32 access_mask); -BOOL open_policy_hnd_link(struct policy_cache *cache, - const POLICY_HND *parent_hnd, - POLICY_HND *hnd, - uint32 access_mask); -int find_policy_by_hnd(struct policy_cache *cache, const POLICY_HND *hnd); -BOOL set_policy_state(struct policy_cache *cache, POLICY_HND *hnd, - void(*fn)(void*), void *dev); -void *get_policy_state_info(struct policy_cache *cache, const POLICY_HND *hnd); -BOOL policy_hnd_set_state_type(struct policy_cache *cache, - POLICY_HND *hnd, int type); -int policy_hnd_get_state_type(struct policy_cache *cache, - const POLICY_HND *hnd); -BOOL policy_hnd_check_state_type(struct policy_cache *cache, - const POLICY_HND *hnd, int type); -BOOL close_policy_hnd(struct policy_cache *cache, POLICY_HND *hnd); -BOOL policy_link_key(struct policy_cache *cache, const POLICY_HND *hnd, - POLICY_HND *to); -const vuser_key *get_policy_vuser_key(struct policy_cache *cache, - const POLICY_HND *hnd); -BOOL pol_get_usr_sesskey(struct policy_cache *cache, const POLICY_HND *hnd, - uchar usr_sess_key[16]); - -/*The following definitions come from lib/vuser.c */ - -BOOL is_valid_user_struct(const vuser_key * key); -user_struct *get_valid_user_struct(const vuser_key * key); -void invalidate_vuid(vuser_key * key); -BOOL validated_username(vuser_key * key, char *name, size_t len); -uint16 create_vuid(pid_t pid, - uid_t uid, gid_t gid, - int n_groups, gid_t * groups, - const char *unix_name, - const char *requested_name, - const char *real_name, - BOOL guest, const NET_USER_INFO_3 * info3); -uint16 register_vuid(pid_t pid, uid_t uid, gid_t gid, - const char *unix_name, - const char *requested_name, - BOOL guest, const NET_USER_INFO_3 * info3); -BOOL check_vuser_ok(struct uid_cache *cache, user_struct * vuser, int snum); - -/*The following definitions come from lib/vuser_db.c */ - -BOOL tdb_delete_vuid( const vuser_key *uk); -BOOL tdb_lookup_vuid( const vuser_key *uk, user_struct **usr); -BOOL tdb_store_vuid( const vuser_key *uk, user_struct *usr); -BOOL vuid_init_db(void); - /*The following definitions come from rpc_parse/parse_creds.c */ BOOL make_creds_unix(CREDS_UNIX *r_u, const char* user_name, diff --git a/source/include/ntdomain.h b/source/include/ntdomain.h index ab7f0731183..b21e23a1510 100644 --- a/source/include/ntdomain.h +++ b/source/include/ntdomain.h @@ -47,6 +47,7 @@ #include "rpc_wkssvc.h" #include "rpc_atsvc.h" #include "rpc_eventlog.h" +#include "rpc_dfs.h" /* MS AD prototypes */ #include "sam.h" diff --git a/source/include/proto.h b/source/include/proto.h index 43d282a6974..30a0caaee30 100644 --- a/source/include/proto.h +++ b/source/include/proto.h @@ -388,269 +388,10 @@ void CatchChildLeaveStatus(void); int vslprintf(char *str, int n, char *format, va_list ap); -/*The following definitions come from libsmb/clientgen.c */ - -int cli_set_port(struct cli_state *cli, int port); -char *cli_errstr(struct cli_state *cli); -void cli_safe_smb_errstr(struct cli_state *cli, char *msg, size_t len); -BOOL get_safe_rap_errstr(int rap_error, char *err_msg, size_t msglen); -void cli_safe_errstr(struct cli_state *cli, char *err_msg, size_t msglen); -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_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); -BOOL cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, const char *)); -BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, - void (*fn)(const char *, uint32, const char *)); -BOOL cli_session_setup_x(struct cli_state *cli, - char *user, - char *pass, int passlen, - char *ntpass, int ntpasslen, - char *user_domain); -BOOL cli_session_setup(struct cli_state *cli, - char *myhostname, char *user, - char *pass, int passlen, - char *ntpass, int ntpasslen, - char *user_domain); -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); -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, const char *fname); -int cli_open(struct cli_state *cli, const 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); -BOOL cli_unlock(struct cli_state *cli, int fnum, uint32 offset, uint32 len, int timeout); -size_t cli_read_one(struct cli_state *cli, int fnum, char *buf, off_t offset, size_t size); -size_t cli_read(struct cli_state *cli, int fnum, char *buf, off_t offset, size_t size, BOOL overlap); -ssize_t cli_write(struct cli_state *cli, - int fnum, uint16 write_mode, - char *buf, off_t offset, size_t size, size_t bytes_left); -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_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); -int cli_list(struct cli_state *cli,const char *Mask,uint16 attribute, - void (*fn)(file_info *, const char *)); -BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char *new_password, - const char *old_password); -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); -void cli_init_creds(struct cli_state *cli, const struct ntuser_creds *usr); -struct cli_state *cli_initialise(struct cli_state *cli); -void cli_close_socket(struct cli_state *cli); -void cli_shutdown(struct cli_state *cli); -int cli_error(struct cli_state *cli, uint8 *eclass, uint32 *num); -void cli_sockopt(struct cli_state *cli, char *options); -uint16 cli_setpid(struct cli_state *cli, uint16 pid); -BOOL cli_reestablish_connection(struct cli_state *cli); -BOOL cli_establish_connection(struct cli_state *cli, - const 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 cli_connect_auth(struct cli_state *cli, - const char* desthost, - struct in_addr *dest_ip, - const struct ntuser_creds *usr); -BOOL cli_connect_servers_auth(struct cli_state *cli, - char *p, - const struct ntuser_creds *usr); -BOOL cli_connect_serverlist(struct cli_state *cli, char *p); -int cli_printjob_del(struct cli_state *cli, int job); -int cli_print_queue(struct cli_state *cli, - void (*fn)(struct print_job_info *)); -BOOL cli_chkpath(struct cli_state *cli, char *path); -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); -BOOL cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail); -BOOL get_any_dc_name(const char *domain, char *srv_name); - -/*The following definitions come from libsmb/credentials.c */ - -char *credstr(const uchar *cred); -void cred_session_key(DOM_CHAL *clnt_chal, DOM_CHAL *srv_chal, const 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(const 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, - const DOM_CRED *rcv_clnt_cred, DOM_CRED *rtn_srv_cred); - -/*The following definitions come from libsmb/namequery.c */ - -BOOL name_status(int fd,char *name,int name_type,BOOL recurse, - struct in_addr to_ip,char *master,char *rname, - void (*fn)(struct packet_struct *)); -struct in_addr *name_query(int fd,const char *name,int name_type, BOOL bcast,BOOL recurse, - struct in_addr to_ip, int *count, void (*fn)(struct packet_struct *)); -FILE *startlmhosts(char *fname); -BOOL getlmhostsent( FILE *fp, pstring name, int *name_type, struct in_addr *ipaddr); -void endlmhosts(FILE *fp); -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); - -/*The following definitions come from libsmb/nmblib.c */ - -void debug_nmb_packet(struct packet_struct *p); -char *nmb_namestr(struct nmb_name *n); -void nmb_safe_namestr(struct nmb_name *n, char *str, size_t len); -struct packet_struct *copy_packet(struct packet_struct *packet); -void free_packet(struct packet_struct *packet); -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, const char *this_scope ); -BOOL nmb_name_equal(struct nmb_name *n1, struct nmb_name *n2); -BOOL send_packet(struct packet_struct *p); -struct packet_struct *receive_packet(int fd,enum packet_type type,int t); -void sort_query_replies(char *data, int n, struct in_addr ip); -BOOL read_nmb_sock(int c, struct nmb_state *con); -int get_nmb_sock(void); -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); -const 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); -void pwd_obfuscate_key(struct pwd_info *pwd, uint32 int_key, char *str_key); -BOOL pwd_compare(const struct pwd_info *_pwd1, const 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, - const uchar lm_pwd[16], - const uchar nt_pwd[16]); -void pwd_get_lm_nt_16(const 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_owf2(struct pwd_info *pwd, const uchar srv_key[8], - const char *user, const char *server, const char *domain, - uchar sess_key[16]); -void pwd_make_lm_nt_owf(struct pwd_info *pwd, uchar cryptkey[8], - uchar sess_key[16]); -void pwd_get_lm_nt_owf(struct pwd_info *pwd, uchar lm_owf[24], - uchar *nt_owf, size_t *nt_owf_len); - /*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 smbhash(uchar *out, const uchar *in, const uchar *key, int forw); -void E_P16(uchar *p14,uchar *p16); -void E_P24(const uchar *p21, const uchar *c8, uchar *p24); -void D_P16(const uchar *p14, const uchar *in, uchar *out); -void E_old_pw_hash( const uchar *p14, const uchar *in, uchar *out); -void cred_hash1(uchar *out, const uchar *in, const uchar *key); -void cred_hash2(uchar *out,uchar *in,uchar *key); -void cred_hash3(uchar *out, const uchar *in,uchar *key, int forw); -void SamOEMhash( uchar *data, const uchar *key, int val); -void sam_pwd_hash(uint32 rid, const uchar *in, uchar *out, int forw); - -/*The following definitions come from libsmb/smbencrypt.c */ - -void SMBencrypt(uchar * pwrd, uchar * c8, uchar * p24); -void SMBNTencrypt(uchar * pwrd, uchar * c8, uchar * p24); -void E_md4hash(uchar * pwrd, uchar * p16); -void lm_owf_genW(const UNISTR2 * pwd, uchar p16[16]); -void lm_owf_gen(const char *pwd, uchar p16[16]); -void nt_owf_genW(const UNISTR2 * pwd, uchar nt_p16[16]); -void nt_owf_gen(const char *pwd, uchar nt_p16[16]); -void nt_lm_owf_genW(const UNISTR2 * pwd, uchar nt_p16[16], uchar lm_p16[16]); -void nt_lm_owf_gen(const char *pwd, uchar nt_p16[16], uchar lm_p16[16]); -void SMBOWFencrypt(const uchar pwrd[16], const uchar * c8, uchar p24[24]); -void SMBOWFencrypt_ntv2(const uchar kr[16], - const uchar * srv_chal, int srv_chal_len, - const uchar * cli_chal, int cli_chal_len, - char resp_buf[16]); -void SMBsesskeygen_ntv2(const uchar kr[16], - const uchar * nt_resp, char sess_key[16]); -void SMBsesskeygen_ntv1(const uchar kr[16], - const uchar * nt_resp, char sess_key[16]); -void SMBgenclientchals(char *lm_cli_chal, - char *nt_cli_chal, int *nt_cli_chal_len, - const char *srv, const char *dom); -void ntv2_owf_gen(const uchar owf[16], - const char *user_n, const char *domain_n, uchar kr_buf[16]); -void NTLMSSPOWFencrypt(const uchar pwrd[8], const uchar * ntlmchalresp, - uchar p24[24]); -BOOL make_oem_passwd_hash(uchar data[516], - const char *pwrd, int new_pw_len, - const uchar old_pw_hash[16], BOOL unicode); -BOOL nt_encrypt_string2(STRING2 * out, const STRING2 * in, const uchar * key); -BOOL nt_decrypt_string2(STRING2 * out, const STRING2 * in, const uchar * key); -void create_ntlmssp_resp(struct pwd_info *pwd, - char *domain, char *user_name, char *my_name, - uint32 ntlmssp_cli_flgs, prs_struct * auth_resp); -BOOL decode_pw_buffer(const char buffer[516], char *new_pwrd, - int new_pwrd_size, uint32 * new_pw_len); -BOOL encode_pw_buffer(char buffer[516], const char *new_pass, - int new_pw_len, BOOL nt_pass_set); - -/*The following definitions come from libsmb/smberr.c */ - -char *smb_err_msg(uint8 class, uint32 num); -BOOL smb_safe_err_msg(uint8 class, uint32 num, char *ret, size_t len); -BOOL smb_safe_errstr(char *inbuf, char *msg, size_t len); -char *smb_errstr(char *inbuf); - /*The following definitions come from lib/snprintf.c */ @@ -660,6 +401,11 @@ void become_root(BOOL save_dir); void unbecome_root(BOOL restore_dir); const vuser_key *get_sec_ctx(void); +/*The following definitions come from lib/surs.c */ + +BOOL surs_sam_sid_to_unixid(DOM_SID *sid, uint32 type, uint32 *id, BOOL create); +BOOL surs_unixid_to_sam_sid(uint32 id, uint32 type, DOM_SID *sid, BOOL create); + /*The following definitions come from lib/sursalgdomonly.c */ BOOL surs_algdomonly_sam_sid_to_unixid(DOM_SID *sid, uint32 type, uint32 *id, @@ -674,11 +420,6 @@ BOOL surs_nt5ldap_sam_sid_to_unixid(LDAPDB *hds, DOM_SID * sid, uint32 type, BOOL surs_nt5ldap_unixid_to_sam_sid(LDAPDB *hds, uint32 id, uint32 type, DOM_SID * sid, BOOL create); -/*The following definitions come from lib/surs.c */ - -BOOL surs_sam_sid_to_unixid(DOM_SID *sid, uint32 type, uint32 *id, BOOL create); -BOOL surs_unixid_to_sam_sid(uint32 id, uint32 type, DOM_SID *sid, BOOL create); - /*The following definitions come from lib/surstdb.c */ BOOL surs_tdb_sam_sid_to_unixid(DOM_SID * sid, uint32 type, uint32 * id, @@ -751,25 +492,6 @@ const struct passwd *Get_Pwnam(char *user,BOOL allow_change); BOOL user_ok(char *user,int snum); BOOL user_in_list(char *user,char *list); -/*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_unistr_array(uint32 num_entries, UNISTR2 **entries); -UNISTR2* add_unistr_to_array(uint32 *len, UNISTR2 ***array, UNISTR2 *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 */ BOOL init_myworkgroup(void); @@ -877,6 +599,25 @@ char *passdb_path(char *name); char *lock_path(char *name); const char *get_sid_name_use_str(uint32 sid_name_use); +/*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_unistr_array(uint32 num_entries, UNISTR2 **entries); +UNISTR2* add_unistr_to_array(uint32 *len, UNISTR2 ***array, UNISTR2 *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); @@ -1111,6 +852,265 @@ BOOL tdb_lookup_vuid( const vuser_key *uk, user_struct **usr); BOOL tdb_store_vuid( const vuser_key *uk, user_struct *usr); BOOL vuid_init_db(void); +/*The following definitions come from libsmb/clientgen.c */ + +int cli_set_port(struct cli_state *cli, int port); +char *cli_errstr(struct cli_state *cli); +void cli_safe_smb_errstr(struct cli_state *cli, char *msg, size_t len); +BOOL get_safe_rap_errstr(int rap_error, char *err_msg, size_t msglen); +void cli_safe_errstr(struct cli_state *cli, char *err_msg, size_t msglen); +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_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); +BOOL cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, const char *)); +BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, + void (*fn)(const char *, uint32, const char *)); +BOOL cli_session_setup_x(struct cli_state *cli, + char *user, + char *pass, int passlen, + char *ntpass, int ntpasslen, + char *user_domain); +BOOL cli_session_setup(struct cli_state *cli, + char *myhostname, char *user, + char *pass, int passlen, + char *ntpass, int ntpasslen, + char *user_domain); +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); +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, const char *fname); +int cli_open(struct cli_state *cli, const 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); +BOOL cli_unlock(struct cli_state *cli, int fnum, uint32 offset, uint32 len, int timeout); +size_t cli_read_one(struct cli_state *cli, int fnum, char *buf, off_t offset, size_t size); +size_t cli_read(struct cli_state *cli, int fnum, char *buf, off_t offset, size_t size, BOOL overlap); +ssize_t cli_write(struct cli_state *cli, + int fnum, uint16 write_mode, + char *buf, off_t offset, size_t size, size_t bytes_left); +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_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); +int cli_list(struct cli_state *cli,const char *Mask,uint16 attribute, + void (*fn)(file_info *, const char *)); +BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char *new_password, + const char *old_password); +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); +void cli_init_creds(struct cli_state *cli, const struct ntuser_creds *usr); +struct cli_state *cli_initialise(struct cli_state *cli); +void cli_close_socket(struct cli_state *cli); +void cli_shutdown(struct cli_state *cli); +int cli_error(struct cli_state *cli, uint8 *eclass, uint32 *num); +void cli_sockopt(struct cli_state *cli, char *options); +uint16 cli_setpid(struct cli_state *cli, uint16 pid); +BOOL cli_reestablish_connection(struct cli_state *cli); +BOOL cli_establish_connection(struct cli_state *cli, + const 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 cli_connect_auth(struct cli_state *cli, + const char* desthost, + struct in_addr *dest_ip, + const struct ntuser_creds *usr); +BOOL cli_connect_servers_auth(struct cli_state *cli, + char *p, + const struct ntuser_creds *usr); +BOOL cli_connect_serverlist(struct cli_state *cli, char *p); +int cli_printjob_del(struct cli_state *cli, int job); +int cli_print_queue(struct cli_state *cli, + void (*fn)(struct print_job_info *)); +BOOL cli_chkpath(struct cli_state *cli, char *path); +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); +BOOL cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail); +BOOL get_any_dc_name(const char *domain, char *srv_name); + +/*The following definitions come from libsmb/credentials.c */ + +char *credstr(const uchar *cred); +void cred_session_key(DOM_CHAL *clnt_chal, DOM_CHAL *srv_chal, const 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(const 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, + const DOM_CRED *rcv_clnt_cred, DOM_CRED *rtn_srv_cred); + +/*The following definitions come from libsmb/namequery.c */ + +BOOL name_status(int fd,char *name,int name_type,BOOL recurse, + struct in_addr to_ip,char *master,char *rname, + void (*fn)(struct packet_struct *)); +struct in_addr *name_query(int fd,const char *name,int name_type, BOOL bcast,BOOL recurse, + struct in_addr to_ip, int *count, void (*fn)(struct packet_struct *)); +FILE *startlmhosts(char *fname); +BOOL getlmhostsent( FILE *fp, pstring name, int *name_type, struct in_addr *ipaddr); +void endlmhosts(FILE *fp); +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); + +/*The following definitions come from libsmb/nmblib.c */ + +void debug_nmb_packet(struct packet_struct *p); +char *nmb_namestr(struct nmb_name *n); +void nmb_safe_namestr(struct nmb_name *n, char *str, size_t len); +struct packet_struct *copy_packet(struct packet_struct *packet); +void free_packet(struct packet_struct *packet); +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, const char *this_scope ); +BOOL nmb_name_equal(struct nmb_name *n1, struct nmb_name *n2); +BOOL send_packet(struct packet_struct *p); +struct packet_struct *receive_packet(int fd,enum packet_type type,int t); +void sort_query_replies(char *data, int n, struct in_addr ip); +BOOL read_nmb_sock(int c, struct nmb_state *con); +int get_nmb_sock(void); +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); +const 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); +void pwd_obfuscate_key(struct pwd_info *pwd, uint32 int_key, char *str_key); +BOOL pwd_compare(const struct pwd_info *_pwd1, const 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, + const uchar lm_pwd[16], + const uchar nt_pwd[16]); +void pwd_get_lm_nt_16(const 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_owf2(struct pwd_info *pwd, const uchar srv_key[8], + const char *user, const char *server, const char *domain, + uchar sess_key[16]); +void pwd_make_lm_nt_owf(struct pwd_info *pwd, uchar cryptkey[8], + uchar sess_key[16]); +void pwd_get_lm_nt_owf(struct pwd_info *pwd, uchar lm_owf[24], + uchar *nt_owf, size_t *nt_owf_len); + +/*The following definitions come from libsmb/smbdes.c */ + +void smbhash(uchar *out, const uchar *in, const uchar *key, int forw); +void E_P16(uchar *p14,uchar *p16); +void E_P24(const uchar *p21, const uchar *c8, uchar *p24); +void D_P16(const uchar *p14, const uchar *in, uchar *out); +void E_old_pw_hash( const uchar *p14, const uchar *in, uchar *out); +void cred_hash1(uchar *out, const uchar *in, const uchar *key); +void cred_hash2(uchar *out,uchar *in,uchar *key); +void cred_hash3(uchar *out, const uchar *in,uchar *key, int forw); +void SamOEMhash( uchar *data, const uchar *key, int val); +void sam_pwd_hash(uint32 rid, const uchar *in, uchar *out, int forw); + +/*The following definitions come from libsmb/smbencrypt.c */ + +void SMBencrypt(uchar * pwrd, uchar * c8, uchar * p24); +void SMBNTencrypt(uchar * pwrd, uchar * c8, uchar * p24); +void E_md4hash(uchar * pwrd, uchar * p16); +void lm_owf_genW(const UNISTR2 * pwd, uchar p16[16]); +void lm_owf_gen(const char *pwd, uchar p16[16]); +void nt_owf_genW(const UNISTR2 * pwd, uchar nt_p16[16]); +void nt_owf_gen(const char *pwd, uchar nt_p16[16]); +void nt_lm_owf_genW(const UNISTR2 * pwd, uchar nt_p16[16], uchar lm_p16[16]); +void nt_lm_owf_gen(const char *pwd, uchar nt_p16[16], uchar lm_p16[16]); +void SMBOWFencrypt(const uchar pwrd[16], const uchar * c8, uchar p24[24]); +void SMBOWFencrypt_ntv2(const uchar kr[16], + const uchar * srv_chal, int srv_chal_len, + const uchar * cli_chal, int cli_chal_len, + char resp_buf[16]); +void SMBsesskeygen_ntv2(const uchar kr[16], + const uchar * nt_resp, char sess_key[16]); +void SMBsesskeygen_ntv1(const uchar kr[16], + const uchar * nt_resp, char sess_key[16]); +void SMBgenclientchals(char *lm_cli_chal, + char *nt_cli_chal, int *nt_cli_chal_len, + const char *srv, const char *dom); +void ntv2_owf_gen(const uchar owf[16], + const char *user_n, const char *domain_n, uchar kr_buf[16]); +void NTLMSSPOWFencrypt(const uchar pwrd[8], const uchar * ntlmchalresp, + uchar p24[24]); +BOOL make_oem_passwd_hash(uchar data[516], + const char *pwrd, int new_pw_len, + const uchar old_pw_hash[16], BOOL unicode); +BOOL nt_encrypt_string2(STRING2 * out, const STRING2 * in, const uchar * key); +BOOL nt_decrypt_string2(STRING2 * out, const STRING2 * in, const uchar * key); +void create_ntlmssp_resp(struct pwd_info *pwd, + char *domain, char *user_name, char *my_name, + uint32 ntlmssp_cli_flgs, prs_struct * auth_resp); +BOOL decode_pw_buffer(const char buffer[516], char *new_pwrd, + int new_pwrd_size, uint32 * new_pw_len); +BOOL encode_pw_buffer(char buffer[516], const char *new_pass, + int new_pw_len, BOOL nt_pass_set); + +/*The following definitions come from libsmb/smberr.c */ + +char *smb_err_msg(uint8 class, uint32 num); +BOOL smb_safe_err_msg(uint8 class, uint32 num, char *ret, size_t len); +BOOL smb_safe_errstr(char *inbuf, char *msg, size_t len); +char *smb_errstr(char *inbuf); + /*The following definitions come from locking/locking.c */ BOOL is_locked(files_struct *fsp,connection_struct *conn, @@ -1263,6 +1263,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); @@ -1293,9 +1296,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); @@ -1522,8 +1522,8 @@ BOOL send_mailslot(BOOL unique, char *mailslot, char *buf, int len, /*The following definitions come from nmbd/nmbd_processlogon.c */ -void process_logon_packet(struct packet_struct *p,char *buf,int len, - char *mailslot); +void process_logon_packet(struct packet_struct *p, char *buf, int len, + char *mailslot); /*The following definitions come from nmbd/nmbd_responserecordsdb.c */ @@ -2084,6 +2084,11 @@ void init_devicemode(NT_DEVICEMODE *nt_devmode); BOOL pcap_printername_ok(char *pszPrintername, char *pszPrintcapname); void pcap_printer_fn(void (*fn)(char *, char *)); +/*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/printing.c */ void lpq_reset(int snum); @@ -2102,11 +2107,6 @@ uint32 status_printqueue(connection_struct *conn,const vuser_key *key, int snum,int status); void load_printers(void); -/*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 */ BOOL profile_setup(BOOL rdonly); @@ -2176,6 +2176,13 @@ BOOL set_policy_con(struct policy_cache *cache, POLICY_HND * hnd, BOOL get_policy_con(struct policy_cache *cache, const POLICY_HND * hnd, struct cli_connection **con); +/*The following definitions come from rpc_client/cli_dfs.c */ + +BOOL dfs_remove(char *srv_name, char *dfs_entrypath, char *dfs_servername, + char *dfs_sharename); +BOOL dfs_add(char *srv_name, char* entrypath, char* servername, char* sharename, char* comment); +uint32 dfs_enum(char *srv_name, uint32 level, DFS_INFO_CTR *ctr); + /*The following definitions come from rpc_client/cli_eventlog.c */ BOOL event_open(const char* srv_name, const char *log, POLICY_HND *hnd); @@ -2578,290 +2585,6 @@ void cli_use_wait_keyboard(void); BOOL wks_query_info( char *srv_name, uint32 switch_value, WKS_INFO_100 *wks100); -/*The following definitions come from rpcclient/cmdat.c */ - - -/*The following definitions come from rpcclient/cmdat_cmds.c */ - -void add_at_commands(void); - -/*The following definitions come from rpcclient/cmd_atsvc.c */ - -void cmd_at(struct client_info *info, int argc, char *argv[]); - -/*The following definitions come from rpcclient/cmd_brs.c */ - -void cmd_brs_query_info(struct client_info *info, int argc, char *argv[]); - -/*The following definitions come from rpcclient/cmd_eventlog.c */ - -void cmd_eventlog(struct client_info *info, int argc, char *argv[]); - -/*The following definitions come from rpcclient/cmd_lsarpc.c */ - -void cmd_lsa_enum_trust_dom(struct client_info *info, int argc, char *argv[]); -void cmd_lsa_query_info(struct client_info *info, int argc, char *argv[]); -void cmd_lsa_lookup_names(struct client_info *info, int argc, char *argv[]); -void cmd_lsa_lookup_sids(struct client_info *info, int argc, char *argv[]); -void cmd_lsa_set_secret(struct client_info *info, int argc, char *argv[]); -void cmd_lsa_create_secret(struct client_info *info, int argc, char *argv[]); -void cmd_lsa_query_secret_secobj(struct client_info *info, int argc, char *argv[]); -void cmd_lsa_query_secret(struct client_info *info, int argc, char *argv[]); - -/*The following definitions come from rpcclient/cmd_netlogon.c */ - -void cmd_netlogon_pwset(struct client_info *info, int argc, char *argv[]); -void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[]); -void cmd_netlogon_domain_test(struct client_info *info, int argc, - char *argv[]); -void cmd_sam_sync(struct client_info *info, int argc, char *argv[]); - -/*The following definitions come from rpcclient/cmd_reg.c */ - -void split_server_keyname(char *srv_name, char *key, const char* arg); -BOOL msrpc_reg_enum_key(const char* srv_name, const char* full_keyname, - REG_FN(reg_fn), - REG_KEY_FN(reg_key_fn), - REG_VAL_FN(reg_val_fn)); -void cmd_reg_enum(struct client_info *info, int argc, char *argv[]); -void cmd_reg_query_info(struct client_info *info, int argc, char *argv[]); -void cmd_reg_query_key(struct client_info *info, int argc, char *argv[]); -void cmd_reg_create_val(struct client_info *info, int argc, char *argv[]); -void cmd_reg_delete_val(struct client_info *info, int argc, char *argv[]); -void cmd_reg_delete_key(struct client_info *info, int argc, char *argv[]); -void cmd_reg_create_key(struct client_info *info, int argc, char *argv[]); -void cmd_reg_test_key_sec(struct client_info *info, int argc, char *argv[]); -void cmd_reg_get_key_sec(struct client_info *info, int argc, char *argv[]); -void cmd_reg_shutdown(struct client_info *info, int argc, char *argv[]); - -/*The following definitions come from rpcclient/cmd_samr.c */ - -void cmd_sam_ntchange_pwd(struct client_info *info, int argc, char *argv[]); -void cmd_sam_test(struct client_info *info, int argc, char *argv[]); -void cmd_sam_lookup_domain(struct client_info *info, int argc, char *argv[]); -void cmd_sam_lookup_names(struct client_info *info, int argc, char *argv[]); -void cmd_sam_lookup_rids(struct client_info *info, int argc, char *argv[]); -void cmd_sam_del_aliasmem(struct client_info *info, int argc, char *argv[]); -void cmd_sam_delete_dom_alias(struct client_info *info, int argc, - char *argv[]); -void cmd_sam_add_aliasmem(struct client_info *info, int argc, char *argv[]); -void cmd_sam_create_dom_trusting(struct client_info *info, int argc, - char *argv[]); -void cmd_sam_create_dom_user(struct client_info *info, int argc, char *argv[]); -void cmd_sam_create_dom_alias(struct client_info *info, int argc, - char *argv[]); -void cmd_sam_del_groupmem(struct client_info *info, int argc, char *argv[]); -void cmd_sam_delete_dom_user(struct client_info *info, int argc, char *argv[]); -void cmd_sam_delete_dom_group(struct client_info *info, int argc, - char *argv[]); -void cmd_sam_add_groupmem(struct client_info *info, int argc, char *argv[]); -void cmd_sam_create_dom_group(struct client_info *info, int argc, - char *argv[]); -void cmd_sam_enum_users(struct client_info *info, int argc, char *argv[]); -void cmd_sam_query_groupmem(struct client_info *info, int argc, char *argv[]); -void cmd_sam_query_group(struct client_info *info, int argc, char *argv[]); -void cmd_sam_query_sec_obj(struct client_info *info, int argc, char *argv[]); -void cmd_sam_query_user(struct client_info *info, int argc, char *argv[]); -void cmd_sam_set_userinfo2(struct client_info *info, int argc, char *argv[]); -void cmd_sam_set_userinfo(struct client_info *info, int argc, char *argv[]); -void cmd_sam_query_dispinfo(struct client_info *info, int argc, char *argv[]); -void cmd_sam_query_dominfo(struct client_info *info, int argc, char *argv[]); -void cmd_sam_query_aliasmem(struct client_info *info, int argc, char *argv[]); -void cmd_sam_query_alias(struct client_info *info, int argc, char *argv[]); -void cmd_sam_enum_aliases(struct client_info *info, int argc, char *argv[]); -void cmd_sam_enum_groups(struct client_info *info, int argc, char *argv[]); -void cmd_sam_enum_domains(struct client_info *info, int argc, char *argv[]); - -/*The following definitions come from rpcclient/cmd_spoolss.c */ - -BOOL msrpc_spoolss_enum_printers(char* srv_name, uint32 flags, uint32 level, PRINTER_INFO_CTR ctr); -void cmd_spoolss_enum_printers(struct client_info *info, int argc, char *argv[]); -void cmd_spoolss_open_printer_ex(struct client_info *info, int argc, char *argv[]); -BOOL msrpc_spoolss_enum_jobs( const char* printer_name, - const char* station, const char* user_name, - uint32 level, - void ***ctr, JOB_INFO_FN(fn)); -void cmd_spoolss_enum_jobs(struct client_info *info, int argc, char *argv[]); -BOOL msrpc_spoolss_enum_printerdata( const char* printer_name, const char* station, const char* user_name ); -void cmd_spoolss_enum_printerdata(struct client_info *info, int argc, char *argv[]); - -/*The following definitions come from rpcclient/cmd_srvsvc.c */ - -BOOL net_srv_get_info(struct client_info *info, - uint32 info_level, - SRV_INFO_CTR *ctr); -void cmd_srv_query_info(struct client_info *info, int argc, char *argv[]); -BOOL msrpc_srv_enum_tprt( const char* dest_srv, - uint32 info_level, - SRV_TPRT_INFO_CTR *ctr, - TPRT_INFO_FN(tprt_fn)); -void cmd_srv_enum_tprt(struct client_info *info, int argc, char *argv[]); -void cmd_srv_enum_conn(struct client_info *info, int argc, char *argv[]); -void cmd_srv_enum_shares(struct client_info *info, int argc, char *argv[]); -void cmd_srv_share_get_info(struct client_info *info, int argc, char *argv[]); -void cmd_srv_enum_sess(struct client_info *info, int argc, char *argv[]); -void cmd_srv_enum_files(struct client_info *info, int argc, char *argv[]); -void cmd_time(struct client_info *info, int argc, char *argv[]); - -/*The following definitions come from rpcclient/cmd_svcctl.c */ - -void svc_display_query_svc_cfg(const QUERY_SERVICE_CONFIG *cfg); -BOOL svc_query_service( POLICY_HND *pol_scm, - const char *svc_name, - SVC_QUERY_FN(svc_query_fn)); -void cmd_svc_info(struct client_info *info, int argc, char *argv[]); -BOOL msrpc_svc_enum(const char* srv_name, - ENUM_SRVC_STATUS **svcs, - uint32 *num_svcs, - SVC_INFO_FN(info_fn), - SVC_QUERY_FN(query_fn)); -void cmd_svc_enum(struct client_info *info, int argc, char *argv[]); -void cmd_svc_stop(struct client_info *info, int argc, char *argv[]); -void cmd_svc_start(struct client_info *info, int argc, char *argv[]); -void cmd_svc_set(struct client_info *info, int argc, char *argv[]); -void cmd_svc_unk3(struct client_info *info, int argc, char *argv[]); - -/*The following definitions come from rpcclient/cmd_wkssvc.c */ - -void cmd_wks_query_info(struct client_info *info, int argc, char *argv[]); - -/*The following definitions come from rpcclient/display_at.c */ - -void display_at_enum_info(FILE *out_hnd, enum action_type action, - uint32 num_jobs, const AT_ENUM_INFO *const jobs, - char *const *const commands); -void display_at_job_info(FILE *out_hnd, enum action_type action, - AT_JOB_INFO *const job, fstring command); - -/*The following definitions come from rpcclient/display_event.c */ - -void display_eventlog_eventrecord(FILE *out_hnd, enum action_type action, EVENTLOGRECORD *const ev); - -/*The following definitions come from rpcclient/display_reg.c */ - -char *get_reg_val_type_str(uint32 type); -void display_reg_value_info(FILE *out_hnd, enum action_type action, - const char *val_name, - uint32 val_type, const BUFFER2 *value); -void display_reg_key_info(FILE *out_hnd, enum action_type action, - const char *key_name, time_t key_mod_time); - -/*The following definitions come from rpcclient/display_sam.c */ - -void display_alias_members(FILE *out_hnd, enum action_type action, - uint32 num_mem, char *const *const sid_mem, - uint32 *const type); -void display_alias_rid_info(FILE *out_hnd, enum action_type action, - DOM_SID *const sid, - uint32 num_rids, uint32 *const rid); -void display_group_members(FILE *out_hnd, enum action_type action, - uint32 num_mem, char *const *const name, uint32 *const type); -void display_group_info_ctr(FILE *out_hnd, enum action_type action, - GROUP_INFO_CTR *const ctr); -void display_group_rid_info(FILE *out_hnd, enum action_type action, - uint32 num_gids, DOM_GID *const gid); -void display_alias_name_info(FILE *out_hnd, enum action_type action, - uint32 num_aliases, fstring *const alias_name, const uint32 *const num_als_usrs); -void display_alias_info_ctr(FILE *out_hnd, enum action_type action, - ALIAS_INFO_CTR *const ctr); -void display_sam_user_info_21(FILE *out_hnd, enum action_type action, SAM_USER_INFO_21 *const usr); -void display_sam_unk_ctr(FILE *out_hnd, enum action_type action, - uint32 switch_value, SAM_UNK_CTR *const ctr); -void display_sam_disp_info_ctr(FILE *out_hnd, enum action_type action, - uint16 level, uint32 count, - SAM_DISPINFO_CTR *const ctr); - -/*The following definitions come from rpcclient/display_sec.c */ - -void display_sec_desc(FILE *out_hnd, enum action_type action, SEC_DESC *const sec); - -/*The following definitions come from rpcclient/display_spool.c */ - -void display_printer_info_ctr(FILE *out_hnd, enum action_type action, uint32 level, - uint32 count, PRINTER_INFO_CTR ctr); -void display_printer_enumdata(FILE *out_hnd, enum action_type action, uint32 idx, - uint32 valuelen, uint16 *value, uint32 rvaluelen, - uint32 type, - uint32 datalen, uint8 *data, uint32 rdatalen); -void display_job_info_2(FILE *out_hnd, enum action_type action, - JOB_INFO_2 *const i2); -void display_job_info_1(FILE *out_hnd, enum action_type action, - JOB_INFO_1 *const i1); -void display_job_info_2_ctr(FILE *out_hnd, enum action_type action, - uint32 count, JOB_INFO_2 *const *const ctr); -void display_job_info_1_ctr(FILE *out_hnd, enum action_type action, - uint32 count, JOB_INFO_1 *const *const ctr); -void display_job_info_ctr(FILE *out_hnd, enum action_type action, - uint32 level, uint32 count, - void *const *const ctr); - -/*The following definitions come from rpcclient/display_srv.c */ - -char *get_file_oplock_str(uint32 op_type); -void display_srv_info_ctr(FILE *out_hnd, enum action_type action, - const SRV_INFO_CTR *ctr); -void display_srv_conn_info_ctr(FILE *out_hnd, enum action_type action, - SRV_CONN_INFO_CTR *const ctr); -void display_tprt_info_0(FILE *out_hnd, enum action_type action, - TPRT_INFO_0 *const info0, TPRT_INFO_0_STR *const str0); -void display_srv_tprt_info_0_ctr(FILE *out_hnd, enum action_type action, - const SRV_TPRT_INFO_0 *const ctr); -void display_srv_tprt_info_ctr(FILE *out_hnd, enum action_type action, - const SRV_TPRT_INFO_CTR *const ctr); -void display_srv_share_info_ctr(FILE *out_hnd, enum action_type action, - SRV_SHARE_INFO_CTR *const ctr); -void display_srv_file_info_ctr(FILE *out_hnd, enum action_type action, - SRV_FILE_INFO_CTR *const ctr); -void display_srv_sess_info_0_ctr(FILE *out_hnd, enum action_type action, - SRV_SESS_INFO_0 *const ctr); -void display_srv_sess_info_1_ctr(FILE *out_hnd, enum action_type action, - SRV_SESS_INFO_1 *const ctr); -void display_srv_sess_info_ctr(FILE *out_hnd, enum action_type action, - SRV_SESS_INFO_CTR *const ctr); -void display_server(FILE *out_hnd, enum action_type action, - char *const sname, uint32 type, char *const comment); -void display_share(FILE *out_hnd, enum action_type action, - char *const sname, uint32 type, char *const comment); -void display_share2(FILE *out_hnd, enum action_type action, - char *const sname, uint32 type, char *const comment, - uint32 perms, uint32 max_uses, uint32 num_uses, - char *const path, char *const password); -void display_name(FILE *out_hnd, enum action_type action, - char *const sname); - -/*The following definitions come from rpcclient/display_svc.c */ - -char *get_svc_start_type_str(uint32 type); -void display_query_svc_cfg(FILE *out_hnd, enum action_type action, - const QUERY_SERVICE_CONFIG *const cfg); -void display_svc_info(FILE *out_hnd, enum action_type action, - const ENUM_SRVC_STATUS *const svc); - -/*The following definitions come from rpcclient/display_sync.c */ - -void display_sam_sync_ctr(FILE *out_hnd, enum action_type action, - SAM_DELTA_HDR *const delta, - SAM_DELTA_CTR *const ctr); -void display_sam_sync(FILE *out_hnd, enum action_type action, - SAM_DELTA_HDR *const deltas, - SAM_DELTA_CTR *const ctr, - uint32 num); - -/*The following definitions come from rpcclient/eventlog.c */ - -int main(int argc, char *argv[]); - -/*The following definitions come from rpcclient/eventlog_cmds.c */ - -void add_evt_commands(void); - -/*The following definitions come from rpcclient/lsa.c */ - - -/*The following definitions come from rpcclient/lsa_cmds.c */ - -void add_lsa_commands(void); - /*The following definitions come from rpc_client/msrpc_lsarpc.c */ uint32 lookup_lsa_names(const char *srv_name, @@ -3118,51 +2841,6 @@ BOOL ncalrpc_l_use_del(const char *pipe_name, void ncalrpc_l_use_enum(uint32 * num_cons, struct use_info ***use); void ncalrpc_use_wait_keyboard(void); -/*The following definitions come from rpcclient/net.c */ - - -/*The following definitions come from rpcclient/net_cmds.c */ - -void add_net_commands(void); - -/*The following definitions come from rpcclient/netlogon_cmds.c */ - -void add_ntl_commands(void); - -/*The following definitions come from rpcclient/regedit.c */ - - -/*The following definitions come from rpcclient/regedit_cmds.c */ - -void add_reg_commands(void); - -/*The following definitions come from rpcclient/rpcclient.c */ - - -/*The following definitions come from rpcclient/samedit.c */ - - -/*The following definitions come from rpcclient/samedit_cmds.c */ - -void add_sam_commands(void); - -/*The following definitions come from rpcclient/spoolss.c */ - -int main(int argc, char *argv[]); - -/*The following definitions come from rpcclient/spoolss_cmds.c */ - -void add_spl_commands(void); - -/*The following definitions come from rpcclient/svcctrl.c */ - -int main(int argc, char *argv[]); - -/*The following definitions come from rpcclient/svcctrl_cmds.c */ - -char *complete_svcenum(char *text, int state); -void add_svc_commands(void); - /*The following definitions come from rpc_parse/parse_creds.c */ BOOL make_creds_unix(CREDS_UNIX *r_u, const char* user_name, @@ -3769,14 +3447,359 @@ BOOL api_svcctl_rpc(rpcsrv_struct *p); BOOL api_wkssvc_rpc(rpcsrv_struct *p); -/*The following definitions come from samrd/samrd.c */ +/*The following definitions come from rpcclient/cmd_atsvc.c */ -msrpc_service_fns *get_service_fns(void); +void cmd_at(struct client_info *info, int argc, char *argv[]); + +/*The following definitions come from rpcclient/cmd_brs.c */ + +void cmd_brs_query_info(struct client_info *info, int argc, char *argv[]); + +/*The following definitions come from rpcclient/cmd_dfs.c */ + +void cmd_dfs_add(struct client_info *info, int argc, char *argv[]); +void cmd_dfs_remove(struct client_info *info, int argc, char *argv[]); +void display_dfs_enum_1(FILE *out_hnd, DFS_INFO_CTR *ctr); +void display_dfs_enum_2(FILE *out_hnd, DFS_INFO_CTR *ctr); +void display_dfs_enum_3_storages(FILE *out_hnd, DFS_INFO_3 *info3); +void display_dfs_enum_3(FILE *out_hnd, DFS_INFO_CTR *ctr); +void display_dfs_enum(FILE *out_hnd, char *srv_name, DFS_INFO_CTR *ctr); +void cmd_dfs_enum(struct client_info *info, int argc, char *argv[]); + +/*The following definitions come from rpcclient/cmd_eventlog.c */ + +void cmd_eventlog(struct client_info *info, int argc, char *argv[]); + +/*The following definitions come from rpcclient/cmd_lsarpc.c */ + +void cmd_lsa_enum_trust_dom(struct client_info *info, int argc, char *argv[]); +void cmd_lsa_query_info(struct client_info *info, int argc, char *argv[]); +void cmd_lsa_lookup_names(struct client_info *info, int argc, char *argv[]); +void cmd_lsa_lookup_sids(struct client_info *info, int argc, char *argv[]); +void cmd_lsa_set_secret(struct client_info *info, int argc, char *argv[]); +void cmd_lsa_create_secret(struct client_info *info, int argc, char *argv[]); +void cmd_lsa_query_secret_secobj(struct client_info *info, int argc, char *argv[]); +void cmd_lsa_query_secret(struct client_info *info, int argc, char *argv[]); + +/*The following definitions come from rpcclient/cmd_netlogon.c */ + +void cmd_netlogon_pwset(struct client_info *info, int argc, char *argv[]); +void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[]); +void cmd_netlogon_domain_test(struct client_info *info, int argc, + char *argv[]); +void cmd_sam_sync(struct client_info *info, int argc, char *argv[]); + +/*The following definitions come from rpcclient/cmd_reg.c */ + +void split_server_keyname(char *srv_name, char *key, const char* arg); +BOOL msrpc_reg_enum_key(const char* srv_name, const char* full_keyname, + REG_FN(reg_fn), + REG_KEY_FN(reg_key_fn), + REG_VAL_FN(reg_val_fn)); +void cmd_reg_enum(struct client_info *info, int argc, char *argv[]); +void cmd_reg_query_info(struct client_info *info, int argc, char *argv[]); +void cmd_reg_query_key(struct client_info *info, int argc, char *argv[]); +void cmd_reg_create_val(struct client_info *info, int argc, char *argv[]); +void cmd_reg_delete_val(struct client_info *info, int argc, char *argv[]); +void cmd_reg_delete_key(struct client_info *info, int argc, char *argv[]); +void cmd_reg_create_key(struct client_info *info, int argc, char *argv[]); +void cmd_reg_test_key_sec(struct client_info *info, int argc, char *argv[]); +void cmd_reg_get_key_sec(struct client_info *info, int argc, char *argv[]); +void cmd_reg_shutdown(struct client_info *info, int argc, char *argv[]); + +/*The following definitions come from rpcclient/cmd_samr.c */ + +void cmd_sam_ntchange_pwd(struct client_info *info, int argc, char *argv[]); +void cmd_sam_test(struct client_info *info, int argc, char *argv[]); +void cmd_sam_lookup_domain(struct client_info *info, int argc, char *argv[]); +void cmd_sam_lookup_names(struct client_info *info, int argc, char *argv[]); +void cmd_sam_lookup_rids(struct client_info *info, int argc, char *argv[]); +void cmd_sam_del_aliasmem(struct client_info *info, int argc, char *argv[]); +void cmd_sam_delete_dom_alias(struct client_info *info, int argc, + char *argv[]); +void cmd_sam_add_aliasmem(struct client_info *info, int argc, char *argv[]); +void cmd_sam_create_dom_trusting(struct client_info *info, int argc, + char *argv[]); +void cmd_sam_create_dom_user(struct client_info *info, int argc, char *argv[]); +void cmd_sam_create_dom_alias(struct client_info *info, int argc, + char *argv[]); +void cmd_sam_del_groupmem(struct client_info *info, int argc, char *argv[]); +void cmd_sam_delete_dom_user(struct client_info *info, int argc, char *argv[]); +void cmd_sam_delete_dom_group(struct client_info *info, int argc, + char *argv[]); +void cmd_sam_add_groupmem(struct client_info *info, int argc, char *argv[]); +void cmd_sam_create_dom_group(struct client_info *info, int argc, + char *argv[]); +void cmd_sam_enum_users(struct client_info *info, int argc, char *argv[]); +void cmd_sam_query_groupmem(struct client_info *info, int argc, char *argv[]); +void cmd_sam_query_group(struct client_info *info, int argc, char *argv[]); +void cmd_sam_query_sec_obj(struct client_info *info, int argc, char *argv[]); +void cmd_sam_query_user(struct client_info *info, int argc, char *argv[]); +void cmd_sam_set_userinfo2(struct client_info *info, int argc, char *argv[]); +void cmd_sam_set_userinfo(struct client_info *info, int argc, char *argv[]); +void cmd_sam_query_dispinfo(struct client_info *info, int argc, char *argv[]); +void cmd_sam_query_dominfo(struct client_info *info, int argc, char *argv[]); +void cmd_sam_query_aliasmem(struct client_info *info, int argc, char *argv[]); +void cmd_sam_query_alias(struct client_info *info, int argc, char *argv[]); +void cmd_sam_enum_aliases(struct client_info *info, int argc, char *argv[]); +void cmd_sam_enum_groups(struct client_info *info, int argc, char *argv[]); +void cmd_sam_enum_domains(struct client_info *info, int argc, char *argv[]); + +/*The following definitions come from rpcclient/cmd_spoolss.c */ + +BOOL msrpc_spoolss_enum_printers(char* srv_name, uint32 flags, uint32 level, PRINTER_INFO_CTR ctr); +void cmd_spoolss_enum_printers(struct client_info *info, int argc, char *argv[]); +void cmd_spoolss_open_printer_ex(struct client_info *info, int argc, char *argv[]); +BOOL msrpc_spoolss_enum_jobs( const char* printer_name, + const char* station, const char* user_name, + uint32 level, + void ***ctr, JOB_INFO_FN(fn)); +void cmd_spoolss_enum_jobs(struct client_info *info, int argc, char *argv[]); +BOOL msrpc_spoolss_enum_printerdata( const char* printer_name, const char* station, const char* user_name ); +void cmd_spoolss_enum_printerdata(struct client_info *info, int argc, char *argv[]); + +/*The following definitions come from rpcclient/cmd_srvsvc.c */ + +BOOL net_srv_get_info(struct client_info *info, + uint32 info_level, + SRV_INFO_CTR *ctr); +void cmd_srv_query_info(struct client_info *info, int argc, char *argv[]); +BOOL msrpc_srv_enum_tprt( const char* dest_srv, + uint32 info_level, + SRV_TPRT_INFO_CTR *ctr, + TPRT_INFO_FN(tprt_fn)); +void cmd_srv_enum_tprt(struct client_info *info, int argc, char *argv[]); +void cmd_srv_enum_conn(struct client_info *info, int argc, char *argv[]); +void cmd_srv_enum_shares(struct client_info *info, int argc, char *argv[]); +void cmd_srv_share_get_info(struct client_info *info, int argc, char *argv[]); +void cmd_srv_enum_sess(struct client_info *info, int argc, char *argv[]); +void cmd_srv_enum_files(struct client_info *info, int argc, char *argv[]); +void cmd_time(struct client_info *info, int argc, char *argv[]); + +/*The following definitions come from rpcclient/cmd_svcctl.c */ + +void svc_display_query_svc_cfg(const QUERY_SERVICE_CONFIG *cfg); +BOOL svc_query_service( POLICY_HND *pol_scm, + const char *svc_name, + SVC_QUERY_FN(svc_query_fn)); +void cmd_svc_info(struct client_info *info, int argc, char *argv[]); +BOOL msrpc_svc_enum(const char* srv_name, + ENUM_SRVC_STATUS **svcs, + uint32 *num_svcs, + SVC_INFO_FN(info_fn), + SVC_QUERY_FN(query_fn)); +void cmd_svc_enum(struct client_info *info, int argc, char *argv[]); +void cmd_svc_stop(struct client_info *info, int argc, char *argv[]); +void cmd_svc_start(struct client_info *info, int argc, char *argv[]); +void cmd_svc_set(struct client_info *info, int argc, char *argv[]); +void cmd_svc_unk3(struct client_info *info, int argc, char *argv[]); + +/*The following definitions come from rpcclient/cmd_wkssvc.c */ + +void cmd_wks_query_info(struct client_info *info, int argc, char *argv[]); + +/*The following definitions come from rpcclient/cmdat.c */ + + +/*The following definitions come from rpcclient/cmdat_cmds.c */ + +void add_at_commands(void); + +/*The following definitions come from rpcclient/dfs_cmds.c */ + +char *complete_dfsenum(char *text, int state); +void add_dfs_commands(void); + +/*The following definitions come from rpcclient/display_at.c */ + +void display_at_enum_info(FILE *out_hnd, enum action_type action, + uint32 num_jobs, const AT_ENUM_INFO *const jobs, + char *const *const commands); +void display_at_job_info(FILE *out_hnd, enum action_type action, + AT_JOB_INFO *const job, fstring command); + +/*The following definitions come from rpcclient/display_event.c */ + +void display_eventlog_eventrecord(FILE *out_hnd, enum action_type action, EVENTLOGRECORD *const ev); + +/*The following definitions come from rpcclient/display_reg.c */ + +char *get_reg_val_type_str(uint32 type); +void display_reg_value_info(FILE *out_hnd, enum action_type action, + const char *val_name, + uint32 val_type, const BUFFER2 *value); +void display_reg_key_info(FILE *out_hnd, enum action_type action, + const char *key_name, time_t key_mod_time); + +/*The following definitions come from rpcclient/display_sam.c */ + +void display_alias_members(FILE *out_hnd, enum action_type action, + uint32 num_mem, char *const *const sid_mem, + uint32 *const type); +void display_alias_rid_info(FILE *out_hnd, enum action_type action, + DOM_SID *const sid, + uint32 num_rids, uint32 *const rid); +void display_group_members(FILE *out_hnd, enum action_type action, + uint32 num_mem, char *const *const name, uint32 *const type); +void display_group_info_ctr(FILE *out_hnd, enum action_type action, + GROUP_INFO_CTR *const ctr); +void display_group_rid_info(FILE *out_hnd, enum action_type action, + uint32 num_gids, DOM_GID *const gid); +void display_alias_name_info(FILE *out_hnd, enum action_type action, + uint32 num_aliases, fstring *const alias_name, const uint32 *const num_als_usrs); +void display_alias_info_ctr(FILE *out_hnd, enum action_type action, + ALIAS_INFO_CTR *const ctr); +void display_sam_user_info_21(FILE *out_hnd, enum action_type action, SAM_USER_INFO_21 *const usr); +void display_sam_unk_ctr(FILE *out_hnd, enum action_type action, + uint32 switch_value, SAM_UNK_CTR *const ctr); +void display_sam_disp_info_ctr(FILE *out_hnd, enum action_type action, + uint16 level, uint32 count, + SAM_DISPINFO_CTR *const ctr); + +/*The following definitions come from rpcclient/display_sec.c */ + +void display_sec_desc(FILE *out_hnd, enum action_type action, SEC_DESC *const sec); + +/*The following definitions come from rpcclient/display_spool.c */ + +void display_printer_info_ctr(FILE *out_hnd, enum action_type action, uint32 level, + uint32 count, PRINTER_INFO_CTR ctr); +void display_printer_enumdata(FILE *out_hnd, enum action_type action, uint32 idx, + uint32 valuelen, uint16 *value, uint32 rvaluelen, + uint32 type, + uint32 datalen, uint8 *data, uint32 rdatalen); +void display_job_info_2(FILE *out_hnd, enum action_type action, + JOB_INFO_2 *const i2); +void display_job_info_1(FILE *out_hnd, enum action_type action, + JOB_INFO_1 *const i1); +void display_job_info_2_ctr(FILE *out_hnd, enum action_type action, + uint32 count, JOB_INFO_2 *const *const ctr); +void display_job_info_1_ctr(FILE *out_hnd, enum action_type action, + uint32 count, JOB_INFO_1 *const *const ctr); +void display_job_info_ctr(FILE *out_hnd, enum action_type action, + uint32 level, uint32 count, + void *const *const ctr); + +/*The following definitions come from rpcclient/display_srv.c */ + +char *get_file_oplock_str(uint32 op_type); +void display_srv_info_ctr(FILE *out_hnd, enum action_type action, + const SRV_INFO_CTR *ctr); +void display_srv_conn_info_ctr(FILE *out_hnd, enum action_type action, + SRV_CONN_INFO_CTR *const ctr); +void display_tprt_info_0(FILE *out_hnd, enum action_type action, + TPRT_INFO_0 *const info0, TPRT_INFO_0_STR *const str0); +void display_srv_tprt_info_0_ctr(FILE *out_hnd, enum action_type action, + const SRV_TPRT_INFO_0 *const ctr); +void display_srv_tprt_info_ctr(FILE *out_hnd, enum action_type action, + const SRV_TPRT_INFO_CTR *const ctr); +void display_srv_share_info_ctr(FILE *out_hnd, enum action_type action, + SRV_SHARE_INFO_CTR *const ctr); +void display_srv_file_info_ctr(FILE *out_hnd, enum action_type action, + SRV_FILE_INFO_CTR *const ctr); +void display_srv_sess_info_0_ctr(FILE *out_hnd, enum action_type action, + SRV_SESS_INFO_0 *const ctr); +void display_srv_sess_info_1_ctr(FILE *out_hnd, enum action_type action, + SRV_SESS_INFO_1 *const ctr); +void display_srv_sess_info_ctr(FILE *out_hnd, enum action_type action, + SRV_SESS_INFO_CTR *const ctr); +void display_server(FILE *out_hnd, enum action_type action, + char *const sname, uint32 type, char *const comment); +void display_share(FILE *out_hnd, enum action_type action, + char *const sname, uint32 type, char *const comment); +void display_share2(FILE *out_hnd, enum action_type action, + char *const sname, uint32 type, char *const comment, + uint32 perms, uint32 max_uses, uint32 num_uses, + char *const path, char *const password); +void display_name(FILE *out_hnd, enum action_type action, + char *const sname); + +/*The following definitions come from rpcclient/display_svc.c */ + +char *get_svc_start_type_str(uint32 type); +void display_query_svc_cfg(FILE *out_hnd, enum action_type action, + const QUERY_SERVICE_CONFIG *const cfg); +void display_svc_info(FILE *out_hnd, enum action_type action, + const ENUM_SRVC_STATUS *const svc); + +/*The following definitions come from rpcclient/display_sync.c */ + +void display_sam_sync_ctr(FILE *out_hnd, enum action_type action, + SAM_DELTA_HDR *const delta, + SAM_DELTA_CTR *const ctr); +void display_sam_sync(FILE *out_hnd, enum action_type action, + SAM_DELTA_HDR *const deltas, + SAM_DELTA_CTR *const ctr, + uint32 num); + +/*The following definitions come from rpcclient/eventlog.c */ + +int main(int argc, char *argv[]); + +/*The following definitions come from rpcclient/eventlog_cmds.c */ + +void add_evt_commands(void); + +/*The following definitions come from rpcclient/lsa.c */ + + +/*The following definitions come from rpcclient/lsa_cmds.c */ + +void add_lsa_commands(void); + +/*The following definitions come from rpcclient/net.c */ + + +/*The following definitions come from rpcclient/net_cmds.c */ + +void add_net_commands(void); + +/*The following definitions come from rpcclient/netlogon_cmds.c */ + +void add_ntl_commands(void); + +/*The following definitions come from rpcclient/regedit.c */ + + +/*The following definitions come from rpcclient/regedit_cmds.c */ + +void add_reg_commands(void); + +/*The following definitions come from rpcclient/rpcclient.c */ + + +/*The following definitions come from rpcclient/samedit.c */ + + +/*The following definitions come from rpcclient/samedit_cmds.c */ + +void add_sam_commands(void); + +/*The following definitions come from rpcclient/spoolss.c */ + +int main(int argc, char *argv[]); + +/*The following definitions come from rpcclient/spoolss_cmds.c */ + +void add_spl_commands(void); + +/*The following definitions come from rpcclient/svcctrl.c */ + +int main(int argc, char *argv[]); + +/*The following definitions come from rpcclient/svcctrl_cmds.c */ + +char *complete_svcenum(char *text, int state); +void add_svc_commands(void); /*The following definitions come from samrd/samr_util.c */ uint32 samr_make_usr_obj_sd(SEC_DESC_BUF *buf, DOM_SID *usr_sid); +/*The following definitions come from samrd/samrd.c */ + +msrpc_service_fns *get_service_fns(void); + /*The following definitions come from samrd/srv_samr_als_tdb.c */ uint32 _samr_add_aliasmem(const POLICY_HND *alias_pol, const DOM_SID *sid); @@ -4586,17 +4609,6 @@ BOOL become_user(connection_struct *conn, uint16 vuid); BOOL become_userk(connection_struct *conn, const vuser_key *key); BOOL unbecome_user(void ); -/*The following definitions come from smbd/vfs.c */ - -int vfs_init_default(connection_struct *conn); -BOOL vfs_init_custom(connection_struct *conn); -BOOL vfs_file_exist(connection_struct *conn,char *fname,SMB_STRUCT_STAT *sbuf); -ssize_t vfs_write_data(files_struct *fsp,char *buffer,size_t N); -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); - /*The following definitions come from smbd/vfs-wrap.c */ int vfswrap_dummy_connect(struct vfs_connection_struct *conn, char *service, @@ -4626,6 +4638,17 @@ int vfswrap_unlink(char *path); int vfswrap_chmod(char *path, mode_t mode); int vfswrap_utime(char *path, struct utimbuf *times); +/*The following definitions come from smbd/vfs.c */ + +int vfs_init_default(connection_struct *conn); +BOOL vfs_init_custom(connection_struct *conn); +BOOL vfs_file_exist(connection_struct *conn,char *fname,SMB_STRUCT_STAT *sbuf); +ssize_t vfs_write_data(files_struct *fsp,char *buffer,size_t N); +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); + /*The following definitions come from smbwrapper/realcalls.c */ int real_utime(const char *name, struct utimbuf *buf); diff --git a/source/include/rpc_client_proto.h b/source/include/rpc_client_proto.h index 28f96834f90..00f308602de 100644 --- a/source/include/rpc_client_proto.h +++ b/source/include/rpc_client_proto.h @@ -68,6 +68,13 @@ BOOL set_policy_con(struct policy_cache *cache, POLICY_HND * hnd, BOOL get_policy_con(struct policy_cache *cache, const POLICY_HND * hnd, struct cli_connection **con); +/*The following definitions come from rpc_client/cli_dfs.c */ + +BOOL dfs_remove(char *srv_name, char *dfs_entrypath, char *dfs_servername, + char *dfs_sharename); +BOOL dfs_add(char *srv_name, char* entrypath, char* servername, char* sharename, char* comment); +uint32 dfs_enum(char *srv_name, uint32 level, DFS_INFO_CTR *ctr); + /*The following definitions come from rpc_client/cli_eventlog.c */ BOOL event_open(const char* srv_name, const char *log, POLICY_HND *hnd); diff --git a/source/include/rpc_dfs.h b/source/include/rpc_dfs.h new file mode 100644 index 00000000000..1677f7f7ed0 --- /dev/null +++ b/source/include/rpc_dfs.h @@ -0,0 +1,144 @@ +#ifndef _RPC_DFS_H +#define _RPC_DFS_H + +/* NETDFS pipe: calls */ +#define DFS_EXIST 0x00 +#define DFS_ADD 0x01 +#define DFS_REMOVE 0x02 +#define DFS_ENUM 0x05 + +/* dfsadd flags */ +#define DFSFLAG_ADD_VOLUME 0x00000001 +#define DFSFLAG_RESTORE_VOLUME 0x00000002 + +typedef struct dfs_r_dfs_exist +{ + uint32 dfs_exist_flag; +} +DFS_R_DFS_EXIST; + +typedef struct dfs_q_dfs_add +{ + uint32 ptr_DfsEntryPath; + UNISTR2 DfsEntryPath; + uint32 ptr_ServerName; + UNISTR2 ServerName; + uint32 ptr_ShareName; + UNISTR2 ShareName; + uint32 ptr_Comment; + UNISTR2 Comment; + uint32 Flags; +} +DFS_Q_DFS_ADD; + +typedef struct dfs_r_dfs_add +{ + uint32 status; +} +DFS_R_DFS_ADD; + +/********************************************/ +typedef struct dfs_q_dfs_remove +{ + UNISTR2 DfsEntryPath; + uint32 ptr_ServerName; + UNISTR2 ServerName; + uint32 ptr_ShareName; + UNISTR2 ShareName; +} +DFS_Q_DFS_REMOVE; + +typedef struct dfs_r_dfs_remove +{ + uint32 status; +} +DFS_R_DFS_REMOVE; + +/********************************************/ +typedef struct dfs_info_1 +{ + uint32 ptr_entrypath; + UNISTR2 entrypath; +} +DFS_INFO_1; + +typedef struct dfs_info_2 +{ + uint32 ptr_entrypath; + UNISTR2 entrypath; + uint32 ptr_comment; + UNISTR2 comment; + uint32 state; + uint32 num_storages; +} +DFS_INFO_2; + +typedef struct dfs_storage_info +{ + uint32 state; + uint32 ptr_servername; + UNISTR2 servername; + uint32 ptr_sharename; + UNISTR2 sharename; +} +DFS_STORAGE_INFO; + +typedef struct dfs_info_3 +{ + uint32 ptr_entrypath; + UNISTR2 entrypath; + uint32 ptr_comment; + UNISTR2 comment; + uint32 state; + uint32 num_storages; + uint32 ptr_storages; + uint32 num_storage_infos; + DFS_STORAGE_INFO* storages; +} +DFS_INFO_3; + +typedef struct dfs_info_ctr +{ + + uint32 switch_value; + uint32 num_entries; + uint32 ptr_dfs_ctr; /* pointer to dfs info union */ + union + { + DFS_INFO_1 *info1; + DFS_INFO_2 *info2; + DFS_INFO_3 *info3; + } dfs; +} +DFS_INFO_CTR; + +typedef struct dfs_q_dfs_enum +{ + uint32 level; + uint32 maxpreflen; + uint32 ptr_buffer; + uint32 level2; + uint32 ptr_num_entries; + uint32 num_entries; + uint32 ptr_num_entries2; + uint32 num_entries2; + ENUM_HND reshnd; +} +DFS_Q_DFS_ENUM; + +typedef struct dfs_r_dfs_enum +{ + DFS_INFO_CTR *ctr; + uint32 ptr_buffer; + uint32 level; + uint32 level2; + uint32 ptr_num_entries; + uint32 num_entries; + uint32 ptr_num_entries2; + uint32 num_entries2; + ENUM_HND reshnd; + uint32 status; +} +DFS_R_DFS_ENUM; + +#endif diff --git a/source/include/rpc_parse_proto.h b/source/include/rpc_parse_proto.h index 5a81fa930d5..2a3bed2b2f3 100644 --- a/source/include/rpc_parse_proto.h +++ b/source/include/rpc_parse_proto.h @@ -48,6 +48,29 @@ BOOL make_brs_r_query_info(BRS_R_QUERY_INFO *r_u, int status) ; BOOL brs_io_r_query_info(char *desc, BRS_R_QUERY_INFO *r_u, prs_struct *ps, int depth); +/*The following definitions come from rpc_parse/parse_dfs.c */ + +BOOL dfs_io_r_dfs_exist(char *desc, DFS_R_DFS_EXIST *q_d, prs_struct *ps, + int depth); +BOOL make_dfs_q_dfs_remove(DFS_Q_DFS_REMOVE *q_d, char *entrypath, + char *servername, char *sharename); +BOOL dfs_io_q_dfs_remove(char *desc, DFS_Q_DFS_REMOVE *q_d, prs_struct *ps, + int depth); +BOOL dfs_io_r_dfs_remove(char *desc, DFS_R_DFS_REMOVE *r_d, prs_struct *ps, + int depth); +BOOL make_dfs_q_dfs_add(DFS_Q_DFS_ADD *q_d, char *entrypath, char *servername, + char *sharename, char *comment, uint32 flags); +BOOL dfs_io_q_dfs_add(char *desc, DFS_Q_DFS_ADD *q_d, prs_struct *ps, + int depth); +BOOL dfs_io_r_dfs_add(char *desc, DFS_R_DFS_ADD *r_d, prs_struct *ps, + int depth); +BOOL make_dfs_q_dfs_enum(DFS_Q_DFS_ENUM *q_d, uint32 level, DFS_INFO_CTR *ctr); +BOOL dfs_io_q_dfs_enum(char *desc, DFS_Q_DFS_ENUM *q_d, prs_struct *ps, + int depth); +BOOL dfs_io_r_dfs_enum(char *desc, DFS_R_DFS_ENUM *q_d, prs_struct *ps, int depth); +BOOL smb_io_dfs_storage_info(char *desc, DFS_INFO_3* info3, + prs_struct *ps, int depth); + /*The following definitions come from rpc_parse/parse_eventlog.c */ BOOL make_eventlog_q_open(EVENTLOG_Q_OPEN *q_u, const char *journal, char *unk); diff --git a/source/include/smb.h b/source/include/smb.h index 76606835c24..f1e3a68e4ea 100644 --- a/source/include/smb.h +++ b/source/include/smb.h @@ -264,6 +264,7 @@ typedef char fstring[FSTRING_LEN]; #define PIPE_ATSVC "\\PIPE\\atsvc" #define PIPE_SPOOLSS "\\PIPE\\spoolss" #define PIPE_EVENTLOG "\\PIPE\\EVENTLOG" +#define PIPE_NETDFS "\\PIPE\\NETDFS" /* 64 bit time (100usec) since ????? - cifs6.txt, section 3.5, page 30 */ typedef struct nttime_info diff --git a/source/include/winbindd_proto.h b/source/include/winbindd_proto.h index b2707570560..61d8802c067 100644 --- a/source/include/winbindd_proto.h +++ b/source/include/winbindd_proto.h @@ -185,263 +185,10 @@ void CatchChildLeaveStatus(void); int vslprintf(char *str, int n, char *format, va_list ap); -/*The following definitions come from libsmb/clientgen.c */ - -int cli_set_port(struct cli_state *cli, int port); -char *cli_errstr(struct cli_state *cli); -void cli_safe_smb_errstr(struct cli_state *cli, char *msg, size_t len); -BOOL get_safe_rap_errstr(int rap_error, char *err_msg, size_t msglen); -void cli_safe_errstr(struct cli_state *cli, char *err_msg, size_t msglen); -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_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); -BOOL cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, const char *)); -BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, - void (*fn)(const char *, uint32, const char *)); -BOOL cli_session_setup_x(struct cli_state *cli, - char *user, - char *pass, int passlen, - char *ntpass, int ntpasslen, - char *user_domain); -BOOL cli_session_setup(struct cli_state *cli, - char *myhostname, char *user, - char *pass, int passlen, - char *ntpass, int ntpasslen, - char *user_domain); -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); -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, const char *fname); -int cli_open(struct cli_state *cli, const 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); -BOOL cli_unlock(struct cli_state *cli, int fnum, uint32 offset, uint32 len, int timeout); -size_t cli_read_one(struct cli_state *cli, int fnum, char *buf, off_t offset, size_t size); -size_t cli_read(struct cli_state *cli, int fnum, char *buf, off_t offset, size_t size, BOOL overlap); -ssize_t cli_write(struct cli_state *cli, - int fnum, uint16 write_mode, - char *buf, off_t offset, size_t size, size_t bytes_left); -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_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); -int cli_list(struct cli_state *cli,const char *Mask,uint16 attribute, - void (*fn)(file_info *, const char *)); -BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char *new_password, - const char *old_password); -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); -void cli_init_creds(struct cli_state *cli, const struct ntuser_creds *usr); -struct cli_state *cli_initialise(struct cli_state *cli); -void cli_close_socket(struct cli_state *cli); -void cli_shutdown(struct cli_state *cli); -int cli_error(struct cli_state *cli, uint8 *eclass, uint32 *num); -void cli_sockopt(struct cli_state *cli, char *options); -uint16 cli_setpid(struct cli_state *cli, uint16 pid); -BOOL cli_reestablish_connection(struct cli_state *cli); -BOOL cli_establish_connection(struct cli_state *cli, - const 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 cli_connect_auth(struct cli_state *cli, - const char* desthost, - struct in_addr *dest_ip, - const struct ntuser_creds *usr); -BOOL cli_connect_servers_auth(struct cli_state *cli, - char *p, - const struct ntuser_creds *usr); -BOOL cli_connect_serverlist(struct cli_state *cli, char *p); -int cli_printjob_del(struct cli_state *cli, int job); -int cli_print_queue(struct cli_state *cli, - void (*fn)(struct print_job_info *)); -BOOL cli_chkpath(struct cli_state *cli, char *path); -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); -BOOL cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail); -BOOL get_any_dc_name(const char *domain, char *srv_name); - -/*The following definitions come from libsmb/credentials.c */ - -char *credstr(const uchar *cred); -void cred_session_key(DOM_CHAL *clnt_chal, DOM_CHAL *srv_chal, const 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(const 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, - const DOM_CRED *rcv_clnt_cred, DOM_CRED *rtn_srv_cred); - -/*The following definitions come from libsmb/namequery.c */ - -BOOL name_status(int fd,char *name,int name_type,BOOL recurse, - struct in_addr to_ip,char *master,char *rname, - void (*fn)(struct packet_struct *)); -struct in_addr *name_query(int fd,const char *name,int name_type, BOOL bcast,BOOL recurse, - struct in_addr to_ip, int *count, void (*fn)(struct packet_struct *)); -FILE *startlmhosts(char *fname); -BOOL getlmhostsent( FILE *fp, pstring name, int *name_type, struct in_addr *ipaddr); -void endlmhosts(FILE *fp); -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); - -/*The following definitions come from libsmb/nmblib.c */ - -void debug_nmb_packet(struct packet_struct *p); -char *nmb_namestr(struct nmb_name *n); -void nmb_safe_namestr(struct nmb_name *n, char *str, size_t len); -struct packet_struct *copy_packet(struct packet_struct *packet); -void free_packet(struct packet_struct *packet); -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, const char *this_scope ); -BOOL nmb_name_equal(struct nmb_name *n1, struct nmb_name *n2); -BOOL send_packet(struct packet_struct *p); -struct packet_struct *receive_packet(int fd,enum packet_type type,int t); -void sort_query_replies(char *data, int n, struct in_addr ip); -BOOL read_nmb_sock(int c, struct nmb_state *con); -int get_nmb_sock(void); -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); -const char *get_nt_error_msg(uint32 nt_code); - -/*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); -void pwd_obfuscate_key(struct pwd_info *pwd, uint32 int_key, char *str_key); -BOOL pwd_compare(const struct pwd_info *_pwd1, const 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, - const uchar lm_pwd[16], - const uchar nt_pwd[16]); -void pwd_get_lm_nt_16(const 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_owf2(struct pwd_info *pwd, const uchar srv_key[8], - const char *user, const char *server, const char *domain, - uchar sess_key[16]); -void pwd_make_lm_nt_owf(struct pwd_info *pwd, uchar cryptkey[8], - uchar sess_key[16]); -void pwd_get_lm_nt_owf(struct pwd_info *pwd, uchar lm_owf[24], - uchar *nt_owf, size_t *nt_owf_len); - /*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 smbhash(uchar *out, const uchar *in, const uchar *key, int forw); -void E_P16(uchar *p14,uchar *p16); -void E_P24(const uchar *p21, const uchar *c8, uchar *p24); -void D_P16(const uchar *p14, const uchar *in, uchar *out); -void E_old_pw_hash( const uchar *p14, const uchar *in, uchar *out); -void cred_hash1(uchar *out, const uchar *in, const uchar *key); -void cred_hash2(uchar *out,uchar *in,uchar *key); -void cred_hash3(uchar *out, const uchar *in,uchar *key, int forw); -void SamOEMhash( uchar *data, const uchar *key, int val); -void sam_pwd_hash(uint32 rid, const uchar *in, uchar *out, int forw); - -/*The following definitions come from libsmb/smbencrypt.c */ - -void SMBencrypt(uchar * pwrd, uchar * c8, uchar * p24); -void SMBNTencrypt(uchar * pwrd, uchar * c8, uchar * p24); -void E_md4hash(uchar * pwrd, uchar * p16); -void lm_owf_genW(const UNISTR2 * pwd, uchar p16[16]); -void lm_owf_gen(const char *pwd, uchar p16[16]); -void nt_owf_genW(const UNISTR2 * pwd, uchar nt_p16[16]); -void nt_owf_gen(const char *pwd, uchar nt_p16[16]); -void nt_lm_owf_genW(const UNISTR2 * pwd, uchar nt_p16[16], uchar lm_p16[16]); -void nt_lm_owf_gen(const char *pwd, uchar nt_p16[16], uchar lm_p16[16]); -void SMBOWFencrypt(const uchar pwrd[16], const uchar * c8, uchar p24[24]); -void SMBOWFencrypt_ntv2(const uchar kr[16], - const uchar * srv_chal, int srv_chal_len, - const uchar * cli_chal, int cli_chal_len, - char resp_buf[16]); -void SMBsesskeygen_ntv2(const uchar kr[16], - const uchar * nt_resp, char sess_key[16]); -void SMBsesskeygen_ntv1(const uchar kr[16], - const uchar * nt_resp, char sess_key[16]); -void SMBgenclientchals(char *lm_cli_chal, - char *nt_cli_chal, int *nt_cli_chal_len, - const char *srv, const char *dom); -void ntv2_owf_gen(const uchar owf[16], - const char *user_n, const char *domain_n, uchar kr_buf[16]); -void NTLMSSPOWFencrypt(const uchar pwrd[8], const uchar * ntlmchalresp, - uchar p24[24]); -BOOL make_oem_passwd_hash(uchar data[516], - const char *pwrd, int new_pw_len, - const uchar old_pw_hash[16], BOOL unicode); -BOOL nt_encrypt_string2(STRING2 * out, const STRING2 * in, const uchar * key); -BOOL nt_decrypt_string2(STRING2 * out, const STRING2 * in, const uchar * key); -void create_ntlmssp_resp(struct pwd_info *pwd, - char *domain, char *user_name, char *my_name, - uint32 ntlmssp_cli_flgs, prs_struct * auth_resp); -BOOL decode_pw_buffer(const char buffer[516], char *new_pwrd, - int new_pwrd_size, uint32 * new_pw_len); -BOOL encode_pw_buffer(char buffer[516], const char *new_pass, - int new_pw_len, BOOL nt_pass_set); - -/*The following definitions come from libsmb/smberr.c */ - -char *smb_err_msg(uint8 class, uint32 num); -BOOL smb_safe_err_msg(uint8 class, uint32 num, char *ret, size_t len); -BOOL smb_safe_errstr(char *inbuf, char *msg, size_t len); -char *smb_errstr(char *inbuf); - /*The following definitions come from lib/snprintf.c */ @@ -451,6 +198,11 @@ void become_root(BOOL save_dir); void unbecome_root(BOOL restore_dir); const vuser_key *get_sec_ctx(void); +/*The following definitions come from lib/surs.c */ + +BOOL surs_sam_sid_to_unixid(DOM_SID *sid, uint32 type, uint32 *id, BOOL create); +BOOL surs_unixid_to_sam_sid(uint32 id, uint32 type, DOM_SID *sid, BOOL create); + /*The following definitions come from lib/sursalgdomonly.c */ BOOL surs_algdomonly_sam_sid_to_unixid(DOM_SID *sid, uint32 type, uint32 *id, @@ -465,11 +217,6 @@ BOOL surs_nt5ldap_sam_sid_to_unixid(LDAPDB *hds, DOM_SID * sid, uint32 type, BOOL surs_nt5ldap_unixid_to_sam_sid(LDAPDB *hds, uint32 id, uint32 type, DOM_SID * sid, BOOL create); -/*The following definitions come from lib/surs.c */ - -BOOL surs_sam_sid_to_unixid(DOM_SID *sid, uint32 type, uint32 *id, BOOL create); -BOOL surs_unixid_to_sam_sid(uint32 id, uint32 type, DOM_SID *sid, BOOL create); - /*The following definitions come from lib/surstdb.c */ BOOL surs_tdb_sam_sid_to_unixid(DOM_SID * sid, uint32 type, uint32 * id, @@ -542,25 +289,6 @@ const struct passwd *Get_Pwnam(char *user,BOOL allow_change); BOOL user_ok(char *user,int snum); BOOL user_in_list(char *user,char *list); -/*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_unistr_array(uint32 num_entries, UNISTR2 **entries); -UNISTR2* add_unistr_to_array(uint32 *len, UNISTR2 ***array, UNISTR2 *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 */ BOOL init_myworkgroup(void); @@ -668,6 +396,25 @@ char *passdb_path(char *name); char *lock_path(char *name); const char *get_sid_name_use_str(uint32 sid_name_use); +/*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_unistr_array(uint32 num_entries, UNISTR2 **entries); +UNISTR2* add_unistr_to_array(uint32 *len, UNISTR2 ***array, UNISTR2 *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); @@ -884,6 +631,259 @@ BOOL tdb_lookup_vuid( const vuser_key *uk, user_struct **usr); BOOL tdb_store_vuid( const vuser_key *uk, user_struct *usr); BOOL vuid_init_db(void); +/*The following definitions come from libsmb/clientgen.c */ + +int cli_set_port(struct cli_state *cli, int port); +char *cli_errstr(struct cli_state *cli); +void cli_safe_smb_errstr(struct cli_state *cli, char *msg, size_t len); +BOOL get_safe_rap_errstr(int rap_error, char *err_msg, size_t msglen); +void cli_safe_errstr(struct cli_state *cli, char *err_msg, size_t msglen); +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_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); +BOOL cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, const char *)); +BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, + void (*fn)(const char *, uint32, const char *)); +BOOL cli_session_setup_x(struct cli_state *cli, + char *user, + char *pass, int passlen, + char *ntpass, int ntpasslen, + char *user_domain); +BOOL cli_session_setup(struct cli_state *cli, + char *myhostname, char *user, + char *pass, int passlen, + char *ntpass, int ntpasslen, + char *user_domain); +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); +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, const char *fname); +int cli_open(struct cli_state *cli, const 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); +BOOL cli_unlock(struct cli_state *cli, int fnum, uint32 offset, uint32 len, int timeout); +size_t cli_read_one(struct cli_state *cli, int fnum, char *buf, off_t offset, size_t size); +size_t cli_read(struct cli_state *cli, int fnum, char *buf, off_t offset, size_t size, BOOL overlap); +ssize_t cli_write(struct cli_state *cli, + int fnum, uint16 write_mode, + char *buf, off_t offset, size_t size, size_t bytes_left); +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_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); +int cli_list(struct cli_state *cli,const char *Mask,uint16 attribute, + void (*fn)(file_info *, const char *)); +BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char *new_password, + const char *old_password); +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); +void cli_init_creds(struct cli_state *cli, const struct ntuser_creds *usr); +struct cli_state *cli_initialise(struct cli_state *cli); +void cli_close_socket(struct cli_state *cli); +void cli_shutdown(struct cli_state *cli); +int cli_error(struct cli_state *cli, uint8 *eclass, uint32 *num); +void cli_sockopt(struct cli_state *cli, char *options); +uint16 cli_setpid(struct cli_state *cli, uint16 pid); +BOOL cli_reestablish_connection(struct cli_state *cli); +BOOL cli_establish_connection(struct cli_state *cli, + const 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 cli_connect_auth(struct cli_state *cli, + const char* desthost, + struct in_addr *dest_ip, + const struct ntuser_creds *usr); +BOOL cli_connect_servers_auth(struct cli_state *cli, + char *p, + const struct ntuser_creds *usr); +BOOL cli_connect_serverlist(struct cli_state *cli, char *p); +int cli_printjob_del(struct cli_state *cli, int job); +int cli_print_queue(struct cli_state *cli, + void (*fn)(struct print_job_info *)); +BOOL cli_chkpath(struct cli_state *cli, char *path); +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); +BOOL cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail); +BOOL get_any_dc_name(const char *domain, char *srv_name); + +/*The following definitions come from libsmb/credentials.c */ + +char *credstr(const uchar *cred); +void cred_session_key(DOM_CHAL *clnt_chal, DOM_CHAL *srv_chal, const 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(const 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, + const DOM_CRED *rcv_clnt_cred, DOM_CRED *rtn_srv_cred); + +/*The following definitions come from libsmb/namequery.c */ + +BOOL name_status(int fd,char *name,int name_type,BOOL recurse, + struct in_addr to_ip,char *master,char *rname, + void (*fn)(struct packet_struct *)); +struct in_addr *name_query(int fd,const char *name,int name_type, BOOL bcast,BOOL recurse, + struct in_addr to_ip, int *count, void (*fn)(struct packet_struct *)); +FILE *startlmhosts(char *fname); +BOOL getlmhostsent( FILE *fp, pstring name, int *name_type, struct in_addr *ipaddr); +void endlmhosts(FILE *fp); +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); + +/*The following definitions come from libsmb/nmblib.c */ + +void debug_nmb_packet(struct packet_struct *p); +char *nmb_namestr(struct nmb_name *n); +void nmb_safe_namestr(struct nmb_name *n, char *str, size_t len); +struct packet_struct *copy_packet(struct packet_struct *packet); +void free_packet(struct packet_struct *packet); +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, const char *this_scope ); +BOOL nmb_name_equal(struct nmb_name *n1, struct nmb_name *n2); +BOOL send_packet(struct packet_struct *p); +struct packet_struct *receive_packet(int fd,enum packet_type type,int t); +void sort_query_replies(char *data, int n, struct in_addr ip); +BOOL read_nmb_sock(int c, struct nmb_state *con); +int get_nmb_sock(void); +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); +const char *get_nt_error_msg(uint32 nt_code); + +/*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); +void pwd_obfuscate_key(struct pwd_info *pwd, uint32 int_key, char *str_key); +BOOL pwd_compare(const struct pwd_info *_pwd1, const 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, + const uchar lm_pwd[16], + const uchar nt_pwd[16]); +void pwd_get_lm_nt_16(const 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_owf2(struct pwd_info *pwd, const uchar srv_key[8], + const char *user, const char *server, const char *domain, + uchar sess_key[16]); +void pwd_make_lm_nt_owf(struct pwd_info *pwd, uchar cryptkey[8], + uchar sess_key[16]); +void pwd_get_lm_nt_owf(struct pwd_info *pwd, uchar lm_owf[24], + uchar *nt_owf, size_t *nt_owf_len); + +/*The following definitions come from libsmb/smbdes.c */ + +void smbhash(uchar *out, const uchar *in, const uchar *key, int forw); +void E_P16(uchar *p14,uchar *p16); +void E_P24(const uchar *p21, const uchar *c8, uchar *p24); +void D_P16(const uchar *p14, const uchar *in, uchar *out); +void E_old_pw_hash( const uchar *p14, const uchar *in, uchar *out); +void cred_hash1(uchar *out, const uchar *in, const uchar *key); +void cred_hash2(uchar *out,uchar *in,uchar *key); +void cred_hash3(uchar *out, const uchar *in,uchar *key, int forw); +void SamOEMhash( uchar *data, const uchar *key, int val); +void sam_pwd_hash(uint32 rid, const uchar *in, uchar *out, int forw); + +/*The following definitions come from libsmb/smbencrypt.c */ + +void SMBencrypt(uchar * pwrd, uchar * c8, uchar * p24); +void SMBNTencrypt(uchar * pwrd, uchar * c8, uchar * p24); +void E_md4hash(uchar * pwrd, uchar * p16); +void lm_owf_genW(const UNISTR2 * pwd, uchar p16[16]); +void lm_owf_gen(const char *pwd, uchar p16[16]); +void nt_owf_genW(const UNISTR2 * pwd, uchar nt_p16[16]); +void nt_owf_gen(const char *pwd, uchar nt_p16[16]); +void nt_lm_owf_genW(const UNISTR2 * pwd, uchar nt_p16[16], uchar lm_p16[16]); +void nt_lm_owf_gen(const char *pwd, uchar nt_p16[16], uchar lm_p16[16]); +void SMBOWFencrypt(const uchar pwrd[16], const uchar * c8, uchar p24[24]); +void SMBOWFencrypt_ntv2(const uchar kr[16], + const uchar * srv_chal, int srv_chal_len, + const uchar * cli_chal, int cli_chal_len, + char resp_buf[16]); +void SMBsesskeygen_ntv2(const uchar kr[16], + const uchar * nt_resp, char sess_key[16]); +void SMBsesskeygen_ntv1(const uchar kr[16], + const uchar * nt_resp, char sess_key[16]); +void SMBgenclientchals(char *lm_cli_chal, + char *nt_cli_chal, int *nt_cli_chal_len, + const char *srv, const char *dom); +void ntv2_owf_gen(const uchar owf[16], + const char *user_n, const char *domain_n, uchar kr_buf[16]); +void NTLMSSPOWFencrypt(const uchar pwrd[8], const uchar * ntlmchalresp, + uchar p24[24]); +BOOL make_oem_passwd_hash(uchar data[516], + const char *pwrd, int new_pw_len, + const uchar old_pw_hash[16], BOOL unicode); +BOOL nt_encrypt_string2(STRING2 * out, const STRING2 * in, const uchar * key); +BOOL nt_decrypt_string2(STRING2 * out, const STRING2 * in, const uchar * key); +void create_ntlmssp_resp(struct pwd_info *pwd, + char *domain, char *user_name, char *my_name, + uint32 ntlmssp_cli_flgs, prs_struct * auth_resp); +BOOL decode_pw_buffer(const char buffer[516], char *new_pwrd, + int new_pwrd_size, uint32 * new_pw_len); +BOOL encode_pw_buffer(char buffer[516], const char *new_pass, + int new_pw_len, BOOL nt_pass_set); + +/*The following definitions come from libsmb/smberr.c */ + +char *smb_err_msg(uint8 class, uint32 num); +BOOL smb_safe_err_msg(uint8 class, uint32 num, char *ret, size_t len); +BOOL smb_safe_errstr(char *inbuf, char *msg, size_t len); +char *smb_errstr(char *inbuf); + /*The following definitions come from nsswitch/winbindd.c */ void exit_server(char *reason); diff --git a/source/rpc_client/cli_connect.c b/source/rpc_client/cli_connect.c index caf83cade2c..53644ea7da9 100644 --- a/source/rpc_client/cli_connect.c +++ b/source/rpc_client/cli_connect.c @@ -157,12 +157,13 @@ static struct cli_connection *cli_con_get(const char *srv_name, ncacn_np_use_add(pipe_name, user_key, srv_name, ntc, True, reuse, &is_new_connection); - if (con->msrpc.smb != NULL) - { - key = con->msrpc.smb->smb->nt.key; - con->msrpc.smb->smb->nt.key.pid = 0; - con->msrpc.smb->smb->nt.key.vuid = UID_FIELD_INVALID; - } + + if (con->msrpc.smb == NULL) + return NULL; + + key = con->msrpc.smb->smb->nt.key; + con->msrpc.smb->smb->nt.key.pid = 0; + con->msrpc.smb->smb->nt.key.vuid = UID_FIELD_INVALID; copy_nt_creds(&con->usr_creds.ntc, &con->msrpc.smb->smb->usr); } diff --git a/source/rpc_client/cli_dfs.c b/source/rpc_client/cli_dfs.c new file mode 100644 index 00000000000..c6ef69190af --- /dev/null +++ b/source/rpc_client/cli_dfs.c @@ -0,0 +1,191 @@ +#ifdef SYSLOG +#undef SYSLOG +#endif + +#include "includes.h" +#include "rpc_parse.h" +#include "nterr.h" + +extern int DEBUGLEVEL; + +/* Called by all dfs operations to verify if a dfs_root exists at server */ +static BOOL _dfs_exist(struct cli_connection *con) +{ + prs_struct buf; + prs_struct rbuf; + prs_struct *ps = &rbuf; + DFS_R_DFS_EXIST q_d; + uint32 dfs_exist_flag = 0; + + prs_init(&buf, 0, 4, False); + prs_init(&rbuf, 0 ,4, True); + + /* make a null request */ + if(!rpc_con_pipe_req(con, DFS_EXIST, &buf, &rbuf)) + { + DEBUG(5,("Null request unsuccessful!\n")); + prs_free_data(&rbuf); + cli_connection_unlink(con); + return False; + } + if(!dfs_io_r_dfs_exist("", &q_d, &rbuf, 0)) + return False; + + prs_free_data(&rbuf); + return q_d.dfs_exist_flag; +} + +BOOL dfs_remove(char *srv_name, char *dfs_entrypath, char *dfs_servername, + char *dfs_sharename) +{ + prs_struct rbuf; + prs_struct buf; + BOOL valid_cfg= False; + DFS_Q_DFS_REMOVE q_d; + struct cli_connection *con=NULL; + + prs_init(&buf, 0, 4, False); + prs_init(&rbuf, 0 ,4, True); + if (!cli_connection_init(srv_name, PIPE_NETDFS, &con)) + return False; + + /* check if server is a dfs server */ + if(!_dfs_exist(con)) + { + DEBUG(5,("dfs_remove: No Dfs root at \\\\%s\n",srv_name)); + return False; + } + + /* store the parameters */ + make_dfs_q_dfs_remove(&q_d, dfs_entrypath, dfs_servername, dfs_sharename); + + /* turn parameters into data stream */ + if(dfs_io_q_dfs_remove("", &q_d, &buf, 0) && + rpc_con_pipe_req(con, DFS_REMOVE, &buf, &rbuf)) + { + DFS_R_DFS_REMOVE r_d; + BOOL p; + ZERO_STRUCT(r_d); + + dfs_io_r_dfs_remove("", &r_d, &rbuf, 0); + p = (rbuf.offset != 0); + + if(p && r_d.status!=0) + { + DEBUG(1,("DFS_REMOVE: %s\n",get_nt_error_msg(r_d.status))); + p = False; + } + + if(p) + valid_cfg = True; + } + prs_free_data(&rbuf); + prs_free_data(&buf); + cli_connection_unlink(con); + return valid_cfg; +} + +BOOL dfs_add(char *srv_name, char* entrypath, char* servername, char* sharename, char* comment) +{ + prs_struct rbuf; + prs_struct buf; + BOOL valid_cfg= False; + DFS_Q_DFS_ADD q_d; + struct cli_connection *con=NULL; + + prs_init(&buf, 0, 4, False); + prs_init(&rbuf, 0 ,4, True); + if (!cli_connection_init(srv_name, PIPE_NETDFS, &con)) + return False; + + if(!_dfs_exist(con)) + { + DEBUG(5,("dfs_add: No Dfs root at \\\\%s\n",srv_name)); + return False; + } + + /* store the parameters */ + make_dfs_q_dfs_add(&q_d, entrypath, servername, sharename, comment, + DFSFLAG_ADD_VOLUME); + + /* turn parameters into data stream */ + if(dfs_io_q_dfs_add("", &q_d, &buf, 0) && + rpc_con_pipe_req(con, DFS_ADD, &buf, &rbuf)) + { + DFS_R_DFS_ADD r_d; + BOOL p; + ZERO_STRUCT(r_d); + + dfs_io_r_dfs_add("", &r_d, &rbuf, 0); + p = (rbuf.offset != 0); + + if(p && r_d.status!=0) + { + DEBUG(1,("DFS_ADD: %s\n",get_nt_error_msg(r_d.status))); + p = False; + } + + if(p) + valid_cfg = True; + } + prs_free_data(&rbuf); + prs_free_data(&buf); + cli_connection_unlink(con); + return valid_cfg; +} + +uint32 dfs_enum(char *srv_name, uint32 level, DFS_INFO_CTR *ctr) +{ + prs_struct rbuf; + prs_struct buf; + BOOL valid_cfg= False; + DFS_Q_DFS_ENUM q_d; + uint32 res = NT_STATUS_UNSUCCESSFUL; + + struct cli_connection *con=NULL; + + prs_init(&buf, 0, 4, False); + prs_init(&rbuf, 0 ,4, True); + if (!cli_connection_init(srv_name, PIPE_NETDFS, &con)) + return NT_STATUS_PIPE_NOT_AVAILABLE; + + if(!_dfs_exist(con)) + { + DEBUG(5,("dfs_add: No Dfs root at \\\\%s\n",srv_name)); + return NT_STATUS_OBJECT_PATH_NOT_FOUND; + } + + /* store the parameters */ + make_dfs_q_dfs_enum(&q_d, level, ctr); + + /* turn parameters into data stream */ + if(dfs_io_q_dfs_enum("", &q_d, &buf, 0) && + rpc_con_pipe_req(con, DFS_ENUM, &buf, &rbuf)) + { + DFS_R_DFS_ENUM r_d; + BOOL p; + ZERO_STRUCT(r_d); + + r_d.ctr = ctr; + dfs_io_r_dfs_enum("", &r_d, &rbuf, 0); + p = (rbuf.offset != 0); + + if(p && r_d.status!=0) + { + DEBUG(1,("DFS_ENUM: %s\n",get_nt_error_msg(r_d.status))); + res = r_d.status; + p = False; + } + + if(p) + valid_cfg = True; + } + prs_free_data(&rbuf); + prs_free_data(&buf); + cli_connection_unlink(con); + if(valid_cfg) + return 0; + else + return res; +} + diff --git a/source/rpc_parse/parse_dfs.c b/source/rpc_parse/parse_dfs.c new file mode 100644 index 00000000000..4587fd46e49 --- /dev/null +++ b/source/rpc_parse/parse_dfs.c @@ -0,0 +1,345 @@ +#include "includes.h" +#include "nterr.h" +#include "rpc_parse.h" + +extern int DEBUGLEVEL; + +/************************************************************* + Read/write a DFS_R_DFS_EXIST structure + ************************************************************/ +BOOL dfs_io_r_dfs_exist(char *desc, DFS_R_DFS_EXIST *q_d, prs_struct *ps, + int depth) +{ + if(q_d == NULL) return False; + + prs_debug(ps, depth, desc, "dfs_io_r_dfs_exist"); + depth++; + + prs_align(ps); + + prs_uint32("exist flag", ps, 0, &(q_d->dfs_exist_flag)); + return True; +} + +/******************************************************************* +Make a DFS_Q_DFS_REMOVE structure +*******************************************************************/ +BOOL make_dfs_q_dfs_remove(DFS_Q_DFS_REMOVE *q_d, char *entrypath, + char *servername, char *sharename) +{ + DEBUG(5,("make_dfs_q_dfs_remove\n")); + make_unistr2(&(q_d->DfsEntryPath), entrypath, strlen(entrypath)+1); + make_unistr2(&(q_d->ServerName), servername, strlen(servername)+1); + make_unistr2(&(q_d->ShareName), sharename, strlen(sharename)+1); + q_d->ptr_ServerName = q_d->ptr_ShareName = 1; +} + +/******************************************************************* +Read/write a DFS_Q_DFS_REMOVE structure +*******************************************************************/ +BOOL dfs_io_q_dfs_remove(char *desc, DFS_Q_DFS_REMOVE *q_d, prs_struct *ps, + int depth) +{ + if(q_d == NULL) return False; + + prs_debug(ps, depth, desc, "dfs_io_q_dfs_remove"); + depth++; + + prs_align(ps); + + smb_io_unistr2("DfsEntryPath",&(q_d->DfsEntryPath), 1, ps, depth); + prs_align(ps); + + prs_uint32("ptr_ServerName", ps, depth, &(q_d->ptr_ServerName)); + smb_io_unistr2("ServerName",&(q_d->ServerName), 1, ps, depth); + prs_align(ps); + + prs_uint32("ptr_ShareName", ps, depth, &(q_d->ptr_ShareName)); + smb_io_unistr2("ShareName",&(q_d->ShareName), 1, ps, depth); + prs_align(ps); + + return True; +} + +/******************************************************************* +Read/write a DFS_R_DFS_REMOVE structure +*******************************************************************/ +BOOL dfs_io_r_dfs_remove(char *desc, DFS_R_DFS_REMOVE *r_d, prs_struct *ps, + int depth) +{ + if(r_d == NULL) return False; + + prs_debug(ps, depth, desc, "dfs_io_r_dfs_remove"); + depth++; + + prs_uint32("status", ps, depth, &(r_d->status)); + + return True; +} + +/******************************************************************* +Make a DFS_Q_DFS_ADD structure +*******************************************************************/ +BOOL make_dfs_q_dfs_add(DFS_Q_DFS_ADD *q_d, char *entrypath, char *servername, + char *sharename, char *comment, uint32 flags) +{ + DEBUG(5,("make_dfs_q_dfs_add\n")); + q_d->ptr_DfsEntryPath = q_d->ptr_ServerName = q_d->ptr_ShareName = 1; + make_unistr2(&(q_d->DfsEntryPath), entrypath, strlen(entrypath)+1); + make_unistr2(&(q_d->ServerName), servername, strlen(servername)+1); + make_unistr2(&(q_d->ShareName), sharename, strlen(sharename)+1); + if(comment != NULL) + { + make_unistr2(&(q_d->Comment), comment, strlen(comment)+1); + q_d->ptr_Comment = 1; + } + else + { + q_d->ptr_Comment = 0; + } + + q_d->Flags = flags; +} + +/************************************************************ + Read/write a DFS_Q_DFS_ADD structure + ************************************************************/ +BOOL dfs_io_q_dfs_add(char *desc, DFS_Q_DFS_ADD *q_d, prs_struct *ps, + int depth) +{ + if(q_d == NULL) return False; + + prs_debug(ps, depth, desc, "dfs_io_q_dfs_add"); + depth++; + + prs_align(ps); + + smb_io_unistr2("DfsEntryPath",&(q_d->DfsEntryPath), 1, ps, depth); + prs_align(ps); + + smb_io_unistr2("ServerName",&(q_d->ServerName), 1, ps, depth); + prs_align(ps); + + prs_uint32("ptr_ShareName", ps, depth, &(q_d->ptr_ShareName)); + smb_io_unistr2("ShareName",&(q_d->ShareName), 1, ps, depth); + prs_align(ps); + + prs_uint32("ptr_Comment", ps, depth, &(q_d->ptr_Comment)); + smb_io_unistr2("",&(q_d->Comment), q_d->ptr_Comment , ps, depth); + prs_align(ps); + + prs_uint32("Flags", ps, depth, &(q_d->Flags)); + return True; +} + +/************************************************************ + Read/write a DFS_R_DFS_ADD structure + ************************************************************/ +BOOL dfs_io_r_dfs_add(char *desc, DFS_R_DFS_ADD *r_d, prs_struct *ps, + int depth) +{ + if(r_d == NULL) return False; + + prs_debug(ps, depth, desc, "dfs_io_r_dfs_add"); + depth++; + + prs_uint32("status", ps, depth, &(r_d->status)); + + return True; +} + +/************************************************************ + Make a DFS_Q_DFS_ENUM structure + ************************************************************/ +BOOL make_dfs_q_dfs_enum(DFS_Q_DFS_ENUM *q_d, uint32 level, DFS_INFO_CTR *ctr) +{ + q_d->level = level; + q_d->maxpreflen = -1; + q_d->ptr_buffer = 1; + q_d->level2 = level; + + q_d->ptr_num_entries = 1; + q_d->num_entries = 0; + q_d->num_entries2 = 0; + q_d->reshnd.ptr_hnd = 1; + q_d->reshnd.handle = 0; +} + +/************************************************************ + Read or write the DFS_Q_DFS_ENUM structure + ************************************************************/ +BOOL dfs_io_q_dfs_enum(char *desc, DFS_Q_DFS_ENUM *q_d, prs_struct *ps, + int depth) +{ + if(q_d == NULL) return False; + + prs_debug(ps, depth, desc, "dfs_io_q_dfs_enum"); + depth++; + + prs_align(ps); + + prs_uint32("level", ps, depth, &(q_d->level)); + prs_uint32("maxpreflen", ps, depth, &(q_d->maxpreflen)); + prs_uint32("ptr_buffer", ps, depth, &(q_d->ptr_buffer)); + prs_uint32("level2", ps, depth, &(q_d->level2)); + prs_uint32("level3", ps, depth, &(q_d->level2)); + + prs_uint32("ptr_num_entries", ps, depth, &(q_d->ptr_num_entries)); + prs_uint32("num_entries", ps, depth, &(q_d->num_entries)); + prs_uint32("num_entries2", ps, depth, &(q_d->num_entries2)); + smb_io_enum_hnd("resume_hnd",&(q_d->reshnd), ps, depth); + return True; +} + +/************************************************************ + Read/write a DFS_R_DFS_ENUM structure + ************************************************************/ +BOOL dfs_io_r_dfs_enum(char *desc, DFS_R_DFS_ENUM *q_d, prs_struct *ps, int depth) +{ + DFS_INFO_CTR *ctr; + if(q_d == NULL) return False; + ctr = q_d->ctr; + if(ctr == NULL) return False; + + prs_debug(ps, depth, desc, "dfs_io_r_dfs_enum"); + depth++; + + prs_align(ps); + + prs_uint32("ptr_buffer", ps, depth, &(q_d->ptr_buffer)); + prs_uint32("level", ps, depth, &(q_d->level)); + prs_uint32("level2", ps, depth, &(ctr->switch_value)); + prs_uint32("ptr_num_entries", ps, depth, &(q_d->ptr_num_entries)); + if(q_d->ptr_num_entries) + prs_uint32("num_entries", ps, depth, &(q_d->num_entries)); + prs_uint32("ptr_num_entries2", ps, depth, &(q_d->ptr_num_entries2)); + if(q_d->ptr_num_entries2) + prs_uint32("num_entries2", ps, depth, &(ctr->num_entries)); + + switch(q_d->level) + { + case 1: + { + int i=0; + + depth++; + /* should depend on whether marshalling or unmarshalling! */ + if(UNMARSHALLING(ps)) + ctr->dfs.info1 = g_new0(DFS_INFO_1, q_d->num_entries); + + for(i=0;i<q_d->num_entries;i++) + { + prs_uint32("ptr_entrypath",ps, depth, &(ctr->dfs.info1[i].ptr_entrypath)); + } + for(i=0;i<q_d->num_entries;i++) + { + smb_io_unistr2("", &(ctr->dfs.info1[i].entrypath), + ctr->dfs.info1[i].ptr_entrypath, + ps, depth); + prs_align(ps); + } + depth--; + break; + } + case 2: + { + int i=0; + depth++; + if(UNMARSHALLING(ps)) + ctr->dfs.info2 = g_new0(DFS_INFO_2, q_d->num_entries); + + for(i=0;i<q_d->num_entries;i++) + { + prs_uint32("ptr_entrypath", ps, depth, + &(ctr->dfs.info2[i].ptr_entrypath)); + prs_uint32("ptr_comment", ps, depth, + &(ctr->dfs.info2[i].ptr_comment)); + prs_uint32("state", ps, depth, &(ctr->dfs.info2[i].state)); + prs_uint32("num_storages", ps, depth, + &(ctr->dfs.info2[i].num_storages)); + } + for(i=0;i<q_d->num_entries;i++) + { + smb_io_unistr2("", &(ctr->dfs.info2[i].entrypath), + ctr->dfs.info2[i].ptr_entrypath, ps, depth); + smb_io_unistr2("",&(ctr->dfs.info2[i].comment), + ctr->dfs.info2[i].ptr_comment, ps, depth); + } + depth--; + break; + } + case 3: + { + int i=0; + depth++; + if(UNMARSHALLING(ps)) + ctr->dfs.info3 = g_new0(DFS_INFO_3, q_d->num_entries); + + for(i=0;i<q_d->num_entries;i++) + { + prs_uint32("ptr_entrypath", ps, depth, + &(ctr->dfs.info3[i].ptr_entrypath)); + prs_uint32("ptr_comment", ps, depth, + &(ctr->dfs.info3[i].ptr_comment)); + prs_uint32("state", ps, depth, &(ctr->dfs.info3[i].state)); + prs_uint32("num_storages", ps, depth, + &(ctr->dfs.info3[i].num_storages)); + prs_uint32("ptr_storages", ps, depth, + &(ctr->dfs.info3[i].ptr_storages)); + } + for(i=0;i<q_d->num_entries;i++) + { + smb_io_unistr2("", &(ctr->dfs.info3[i].entrypath), + ctr->dfs.info3[i].ptr_entrypath, ps, depth); + prs_align(ps); + smb_io_unistr2("", &(ctr->dfs.info3[i].comment), + ctr->dfs.info3[i].ptr_comment, ps, depth); + prs_align(ps); + prs_uint32("num_storage_infos", ps, depth, + &(ctr->dfs.info3[i].num_storage_infos)); + if(!smb_io_dfs_storage_info("storage_info", + &(ctr->dfs.info3[i]), + ps, depth)) + return False; + } + } + } + + smb_io_enum_hnd("resume_hnd", &(q_d->reshnd), ps, depth); + prs_uint32("status", ps, depth, &(q_d->status)); +} + +BOOL smb_io_dfs_storage_info(char *desc, DFS_INFO_3* info3, + prs_struct *ps, int depth) +{ + int i=0; + if(info3 == NULL) return False; + + prs_debug(ps, depth, desc, "smb_io_dfs_storage_info"); + depth++; + + if(UNMARSHALLING(ps)) + info3->storages = g_new0(DFS_STORAGE_INFO, info3->num_storage_infos); + + for(i=0;i<info3->num_storage_infos;i++) + { + prs_uint32("storage_state", ps, depth, &(info3->storages[i].state)); + prs_uint32("ptr_servername", ps, depth, + &(info3->storages[i].ptr_servername)); + prs_uint32("ptr_sharename", ps, depth, + &(info3->storages[i].ptr_sharename)); + } + for(i=0;i<info3->num_storage_infos;i++) + { + smb_io_unistr2("servername", &(info3->storages[i].servername), + info3->storages[i].ptr_servername, ps, depth); + prs_align(ps); + smb_io_unistr2("sharename", &(info3->storages[i].sharename), + info3->storages[i].ptr_sharename, ps, depth); + prs_align(ps); + } + return True; +} + + + diff --git a/source/rpc_parse/parse_rpc.c b/source/rpc_parse/parse_rpc.c index c482561436c..332bdf8f3b8 100644 --- a/source/rpc_parse/parse_rpc.c +++ b/source/rpc_parse/parse_rpc.c @@ -1,15 +1,6 @@ /* * Unix SMB/Netbios implementation. - * Version 1.9. - * RPC Pipe client / server routines - * Copyright (C) Andrew Tridgell 1992-2000, - * Copyright (C) Luke Kenneth Casson Leighton 1996-2000, - * Copyright (C) Paul Ashton 1997-2000. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -158,6 +149,15 @@ interface/version dce/rpc pipe identification }, 0x00 \ } +#define SYNT_NETDFS_V3 \ +{ \ + { \ + 0x4fc742e0, 0x4a10, 0x11cf, \ + { 0x82, 0x73, 0x00, 0xaa, \ + 0x00, 0x4a, 0xe6, 0x73 } \ + }, 0x03 \ +} + struct pipe_id_info pipe_names[] = { /* client pipe , abstract syntax , server pipe , transfer syntax */ {PIPE_LSARPC, SYNT_LSARPC_V0, PIPE_LSASS, TRANS_SYNT_V2}, @@ -171,6 +171,7 @@ struct pipe_id_info pipe_names[] = { {PIPE_ATSVC, SYNT_ATSVC_V1, PIPE_ATSVC, TRANS_SYNT_V2}, {PIPE_SPOOLSS, SYNT_SPOOLSS_V1, PIPE_SPOOLSS, TRANS_SYNT_V2}, {PIPE_EVENTLOG, SYNT_EVENTLOG_V0, PIPE_EVENTLOG, TRANS_SYNT_V2}, + {PIPE_NETDFS, SYNT_NETDFS_V3, PIPE_NETDFS, TRANS_SYNT_V2}, {NULL, SYNT_NONE_V0, NULL, SYNT_NONE_V0} }; diff --git a/source/rpcclient/cmd_dfs.c b/source/rpcclient/cmd_dfs.c new file mode 100644 index 00000000000..cd3be42f2a9 --- /dev/null +++ b/source/rpcclient/cmd_dfs.c @@ -0,0 +1,244 @@ +#ifdef SYSLOG +#undef SYSLOG +#endif + +#include "includes.h" +#include "nterr.h" +#include "rpc_parse.h" + +extern int DEBUGLEVEL; + +#define DEBUG_TESTING + +extern FILE* out_hnd; + +extern struct user_creds *usr_creds; + +void cmd_dfs_add(struct client_info *info, int argc, char *argv[]) +{ + fstring srv_name; + char *entrypath, *servername, *sharename, *comment=NULL; + + /* parse out the args */ + if(argc < 4) + { + report(out_hnd, "dfsadd Dfspath storage_server share [\"comment\"]\n"); + return; + } + + fstrcpy(srv_name,"\\\\"); + fstrcat(srv_name, info->dest_host); + strupper(srv_name); + + entrypath = argv[1]; + servername = argv[2]; + sharename = argv[3]; + if(argc > 4) + comment = argv[4]; + + DEBUG(5,("Adding Dfs path: %s\n(physically located at \\\\%s\\%s\n",entrypath, + servername,sharename)); + + if(!dfs_add(srv_name, entrypath, servername, sharename, comment)) + { + report(out_hnd, "dfsadd: Unable to add dfs share\n"); + return; + } + else + { + report(out_hnd, "dfsadd: Successfully added dfs share\n"); + return; + } +} + +void cmd_dfs_remove(struct client_info *info, int argc, char *argv[]) +{ + fstring srv_name; + char *dfs_entrypath, *dfs_servername, *dfs_sharename; + + if(argc != 4) + { + report(out_hnd, "dfsremove Dfspath storage_server share\n"); + return; + } + + fstrcpy(srv_name, "\\\\"); + fstrcat(srv_name, info->dest_host); + strupper(srv_name); + + dfs_entrypath = argv[1]; + dfs_servername = argv[2]; + dfs_sharename = argv[3]; + + DEBUG(5,("Removing Dfs path: %s\n[physically located at \\\\%s\\%s\n", + dfs_entrypath, dfs_servername, dfs_sharename)); + + if(!dfs_remove(srv_name, dfs_entrypath, dfs_servername, dfs_sharename)) + { + report(out_hnd, "dfsremove: Unsuccessful!\n"); + return; + } + else + { + report(out_hnd, "dfsremove: Removed.\n"); + return; + } +} + +void display_dfs_enum_1(FILE *out_hnd, DFS_INFO_CTR *ctr) +{ + int i=0; + for(i=0;i<ctr->num_entries;i++) + { + fstring path; + UNISTR2 *unipath = &(ctr->dfs.info1[i].entrypath); + unistr2_to_ascii(path, unipath, sizeof(path)-1); + report(out_hnd, "Path: %s\n",path); + } + free(ctr->dfs.info1); +} + +void display_dfs_enum_2(FILE *out_hnd, DFS_INFO_CTR *ctr) +{ + int i=0; + for(i=0;i<ctr->num_entries;i++) + { + fstring path, comment; + fstring state; + UNISTR2 *unipath = &(ctr->dfs.info2[i].entrypath); + UNISTR2 *unicomment = &(ctr->dfs.info2[i].comment); + unistr2_to_ascii(path, unipath, sizeof(path)-1); + unistr2_to_ascii(comment, unicomment, sizeof(comment)-1); + + report(out_hnd, "Path: %s\n",path); + if(*comment) + report(out_hnd, "Comment: [%s]\n",comment); + + switch(ctr->dfs.info2[i].state) + { + case 1: fstrcpy(state, "OK"); break; + case 2: fstrcpy(state, "INCONSISTENT"); break; + case 3: fstrcpy(state, "OFFLINE"); break; + case 4: fstrcpy(state, "ONLINE"); break; + default: fstrcpy(state, "UNKNOWN"); break; + } + report(out_hnd, "State: %s Number of storages: %u\n\n",state, + ctr->dfs.info2[i].num_storages); + } + free(ctr->dfs.info2); +} + +void display_dfs_enum_3_storages(FILE *out_hnd, DFS_INFO_3 *info3) +{ + int i=0; + if((info3 == NULL) || (info3->storages==NULL)) + return; + + for(i=0;i<info3->num_storages;i++) + { + DFS_STORAGE_INFO *stor = &(info3->storages[i]); + fstring servername, sharename,storagepath; + unistr2_to_ascii(servername, &(stor->servername), sizeof(servername)-1); + unistr2_to_ascii(sharename, &(stor->sharename), sizeof(sharename)-1); + fstrcpy(storagepath,"\\\\"); + fstrcat(storagepath,servername); + fstrcat(storagepath,"\\"); + fstrcat(storagepath,sharename); + + report(out_hnd, " Storage %1u: %-33s[%s] \n",i+1, storagepath, + (stor->state==2?"ONLINE":"OFFLINE")); + } +} +void display_dfs_enum_3(FILE *out_hnd, DFS_INFO_CTR *ctr) +{ + int i=0; + + for(i=0;i<ctr->num_entries;i++) + { + fstring path, comment; + fstring state; + UNISTR2 *unipath = &(ctr->dfs.info3[i].entrypath); + UNISTR2 *unicomment = &(ctr->dfs.info3[i].comment); + unistr2_to_ascii(path, unipath, sizeof(path)-1); + unistr2_to_ascii(comment, unicomment, sizeof(comment)-1); + + switch(ctr->dfs.info3[i].state) + { + case 1: fstrcpy(state, "OK"); break; + case 2: fstrcpy(state, "INCONSISTENT"); break; + case 3: fstrcpy(state, "OFFLINE"); break; + case 4: fstrcpy(state, "ONLINE"); break; + default: fstrcpy(state, "UNKNOWN"); break; + } + + report(out_hnd, "Dfs path:%-40sState: %s\n",path,state); + if(*comment) + report(out_hnd, "Comment: [%s]\n",comment); + + display_dfs_enum_3_storages(out_hnd, &(ctr->dfs.info3[i])); + report(out_hnd,"\n"); + } + free(ctr->dfs.info3); +} +void display_dfs_enum(FILE *out_hnd, char *srv_name, DFS_INFO_CTR *ctr) +{ + /* print header */ + report(out_hnd, "\tDfs Namespace at %s [Info level %u]\n\n",srv_name, + ctr->switch_value); + switch(ctr->switch_value) + { + case 1: + display_dfs_enum_1(out_hnd, ctr); + break; + case 2: + display_dfs_enum_2(out_hnd, ctr); + break; + case 3: + display_dfs_enum_3(out_hnd, ctr); + break; + default: + report(out_hnd, "\tUnknown info level [%u]\n",ctr->switch_value); + } + report(out_hnd, "\n"); +} + +/**************************************************************************** + DFS enum query + ****************************************************************************/ +void cmd_dfs_enum(struct client_info *info, int argc, char *argv[]) +{ + fstring srv_name; + DFS_INFO_CTR ctr; + uint32 info_level = 3; + uint32 res=0; + fstrcpy(srv_name,"\\\\"); + fstrcat(srv_name, info->dest_host); + strupper(srv_name); + + if(argc > 2) + { + report(out_hnd, "dfsenum [1,2,3]\n"); + return; + } + + if(argc == 2) + info_level = (uint32)strtol(argv[1], (char**)NULL, 10); + + if(info_level<1 || info_level>3) + { + report(out_hnd, "dfsenum [1,2,3]\n"); + return; + } + DEBUG(5,("cmd_dfs_enum: info_level: %u query\n",info_level)); + + res = dfs_enum(srv_name, info_level, &ctr); + if(res==0) + { + DEBUG(5,("cmd_dfs_enum: query succeeded\n")); + display_dfs_enum(out_hnd, srv_name, &ctr); + } + else + report(out_hnd, "FAILED: %s\n",get_nt_error_msg(res)); +} + + diff --git a/source/rpcclient/dfs_cmds.c b/source/rpcclient/dfs_cmds.c new file mode 100644 index 00000000000..6c21970333b --- /dev/null +++ b/source/rpcclient/dfs_cmds.c @@ -0,0 +1,64 @@ +#include "includes.h" +#include "ntdomain.h" +#include "rpcclient.h" +#include "rpc_parse.h" + +extern struct client_info cli_info; + +/* DFS command completion function */ +char *complete_dfsenum(char *text, int state) +{ + static uint32 i=0; + DFS_INFO_CTR ctr; + fstring srv_name; + + fstrcpy(srv_name, "\\\\"); + fstrcat(srv_name, cli_info.dest_host); + strupper(srv_name); + + /* first time that the completion is called */ + if(i==0 && state==0) + { + free(ctr.dfs.info1); + if(0 != dfs_enum(srv_name, 1, &ctr)) + { + return NULL; + } + + } + + for(; i<ctr.num_entries;i++) + { + fstring dfspath; + unistr2_to_ascii(dfspath, &(ctr.dfs.info1[i].entrypath), + sizeof(dfspath)-1); + strupper(dfspath); + if(text==NULL || text[0] == 0 || + strnequal(text, dfspath, strlen(text))) + { + char *name = strdup(dfspath); + i++; + return name; + } + } + return NULL; +} + + +/**************************************************************************** + Defines Dfs commands supported by this client + ***************************************************************************/ + +static const struct command_set dfs_commands[] = +{ + { "dfsenum", cmd_dfs_enum, "Enumerate Dfs volumes", {NULL, NULL} }, + { "dfsadd" , cmd_dfs_add, "Add a Dfs volume", {complete_dfsenum, NULL} }, + { "dfsremove", cmd_dfs_remove, "Remove a Dfs volume", + {complete_dfsenum, NULL} }, + { "", NULL, NULL, {NULL, NULL} } +}; + +void add_dfs_commands(void) +{ + add_command_set(dfs_commands); +} diff --git a/source/rpcclient/rpcclient.c b/source/rpcclient/rpcclient.c index 7477cacb529..09289af4b47 100644 --- a/source/rpcclient/rpcclient.c +++ b/source/rpcclient/rpcclient.c @@ -35,6 +35,7 @@ add_ntl_commands(); add_at_commands(); add_spl_commands(); + add_dfs_commands(); return command_main(argc, argv); } |