diff options
author | Gerald Carter <jerry@samba.org> | 2001-05-31 17:46:42 +0000 |
---|---|---|
committer | Gerald Carter <jerry@samba.org> | 2001-05-31 17:46:42 +0000 |
commit | 937b9b44b3477ac27046ce03bbc87b251e251ab2 (patch) | |
tree | 519d6a2330bfb81e3726b3e061a9799bc29bb498 | |
parent | 7e9318b084d7fecd70fae58d991483b3d4e4f24a (diff) | |
download | samba-937b9b44b3477ac27046ce03bbc87b251e251ab2.tar.gz samba-937b9b44b3477ac27046ce03bbc87b251e251ab2.tar.xz samba-937b9b44b3477ac27046ce03bbc87b251e251ab2.zip |
sync'in up with HEAD
-rw-r--r-- | source/Makefile.in | 4 | ||||
-rw-r--r-- | source/include/proto.h | 41 | ||||
-rw-r--r-- | source/include/rpc_netlogon.h | 76 | ||||
-rw-r--r-- | source/rpc_parse/parse_net.c | 142 | ||||
-rw-r--r-- | source/rpcclient/cmd_netlogon.c | 106 | ||||
-rw-r--r-- | source/rpcclient/cmd_srvsvc.c | 243 | ||||
-rw-r--r-- | source/rpcclient/rpcclient.c | 69 |
7 files changed, 610 insertions, 71 deletions
diff --git a/source/Makefile.in b/source/Makefile.in index 42cd0f0f442..4bf6d699111 100644 --- a/source/Makefile.in +++ b/source/Makefile.in @@ -126,6 +126,7 @@ 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 \ + libsmb/cli_netlogon.o libsmb/cli_srvsvc.o \ rpc_client/cli_pipe.o RPC_SERVER_OBJ = rpc_server/srv_lsa.o rpc_server/srv_lsa_nt.o \ @@ -243,7 +244,8 @@ SMBPASSWD_OBJ = utils/smbpasswd.o $(PARAM_OBJ) \ $(UBIQX_OBJ) $(RPC_PARSE_OBJ) $(RPC_CLIENT_OBJ) $(LIB_OBJ) RPCCLIENT_OBJ1 = rpcclient/rpcclient.o rpcclient/cmd_spoolss.o \ - rpcclient/cmd_samr.o rpcclient/cmd_lsarpc.o + rpcclient/cmd_samr.o rpcclient/cmd_lsarpc.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/include/proto.h b/source/include/proto.h index 4909f22a4b2..65ab3e83d19 100644 --- a/source/include/proto.h +++ b/source/include/proto.h @@ -763,6 +763,15 @@ uint32 cli_lsa_enum_trust_dom(struct cli_state *cli, TALLOC_CTX *mem_ctx, uint32 *num_domains, char ***domain_names, DOM_SID **domain_sids); +/*The following definitions come from libsmb/cli_netlogon.c */ + +struct cli_state *cli_netlogon_initialise(struct cli_state *cli, + char *system_name, + struct ntuser_creds *creds); +void cli_netlogon_shutdown(struct cli_state *cli); +uint32 cli_netlogon_logon_ctrl2(struct cli_state *cli, TALLOC_CTX *mem_ctx, + uint32 query_level); + /*The following definitions come from libsmb/cli_samr.c */ struct cli_state *cli_samr_initialise(struct cli_state *cli, char *system_name, @@ -905,6 +914,15 @@ uint32 cli_spoolss_deleteprinterdriver ( char *driver ); +/*The following definitions come from libsmb/cli_srvsvc.c */ + +struct cli_state *cli_svrsvc_initialise(struct cli_state *cli, + char *system_name, + struct ntuser_creds *creds); +void cli_srvsvc_shutdown(struct cli_state *cli); +uint32 cli_srvsvc_net_srv_get_info(struct cli_state *cli, TALLOC_CTX *mem_ctx, + uint32 switch_value, SRV_INFO_CTR *ctr); + /*The following definitions come from libsmb/cliconnect.c */ BOOL cli_session_setup(struct cli_state *cli, @@ -2447,10 +2465,21 @@ BOOL prs_uint64(char *name, prs_struct *ps, int depth, UINT64_S *data64); /*The following definitions come from rpc_parse/parse_net.c */ BOOL net_io_q_logon_ctrl2(char *desc, NET_Q_LOGON_CTRL2 *q_l, prs_struct *ps, int depth); -void init_r_logon_ctrl2(NET_R_LOGON_CTRL2 *r_l, uint32 query_level, - uint32 flags, uint32 pdc_status, uint32 logon_attempts, - uint32 tc_status, char *trusted_domain_name); +void init_net_q_logon_ctrl2(NET_Q_LOGON_CTRL2 *q_l, char *srv_name, + uint32 query_level); +void init_net_r_logon_ctrl2(NET_R_LOGON_CTRL2 *r_l, uint32 query_level, + uint32 flags, uint32 pdc_status, + uint32 logon_attempts, uint32 tc_status, + char *trusted_domain_name); BOOL net_io_r_logon_ctrl2(char *desc, NET_R_LOGON_CTRL2 *r_l, prs_struct *ps, int depth); +BOOL net_io_q_logon_ctrl(char *desc, NET_Q_LOGON_CTRL *q_l, prs_struct *ps, + int depth); +void init_net_q_logon_ctrl(NET_Q_LOGON_CTRL *q_l, char *srv_name, + uint32 query_level); +void init_net_r_logon_ctrl(NET_R_LOGON_CTRL *r_l, uint32 query_level, + uint32 flags, uint32 pdc_status); +BOOL net_io_r_logon_ctrl(char *desc, NET_R_LOGON_CTRL *r_l, prs_struct *ps, + int depth); void init_r_trust_dom(NET_R_TRUST_DOM_LIST *r_t, uint32 num_doms, char *dom_name); BOOL net_io_r_trust_dom(char *desc, NET_R_TRUST_DOM_LIST *r_t, prs_struct *ps, int depth); @@ -3800,6 +3829,9 @@ uint32 _wks_query_info(pipes_struct *p, WKS_Q_QUERY_INFO *q_u, WKS_R_QUERY_INFO /*The following definitions come from rpcclient/cmd_lsarpc.c */ +/*The following definitions come from rpcclient/cmd_netlogon.c */ + + /*The following definitions come from rpcclient/cmd_samr.c */ @@ -3808,6 +3840,9 @@ uint32 _wks_query_info(pipes_struct *p, WKS_Q_QUERY_INFO *q_u, WKS_R_QUERY_INFO BOOL get_short_archi(char *short_archi, char *long_archi); void set_drv_info_3_env (DRIVER_INFO_3 *info, const char *arch); +/*The following definitions come from rpcclient/cmd_srvsvc.c */ + + /*The following definitions come from rpcclient/rpcclient.c */ void fetch_domain_sid(struct cli_state *cli); diff --git a/source/include/rpc_netlogon.h b/source/include/rpc_netlogon.h index a0e286d5350..f15cec3ca9a 100644 --- a/source/include/rpc_netlogon.h +++ b/source/include/rpc_netlogon.h @@ -31,6 +31,8 @@ #define NET_REQCHAL 0x04 #define NET_AUTH 0x05 #define NET_SRVPWSET 0x06 +#define NET_SAM_DELTAS 0x07 +#define NET_LOGON_CTRL 0x0c #define NET_AUTH2 0x0f #define NET_LOGON_CTRL2 0x0e #define NET_SAM_SYNC 0x10 @@ -162,25 +164,6 @@ typedef struct net_user_info_3 } NET_USER_INFO_3; -/******************************************************** - Logon Control Query - - query_level 0x1 - pdc status - query_level 0x3 - number of logon attempts. - - ********************************************************/ -/* NET_Q_LOGON_CTRL2 - LSA Netr Logon Control 2*/ -typedef struct net_q_logon_ctrl2_info -{ - uint32 ptr; /* undocumented buffer pointer */ - UNISTR2 uni_server_name; /* server name, starting with two '\'s */ - - uint32 function_code; /* 0x1 */ - uint32 query_level; /* 0x1, 0x3 */ - uint32 switch_value; /* 0x1 */ - -} NET_Q_LOGON_CTRL2; - /* NETLOGON_INFO_1 - pdc status info, i presume */ typedef struct netlogon_1_info { @@ -213,6 +196,59 @@ typedef struct netlogon_3_info } NETLOGON_INFO_3; +/******************************************************** + Logon Control Query + + This is generated by a nltest /bdc_query:DOMAIN + + query_level 0x1, function_code 0x1 + + ********************************************************/ + +/* NET_Q_LOGON_CTRL - LSA Netr Logon Control */ + +typedef struct net_q_logon_ctrl_info +{ + uint32 ptr; + UNISTR2 uni_server_name; + uint32 function_code; + uint32 query_level; +} NET_Q_LOGON_CTRL; + +/* NET_R_LOGON_CTRL - LSA Netr Logon Control */ + +typedef struct net_r_logon_ctrl_info +{ + uint32 switch_value; + uint32 ptr; + + union { + NETLOGON_INFO_1 info1; + } logon; + + uint32 status; +} NET_R_LOGON_CTRL; + +/******************************************************** + Logon Control2 Query + + query_level 0x1 - pdc status + query_level 0x3 - number of logon attempts. + + ********************************************************/ + +/* NET_Q_LOGON_CTRL2 - LSA Netr Logon Control 2 */ +typedef struct net_q_logon_ctrl2_info +{ + uint32 ptr; /* undocumented buffer pointer */ + UNISTR2 uni_server_name; /* server name, starting with two '\'s */ + + uint32 function_code; /* 0x1 */ + uint32 query_level; /* 0x1, 0x3 */ + uint32 switch_value; /* 0x1 */ + +} NET_Q_LOGON_CTRL2; + /******************************************************* Logon Control Response @@ -445,6 +481,4 @@ typedef struct net_r_sam_logoff_info } NET_R_SAM_LOGOFF; - #endif /* _RPC_NETLOGON_H */ - diff --git a/source/rpc_parse/parse_net.c b/source/rpc_parse/parse_net.c index dba1337c0a7..6a50c766772 100644 --- a/source/rpc_parse/parse_net.c +++ b/source/rpc_parse/parse_net.c @@ -217,14 +217,31 @@ BOOL net_io_q_logon_ctrl2(char *desc, NET_Q_LOGON_CTRL2 *q_l, prs_struct *ps, in } /******************************************************************* + Inits an NET_Q_LOGON_CTRL2 structure. +********************************************************************/ + +void init_net_q_logon_ctrl2(NET_Q_LOGON_CTRL2 *q_l, char *srv_name, + uint32 query_level) +{ + DEBUG(5,("init_q_logon_ctrl2\n")); + + q_l->function_code = 0x01; + q_l->query_level = query_level; + q_l->switch_value = 0x01; + + init_unistr2(&q_l->uni_server_name, srv_name, strlen(srv_name) + 1); +} + +/******************************************************************* Inits an NET_R_LOGON_CTRL2 structure. ********************************************************************/ -void init_r_logon_ctrl2(NET_R_LOGON_CTRL2 *r_l, uint32 query_level, - uint32 flags, uint32 pdc_status, uint32 logon_attempts, - uint32 tc_status, char *trusted_domain_name) +void init_net_r_logon_ctrl2(NET_R_LOGON_CTRL2 *r_l, uint32 query_level, + uint32 flags, uint32 pdc_status, + uint32 logon_attempts, uint32 tc_status, + char *trusted_domain_name) { - DEBUG(5,("make_r_logon_ctrl2\n")); + DEBUG(5,("init_r_logon_ctrl2\n")); r_l->switch_value = query_level; /* should only be 0x1 */ @@ -301,6 +318,113 @@ BOOL net_io_r_logon_ctrl2(char *desc, NET_R_LOGON_CTRL2 *r_l, prs_struct *ps, in } /******************************************************************* + Reads or writes an NET_Q_LOGON_CTRL structure. +********************************************************************/ + +BOOL net_io_q_logon_ctrl(char *desc, NET_Q_LOGON_CTRL *q_l, prs_struct *ps, + int depth) +{ + prs_debug(ps, depth, desc, "net_io_q_logon_ctrl"); + depth++; + + if(!prs_align(ps)) + return False; + + if(!prs_uint32("ptr ", ps, depth, &q_l->ptr)) + return False; + + if(!smb_io_unistr2 ("", &q_l->uni_server_name, q_l->ptr, ps, depth)) + return False; + + if(!prs_align(ps)) + return False; + + if(!prs_uint32("function_code", ps, depth, &q_l->function_code)) + return False; + if(!prs_uint32("query_level ", ps, depth, &q_l->query_level)) + return False; + + return True; +} + +/******************************************************************* + Inits an NET_Q_LOGON_CTRL structure. +********************************************************************/ + +void init_net_q_logon_ctrl(NET_Q_LOGON_CTRL *q_l, char *srv_name, + uint32 query_level) +{ + DEBUG(5,("init_q_logon_ctrl\n")); + + q_l->function_code = 0x01; /* ??? */ + q_l->query_level = query_level; + + init_unistr2(&q_l->uni_server_name, srv_name, strlen(srv_name) + 1); +} + +/******************************************************************* + Inits an NET_R_LOGON_CTRL structure. +********************************************************************/ + +void init_net_r_logon_ctrl(NET_R_LOGON_CTRL *r_l, uint32 query_level, + uint32 flags, uint32 pdc_status) +{ + DEBUG(5,("init_r_logon_ctrl\n")); + + r_l->switch_value = query_level; /* should only be 0x1 */ + + switch (query_level) { + case 1: + r_l->ptr = 1; /* undocumented pointer */ + init_netinfo_1(&r_l->logon.info1, flags, pdc_status); + r_l->status = 0; + break; + default: + DEBUG(2,("init_r_logon_ctrl: unsupported switch value %d\n", + r_l->switch_value)); + r_l->ptr = 0; /* undocumented pointer */ + + /* take a guess at an error code... */ + r_l->status = NT_STATUS_INVALID_INFO_CLASS; + break; + } +} + +/******************************************************************* + Reads or writes an NET_R_LOGON_CTRL structure. +********************************************************************/ + +BOOL net_io_r_logon_ctrl(char *desc, NET_R_LOGON_CTRL *r_l, prs_struct *ps, + int depth) +{ + prs_debug(ps, depth, desc, "net_io_r_logon_ctrl"); + depth++; + + if(!prs_uint32("switch_value ", ps, depth, &r_l->switch_value)) + return False; + if(!prs_uint32("ptr ", ps, depth, &r_l->ptr)) + return False; + + if (r_l->ptr != 0) { + switch (r_l->switch_value) { + case 1: + if(!net_io_netinfo_1("", &r_l->logon.info1, ps, depth)) + return False; + break; + default: + DEBUG(2,("net_io_r_logon_ctrl: unsupported switch value %d\n", + r_l->switch_value)); + break; + } + } + + if(!prs_uint32("status ", ps, depth, &r_l->status)) + return False; + + return True; +} + +/******************************************************************* Inits an NET_R_TRUST_DOM_LIST structure. ********************************************************************/ @@ -309,7 +433,7 @@ void init_r_trust_dom(NET_R_TRUST_DOM_LIST *r_t, { int i = 0; - DEBUG(5,("make_r_trust_dom\n")); + DEBUG(5,("init_r_trust_dom\n")); for (i = 0; i < MAX_TRUST_DOMS; i++) { r_t->uni_trust_dom_name[i].uni_str_len = 0; @@ -410,7 +534,7 @@ void init_q_req_chal(NET_Q_REQ_CHAL *q_c, char *logon_srv, char *logon_clnt, DOM_CHAL *clnt_chal) { - DEBUG(5,("make_q_req_chal: %d\n", __LINE__)); + DEBUG(5,("init_q_req_chal: %d\n", __LINE__)); q_c->undoc_buffer = 1; /* don't know what this buffer is */ @@ -419,7 +543,7 @@ void init_q_req_chal(NET_Q_REQ_CHAL *q_c, memcpy(q_c->clnt_chal.data, clnt_chal->data, sizeof(clnt_chal->data)); - DEBUG(5,("make_q_req_chal: %d\n", __LINE__)); + DEBUG(5,("init_q_req_chal: %d\n", __LINE__)); } /******************************************************************* @@ -624,7 +748,7 @@ BOOL net_io_r_auth_2(char *desc, NET_R_AUTH_2 *r_a, prs_struct *ps, int depth) void init_q_srv_pwset(NET_Q_SRV_PWSET *q_s, char *logon_srv, char *acct_name, uint16 sec_chan, char *comp_name, DOM_CRED *cred, char nt_cypher[16]) { - DEBUG(5,("make_q_srv_pwset\n")); + DEBUG(5,("init_q_srv_pwset\n")); init_clnt_info(&q_s->clnt_id, logon_srv, acct_name, sec_chan, comp_name, cred); @@ -736,7 +860,7 @@ void init_id_info1(NET_ID_INFO_1 *id, char *domain_name, unsigned char lm_owf[16]; unsigned char nt_owf[16]; - DEBUG(5,("make_id_info1: %d\n", __LINE__)); + DEBUG(5,("init_id_info1: %d\n", __LINE__)); id->ptr_id_info1 = 1; diff --git a/source/rpcclient/cmd_netlogon.c b/source/rpcclient/cmd_netlogon.c new file mode 100644 index 00000000000..184771a7ad3 --- /dev/null +++ b/source/rpcclient/cmd_netlogon.c @@ -0,0 +1,106 @@ +/* + Unix SMB/Netbios implementation. + 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 + (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" + +extern int DEBUGLEVEL; + +static uint32 cmd_netlogon_logon_ctrl2(struct cli_state *cli, int argc, + char **argv) +{ + uint32 query_level = 1; + TALLOC_CTX *mem_ctx; + uint32 result = NT_STATUS_UNSUCCESSFUL; + + if (argc > 1) { + printf("Usage: %s\n", argv[0]); + return 0; + } + + if (!(mem_ctx = talloc_init())) { + DEBUG(0,("cmd_srvsvc_srv_query_info: talloc_init failed\n")); + goto done; + } + + /* Initialise RPC connection */ + + if (!cli_nt_session_open (cli, PIPE_NETLOGON)) { + DEBUG(0, ("Could not initialize srvsvc pipe!\n")); + goto done; + } + + if ((result = cli_netlogon_logon_ctrl2(cli, mem_ctx, query_level)) + != NT_STATUS_NOPROBLEMO) { + goto done; + } + + /* Display results */ + + done: + return result; +} + +static uint32 cmd_netlogon_logon_ctrl(struct cli_state *cli, int argc, + char **argv) +{ + uint32 query_level = 1; + TALLOC_CTX *mem_ctx; + uint32 result = NT_STATUS_UNSUCCESSFUL; + + if (argc > 1) { + printf("Usage: %s\n", argv[0]); + return 0; + } + + if (!(mem_ctx = talloc_init())) { + DEBUG(0,("cmd_srvsvc_srv_query_info: talloc_init failed\n")); + goto done; + } + + /* Initialise RPC connection */ + + if (!cli_nt_session_open (cli, PIPE_NETLOGON)) { + DEBUG(0, ("Could not initialize srvsvc pipe!\n")); + goto done; + } + +#if 0 + if ((result = cli_netlogon_logon_ctrl(cli, mem_ctx, query_level)) + != NT_STATUS_NOPROBLEMO) { + goto done; + } +#endif + + /* Display results */ + + done: + return result; +} + +/* List of commands exported by this module */ + +struct cmd_set netlogon_commands[] = { + { "NETLOGON", NULL, "" }, + { "logonctrl2", cmd_netlogon_logon_ctrl2, "Logon Control 2" }, + { "logonctrl", cmd_netlogon_logon_ctrl, "Logon Control" }, + { NULL, NULL, NULL } +}; diff --git a/source/rpcclient/cmd_srvsvc.c b/source/rpcclient/cmd_srvsvc.c new file mode 100644 index 00000000000..b804cc383db --- /dev/null +++ b/source/rpcclient/cmd_srvsvc.c @@ -0,0 +1,243 @@ +/* + Unix SMB/Netbios implementation. + Version 2.2 + RPC pipe client + + Copyright (C) Andrew Tridgell 1992-1999 + Copyright (C) Luke Kenneth Casson Leighton 1996 - 1999 + 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 + (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" + +extern int DEBUGLEVEL; + +/* Display server query info */ + +static char *get_server_type_str(uint32 type) +{ + static fstring typestr; + int i; + + if (type == SV_TYPE_ALL) { + fstrcpy(typestr, "All"); + return typestr; + } + + typestr[0] = 0; + + for (i = 0; i < 32; i++) { + if (type & (1 << i)) { + switch (1 << i) { + case SV_TYPE_WORKSTATION: + fstrcat(typestr, "Wk "); + break; + case SV_TYPE_SERVER: + fstrcat(typestr, "Sv "); + break; + case SV_TYPE_SQLSERVER: + fstrcat(typestr, "Sql "); + break; + case SV_TYPE_DOMAIN_CTRL: + fstrcat(typestr, "PDC "); + break; + case SV_TYPE_DOMAIN_BAKCTRL: + fstrcat(typestr, "BDC "); + break; + case SV_TYPE_TIME_SOURCE: + fstrcat(typestr, "Tim "); + break; + case SV_TYPE_AFP: + fstrcat(typestr, "AFP "); + break; + case SV_TYPE_NOVELL: + fstrcat(typestr, "Nov "); + break; + case SV_TYPE_DOMAIN_MEMBER: + fstrcat(typestr, "Dom "); + break; + case SV_TYPE_PRINTQ_SERVER: + fstrcat(typestr, "PrQ "); + break; + case SV_TYPE_DIALIN_SERVER: + fstrcat(typestr, "Din "); + break; + case SV_TYPE_SERVER_UNIX: + fstrcat(typestr, "Unx "); + break; + case SV_TYPE_NT: + fstrcat(typestr, "NT "); + break; + case SV_TYPE_WFW: + fstrcat(typestr, "Wfw "); + break; + case SV_TYPE_SERVER_MFPN: + fstrcat(typestr, "Mfp "); + break; + case SV_TYPE_SERVER_NT: + fstrcat(typestr, "SNT "); + break; + case SV_TYPE_POTENTIAL_BROWSER: + fstrcat(typestr, "PtB "); + break; + case SV_TYPE_BACKUP_BROWSER: + fstrcat(typestr, "BMB "); + break; + case SV_TYPE_MASTER_BROWSER: + fstrcat(typestr, "LMB "); + break; + case SV_TYPE_DOMAIN_MASTER: + fstrcat(typestr, "DMB "); + break; + case SV_TYPE_SERVER_OSF: + fstrcat(typestr, "OSF "); + break; + case SV_TYPE_SERVER_VMS: + fstrcat(typestr, "VMS "); + break; + case SV_TYPE_WIN95_PLUS: + fstrcat(typestr, "W95 "); + break; + case SV_TYPE_ALTERNATE_XPORT: + fstrcat(typestr, "Xpt "); + break; + case SV_TYPE_LOCAL_LIST_ONLY: + fstrcat(typestr, "Dom "); + break; + case SV_TYPE_DOMAIN_ENUM: + fstrcat(typestr, "Loc "); + break; + } + } + } + + i = strlen(typestr) - 1; + + if (typestr[i] == ' ') + typestr[i] = 0; + + return typestr; +} + +static void display_server(char *sname, uint32 type, const char *comment) +{ + printf("\t%-15.15s%-20s %s\n", sname, get_server_type_str(type), + comment); +} + +static void display_srv_info_101(SRV_INFO_101 *sv101) +{ + fstring name; + fstring comment; + + unistr2_to_ascii(name, &sv101->uni_name, sizeof(name) - 1); + unistr2_to_ascii(comment, &sv101->uni_comment, sizeof(comment) - 1); + + display_server(name, sv101->srv_type, comment); + + printf("\tplatform_id :\t%d\n", sv101->platform_id); + printf("\tos version :\t%d.%d\n", sv101->ver_major, + sv101->ver_minor); + + printf("\tserver type :\t0x%x\n", sv101->srv_type); +} + +static void display_srv_info_102(SRV_INFO_102 *sv102) +{ + fstring name; + fstring comment; + fstring usr_path; + + unistr2_to_ascii(name, &sv102->uni_name, sizeof(name) - 1); + unistr2_to_ascii(comment, &sv102->uni_comment, sizeof(comment) - 1); + unistr2_to_ascii(usr_path, &sv102->uni_usr_path, sizeof(usr_path) - 1); + + display_server(name, sv102->srv_type, comment); + + printf("\tplatform_id :\t%d\n", sv102->platform_id); + printf("\tos version :\t%d.%d\n", sv102->ver_major, + sv102->ver_minor); + + printf("\tusers :\t%x\n", sv102->users); + printf("\tdisc, hidden :\t%x, %x\n", sv102->disc, sv102->hidden); + printf("\tannounce, delta :\t%d, %d\n", sv102->announce, + sv102->ann_delta); + printf("\tlicenses :\t%d\n", sv102->licenses); + printf("\tuser path :\t%s\n", usr_path); +} + +/* Server query info */ + +static uint32 cmd_srvsvc_srv_query_info(struct cli_state *cli, int argc, + char **argv) +{ + uint32 info_level = 101; + SRV_INFO_CTR ctr; + TALLOC_CTX *mem_ctx; + uint32 result = NT_STATUS_UNSUCCESSFUL; + + if (argc > 2) { + printf("Usage: %s [infolevel]\n", argv[0]); + return 0; + } + + if (argc == 2) + info_level = atoi(argv[1]); + + if (!(mem_ctx = talloc_init())) { + DEBUG(0,("cmd_srvsvc_srv_query_info: talloc_init failed\n")); + goto done; + } + + /* Initialise RPC connection */ + + if (!cli_nt_session_open (cli, PIPE_SRVSVC)) { + DEBUG(0, ("Could not initialize srvsvc pipe!\n")); + goto done; + } + + if ((result = cli_srvsvc_net_srv_get_info(cli, mem_ctx, info_level, + &ctr) + != NT_STATUS_NOPROBLEMO)) { + goto done; + } + + /* Display results */ + + switch (info_level) { + case 101: + display_srv_info_101(&ctr.srv.sv101); + break; + case 102: + display_srv_info_102(&ctr.srv.sv102); + break; + default: + printf("unsupported info level %d\n", info_level); + break; + } + + done: + return result; +} + +/* List of commands exported by this module */ + +struct cmd_set srvsvc_commands[] = { + { "SRVSVC", NULL, "" }, + { "srvinfo", cmd_srvsvc_srv_query_info, "Server query info" }, + { NULL, NULL, NULL } +}; diff --git a/source/rpcclient/rpcclient.c b/source/rpcclient/rpcclient.c index cc6067b71e5..53d5b40698c 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 ****************************************************************************/ @@ -160,25 +155,6 @@ static void read_authfile ( return; } -static char* next_command ( - char** cmdstr -) -{ - static pstring command; - char *p; - - if (!cmdstr || !(*cmdstr)) - return NULL; - - p = strchr(*cmdstr, ';'); - if (p) - *p = '\0'; - pstrcpy(command, *cmdstr); - *cmdstr = p; - - return command; -} - static void get_username (char *username) { if (getenv("USER")) @@ -323,6 +299,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; @@ -525,6 +519,7 @@ static void usage(char *pname) username, domain, server; + struct cmd_set **cmd_set; charset_initialise(); setlinebuf(stdout); @@ -640,27 +635,26 @@ 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; + fstring cmd; char *p = cmdstr; - while((cmd=next_command(&p)) != NULL) { + while(next_token(&p, cmd, ";", sizeof(fstring))) { process_cmd(&cli, cmd); } @@ -668,6 +662,7 @@ static void usage(char *pname) } /* Loop around accepting commands */ + while(1) { pstring prompt; char *line; |