diff options
author | Tim Potter <tpot@samba.org> | 2001-05-24 00:20:32 +0000 |
---|---|---|
committer | Tim Potter <tpot@samba.org> | 2001-05-24 00:20:32 +0000 |
commit | 3343c9f0d67d98687e5933e1a73c0ff487279160 (patch) | |
tree | 06f74b4a295c36c0f8bb6f352d6c57548baec114 | |
parent | ec64ddac5fa4688b18484d6599b17b8c4bcd34c0 (diff) | |
download | samba-3343c9f0d67d98687e5933e1a73c0ff487279160.tar.gz samba-3343c9f0d67d98687e5933e1a73c0ff487279160.tar.xz samba-3343c9f0d67d98687e5933e1a73c0ff487279160.zip |
Added stubs for SRVSVC and NETLOGON rpcclient commands.
-rw-r--r-- | source/Makefile.in | 6 | ||||
-rw-r--r-- | source/libsmb/cli_netlogon.c | 142 | ||||
-rw-r--r-- | source/libsmb/cli_srvsvc.c | 82 | ||||
-rw-r--r-- | source/rpcclient/cmd_netlogon.c | 124 | ||||
-rw-r--r-- | source/rpcclient/cmd_srvsvc.c | 317 | ||||
-rw-r--r-- | source/rpcclient/rpcclient.c | 46 |
6 files changed, 289 insertions, 428 deletions
diff --git a/source/Makefile.in b/source/Makefile.in index ee96c50e2e5..b5f0676ddcd 100644 --- a/source/Makefile.in +++ b/source/Makefile.in @@ -124,7 +124,8 @@ LIBSMB_OBJ = libsmb/clientgen.o libsmb/cliconnect.o libsmb/clifile.o \ libsmb/passchange.o libsmb/unexpected.o $(RPC_PARSE_OBJ1) LIBMSRPC_OBJ = libsmb/cli_lsarpc.o libsmb/cli_samr.o libsmb/cli_spoolss.o \ - rpc_client/cli_pipe.o nsswitch/winbindd_glue.o + libsmb/cli_netlogon.o libsmb/cli_srvsvc.o \ + rpc_client/cli_pipe.o nsswitch/winbindd_glue.o RPC_SERVER_OBJ = rpc_server/srv_lsa.o rpc_server/srv_lsa_nt.o \ rpc_server/srv_lsa_hnd.o rpc_server/srv_netlog.o rpc_server/srv_netlog_nt.o \ @@ -254,7 +255,8 @@ SMBGROUPEDIT_OBJ = utils/smbgroupedit.o $(GROUPDB_OBJ) $(PARAM_OBJ) \ $(LIBSMB_OBJ) $(PASSDB_OBJ) $(UBIQX_OBJ) $(LIB_OBJ) RPCCLIENT_OBJ1 = rpcclient/rpcclient.o rpcclient/cmd_lsarpc.o \ - rpcclient/cmd_samr.o rpcclient/cmd_spoolss.o + rpcclient/cmd_samr.o rpcclient/cmd_spoolss.o \ + rpcclient/cmd_netlogon.o rpcclient/cmd_srvsvc.o RPCCLIENT_OBJ = $(RPCCLIENT_OBJ1) \ $(PARAM_OBJ) $(LIBSMB_OBJ) $(UBIQX_OBJ) $(LIB_OBJ) \ diff --git a/source/libsmb/cli_netlogon.c b/source/libsmb/cli_netlogon.c new file mode 100644 index 00000000000..ee0ed828293 --- /dev/null +++ b/source/libsmb/cli_netlogon.c @@ -0,0 +1,142 @@ +/* + Unix SMB/Netbios implementation. + Version 1.9. + NT Domain Authentication SMB / MSRPC client + Copyright (C) Andrew Tridgell 1994-2000 + Copyright (C) Luke Kenneth Casson Leighton 1996-2000 + Copyright (C) Tim Potter 2001 + + 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, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +/* Opens a SMB connection to the netlogon pipe */ + +struct cli_state *cli_netlogon_initialise(struct cli_state *cli, + char *system_name, + struct ntuser_creds *creds) +{ + struct in_addr dest_ip; + struct nmb_name calling, called; + fstring dest_host; + extern pstring global_myname; + struct ntuser_creds anon; + + /* Initialise cli_state information */ + + if (!cli_initialise(cli)) { + return NULL; + } + + if (!creds) { + ZERO_STRUCT(anon); + anon.pwd.null_pwd = 1; + creds = &anon; + } + + cli_init_creds(cli, creds); + + /* Establish a SMB connection */ + + if (!resolve_srv_name(system_name, dest_host, &dest_ip)) { + return NULL; + } + + make_nmb_name(&called, dns_to_netbios_name(dest_host), 0x20); + make_nmb_name(&calling, dns_to_netbios_name(global_myname), 0); + + if (!cli_establish_connection(cli, dest_host, &dest_ip, &calling, + &called, "IPC$", "IPC", False, True)) { + return NULL; + } + + /* Open a NT session thingy */ + + if (!cli_nt_session_open(cli, PIPE_NETLOGON)) { + cli_shutdown(cli); + return NULL; + } + + return cli; +} + +/* Shut down a SMB connection to the netlogon pipe */ + +void cli_netlogon_shutdown(struct cli_state *cli) +{ + if (cli->fd != -1) cli_ulogoff(cli); + cli_shutdown(cli); +} + +/*************************************************************************** +Synchronise SAM Database (requires SEC_CHAN_BDC). +****************************************************************************/ +BOOL cli_net_sam_sync(struct cli_state *cli, TALLOC_CTX *mem_ctx, + char *srv_name, uint32 database_id, uint32 *num_deltas, + SAM_DELTA_HDR *hdr_deltas, SAM_DELTA_CTR *deltas) +{ + prs_struct qbuf, rbuf; + NET_Q_SAM_SYNC q; + NET_R_SAM_SYNC r; + uint32 result = NT_STATUS_UNSUCCESSFUL; + DOM_CRED new_clnt_cred; + uint8 sess_key[16]; + + ZERO_STRUCT(q); + ZERO_STRUCT(r); + + /* Initialise parse structures */ + + prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL); + prs_init(&rbuf, 0, mem_ctx, UNMARSHALL); + + /* Initialise input parameters */ + + init_q_sam_sync(&q, srv_name, cli->clnt_name_slash, &new_clnt_cred, + database_id); + + /* Marshall data and send request */ + + if (!net_io_q_sam_sync("", &q, &qbuf, 0) || + !rpc_api_pipe_req(cli, NET_SAM_SYNC, &qbuf, &rbuf)) { + goto done; + } + + r.hdr_deltas = hdr_deltas; + r.deltas = deltas; + + if (!net_io_r_sam_sync("", sess_key, &r, &rbuf, 0)) { + goto done; + } + + if ((result = r.status) != NT_STATUS_NOPROBLEMO) { + goto done; + } + +#if 0 + /* Update the credentials. */ + if (ok && !cli_con_deal_with_creds(con, &(r_s.srv_creds))) + { + *num_deltas = r_s.num_deltas2; + } +#endif + + done: + prs_mem_free(&rbuf); + prs_mem_free(&qbuf); + + return result; +} diff --git a/source/libsmb/cli_srvsvc.c b/source/libsmb/cli_srvsvc.c new file mode 100644 index 00000000000..9d13e949303 --- /dev/null +++ b/source/libsmb/cli_srvsvc.c @@ -0,0 +1,82 @@ +/* + Unix SMB/Netbios implementation. + Version 1.9. + NT Domain Authentication SMB / MSRPC client + Copyright (C) Andrew Tridgell 1994-2000 + Copyright (C) Luke Kenneth Casson Leighton 1996-2000 + Copyright (C) Tim Potter 2001 + + 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, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +/* Opens a SMB connection to the svrsvc pipe */ + +struct cli_state *cli_svrsvc_initialise(struct cli_state *cli, + char *system_name, + struct ntuser_creds *creds) +{ + struct in_addr dest_ip; + struct nmb_name calling, called; + fstring dest_host; + extern pstring global_myname; + struct ntuser_creds anon; + + /* Initialise cli_state information */ + + if (!cli_initialise(cli)) { + return NULL; + } + + if (!creds) { + ZERO_STRUCT(anon); + anon.pwd.null_pwd = 1; + creds = &anon; + } + + cli_init_creds(cli, creds); + + /* Establish a SMB connection */ + + if (!resolve_srv_name(system_name, dest_host, &dest_ip)) { + return NULL; + } + + make_nmb_name(&called, dns_to_netbios_name(dest_host), 0x20); + make_nmb_name(&calling, dns_to_netbios_name(global_myname), 0); + + if (!cli_establish_connection(cli, dest_host, &dest_ip, &calling, + &called, "IPC$", "IPC", False, True)) { + return NULL; + } + + /* Open a NT session thingy */ + + if (!cli_nt_session_open(cli, PIPE_SRVSVC)) { + cli_shutdown(cli); + return NULL; + } + + return cli; +} + +/* Shut down a SMB connection to the srvsvc pipe */ + +void cli_srvsvc_shutdown(struct cli_state *cli) +{ + if (cli->fd != -1) cli_ulogoff(cli); + cli_shutdown(cli); +} diff --git a/source/rpcclient/cmd_netlogon.c b/source/rpcclient/cmd_netlogon.c index 93be5f5652e..697cf26be1c 100644 --- a/source/rpcclient/cmd_netlogon.c +++ b/source/rpcclient/cmd_netlogon.c @@ -1,10 +1,10 @@ /* Unix SMB/Netbios implementation. - Version 1.9. - NT Domain Authentication SMB / MSRPC client - Copyright (C) Andrew Tridgell 1994-1997 - Copyright (C) Luke Kenneth Casson Leighton 1996-1997 - + Version 2.2 + RPC pipe client + + Copyright (C) Tim Potter 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 @@ -20,117 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -#ifdef SYSLOG -#undef SYSLOG -#endif - #include "includes.h" extern int DEBUGLEVEL; -#define DEBUG_TESTING - -extern struct cli_state *smb_cli; - -extern FILE* out_hnd; - - -/**************************************************************************** -experimental nt login. -****************************************************************************/ -void cmd_netlogon_login_test(struct client_info *info) -{ - extern BOOL global_machine_password_needs_changing; - - fstring nt_user_name; - fstring password; - BOOL res = True; - char *nt_password; - unsigned char trust_passwd[16]; - -#if 0 - /* machine account passwords */ - pstring new_mach_pwd; - - /* initialisation */ - new_mach_pwd[0] = 0; -#endif - - if (!next_token(NULL, nt_user_name, NULL, sizeof(nt_user_name))) - { - fstrcpy(nt_user_name, smb_cli->user_name); - if (nt_user_name[0] == 0) - { - fprintf(out_hnd,"ntlogin: must specify username with anonymous connection\n"); - return; - } - } - - if (next_token(NULL, password, NULL, sizeof(password))) - { - nt_password = password; - } - else - { - nt_password = getpass("Enter NT Login password:"); - } - - DEBUG(5,("do_nt_login_test: username %s\n", nt_user_name)); - - res = res ? secrets_fetch_trust_account_password(smb_cli->domain, - trust_passwd, NULL) : False; - -#if 0 - /* check whether the user wants to change their machine password */ - res = res ? trust_account_check(info->dest_ip, info->dest_host, - info->myhostname, smb_cli->domain, - info->mach_acct, new_mach_pwd) : False; -#endif - /* open NETLOGON session. negotiate credentials */ - res = res ? cli_nt_session_open(smb_cli, PIPE_NETLOGON) : False; - - res = res ? cli_nt_setup_creds(smb_cli, trust_passwd) : False; - -#if 0 - /* change the machine password? */ - if (global_machine_password_needs_changing) - { - unsigned char new_trust_passwd[16]; - generate_random_buffer(new_trust_passwd, 16, True); - res = res ? cli_nt_srv_pwset(smb_cli, new_trust_passwd) : False; - - if (res) - { - global_machine_password_needs_changing = !set_trust_account_password(smb_cli->domain, - new_trust_passwd); - } - - memset(new_trust_passwd, 0, 16); - } -#endif - - memset(trust_passwd, 0, 16); - - /* do an NT login */ - res = res ? cli_nt_login_interactive(smb_cli, - smb_cli->domain, nt_user_name, - getuid(), nt_password, - &info->dom.ctr, &info->dom.user_info3) : False; - - /*** clear out the password ***/ - memset(password, 0, sizeof(password)); - - /* ok! you're logged in! do anything you like, then... */ - - /* do an NT logout */ - res = res ? cli_nt_logoff(smb_cli, &info->dom.ctr) : False; - - /* close the session */ - cli_nt_session_close(smb_cli); - - fprintf(out_hnd,"cmd_nt_login: login (%s) test succeeded: %s\n", - nt_user_name, BOOLSTR(res)); -} +/* List of commands exported by this module */ +struct cmd_set netlogon_commands[] = { + { "NETLOGON", NULL, "" }, + { NULL, NULL, NULL } +}; diff --git a/source/rpcclient/cmd_srvsvc.c b/source/rpcclient/cmd_srvsvc.c index e1d95af381f..636e708a09f 100644 --- a/source/rpcclient/cmd_srvsvc.c +++ b/source/rpcclient/cmd_srvsvc.c @@ -1,10 +1,10 @@ /* Unix SMB/Netbios implementation. - Version 1.9. - NT Domain Authentication SMB / MSRPC client - Copyright (C) Andrew Tridgell 1994-1997 - Copyright (C) Luke Kenneth Casson Leighton 1996-1997 - + Version 2.2 + RPC pipe client + + Copyright (C) Tim Potter 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 @@ -20,308 +20,33 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -#ifdef SYSLOG -#undef SYSLOG -#endif - #include "includes.h" extern int DEBUGLEVEL; -#define DEBUG_TESTING +/* Server query info */ -extern struct cli_state *smb_cli; - -extern FILE* out_hnd; - - -/**************************************************************************** -server get info query -****************************************************************************/ -void cmd_srv_query_info(struct client_info *info) +static uint32 cmd_srvsvc_srv_query_info(struct cli_state *cli, int argc, + char **argv) { - fstring dest_srv; - fstring tmp; - SRV_INFO_CTR ctr; uint32 info_level = 101; + SRV_INFO_CTR ctr; + TALLOC_CTX *mem_ctx; - BOOL res = True; - - memset((char *)&ctr, '\0', sizeof(ctr)); - - fstrcpy(dest_srv, "\\\\"); - fstrcat(dest_srv, info->dest_host); - strupper(dest_srv); - - if (next_token(NULL, tmp, NULL, sizeof(tmp)-1)) - { - info_level = (uint32)strtol(tmp, (char**)NULL, 10); - } - - DEBUG(4,("cmd_srv_query_info: server:%s info level: %d\n", - dest_srv, (int)info_level)); - - DEBUG(5, ("cmd_srv_query_info: smb_cli->fd:%d\n", smb_cli->fd)); - - /* open LSARPC session. */ - res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC) : False; - - /* send info level: receive requested info. hopefully. */ - res = res ? do_srv_net_srv_get_info(smb_cli, - dest_srv, info_level, &ctr) : False; - - /* close the session */ - cli_nt_session_close(smb_cli); - - if (res) - { - DEBUG(5,("cmd_srv_query_info: query succeeded\n")); - - display_srv_info_ctr(out_hnd, ACTION_HEADER , &ctr); - display_srv_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr); - display_srv_info_ctr(out_hnd, ACTION_FOOTER , &ctr); - } - else - { - DEBUG(5,("cmd_srv_query_info: query failed\n")); - } -} - -/**************************************************************************** -server enum connections -****************************************************************************/ -void cmd_srv_enum_conn(struct client_info *info) -{ - fstring dest_srv; - fstring qual_srv; - fstring tmp; - SRV_CONN_INFO_CTR ctr; - ENUM_HND hnd; - uint32 info_level = 0; - - BOOL res = True; - - memset((char *)&ctr, '\0', sizeof(ctr)); - - fstrcpy(qual_srv, "\\\\"); - fstrcat(qual_srv, info->myhostname); - strupper(qual_srv); - - fstrcpy(dest_srv, "\\\\"); - fstrcat(dest_srv, info->dest_host); - strupper(dest_srv); - - if (next_token(NULL, tmp, NULL, sizeof(tmp)-1)) - { - info_level = (uint32)strtol(tmp, (char**)NULL, 10); - } - - DEBUG(4,("cmd_srv_enum_conn: server:%s info level: %d\n", - dest_srv, (int)info_level)); - - DEBUG(5, ("cmd_srv_enum_conn: smb_cli->fd:%d\n", smb_cli->fd)); - - /* open srvsvc session. */ - res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC) : False; - - hnd.ptr_hnd = 1; - hnd.handle = 0; - - /* enumerate connections on server */ - res = res ? do_srv_net_srv_conn_enum(smb_cli, - dest_srv, qual_srv, - info_level, &ctr, 0xffffffff, &hnd) : False; - - if (res) - { - display_srv_conn_info_ctr(out_hnd, ACTION_HEADER , &ctr); - display_srv_conn_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr); - display_srv_conn_info_ctr(out_hnd, ACTION_FOOTER , &ctr); - } - - /* close the session */ - cli_nt_session_close(smb_cli); - - if (res) - { - DEBUG(5,("cmd_srv_enum_conn: query succeeded\n")); - } - else - { - DEBUG(5,("cmd_srv_enum_conn: query failed\n")); - } -} - -/**************************************************************************** -server enum shares -****************************************************************************/ -void cmd_srv_enum_shares(struct client_info *info) -{ - fstring dest_srv; - fstring tmp; - SRV_R_NET_SHARE_ENUM r_o; - ENUM_HND hnd; - uint32 info_level = 1; - - BOOL res = True; - - fstrcpy(dest_srv, "\\\\"); - fstrcat(dest_srv, info->dest_host); - strupper(dest_srv); - - if (next_token(NULL, tmp, NULL, sizeof(tmp)-1)) - { - info_level = (uint32)strtol(tmp, (char**)NULL, 10); - } - - DEBUG(4,("cmd_srv_enum_shares: server:%s info level: %d\n", - dest_srv, (int)info_level)); - - DEBUG(5, ("cmd_srv_enum_shares: smb_cli->fd:%d\n", smb_cli->fd)); - - /* open srvsvc session. */ - res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC) : False; - - hnd.ptr_hnd = 0; - hnd.handle = 0; - - /* enumerate shares_files on server */ - res = res ? do_srv_net_srv_share_enum(smb_cli, - dest_srv, - info_level, &r_o, 0xffffffff, &hnd) : False; - - if (res) - { - display_srv_share_info_ctr(out_hnd, ACTION_HEADER , &r_o.ctr); - display_srv_share_info_ctr(out_hnd, ACTION_ENUMERATE, &r_o.ctr); - display_srv_share_info_ctr(out_hnd, ACTION_FOOTER , &r_o.ctr); - free_srv_r_net_share_enum(&r_o); + if (argc > 2) { + printf("Usage: %s [infolevel]\n", argv[0]); + return 0; } - /* close the session */ - cli_nt_session_close(smb_cli); + if (argc == 2) + info_level = atoi(argv[1]); - if (res) - { - DEBUG(5,("cmd_srv_enum_shares: query succeeded\n")); - } - else - { - DEBUG(5,("cmd_srv_enum_shares: query failed\n")); - } + return 0; } -/**************************************************************************** -server enum sessions -****************************************************************************/ -void cmd_srv_enum_sess(struct client_info *info) -{ - fstring dest_srv; - fstring tmp; - SRV_SESS_INFO_CTR ctr; - ENUM_HND hnd; - uint32 info_level = 0; - - BOOL res = True; - - memset((char *)&ctr, '\0', sizeof(ctr)); - - fstrcpy(dest_srv, "\\\\"); - fstrcat(dest_srv, info->dest_host); - strupper(dest_srv); - - if (next_token(NULL, tmp, NULL, sizeof(tmp)-1)) - { - info_level = (uint32)strtol(tmp, (char**)NULL, 10); - } - - DEBUG(4,("cmd_srv_enum_sess: server:%s info level: %d\n", - dest_srv, (int)info_level)); - - DEBUG(5, ("cmd_srv_enum_sess: smb_cli->fd:%d\n", smb_cli->fd)); - - /* open srvsvc session. */ - res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC) : False; - - hnd.ptr_hnd = 1; - hnd.handle = 0; - - /* enumerate sessions on server */ - res = res ? do_srv_net_srv_sess_enum(smb_cli, - dest_srv, NULL, info_level, &ctr, 0x1000, &hnd) : False; - - /* close the session */ - cli_nt_session_close(smb_cli); - - if (res) - { - DEBUG(5,("cmd_srv_enum_sess: query succeeded\n")); - } - else - { - DEBUG(5,("cmd_srv_enum_sess: query failed\n")); - } -} - -/**************************************************************************** -server enum files -****************************************************************************/ -void cmd_srv_enum_files(struct client_info *info) -{ - fstring dest_srv; - fstring tmp; - SRV_FILE_INFO_CTR ctr; - ENUM_HND hnd; - uint32 info_level = 3; - - BOOL res = True; - - memset((char *)&ctr, '\0', sizeof(ctr)); - - fstrcpy(dest_srv, "\\\\"); - fstrcat(dest_srv, info->dest_host); - strupper(dest_srv); - - if (next_token(NULL, tmp, NULL, sizeof(tmp)-1)) - { - info_level = (uint32)strtol(tmp, (char**)NULL, 10); - } - - DEBUG(4,("cmd_srv_enum_files: server:%s info level: %d\n", - dest_srv, (int)info_level)); - - DEBUG(5, ("cmd_srv_enum_files: smb_cli->fd:%d\n", smb_cli->fd)); - - /* open srvsvc session. */ - res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC) : False; - - hnd.ptr_hnd = 1; - hnd.handle = 0; - - /* enumerate files on server */ - res = res ? do_srv_net_srv_file_enum(smb_cli, - dest_srv, NULL, info_level, &ctr, 0x1000, &hnd) : False; - - - if (res) - { - display_srv_file_info_ctr(out_hnd, ACTION_HEADER , &ctr); - display_srv_file_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr); - display_srv_file_info_ctr(out_hnd, ACTION_FOOTER , &ctr); - } - - /* close the session */ - cli_nt_session_close(smb_cli); - - if (res) - { - DEBUG(5,("cmd_srv_enum_files: query succeeded\n")); - } - else - { - DEBUG(5,("cmd_srv_enum_files: query failed\n")); - } -} +/* List of commands exported by this module */ +struct cmd_set srvsvc_commands[] = { + { "SRVSVC", NULL, "" }, + { NULL, NULL, NULL } +}; diff --git a/source/rpcclient/rpcclient.c b/source/rpcclient/rpcclient.c index dc93c0536bb..9d2a0de92d8 100644 --- a/source/rpcclient/rpcclient.c +++ b/source/rpcclient/rpcclient.c @@ -25,20 +25,15 @@ extern int DEBUGLEVEL; extern fstring debugf; -/* Various pipe commands */ -extern struct cmd_set lsarpc_commands[]; -extern struct cmd_set samr_commands[]; -extern struct cmd_set spoolss_commands[]; +DOM_SID domain_sid; /* List to hold groups of commands */ + static struct cmd_list { struct cmd_list *prev, *next; struct cmd_set *cmd_set; } *cmd_list; - -DOM_SID domain_sid; - /**************************************************************************** handle completion of commands for readline ****************************************************************************/ @@ -323,6 +318,24 @@ static struct cmd_set separator_command[] = { }; +/* Various pipe commands */ + +extern struct cmd_set lsarpc_commands[]; +extern struct cmd_set samr_commands[]; +extern struct cmd_set spoolss_commands[]; +extern struct cmd_set netlogon_commands[]; +extern struct cmd_set srvsvc_commands[]; + +static struct cmd_set *rpcclient_command_list[] = { + rpcclient_commands, + lsarpc_commands, + samr_commands, + spoolss_commands, + netlogon_commands, + srvsvc_commands, + NULL +}; + void add_command_set(struct cmd_set *cmd_set) { struct cmd_list *entry; @@ -519,6 +532,7 @@ static void usage(char *pname) username, domain, server; + struct cmd_set **cmd_set; charset_initialise(); setlinebuf(stdout); @@ -634,22 +648,21 @@ static void usage(char *pname) } /* There are no pointers in ntuser_creds struct so zero it out */ + ZERO_STRUCTP (&creds); /* Load command lists */ - add_command_set(rpcclient_commands); - add_command_set(separator_command); - - add_command_set(spoolss_commands); - add_command_set(separator_command); - add_command_set(lsarpc_commands); - add_command_set(separator_command); + cmd_set = rpcclient_command_list; - add_command_set(samr_commands); - add_command_set(separator_command); + while(*cmd_set) { + add_command_set(*cmd_set); + add_command_set(separator_command); + cmd_set++; + } /* Do anything specified with -c */ + if (cmdstr[0]) { char *cmd; char *p = cmdstr; @@ -662,6 +675,7 @@ static void usage(char *pname) } /* Loop around accepting commands */ + while(1) { pstring prompt; char *line; |