mirror of
https://github.com/samba-team/samba.git
synced 2024-12-25 23:21:54 +03:00
NetServerTransportEnum parsing, client-side and rpcclient "srvtransports" added.
This commit is contained in:
parent
bc5d021916
commit
37f4aac06f
@ -610,6 +610,7 @@ char *skip_unibuf(char *srcbuf, int len);
|
||||
char *uni_strncpy(char *destbuf, const char *srcbuf, int len);
|
||||
uint32 buffer2_to_uint32(const BUFFER2 *str);
|
||||
void buffer2_to_multistr(char *dest, const BUFFER2 *str, size_t maxlen);
|
||||
void buffer4_to_str(char *dest, const BUFFER4 *str, size_t maxlen);
|
||||
|
||||
/*The following definitions come from libsmb/clientgen.c */
|
||||
|
||||
@ -2003,6 +2004,11 @@ BOOL samr_query_dispinfo(struct cli_state *cli, uint16 fnum,
|
||||
|
||||
/*The following definitions come from rpc_client/cli_srvsvc.c */
|
||||
|
||||
BOOL do_srv_net_srv_tprt_enum(struct cli_state *cli, uint16 fnum,
|
||||
char *server_name,
|
||||
uint32 switch_value, SRV_TPRT_INFO_CTR *ctr,
|
||||
uint32 preferred_len,
|
||||
ENUM_HND *hnd);
|
||||
BOOL do_srv_net_srv_conn_enum(struct cli_state *cli, uint16 fnum,
|
||||
char *server_name, char *qual_name,
|
||||
uint32 switch_value, SRV_CONN_INFO_CTR *ctr,
|
||||
@ -2174,6 +2180,7 @@ BOOL make_buffer3_str(BUFFER3 *str, const char *buf, int len);
|
||||
BOOL make_buffer3_hex(BUFFER3 *str, char *buf);
|
||||
BOOL make_buffer3_bytes(BUFFER3 *str, uint8 *buf, int len);
|
||||
BOOL smb_io_buffer3(char *desc, BUFFER3 *buf3, prs_struct *ps, int depth);
|
||||
BOOL make_buffer4_str(BUFFER4 *str, const char *buf, int len);
|
||||
BOOL smb_io_buffer4(char *desc, BUFFER4 *buf4, uint32 buffer, prs_struct *ps, int depth);
|
||||
BOOL init_buffer5(BUFFER5 **str);
|
||||
BOOL clear_buffer5(BUFFER5 **str);
|
||||
@ -2983,6 +2990,21 @@ BOOL make_srv_q_net_conn_enum(SRV_Q_NET_CONN_ENUM *q_n,
|
||||
ENUM_HND *hnd);
|
||||
BOOL srv_io_q_net_conn_enum(char *desc, SRV_Q_NET_CONN_ENUM *q_n, prs_struct *ps, int depth);
|
||||
BOOL srv_io_r_net_conn_enum(char *desc, SRV_R_NET_CONN_ENUM *r_n, prs_struct *ps, int depth);
|
||||
BOOL make_srv_tprt_info0_str(TPRT_INFO_0_STR *tp0,
|
||||
char *trans_name,
|
||||
char *trans_addr, uint32 trans_addr_len,
|
||||
char *addr_name);
|
||||
BOOL make_srv_tprt_info0(TPRT_INFO_0 *tp0,
|
||||
uint32 num_vcs, uint32 trans_addr_len,
|
||||
char *trans_name, char *trans_addr,
|
||||
char *addr_name);
|
||||
BOOL make_srv_q_net_tprt_enum(SRV_Q_NET_TPRT_ENUM *q_n,
|
||||
char *srv_name,
|
||||
uint32 tprt_level, SRV_TPRT_INFO_CTR *ctr,
|
||||
uint32 preferred_len,
|
||||
ENUM_HND *hnd);
|
||||
BOOL srv_io_q_net_tprt_enum(char *desc, SRV_Q_NET_TPRT_ENUM *q_n, prs_struct *ps, int depth);
|
||||
BOOL srv_io_r_net_tprt_enum(char *desc, SRV_R_NET_TPRT_ENUM *r_n, prs_struct *ps, int depth);
|
||||
BOOL make_srv_file_info3_str(FILE_INFO_3_STR *fi3, char *user_name, char *path_name);
|
||||
BOOL make_srv_file_info3(FILE_INFO_3 *fl3,
|
||||
uint32 id, uint32 perms, uint32 num_locks,
|
||||
@ -3272,6 +3294,7 @@ 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);
|
||||
void cmd_srv_enum_tprt(struct client_info *info);
|
||||
void cmd_srv_enum_conn(struct client_info *info);
|
||||
void cmd_srv_enum_shares(struct client_info *info);
|
||||
void cmd_srv_enum_sess(struct client_info *info);
|
||||
@ -3307,6 +3330,12 @@ void display_srv_conn_info_1_ctr(FILE *out_hnd, enum action_type action,
|
||||
SRV_CONN_INFO_1 *ctr);
|
||||
void display_srv_conn_info_ctr(FILE *out_hnd, enum action_type action,
|
||||
SRV_CONN_INFO_CTR *ctr);
|
||||
void display_tprt_info_0(FILE *out_hnd, enum action_type action,
|
||||
TPRT_INFO_0 *info0, TPRT_INFO_0_STR *str0);
|
||||
void display_srv_tprt_info_0_ctr(FILE *out_hnd, enum action_type action,
|
||||
SRV_TPRT_INFO_0 *ctr);
|
||||
void display_srv_tprt_info_ctr(FILE *out_hnd, enum action_type action,
|
||||
SRV_TPRT_INFO_CTR *ctr);
|
||||
void display_share_info_1(FILE *out_hnd, enum action_type action,
|
||||
SH_INFO_1 *info1, SH_INFO_1_STR *str1);
|
||||
void display_share_info_2(FILE *out_hnd, enum action_type action,
|
||||
|
@ -30,6 +30,7 @@
|
||||
#define SRV_NETFILEENUM 0x09
|
||||
#define SRV_NETSESSENUM 0x0c
|
||||
#define SRV_NETSHAREENUM 0x0f
|
||||
#define SRV_NETTRANSPORTENUM 0x1a
|
||||
#define SRV_NET_SRV_GET_INFO 0x15
|
||||
#define SRV_NET_SRV_SET_INFO 0x16
|
||||
#define SRV_NET_REMOTE_TOD 0x1c
|
||||
@ -103,11 +104,11 @@ typedef struct srv_sess_info_ctr_info
|
||||
uint32 switch_value; /* switch value */
|
||||
uint32 ptr_sess_ctr; /* pointer to sess info union */
|
||||
union
|
||||
{
|
||||
{
|
||||
SRV_SESS_INFO_0 info0; /* session info level 0 */
|
||||
SRV_SESS_INFO_1 info1; /* session info level 1 */
|
||||
|
||||
} sess;
|
||||
} sess;
|
||||
|
||||
} SRV_SESS_INFO_CTR;
|
||||
|
||||
@ -209,11 +210,11 @@ typedef struct srv_conn_info_ctr_info
|
||||
uint32 switch_value; /* switch value */
|
||||
uint32 ptr_conn_ctr; /* pointer to conn info union */
|
||||
union
|
||||
{
|
||||
{
|
||||
SRV_CONN_INFO_0 info0; /* connection info level 0 */
|
||||
SRV_CONN_INFO_1 info1; /* connection info level 1 */
|
||||
|
||||
} conn;
|
||||
} conn;
|
||||
|
||||
} SRV_CONN_INFO_CTR;
|
||||
|
||||
@ -250,6 +251,85 @@ typedef struct r_net_conn_enum_info
|
||||
|
||||
} SRV_R_NET_CONN_ENUM;
|
||||
|
||||
/* oops - this is going to take up a *massive* amount of stack. */
|
||||
/* the UNISTR2s already have 1024 uint16 chars in them... */
|
||||
#define MAX_TPRT_ENTRIES 32
|
||||
|
||||
/* TPRT_INFO_0 (pointers to level 0 transport info strings) */
|
||||
typedef struct ptr_tprt_info0
|
||||
{
|
||||
uint32 num_vcs; /* number of clients using transport */
|
||||
uint32 ptr_trans_name; /* pointer to transport name. */
|
||||
uint32 ptr_trans_addr; /* pointer to transport address */
|
||||
uint32 trans_addr_len; /* length of transport address */
|
||||
uint32 ptr_addr_name; /* pointer to network address name. */
|
||||
|
||||
} TPRT_INFO_0;
|
||||
|
||||
/* TPRT_INFO_0_STR (level 0 transport info strings) */
|
||||
typedef struct str_tprt_info0
|
||||
{
|
||||
UNISTR2 uni_trans_name; /* unicode string of transport */
|
||||
BUFFER4 buf_trans_addr; /* buffer for transport address */
|
||||
UNISTR2 uni_addr_name; /* unicode string of network address */
|
||||
|
||||
} TPRT_INFO_0_STR;
|
||||
|
||||
/* SRV_TPRT_INFO_0 */
|
||||
typedef struct srv_tprt_info_0_info
|
||||
{
|
||||
uint32 num_entries_read; /* EntriesRead */
|
||||
uint32 ptr_tprt_info; /* Buffer */
|
||||
uint32 num_entries_read2; /* EntriesRead */
|
||||
|
||||
TPRT_INFO_0 info_0 [MAX_TPRT_ENTRIES]; /* transport entry pointers */
|
||||
TPRT_INFO_0_STR info_0_str[MAX_TPRT_ENTRIES]; /* transport entry strings */
|
||||
|
||||
} SRV_TPRT_INFO_0;
|
||||
|
||||
/* SRV_TPRT_INFO_CTR */
|
||||
typedef struct srv_tprt_info_ctr_info
|
||||
{
|
||||
uint32 switch_value; /* switch value */
|
||||
uint32 ptr_tprt_ctr; /* pointer to tprt info union */
|
||||
union
|
||||
{
|
||||
SRV_TPRT_INFO_0 info0; /* tprtection info level 0 */
|
||||
|
||||
} tprt;
|
||||
|
||||
} SRV_TPRT_INFO_CTR;
|
||||
|
||||
|
||||
/* SRV_Q_NET_TPRT_ENUM */
|
||||
typedef struct q_net_tprt_enum_info
|
||||
{
|
||||
uint32 ptr_srv_name; /* pointer (to server name) */
|
||||
UNISTR2 uni_srv_name; /* server name "\\server" */
|
||||
|
||||
uint32 tprt_level; /* transport level */
|
||||
|
||||
SRV_TPRT_INFO_CTR *ctr;
|
||||
|
||||
uint32 preferred_len; /* preferred maximum length (0xffff ffff) */
|
||||
ENUM_HND enum_hnd;
|
||||
|
||||
} SRV_Q_NET_TPRT_ENUM;
|
||||
|
||||
/* SRV_R_NET_TPRT_ENUM */
|
||||
typedef struct r_net_tprt_enum_info
|
||||
{
|
||||
uint32 tprt_level; /* share level */
|
||||
|
||||
SRV_TPRT_INFO_CTR *ctr;
|
||||
|
||||
uint32 total_entries; /* total number of entries */
|
||||
ENUM_HND enum_hnd;
|
||||
|
||||
uint32 status; /* return status */
|
||||
|
||||
} SRV_R_NET_TPRT_ENUM;
|
||||
|
||||
/* oops - this is going to take up a *massive* amount of stack. */
|
||||
/* the UNISTR2s already have 1024 uint16 chars in them... */
|
||||
#define MAX_SHARE_ENTRIES 128
|
||||
@ -325,11 +405,11 @@ typedef struct srv_share_info_1_info
|
||||
uint32 switch_value; /* switch value */
|
||||
uint32 ptr_share_ctr; /* pointer to share info union */
|
||||
union
|
||||
{
|
||||
{
|
||||
SRV_SHARE_INFO_1 info1; /* share info level 1 */
|
||||
SRV_SHARE_INFO_2 info2; /* share info level 2 */
|
||||
|
||||
} share;
|
||||
} share;
|
||||
|
||||
} SRV_SHARE_INFO_CTR;
|
||||
|
||||
@ -405,10 +485,10 @@ typedef struct srv_file_info_3_info
|
||||
uint32 switch_value; /* switch value */
|
||||
uint32 ptr_file_ctr; /* pointer to file info union */
|
||||
union
|
||||
{
|
||||
{
|
||||
SRV_FILE_INFO_3 info3; /* file info with 0 entries */
|
||||
|
||||
} file;
|
||||
} file;
|
||||
|
||||
} SRV_FILE_INFO_CTR;
|
||||
|
||||
@ -493,11 +573,11 @@ typedef struct srv_info_ctr_info
|
||||
uint32 switch_value; /* switch value */
|
||||
uint32 ptr_srv_ctr; /* pointer to server info */
|
||||
union
|
||||
{
|
||||
{
|
||||
SRV_INFO_102 sv102; /* server info level 102 */
|
||||
SRV_INFO_101 sv101; /* server info level 101 */
|
||||
|
||||
} srv;
|
||||
} srv;
|
||||
|
||||
} SRV_INFO_CTR;
|
||||
|
||||
|
@ -238,3 +238,26 @@ void buffer2_to_multistr(char *dest, const BUFFER2 *str, size_t maxlen)
|
||||
|
||||
*dest = 0;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Convert a buffer4 to space-separated ASCII.
|
||||
********************************************************************/
|
||||
void buffer4_to_str(char *dest, const BUFFER4 *str, size_t maxlen)
|
||||
{
|
||||
char *destend;
|
||||
const uchar *src;
|
||||
size_t len;
|
||||
register uint16 c;
|
||||
|
||||
src = str->buffer;
|
||||
len = MIN(str->buf_len, maxlen);
|
||||
destend = dest + len;
|
||||
|
||||
while (dest < destend)
|
||||
{
|
||||
c = *(src++);
|
||||
*(dest++) = (char)c;
|
||||
}
|
||||
|
||||
*dest = 0;
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ BOOL lsa_open_policy(struct cli_state *cli, uint16 fnum,
|
||||
if (sec_qos)
|
||||
{
|
||||
make_lsa_sec_qos(&qos, 2, 1, 0, 0x20000000);
|
||||
make_q_open_pol(&q_o, 0x5c, 0, 0, &qos);
|
||||
make_q_open_pol(&q_o, 0x5c, 0, 0x02000000, &qos);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -31,6 +31,83 @@
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
/****************************************************************************
|
||||
do a server net tprt enum
|
||||
****************************************************************************/
|
||||
BOOL do_srv_net_srv_tprt_enum(struct cli_state *cli, uint16 fnum,
|
||||
char *server_name,
|
||||
uint32 switch_value, SRV_TPRT_INFO_CTR *ctr,
|
||||
uint32 preferred_len,
|
||||
ENUM_HND *hnd)
|
||||
{
|
||||
prs_struct data;
|
||||
prs_struct rdata;
|
||||
SRV_Q_NET_TPRT_ENUM q_o;
|
||||
BOOL valid_enum = False;
|
||||
|
||||
if (server_name == NULL || ctr == NULL || preferred_len == 0) return False;
|
||||
|
||||
prs_init(&data , 1024, 4, SAFETY_MARGIN, False);
|
||||
prs_init(&rdata, 0 , 4, SAFETY_MARGIN, True );
|
||||
|
||||
/* create and send a MSRPC command with api SRV_NETTPRTENUM */
|
||||
|
||||
DEBUG(4,("SRV Net Server Transport Enum(%s), level %d, enum:%8x\n",
|
||||
server_name, switch_value, get_enum_hnd(hnd)));
|
||||
|
||||
ctr->switch_value = switch_value;
|
||||
ctr->ptr_tprt_ctr = 1;
|
||||
ctr->tprt.info0.num_entries_read = 0;
|
||||
ctr->tprt.info0.ptr_tprt_info = 1;
|
||||
|
||||
/* store the parameters */
|
||||
make_srv_q_net_tprt_enum(&q_o, server_name,
|
||||
switch_value, ctr,
|
||||
preferred_len,
|
||||
hnd);
|
||||
|
||||
/* turn parameters into data stream */
|
||||
srv_io_q_net_tprt_enum("", &q_o, &data, 0);
|
||||
|
||||
/* send the data on \PIPE\ */
|
||||
if (rpc_api_pipe_req(cli, fnum, SRV_NETTRANSPORTENUM, &data, &rdata))
|
||||
{
|
||||
SRV_R_NET_TPRT_ENUM r_o;
|
||||
BOOL p;
|
||||
|
||||
r_o.ctr = ctr;
|
||||
|
||||
srv_io_r_net_tprt_enum("", &r_o, &rdata, 0);
|
||||
p = rdata.offset != 0;
|
||||
|
||||
if (p && r_o.status != 0)
|
||||
{
|
||||
/* report error code */
|
||||
DEBUG(0,("SRV_R_NET_SRV_GET_INFO: %s\n", get_nt_error_msg(r_o.status)));
|
||||
p = 0;
|
||||
}
|
||||
|
||||
if (p && r_o.ctr->switch_value != switch_value)
|
||||
{
|
||||
/* different switch levels. oops. */
|
||||
DEBUG(0,("SRV_R_NET_SRV_TPRT_ENUM: info class %d does not match request %d\n",
|
||||
r_o.ctr->switch_value, switch_value));
|
||||
p = 0;
|
||||
}
|
||||
|
||||
if (p)
|
||||
{
|
||||
/* ok, at last: we're happy. */
|
||||
valid_enum = True;
|
||||
}
|
||||
}
|
||||
|
||||
prs_mem_free(&data );
|
||||
prs_mem_free(&rdata );
|
||||
|
||||
return valid_enum;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
do a server net conn enum
|
||||
****************************************************************************/
|
||||
|
@ -540,11 +540,11 @@ BOOL make_q_query_secret(LSA_Q_QUERY_SECRET *q_q, POLICY_HND *pol)
|
||||
memcpy(&(q_q->pol), pol, sizeof(q_q->pol));
|
||||
|
||||
/* Want secret */
|
||||
q_q->info.ptr_value = 1;
|
||||
q_q->info.ptr_value = 0;
|
||||
q_q->info.value.ptr_secret = 0;
|
||||
|
||||
/* Want last change time */
|
||||
q_q->info.ptr_update = 1;
|
||||
q_q->info.ptr_update = 0;
|
||||
|
||||
/* Don't care about old info */
|
||||
q_q->oldinfo.ptr_value = 0;
|
||||
|
@ -557,6 +557,22 @@ BOOL smb_io_buffer3(char *desc, BUFFER3 *buf3, prs_struct *ps, int depth)
|
||||
return True;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
creates a BUFFER4 structure.
|
||||
********************************************************************/
|
||||
BOOL make_buffer4_str(BUFFER4 *str, const char *buf, int len)
|
||||
{
|
||||
ZERO_STRUCTP(str);
|
||||
|
||||
/* set up string lengths. */
|
||||
str->buf_len = len * 2;
|
||||
|
||||
/* store the string (little endian buffer) */
|
||||
ascii_to_unibuf((char*)str->buffer, buf, str->buf_len);
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
reads or writes a BUFFER4 structure.
|
||||
********************************************************************/
|
||||
|
@ -423,7 +423,8 @@ BOOL make_srv_sess_info0_str(SESS_INFO_0_STR *ss0, char *name)
|
||||
/*******************************************************************
|
||||
reads or writes a structure.
|
||||
********************************************************************/
|
||||
static BOOL srv_io_sess_info0_str(char *desc, SESS_INFO_0_STR *ss0, prs_struct *ps, int depth)
|
||||
static BOOL srv_io_sess_info0_str(char *desc, SESS_INFO_0_STR *ss0,
|
||||
const SESS_INFO_0 *si0, prs_struct *ps, int depth)
|
||||
{
|
||||
if (ss0 == NULL) return False;
|
||||
|
||||
@ -432,7 +433,7 @@ static BOOL srv_io_sess_info0_str(char *desc, SESS_INFO_0_STR *ss0, prs_struct
|
||||
|
||||
prs_align(ps);
|
||||
|
||||
smb_io_unistr2("", &(ss0->uni_name), True, ps, depth);
|
||||
smb_io_unistr2("", &(ss0->uni_name), si0->ptr_name, ps, depth);
|
||||
|
||||
return True;
|
||||
}
|
||||
@ -505,7 +506,9 @@ static BOOL srv_io_srv_sess_info_0(char *desc, SRV_SESS_INFO_0 *ss0, prs_struct
|
||||
for (i = 0; i < num_entries; i++)
|
||||
{
|
||||
prs_grow(ps);
|
||||
srv_io_sess_info0_str("", &(ss0->info_0_str[i]), ps, depth);
|
||||
srv_io_sess_info0_str("", &(ss0->info_0_str[i]),
|
||||
&(ss0->info_0[i]),
|
||||
ps, depth);
|
||||
}
|
||||
|
||||
prs_align(ps);
|
||||
@ -532,7 +535,9 @@ BOOL make_srv_sess_info1_str(SESS_INFO_1_STR *ss1, char *name, char *user)
|
||||
/*******************************************************************
|
||||
reads or writes a structure.
|
||||
********************************************************************/
|
||||
static BOOL srv_io_sess_info1_str(char *desc, SESS_INFO_1_STR *ss1, prs_struct *ps, int depth)
|
||||
static BOOL srv_io_sess_info1_str(char *desc, SESS_INFO_1_STR *ss1,
|
||||
SESS_INFO_1 *si1,
|
||||
prs_struct *ps, int depth)
|
||||
{
|
||||
if (ss1 == NULL) return False;
|
||||
|
||||
@ -541,8 +546,8 @@ static BOOL srv_io_sess_info1_str(char *desc, SESS_INFO_1_STR *ss1, prs_struct
|
||||
|
||||
prs_align(ps);
|
||||
|
||||
smb_io_unistr2("", &(ss1->uni_name), True, ps, depth);
|
||||
smb_io_unistr2("", &(ss1->uni_user), True, ps, depth);
|
||||
smb_io_unistr2("", &(ss1->uni_name), si1->ptr_name, ps, depth);
|
||||
smb_io_unistr2("", &(ss1->uni_user), si1->ptr_user, ps, depth);
|
||||
|
||||
return True;
|
||||
}
|
||||
@ -630,7 +635,9 @@ static BOOL srv_io_srv_sess_info_1(char *desc, SRV_SESS_INFO_1 *ss1, prs_struct
|
||||
for (i = 0; i < num_entries; i++)
|
||||
{
|
||||
prs_grow(ps);
|
||||
srv_io_sess_info1_str("", &(ss1->info_1_str[i]), ps, depth);
|
||||
srv_io_sess_info1_str("", &(ss1->info_1_str[i]),
|
||||
&(ss1->info_1[i]),
|
||||
ps, depth);
|
||||
}
|
||||
|
||||
prs_align(ps);
|
||||
@ -860,7 +867,8 @@ BOOL make_srv_conn_info1_str(CONN_INFO_1_STR *ss1, char *usr_name, char *net_nam
|
||||
/*******************************************************************
|
||||
reads or writes a structure.
|
||||
********************************************************************/
|
||||
static BOOL srv_io_conn_info1_str(char *desc, CONN_INFO_1_STR *ss1, prs_struct *ps, int depth)
|
||||
static BOOL srv_io_conn_info1_str(char *desc, CONN_INFO_1_STR *ss1,
|
||||
CONN_INFO_1 *ci1, prs_struct *ps, int depth)
|
||||
{
|
||||
if (ss1 == NULL) return False;
|
||||
|
||||
@ -869,8 +877,8 @@ static BOOL srv_io_conn_info1_str(char *desc, CONN_INFO_1_STR *ss1, prs_struct
|
||||
|
||||
prs_align(ps);
|
||||
|
||||
smb_io_unistr2("", &(ss1->uni_usr_name), True, ps, depth);
|
||||
smb_io_unistr2("", &(ss1->uni_net_name), True, ps, depth);
|
||||
smb_io_unistr2("", &(ss1->uni_usr_name), ci1->ptr_usr_name, ps, depth);
|
||||
smb_io_unistr2("", &(ss1->uni_net_name), ci1->ptr_net_name, ps, depth);
|
||||
|
||||
return True;
|
||||
}
|
||||
@ -958,7 +966,9 @@ static BOOL srv_io_srv_conn_info_1(char *desc, SRV_CONN_INFO_1 *ss1, prs_struct
|
||||
for (i = 0; i < num_entries; i++)
|
||||
{
|
||||
prs_grow(ps);
|
||||
srv_io_conn_info1_str("", &(ss1->info_1_str[i]), ps, depth);
|
||||
srv_io_conn_info1_str("", &(ss1->info_1_str[i]),
|
||||
&(ss1->info_1[i]),
|
||||
ps, depth);
|
||||
}
|
||||
|
||||
prs_align(ps);
|
||||
@ -1096,6 +1106,252 @@ BOOL srv_io_r_net_conn_enum(char *desc, SRV_R_NET_CONN_ENUM *r_n, prs_struct *p
|
||||
return True;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
makes a TPRT_INFO_0_STR structure
|
||||
********************************************************************/
|
||||
BOOL make_srv_tprt_info0_str(TPRT_INFO_0_STR *tp0,
|
||||
char *trans_name,
|
||||
char *trans_addr, uint32 trans_addr_len,
|
||||
char *addr_name)
|
||||
{
|
||||
if (tp0 == NULL) return False;
|
||||
|
||||
DEBUG(5,("make_srv_tprt_info0_str\n"));
|
||||
|
||||
make_unistr2(&(tp0->uni_trans_name), trans_name, strlen(trans_name)+1);
|
||||
make_buffer4_str(&(tp0->buf_trans_addr), trans_addr, trans_addr_len);
|
||||
make_unistr2(&(tp0->uni_addr_name ), addr_name, strlen(addr_name)+1);
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
reads or writes a structure.
|
||||
********************************************************************/
|
||||
static BOOL srv_io_tprt_info0_str(char *desc, TPRT_INFO_0_STR *tp0,
|
||||
TPRT_INFO_0 *ti0,
|
||||
prs_struct *ps, int depth)
|
||||
{
|
||||
if (tp0 == NULL) return False;
|
||||
|
||||
prs_debug(ps, depth, desc, "srv_io_tprt_info0_str");
|
||||
depth++;
|
||||
|
||||
prs_align(ps);
|
||||
|
||||
smb_io_unistr2("", &(tp0->uni_trans_name), ti0->ptr_trans_name, ps, depth);
|
||||
smb_io_buffer4("", &(tp0->buf_trans_addr), ti0->ptr_trans_addr, ps, depth);
|
||||
smb_io_unistr2("", &(tp0->uni_addr_name ), ti0->ptr_addr_name, ps, depth);
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
makes a TPRT_INFO_0 structure
|
||||
********************************************************************/
|
||||
BOOL make_srv_tprt_info0(TPRT_INFO_0 *tp0,
|
||||
uint32 num_vcs, uint32 trans_addr_len,
|
||||
char *trans_name, char *trans_addr,
|
||||
char *addr_name)
|
||||
{
|
||||
if (tp0 == NULL) return False;
|
||||
|
||||
DEBUG(5,("make_srv_tprt_info0: %s %s\n", trans_name, addr_name));
|
||||
|
||||
tp0->num_vcs = num_vcs;
|
||||
tp0->ptr_trans_name = trans_name != NULL ? 1 : 0;
|
||||
tp0->ptr_trans_addr = trans_addr != NULL ? 1 : 0;
|
||||
tp0->trans_addr_len = trans_addr_len;
|
||||
tp0->ptr_addr_name = addr_name != NULL ? 1 : 0;
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
reads or writes a structure.
|
||||
********************************************************************/
|
||||
static BOOL srv_io_tprt_info0(char *desc, TPRT_INFO_0 *tp0, prs_struct *ps, int depth)
|
||||
{
|
||||
if (tp0 == NULL) return False;
|
||||
|
||||
prs_debug(ps, depth, desc, "srv_io_tprt_info0");
|
||||
depth++;
|
||||
|
||||
prs_align(ps);
|
||||
|
||||
prs_uint32("num_vcs ", ps, depth, &(tp0->num_vcs ));
|
||||
prs_uint32("ptr_trans_name", ps, depth, &(tp0->ptr_trans_name));
|
||||
prs_uint32("ptr_trans_addr", ps, depth, &(tp0->ptr_trans_addr));
|
||||
prs_uint32("trans_addr_len", ps, depth, &(tp0->trans_addr_len));
|
||||
prs_uint32("ptr_addr_name ", ps, depth, &(tp0->ptr_addr_name ));
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
reads or writes a structure.
|
||||
********************************************************************/
|
||||
static BOOL srv_io_srv_tprt_info_0(char *desc, SRV_TPRT_INFO_0 *tp0, prs_struct *ps, int depth)
|
||||
{
|
||||
if (tp0 == NULL) return False;
|
||||
|
||||
prs_debug(ps, depth, desc, "srv_io_srv_tprt_info_0");
|
||||
depth++;
|
||||
|
||||
prs_align(ps);
|
||||
|
||||
prs_uint32("num_entries_read", ps, depth, &(tp0->num_entries_read));
|
||||
prs_uint32("ptr_tprt_info", ps, depth, &(tp0->ptr_tprt_info));
|
||||
|
||||
if (tp0->ptr_tprt_info != 0)
|
||||
{
|
||||
uint32 i;
|
||||
uint32 num_entries = tp0->num_entries_read;
|
||||
if (num_entries > MAX_TPRT_ENTRIES)
|
||||
{
|
||||
num_entries = MAX_TPRT_ENTRIES; /* report this! */
|
||||
}
|
||||
|
||||
prs_uint32("num_entries_read2", ps, depth, &(tp0->num_entries_read2));
|
||||
|
||||
for (i = 0; i < num_entries; i++)
|
||||
{
|
||||
prs_grow(ps);
|
||||
srv_io_tprt_info0("", &(tp0->info_0[i]), ps, depth);
|
||||
}
|
||||
|
||||
for (i = 0; i < num_entries; i++)
|
||||
{
|
||||
prs_grow(ps);
|
||||
srv_io_tprt_info0_str("", &(tp0->info_0_str[i]),
|
||||
&(tp0->info_0[i]),
|
||||
ps, depth);
|
||||
}
|
||||
|
||||
prs_align(ps);
|
||||
}
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
reads or writes a structure.
|
||||
********************************************************************/
|
||||
static BOOL srv_io_srv_tprt_ctr(char *desc, SRV_TPRT_INFO_CTR *ctr, prs_struct *ps, int depth)
|
||||
{
|
||||
if (ctr == NULL) return False;
|
||||
|
||||
prs_debug(ps, depth, desc, "srv_io_srv_tprt_ctr");
|
||||
depth++;
|
||||
|
||||
prs_align(ps);
|
||||
|
||||
prs_uint32("switch_value", ps, depth, &(ctr->switch_value));
|
||||
prs_uint32("ptr_tprt_ctr", ps, depth, &(ctr->ptr_tprt_ctr));
|
||||
|
||||
if (ctr->ptr_tprt_ctr != 0)
|
||||
{
|
||||
switch (ctr->switch_value)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
srv_io_srv_tprt_info_0("", &(ctr->tprt.info0), ps, depth);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
DEBUG(5,("%s no transport info at switch_value %d\n",
|
||||
tab_depth(depth), ctr->switch_value));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
reads or writes a structure.
|
||||
********************************************************************/
|
||||
BOOL make_srv_q_net_tprt_enum(SRV_Q_NET_TPRT_ENUM *q_n,
|
||||
char *srv_name,
|
||||
uint32 tprt_level, SRV_TPRT_INFO_CTR *ctr,
|
||||
uint32 preferred_len,
|
||||
ENUM_HND *hnd)
|
||||
{
|
||||
if (q_n == NULL || ctr == NULL || hnd == NULL) return False;
|
||||
|
||||
q_n->ctr = ctr;
|
||||
|
||||
DEBUG(5,("make_q_net_tprt_enum\n"));
|
||||
|
||||
make_buf_unistr2(&(q_n->uni_srv_name ), &(q_n->ptr_srv_name ), srv_name );
|
||||
|
||||
q_n->tprt_level = tprt_level;
|
||||
q_n->preferred_len = preferred_len;
|
||||
|
||||
memcpy(&(q_n->enum_hnd), hnd, sizeof(*hnd));
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
reads or writes a structure.
|
||||
********************************************************************/
|
||||
BOOL srv_io_q_net_tprt_enum(char *desc, SRV_Q_NET_TPRT_ENUM *q_n, prs_struct *ps, int depth)
|
||||
{
|
||||
if (q_n == NULL) return False;
|
||||
|
||||
prs_debug(ps, depth, desc, "srv_io_q_net_tprt_enum");
|
||||
depth++;
|
||||
|
||||
prs_align(ps);
|
||||
|
||||
prs_uint32("ptr_srv_name ", ps, depth, &(q_n->ptr_srv_name));
|
||||
smb_io_unistr2("", &(q_n->uni_srv_name), q_n->ptr_srv_name, ps, depth);
|
||||
|
||||
prs_align(ps);
|
||||
|
||||
prs_uint32("tprt_level", ps, depth, &(q_n->tprt_level ));
|
||||
|
||||
if (((int)q_n->tprt_level) != -1)
|
||||
{
|
||||
srv_io_srv_tprt_ctr("tprt_ctr", q_n->ctr, ps, depth);
|
||||
}
|
||||
|
||||
prs_uint32("preferred_len", ps, depth, &(q_n->preferred_len));
|
||||
|
||||
smb_io_enum_hnd("enum_hnd", &(q_n->enum_hnd), ps, depth);
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
reads or writes a structure.
|
||||
********************************************************************/
|
||||
BOOL srv_io_r_net_tprt_enum(char *desc, SRV_R_NET_TPRT_ENUM *r_n, prs_struct *ps, int depth)
|
||||
{
|
||||
if (r_n == NULL) return False;
|
||||
|
||||
prs_debug(ps, depth, desc, "srv_io_r_net_tprt_enum");
|
||||
depth++;
|
||||
|
||||
prs_align(ps);
|
||||
|
||||
prs_uint32("tprt_level", ps, depth, &(r_n->tprt_level));
|
||||
|
||||
if (((int)r_n->tprt_level) != -1)
|
||||
{
|
||||
srv_io_srv_tprt_ctr("tprt_ctr", r_n->ctr, ps, depth);
|
||||
}
|
||||
|
||||
prs_uint32("total_entries", ps, depth, &(r_n->total_entries));
|
||||
smb_io_enum_hnd("enum_hnd", &(r_n->enum_hnd), ps, depth);
|
||||
prs_uint32("status ", ps, depth, &(r_n->status));
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
makes a FILE_INFO_3_STR structure
|
||||
********************************************************************/
|
||||
|
@ -343,12 +343,12 @@ void cmd_lsa_query_secret(struct client_info *info)
|
||||
/* lookup domain controller; receive a policy handle */
|
||||
res = res ? lsa_open_policy(smb_cli, nt_pipe_fnum,
|
||||
srv_name,
|
||||
&info->dom.lsa_info_pol, False) : False;
|
||||
&info->dom.lsa_info_pol, True) : False;
|
||||
|
||||
/* lookup domain controller; receive a policy handle */
|
||||
res1 = res ? lsa_open_secret(smb_cli, nt_pipe_fnum,
|
||||
&info->dom.lsa_info_pol,
|
||||
secret_name, 0xf003f, &hnd_secret) : False;
|
||||
secret_name, 0x02000000, &hnd_secret) : False;
|
||||
|
||||
res2 = res1 ? lsa_query_secret(smb_cli, nt_pipe_fnum,
|
||||
&hnd_secret, &enc_secret, &last_update) : False;
|
||||
|
@ -102,6 +102,67 @@ void cmd_srv_query_info(struct client_info *info)
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
server enum transports
|
||||
****************************************************************************/
|
||||
void cmd_srv_enum_tprt(struct client_info *info)
|
||||
{
|
||||
uint16 nt_pipe_fnum;
|
||||
fstring dest_srv;
|
||||
fstring tmp;
|
||||
SRV_TPRT_INFO_CTR ctr;
|
||||
ENUM_HND hnd;
|
||||
uint32 info_level = 0;
|
||||
|
||||
BOOL res = True;
|
||||
|
||||
bzero(&ctr, 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_tprt: server:%s info level: %d\n",
|
||||
dest_srv, (int)info_level));
|
||||
|
||||
DEBUG(5, ("cmd_srv_enum_tprt: smb_cli->fd:%d\n", smb_cli->fd));
|
||||
|
||||
/* open srvsvc session. */
|
||||
res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC, &nt_pipe_fnum) : False;
|
||||
|
||||
hnd.ptr_hnd = 1;
|
||||
hnd.handle = 0;
|
||||
|
||||
/* enumerate transports on server */
|
||||
res = res ? do_srv_net_srv_tprt_enum(smb_cli, nt_pipe_fnum,
|
||||
dest_srv,
|
||||
info_level, &ctr, 0xffffffff, &hnd) : False;
|
||||
|
||||
if (res)
|
||||
{
|
||||
display_srv_tprt_info_ctr(out_hnd, ACTION_HEADER , &ctr);
|
||||
display_srv_tprt_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr);
|
||||
display_srv_tprt_info_ctr(out_hnd, ACTION_FOOTER , &ctr);
|
||||
}
|
||||
|
||||
/* close the session */
|
||||
cli_nt_session_close(smb_cli, nt_pipe_fnum);
|
||||
|
||||
if (res)
|
||||
{
|
||||
DEBUG(5,("cmd_srv_enum_tprt: query succeeded\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG(5,("cmd_srv_enum_tprt: query failed\n"));
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
server enum connections
|
||||
****************************************************************************/
|
||||
|
@ -478,6 +478,117 @@ void display_srv_conn_info_ctr(FILE *out_hnd, enum action_type action,
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
transport info level 0 display function
|
||||
****************************************************************************/
|
||||
void display_tprt_info_0(FILE *out_hnd, enum action_type action,
|
||||
TPRT_INFO_0 *info0, TPRT_INFO_0_STR *str0)
|
||||
{
|
||||
if (info0 == NULL || str0 == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case ACTION_HEADER:
|
||||
{
|
||||
fprintf(out_hnd, "Connection Info Level 0:\n");
|
||||
|
||||
break;
|
||||
}
|
||||
case ACTION_ENUMERATE:
|
||||
{
|
||||
fstring trans_name;
|
||||
fstring trans_addr;
|
||||
fstring addr_name;
|
||||
|
||||
unistr2_to_ascii(trans_name, &str0->uni_trans_name, sizeof(trans_name)-1);
|
||||
buffer4_to_str(trans_addr, &str0->buf_trans_addr, sizeof(trans_addr)-1);
|
||||
unistr2_to_ascii(addr_name, &str0->uni_addr_name, sizeof(addr_name)-1);
|
||||
|
||||
fprintf(out_hnd, "\tnum_vcs :\t%d\n", info0->num_vcs);
|
||||
fprintf(out_hnd, "\ttransport name:\t%s\n", trans_name);
|
||||
fprintf(out_hnd, "\ttransport addr:\t%s\n", trans_addr);
|
||||
fprintf(out_hnd, "\taddress name:\t%s\n", addr_name);
|
||||
|
||||
break;
|
||||
}
|
||||
case ACTION_FOOTER:
|
||||
{
|
||||
fprintf(out_hnd, "\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
transport info level 0 container display function
|
||||
****************************************************************************/
|
||||
void display_srv_tprt_info_0_ctr(FILE *out_hnd, enum action_type action,
|
||||
SRV_TPRT_INFO_0 *ctr)
|
||||
{
|
||||
if (ctr == NULL)
|
||||
{
|
||||
fprintf(out_hnd, "display_srv_tprt_info_0_ctr: unavailable due to an internal error\n");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case ACTION_HEADER:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case ACTION_ENUMERATE:
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ctr->num_entries_read; i++)
|
||||
{
|
||||
display_tprt_info_0(out_hnd, ACTION_HEADER , &(ctr->info_0[i]), &(ctr->info_0_str[i]));
|
||||
display_tprt_info_0(out_hnd, ACTION_ENUMERATE, &(ctr->info_0[i]), &(ctr->info_0_str[i]));
|
||||
display_tprt_info_0(out_hnd, ACTION_FOOTER , &(ctr->info_0[i]), &(ctr->info_0_str[i]));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ACTION_FOOTER:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
transport info container display function
|
||||
****************************************************************************/
|
||||
void display_srv_tprt_info_ctr(FILE *out_hnd, enum action_type action,
|
||||
SRV_TPRT_INFO_CTR *ctr)
|
||||
{
|
||||
if (ctr == NULL || ctr->ptr_tprt_ctr == 0)
|
||||
{
|
||||
fprintf(out_hnd, "display_srv_tprt_info_ctr: unavailable due to an internal error\n");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (ctr->switch_value)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
display_srv_tprt_info_0_ctr(out_hnd, action,
|
||||
&(ctr->tprt.info0));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
fprintf(out_hnd, "display_srv_tprt_info_ctr: Unknown Info Level\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
share info level 1 display function
|
||||
****************************************************************************/
|
||||
|
@ -242,6 +242,12 @@ commands[] =
|
||||
"List shares on a server",
|
||||
{COMPL_NONE, COMPL_NONE}
|
||||
},
|
||||
{
|
||||
"srvtransports",
|
||||
cmd_srv_enum_tprt,
|
||||
"List transports on a server",
|
||||
{COMPL_NONE, COMPL_NONE}
|
||||
},
|
||||
{
|
||||
"srvconnections",
|
||||
cmd_srv_enum_conn,
|
||||
|
Loading…
Reference in New Issue
Block a user