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 | 40ff4007c7ea1c1512592c8a0cb3833be2fe97d1 (patch) | |
tree | aa5fbaec09687ce62c380f15822659753fc89483 /source3/rpcclient | |
parent | b065de612caef016876328a3ab8cf842f700921b (diff) | |
download | samba-40ff4007c7ea1c1512592c8a0cb3833be2fe97d1.tar.gz samba-40ff4007c7ea1c1512592c8a0cb3833be2fe97d1.tar.bz2 samba-40ff4007c7ea1c1512592c8a0cb3833be2fe97d1.zip |
Added stubs for SRVSVC and NETLOGON rpcclient commands.
(This used to be commit 3343c9f0d67d98687e5933e1a73c0ff487279160)
Diffstat (limited to 'source3/rpcclient')
-rw-r--r-- | source3/rpcclient/cmd_netlogon.c | 124 | ||||
-rw-r--r-- | source3/rpcclient/cmd_srvsvc.c | 317 | ||||
-rw-r--r-- | source3/rpcclient/rpcclient.c | 46 |
3 files changed, 61 insertions, 426 deletions
diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 93be5f5652..697cf26be1 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/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/source3/rpcclient/cmd_srvsvc.c b/source3/rpcclient/cmd_srvsvc.c index e1d95af381..636e708a09 100644 --- a/source3/rpcclient/cmd_srvsvc.c +++ b/source3/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/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c index dc93c0536b..9d2a0de92d 100644 --- a/source3/rpcclient/rpcclient.c +++ b/source3/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; |