summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/Makefile.in12
-rw-r--r--source3/include/proto.h49
-rw-r--r--source3/libsmb/clientgen.c162
-rw-r--r--source3/rpc_client/cli_pipe.c941
-rw-r--r--source3/rpc_client/cli_srvsvc.c20
-rw-r--r--source3/rpc_client/cli_wkssvc.c2
-rw-r--r--source3/rpc_parse/parse_srv.c109
-rw-r--r--source3/rpcclient/cmd_srvsvc.c65
-rw-r--r--source3/rpcclient/rpcclient.c2
9 files changed, 780 insertions, 582 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in
index fe6464b213..125656ba87 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -111,9 +111,15 @@ RPC_PARSE_OBJ = rpc_parse/parse_lsa.o rpc_parse/parse_misc.o \
rpc_parse/parse_samr.o rpc_parse/parse_srv.o \
rpc_parse/parse_wks.o
-RPC_CLIENT_OBJ = rpc_client/cli_login.o rpc_client/cli_netlogon.o \
- rpc_client/cli_pipe.o rpc_client/cli_lsarpc.o \
- rpc_client/cli_wkssvc.o rpc_client/cli_samr.o
+RPC_CLIENT_OBJ = \
+ rpc_client/cli_login.o \
+ rpc_client/cli_netlogon.o \
+ rpc_client/cli_pipe.o \
+ rpc_client/cli_lsarpc.o \
+ rpc_client/cli_wkssvc.o \
+ rpc_client/cli_srvsvc.o \
+ rpc_client/cli_samr.o
+
LOCKING_OBJ = locking/locking.o locking/locking_shm.o locking/locking_slow.o \
locking/shmem.o locking/shmem_sysv.o
diff --git a/source3/include/proto.h b/source3/include/proto.h
index d329961623..e120e5021e 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -403,7 +403,7 @@ BOOL cli_session_request(struct cli_state *cli,
BOOL cli_connect(struct cli_state *cli, char *host, struct in_addr *ip);
BOOL cli_initialise(struct cli_state *cli);
void cli_shutdown(struct cli_state *cli);
-void cli_error(struct cli_state *cli, int *eclass, int *num);
+BOOL cli_error(struct cli_state *cli, uint8 *eclass, uint32 *num);
void cli_sockopt(struct cli_state *cli, char *options);
uint16 cli_setpid(struct cli_state *cli, uint16 pid);
BOOL cli_reestablish_connection(struct cli_state *cli);
@@ -1275,6 +1275,31 @@ BOOL do_samr_query_userinfo(struct cli_state *cli,
POLICY_HND *pol, uint16 switch_value, void* usr);
BOOL do_samr_close(struct cli_state *cli, POLICY_HND *hnd);
+/*The following definitions come from rpc_client/cli_srvsvc.c */
+
+BOOL do_srv_net_srv_conn_enum(struct cli_state *cli,
+ char *server_name, char *qual_name,
+ uint32 switch_value, SRV_CONN_INFO_CTR *ctr,
+ uint32 preferred_len,
+ ENUM_HND *hnd);
+BOOL do_srv_net_srv_sess_enum(struct cli_state *cli,
+ char *server_name, char *qual_name,
+ uint32 switch_value, SRV_SESS_INFO_CTR *ctr,
+ uint32 preferred_len,
+ ENUM_HND *hnd);
+BOOL do_srv_net_srv_share_enum(struct cli_state *cli,
+ char *server_name,
+ uint32 switch_value, SRV_SHARE_INFO_CTR *ctr,
+ uint32 preferred_len,
+ ENUM_HND *hnd);
+BOOL do_srv_net_srv_file_enum(struct cli_state *cli,
+ char *server_name, char *qual_name,
+ uint32 switch_value, SRV_FILE_INFO_CTR *ctr,
+ uint32 preferred_len,
+ ENUM_HND *hnd);
+BOOL do_srv_net_srv_get_info(struct cli_state *cli,
+ char *server_name, uint32 switch_value, SRV_INFO_CTR *ctr);
+
/*The following definitions come from rpc_client/cli_wkssvc.c */
BOOL do_wks_query_info(struct cli_state *cli,
@@ -1668,6 +1693,11 @@ void make_srv_share_info2(SH_INFO_2 *sh2,
char *net_name, uint32 type, char *remark,
uint32 perms, uint32 max_uses, uint32 num_uses,
char *path, char *passwd);
+void make_srv_q_net_share_enum(SRV_Q_NET_SHARE_ENUM *q_n,
+ char *srv_name,
+ uint32 share_level, SRV_SHARE_INFO_CTR *ctr,
+ uint32 preferred_len,
+ ENUM_HND *hnd);
void srv_io_q_net_share_enum(char *desc, SRV_Q_NET_SHARE_ENUM *q_n, prs_struct *ps, int depth);
void srv_io_r_net_share_enum(char *desc, SRV_R_NET_SHARE_ENUM *r_n, prs_struct *ps, int depth);
void make_srv_sess_info0_str(SESS_INFO_0_STR *ss0, char *name);
@@ -1677,6 +1707,11 @@ void make_srv_sess_info1(SESS_INFO_1 *ss1,
char *name, char *user,
uint32 num_opens, uint32 open_time, uint32 idle_time,
uint32 user_flags);
+void make_srv_q_net_sess_enum(SRV_Q_NET_SESS_ENUM *q_n,
+ char *srv_name, char *qual_name,
+ uint32 sess_level, SRV_SESS_INFO_CTR *ctr,
+ uint32 preferred_len,
+ ENUM_HND *hnd);
void srv_io_q_net_sess_enum(char *desc, SRV_Q_NET_SESS_ENUM *q_n, prs_struct *ps, int depth);
void srv_io_r_net_sess_enum(char *desc, SRV_R_NET_SESS_ENUM *r_n, prs_struct *ps, int depth);
void make_srv_conn_info0(CONN_INFO_0 *ss0, uint32 id);
@@ -1685,12 +1720,22 @@ void make_srv_conn_info1(CONN_INFO_1 *ss1,
uint32 id, uint32 type,
uint32 num_opens, uint32 num_users, uint32 open_time,
char *usr_name, char *net_name);
+void make_srv_q_net_conn_enum(SRV_Q_NET_CONN_ENUM *q_n,
+ char *srv_name, char *qual_name,
+ uint32 conn_level, SRV_CONN_INFO_CTR *ctr,
+ uint32 preferred_len,
+ ENUM_HND *hnd);
void srv_io_q_net_conn_enum(char *desc, SRV_Q_NET_CONN_ENUM *q_n, prs_struct *ps, int depth);
void srv_io_r_net_conn_enum(char *desc, SRV_R_NET_CONN_ENUM *r_n, prs_struct *ps, int depth);
void make_srv_file_info3_str(FILE_INFO_3_STR *fi3, char *user_name, char *path_name);
void make_srv_file_info3(FILE_INFO_3 *fl3,
uint32 id, uint32 perms, uint32 num_locks,
char *path_name, char *user_name);
+void make_srv_q_net_file_enum(SRV_Q_NET_FILE_ENUM *q_n,
+ char *srv_name, char *qual_name,
+ uint32 file_level, SRV_FILE_INFO_CTR *ctr,
+ uint32 preferred_len,
+ ENUM_HND *hnd);
void srv_io_q_net_file_enum(char *desc, SRV_Q_NET_FILE_ENUM *q_n, prs_struct *ps, int depth);
void srv_io_r_net_file_enum(char *desc, SRV_R_NET_FILE_ENUM *r_n, prs_struct *ps, int depth);
void make_srv_info_101(SRV_INFO_101 *sv101, uint32 platform_id, char *name,
@@ -1701,6 +1746,8 @@ void make_srv_info_102(SRV_INFO_102 *sv102, uint32 platform_id, char *name,
uint32 srv_type, uint32 users, uint32 disc, uint32 hidden,
uint32 announce, uint32 ann_delta, uint32 licenses,
char *usr_path);
+void make_srv_q_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *srv,
+ char *server_name, uint32 switch_value);
void srv_io_q_net_srv_get_info(char *desc, SRV_Q_NET_SRV_GET_INFO *q_n, prs_struct *ps, int depth);
void make_srv_r_net_srv_get_info(SRV_R_NET_SRV_GET_INFO *srv,
uint32 switch_value, SRV_INFO_CTR *ctr, uint32 status);
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index 81842d920f..4c1690f6f2 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -63,51 +63,61 @@ static char *cli_smb_errstr(struct cli_state *cli)
char *cli_errstr(struct cli_state *cli)
{
- static fstring error_message;
- int errclass;
- int errnum;
- int i;
-
- /*
- * Errors are of three kinds - smb errors,
- * dealt with by cli_smb_errstr, NT errors,
- * whose code is in cli.nt_error, and rap
- * errors, whose error code is in cli.rap_error.
- */
+ static fstring error_message;
+ uint8 errclass;
+ uint32 errnum;
+ int i;
- cli_error(cli, &errclass, &errnum);
- if(errclass != 0)
- return cli_smb_errstr(cli);
+ /*
+ * Errors are of three kinds - smb errors,
+ * dealt with by cli_smb_errstr, NT errors,
+ * whose code is in cli.nt_error, and rap
+ * errors, whose error code is in cli.rap_error.
+ */
- /*
- * Was it an NT error ?
- */
+ cli_error(cli, &errclass, &errnum);
- if(cli->nt_error) {
- char *nt_msg = get_nt_error_msg(cli->nt_error);
+ if (errclass != 0)
+ {
+ return cli_smb_errstr(cli);
+ }
- if(nt_msg == NULL)
- slprintf(error_message, sizeof(fstring) - 1, "NT code %d", cli->nt_error);
- else
- fstrcpy(error_message, nt_msg);
+ /*
+ * Was it an NT error ?
+ */
- return error_message;
- }
+ if (cli->nt_error)
+ {
+ char *nt_msg = get_nt_error_msg(cli->nt_error);
- /*
- * Must have been a rap error.
- */
+ if (nt_msg == NULL)
+ {
+ slprintf(error_message, sizeof(fstring) - 1, "NT code %d", cli->nt_error);
+ }
+ else
+ {
+ fstrcpy(error_message, nt_msg);
+ }
- slprintf(error_message, sizeof(error_message) - 1, "code %d", cli->rap_error);
-
- for(i = 0; rap_errmap[i].message != NULL; i++) {
- if (rap_errmap[i].err == cli->rap_error) {
- fstrcpy( error_message, rap_errmap[i].message);
- break;
- }
- }
-
- return error_message;
+ return error_message;
+ }
+
+ /*
+ * Must have been a rap error.
+ */
+
+ slprintf(error_message, sizeof(error_message) - 1, "code %d", cli->rap_error);
+
+ for (i = 0; rap_errmap[i].message != NULL; i++)
+ {
+ if (rap_errmap[i].err == cli->rap_error)
+ {
+ fstrcpy( error_message, rap_errmap[i].message);
+ break;
+ }
+ }
+
+ return error_message;
}
/****************************************************************************
@@ -262,8 +272,11 @@ static BOOL cli_receive_trans(struct cli_state *cli,int trans,
CVAL(cli->inbuf,smb_com)));
return(False);
}
- if (CVAL(cli->inbuf,smb_rcls) != 0)
+
+ if (cli_error(cli, NULL, NULL))
+ {
return(False);
+ }
/* parse out the lengths */
total_data = SVAL(cli->inbuf,smb_tdrcnt);
@@ -313,8 +326,10 @@ static BOOL cli_receive_trans(struct cli_state *cli,int trans,
CVAL(cli->inbuf,smb_com)));
return(False);
}
- if (CVAL(cli->inbuf,smb_rcls) != 0)
+ if (cli_error(cli, NULL, NULL))
+ {
return(False);
+ }
}
return(True);
@@ -330,7 +345,7 @@ BOOL cli_api_pipe(struct cli_state *cli, char *pipe_name, int pipe_name_len,
char **rparam, uint32 *rparam_count,
char **rdata, uint32 *rdata_count)
{
- if(pipe_name_len == 0)
+ if (pipe_name_len == 0)
pipe_name_len = strlen(pipe_name);
cli_send_trans(cli, SMBtrans,
@@ -602,7 +617,7 @@ BOOL cli_session_setup(struct cli_state *cli,
return False;
}
- if(((passlen == 0) || (passlen == 1)) && (pass[0] == '\0')) {
+ if (((passlen == 0) || (passlen == 1)) && (pass[0] == '\0')) {
/* Null session connect. */
pword[0] = '\0';
} else {
@@ -620,7 +635,8 @@ BOOL cli_session_setup(struct cli_state *cli,
/* send a session setup command */
bzero(cli->outbuf,smb_size);
- if (cli->protocol < PROTOCOL_NT1) {
+ if (cli->protocol < PROTOCOL_NT1)
+ {
set_message(cli->outbuf,10,1 + strlen(user) + passlen,True);
CVAL(cli->outbuf,smb_com) = SMBsesssetupX;
cli_setup_packet(cli);
@@ -636,7 +652,9 @@ BOOL cli_session_setup(struct cli_state *cli,
p += passlen;
pstrcpy(p,user);
strupper(p);
- } else {
+ }
+ else
+ {
set_message(cli->outbuf,13,0,True);
CVAL(cli->outbuf,smb_com) = SMBsesssetupX;
cli_setup_packet(cli);
@@ -648,11 +666,15 @@ BOOL cli_session_setup(struct cli_state *cli,
SIVAL(cli->outbuf,smb_vwv5,cli->sesskey);
SSVAL(cli->outbuf,smb_vwv7,passlen);
SSVAL(cli->outbuf,smb_vwv8,ntpasslen);
+ SSVAL(cli->outbuf,smb_vwv11,CAP_STATUS32);
p = smb_buf(cli->outbuf);
memcpy(p,pword,passlen);
p += SVAL(cli->outbuf,smb_vwv7);
- memcpy(p,ntpass,ntpasslen);
- p += SVAL(cli->outbuf,smb_vwv8);
+ if (ntpasslen != 0)
+ {
+ memcpy(p,ntpass,ntpasslen);
+ p += SVAL(cli->outbuf,smb_vwv8);
+ }
pstrcpy(p,user);
strupper(p);
p = skip_string(p,1);
@@ -1718,12 +1740,12 @@ BOOL cli_oem_change_password(struct cli_state *cli, char *user, char *new_passwo
char *rdata = NULL;
int rprcnt, rdrcnt;
- if(strlen(user) >= sizeof(fstring)-1) {
+ if (strlen(user) >= sizeof(fstring)-1) {
DEBUG(0,("cli_oem_change_password: user name %s is too long.\n", user));
return False;
}
- if(new_pw_len > 512) {
+ if (new_pw_len > 512) {
DEBUG(0,("cli_oem_change_password: new password for user %s is too long.\n", user));
return False;
}
@@ -1775,7 +1797,7 @@ BOOL cli_oem_change_password(struct cli_state *cli, char *user, char *new_passwo
data_len = 532;
- if(cli_send_trans(cli,SMBtrans,
+ if (cli_send_trans(cli,SMBtrans,
PIPE_LANMAN,strlen(PIPE_LANMAN), /* name, length */
0,0, /* fid, flags */
NULL,0,0, /* setup, length, max */
@@ -1787,10 +1809,10 @@ BOOL cli_oem_change_password(struct cli_state *cli, char *user, char *new_passwo
return False;
}
- if(cli_receive_trans(cli,SMBtrans,
+ if (cli_receive_trans(cli,SMBtrans,
&rparam, &rprcnt,
&rdata, &rdrcnt)) {
- if(rparam)
+ if (rparam)
cli->rap_error = SVAL(rparam,0);
}
@@ -1919,9 +1941,9 @@ retry:
return False;
#ifdef WITH_SSL
- if(CVAL(cli->inbuf,0) == 0x83 && CVAL(cli->inbuf,4) == 0x8e){ /* use ssl */
- if(!sslutil_fd_is_ssl(cli->fd)){
- if(sslutil_connect(cli->fd) == 0)
+ if (CVAL(cli->inbuf,0) == 0x83 && CVAL(cli->inbuf,4) == 0x8e){ /* use ssl */
+ if (!sslutil_fd_is_ssl(cli->fd)){
+ if (sslutil_connect(cli->fd) == 0)
goto retry;
}
}
@@ -1947,7 +1969,7 @@ BOOL cli_connect(struct cli_state *cli, char *host, struct in_addr *ip)
fstrcpy(cli->desthost, host);
if (!ip || ip_equal(*ip, ipzero)) {
- if(!resolve_name( cli->desthost, &dest_ip)) {
+ if (!resolve_name( cli->desthost, &dest_ip)) {
return False;
}
} else {
@@ -2007,13 +2029,37 @@ void cli_shutdown(struct cli_state *cli)
memset(cli, 0, sizeof(*cli));
}
+
/****************************************************************************
return error codes for the last packet
****************************************************************************/
-void cli_error(struct cli_state *cli, int *eclass, int *num)
+BOOL cli_error(struct cli_state *cli, uint8 *eclass, uint32 *num)
{
- *eclass = CVAL(cli->inbuf,smb_rcls);
- *num = SVAL(cli->inbuf,smb_err);
+ int flgs2 = SVAL(cli->inbuf,smb_flg2);
+
+ if (eclass) *eclass = 0;
+ if (num ) *num = 0;
+
+ if (flgs2 & FLAGS2_32_BIT_ERROR_CODES)
+ {
+ /* 32 bit error codes detected */
+ uint32 nt_err = IVAL(cli->inbuf,smb_rcls);
+ if (num) *num = nt_err;
+ DEBUG(10,("cli_error: 32 bit codes: code=%08x\n", nt_err));
+ return (IS_BITS_SET_ALL(nt_err, 0xc0000000));
+ }
+ else
+ {
+ /* dos 16 bit error codes detected */
+ char rcls = CVAL(cli->inbuf,smb_rcls);
+ if (rcls != 0)
+ {
+ if (eclass) *eclass = rcls;
+ if (num ) *num = SVAL(cli->inbuf,smb_err);
+ return True;
+ }
+ }
+ return False;
}
/****************************************************************************
diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c
index b178f38a58..0258c1a0e7 100644
--- a/source3/rpc_client/cli_pipe.c
+++ b/source3/rpc_client/cli_pipe.c
@@ -51,62 +51,59 @@ static BOOL rpc_read(struct cli_state *cli,
prs_struct *rdata, uint32 data_to_read,
uint32 rdata_offset)
{
- int size = 0x1630;
- int file_offset = rdata_offset;
- int num_read;
- char *data = rdata->data->data;
- uint32 err;
- uint32 errclass;
- uint32 new_data_size = rdata->data->data_used + data_to_read;
+ int size = 0x1630;
+ int file_offset = rdata_offset;
+ int num_read;
+ char *data = rdata->data->data;
+ uint32 err;
+ uint32 new_data_size = rdata->data->data_used + data_to_read;
- data += rdata_offset;
+ data += rdata_offset;
- file_offset -= rdata_offset;
+ file_offset -= rdata_offset;
- DEBUG(5,("rpc_read: data_to_read: %d data offset: %d file offset: %d\n",
- data_to_read, rdata_offset, file_offset));
+ DEBUG(5,("rpc_read: data_to_read: %d data offset: %d file offset: %d\n",
+ data_to_read, rdata_offset, file_offset));
- if (new_data_size > rdata->data->data_size)
- {
- mem_grow_data(&rdata->data, True, new_data_size, True);
- DEBUG(5,("rpc_read: grow buffer to %d\n", rdata->data->data_used));
- }
+ if (new_data_size > rdata->data->data_size)
+ {
+ mem_grow_data(&rdata->data, True, new_data_size, True);
+ DEBUG(5,("rpc_read: grow buffer to %d\n", rdata->data->data_used));
+ }
- do /* read data using SMBreadX */
- {
- if (size > data_to_read)
- size = data_to_read;
+ do /* read data using SMBreadX */
+ {
+ if (size > data_to_read)
+ size = data_to_read;
- new_data_size = rdata->data->data_used + size;
+ new_data_size = rdata->data->data_used + size;
- if (new_data_size > rdata->data->data_size)
- {
- mem_grow_data(&rdata->data, True, new_data_size, True);
- DEBUG(5,("rpc_read: grow buffer to %d\n", rdata->data->data_used));
- }
+ if (new_data_size > rdata->data->data_size)
+ {
+ mem_grow_data(&rdata->data, True, new_data_size, True);
+ DEBUG(5,("rpc_read: grow buffer to %d\n", rdata->data->data_used));
+ }
- num_read = cli_read(cli, cli->nt_pipe_fnum, data, file_offset + 0x100000, size);
+ num_read = cli_read(cli, cli->nt_pipe_fnum, data, file_offset + 0x100000, size);
- DEBUG(5,("rpc_read: read offset: %d read: %d to read: %d\n",
- file_offset, num_read, data_to_read));
+ DEBUG(5,("rpc_read: read offset: %d read: %d to read: %d\n",
+ file_offset, num_read, data_to_read));
- data_to_read -= num_read;
- file_offset += num_read;
- data += num_read;
+ data_to_read -= num_read;
+ file_offset += num_read;
+ data += num_read;
- cli_error(cli, (int *)&errclass, (int *)&err);
- if (errclass != 0)
- return False;
+ if (cli_error(cli, NULL, &err)) return False;
- } while (num_read > 0 && data_to_read > 0);
- /* && err == (0x80000000 | STATUS_BUFFER_OVERFLOW)); */
+ } while (num_read > 0 && data_to_read > 0);
+ /* && err == (0x80000000 | STATUS_BUFFER_OVERFLOW)); */
- mem_realloc_data(rdata->data, file_offset + rdata_offset);
- rdata->data->offset.end = file_offset + rdata_offset;
+ mem_realloc_data(rdata->data, file_offset + rdata_offset);
+ rdata->data->offset.end = file_offset + rdata_offset;
- DEBUG(5,("rpc_read: data supposedly left to read:0x%x\n", data_to_read));
+ DEBUG(5,("rpc_read: data supposedly left to read:0x%x\n", data_to_read));
- return data_to_read == 0;
+ return data_to_read == 0;
}
/****************************************************************************
@@ -115,27 +112,27 @@ static BOOL rpc_read(struct cli_state *cli,
static BOOL rpc_check_hdr(prs_struct *rdata, uint8 *pkt_type,
BOOL *first, BOOL *last, int *len)
{
- RPC_HDR rhdr;
+ RPC_HDR rhdr;
- DEBUG(5,("rpc_check_hdr: rdata->data->data_used: %d\n", rdata->data->data_used));
+ DEBUG(5,("rpc_check_hdr: rdata->data->data_used: %d\n", rdata->data->data_used));
- smb_io_rpc_hdr ("rpc_hdr ", &rhdr , rdata, 0);
+ smb_io_rpc_hdr ("rpc_hdr ", &rhdr , rdata, 0);
- if (!rdata->offset || rdata->offset != 0x10)
- {
- DEBUG(0,("cli_pipe: error in rpc header\n"));
- return False;
- }
+ if (!rdata->offset || rdata->offset != 0x10)
+ {
+ DEBUG(0,("cli_pipe: error in rpc header\n"));
+ return False;
+ }
- DEBUG(5,("rpc_check_hdr: (after smb_io_rpc_hdr call) rdata->data->data_used: %d\n",
- rdata->data->data_used));
+ DEBUG(5,("rpc_check_hdr: (after smb_io_rpc_hdr call) rdata->data->data_used: %d\n",
+ rdata->data->data_used));
- (*first ) = IS_BITS_SET_ALL(rhdr.flags, RPC_FLG_FIRST);
- (*last ) = IS_BITS_SET_ALL(rhdr.flags, RPC_FLG_LAST );
- (*len ) = rhdr.frag_len - rdata->data->data_used;
- (*pkt_type) = rhdr.pkt_type;
+ (*first ) = IS_BITS_SET_ALL(rhdr.flags, RPC_FLG_FIRST);
+ (*last ) = IS_BITS_SET_ALL(rhdr.flags, RPC_FLG_LAST );
+ (*len ) = rhdr.frag_len - rdata->data->data_used;
+ (*pkt_type) = rhdr.pkt_type;
- return True;
+ return True;
}
/****************************************************************************
@@ -160,128 +157,125 @@ static BOOL rpc_api_pipe(struct cli_state *cli, uint16 cmd,
prs_struct *param , prs_struct *data,
prs_struct *rparam, prs_struct *rdata)
{
- int len;
-
- uint16 setup[2]; /* only need 2 uint16 setup parameters */
- uint32 err;
- uint32 errclass;
- uint8 pkt_type = 0xff;
- BOOL first = True;
- BOOL last = True;
-
- /*
- * Setup the pointers from the incoming.
- */
- char *pparams = param ? param->data->data : NULL;
- int params_len = param ? param->data->data_used : 0;
- char *pdata = data ? data->data->data : NULL;
- int data_len = data ? data->data->data_used : 0;
-
- /*
- * Setup the pointers to the outgoing.
- */
- char **pp_ret_params = rparam ? &rparam->data->data : NULL;
- uint32 *p_ret_params_len = rparam ? &rparam->data->data_used : NULL;
-
- char **pp_ret_data = rdata ? &rdata->data->data : NULL;
- uint32 *p_ret_data_len = rdata ? &rdata->data->data_used : NULL;
-
- /* create setup parameters. */
- setup[0] = cmd;
- setup[1] = cli->nt_pipe_fnum; /* pipe file handle. got this from an SMBOpenX. */
-
- /* send the data: receive a response. */
- if (!cli_api_pipe(cli, "\\PIPE\\\0\0\0", 8,
- setup, 2, 0, /* Setup, length, max */
- pparams, params_len, 0, /* Params, length, max */
- pdata, data_len, 1024, /* data, length, max */
- pp_ret_params, p_ret_params_len, /* return params, len */
- pp_ret_data, p_ret_data_len)) /* return data, len */
- {
- DEBUG(0, ("cli_pipe: return critical error. Error was %s\n", cli_errstr(cli)));
- return False;
- }
-
- if (rdata->data->data == NULL)
- return False;
-
- /**** parse the header: check it's a response record */
-
- rdata->data->offset.start = 0;
- rdata->data->offset.end = rdata->data->data_used;
- rdata->offset = 0;
-
- /* cli_api_pipe does an ordinary Realloc - we have no margins now. */
- rdata->data->margin = 0;
- if(rparam)
- rparam->data->margin = 0;
-
- if (!rpc_check_hdr(rdata, &pkt_type, &first, &last, &len))
- return False;
-
- if (pkt_type == RPC_RESPONSE)
- {
- RPC_HDR_RESP rhdr_resp;
- smb_io_rpc_hdr_resp("rpc_hdr_resp", &rhdr_resp, rdata, 0);
- }
-
- DEBUG(5,("rpc_api_pipe: len left: %d smbtrans read: %d\n",
- len, rdata->data->data_used));
-
- /* check if data to be sent back was too large for one SMB. */
- /* err status is only informational: the _real_ check is on the length */
- if (len > 0) /* || err == (0x80000000 | STATUS_BUFFER_OVERFLOW)) */
- {
- if (!rpc_read(cli, rdata, len, rdata->data->data_used))
- return False;
- }
-
- /* only one rpc fragment, and it has been read */
- if (first && last)
- {
- DEBUG(6,("rpc_api_pipe: fragment first and last both set\n"));
- return True;
- }
-
- while (!last) /* read more fragments until we get the last one */
- {
- RPC_HDR rhdr;
- RPC_HDR_RESP rhdr_resp;
- int num_read;
- prs_struct hps;
-
- prs_init(&hps, 0x18, 4, 0, True);
-
- num_read = cli_read(cli, cli->nt_pipe_fnum, hps.data->data, 0, 0x18);
- DEBUG(5,("rpc_api_pipe: read header (size:%d)\n", num_read));
-
- if (num_read != 0x18)
- return False;
-
- smb_io_rpc_hdr ("rpc_hdr ", &rhdr , &hps, 0);
- smb_io_rpc_hdr_resp("rpc_hdr_resp", &rhdr_resp, &hps, 0);
-
- prs_mem_free(&hps);
-
- cli_error(cli, (int *)&errclass, (int *)&err);
- if (errclass != 0)
- return False;
-
- first = IS_BITS_SET_ALL(rhdr.flags, RPC_FLG_FIRST);
- last = IS_BITS_SET_ALL(rhdr.flags, RPC_FLG_LAST );
-
- if (first)
- {
- DEBUG(0,("rpc_api_pipe: wierd rpc header received\n"));
- return False;
- }
-
- len = rhdr.frag_len - hps.offset;
- if (!rpc_read(cli, rdata, len, rdata->data->data_used))
- return False;
- }
-
- return True;
+ int len;
+
+ uint16 setup[2]; /* only need 2 uint16 setup parameters */
+ uint32 err;
+ uint8 pkt_type = 0xff;
+ BOOL first = True;
+ BOOL last = True;
+
+ /*
+ * Setup the pointers from the incoming.
+ */
+ char *pparams = param ? param->data->data : NULL;
+ int params_len = param ? param->data->data_used : 0;
+ char *pdata = data ? data->data->data : NULL;
+ int data_len = data ? data->data->data_used : 0;
+
+ /*
+ * Setup the pointers to the outgoing.
+ */
+ char **pp_ret_params = rparam ? &rparam->data->data : NULL;
+ uint32 *p_ret_params_len = rparam ? &rparam->data->data_used : NULL;
+
+ char **pp_ret_data = rdata ? &rdata->data->data : NULL;
+ uint32 *p_ret_data_len = rdata ? &rdata->data->data_used : NULL;
+
+ /* create setup parameters. */
+ setup[0] = cmd;
+ setup[1] = cli->nt_pipe_fnum; /* pipe file handle. got this from an SMBOpenX. */
+
+ /* send the data: receive a response. */
+ if (!cli_api_pipe(cli, "\\PIPE\\\0\0\0", 8,
+ setup, 2, 0, /* Setup, length, max */
+ pparams, params_len, 0, /* Params, length, max */
+ pdata, data_len, 1024, /* data, length, max */
+ pp_ret_params, p_ret_params_len, /* return params, len */
+ pp_ret_data, p_ret_data_len)) /* return data, len */
+ {
+ DEBUG(0, ("cli_pipe: return critical error. Error was %s\n", cli_errstr(cli)));
+ return False;
+ }
+
+ if (rdata->data->data == NULL) return False;
+
+ /**** parse the header: check it's a response record */
+
+ rdata->data->offset.start = 0;
+ rdata->data->offset.end = rdata->data->data_used;
+ rdata->offset = 0;
+
+ /* cli_api_pipe does an ordinary Realloc - we have no margins now. */
+ rdata->data->margin = 0;
+ if (rparam) rparam->data->margin = 0;
+
+ if (!rpc_check_hdr(rdata, &pkt_type, &first, &last, &len)) return False;
+
+ if (pkt_type == RPC_RESPONSE)
+ {
+ RPC_HDR_RESP rhdr_resp;
+ smb_io_rpc_hdr_resp("rpc_hdr_resp", &rhdr_resp, rdata, 0);
+ }
+
+ DEBUG(5,("rpc_api_pipe: len left: %d smbtrans read: %d\n",
+ len, rdata->data->data_used));
+
+ /* check if data to be sent back was too large for one SMB. */
+ /* err status is only informational: the _real_ check is on the length */
+ if (len > 0) /* || err == (0x80000000 | STATUS_BUFFER_OVERFLOW)) */
+ {
+ if (!rpc_read(cli, rdata, len, rdata->data->data_used))
+ {
+ return False;
+ }
+ }
+
+ /* only one rpc fragment, and it has been read */
+ if (first && last)
+ {
+ DEBUG(6,("rpc_api_pipe: fragment first and last both set\n"));
+ return True;
+ }
+
+ while (!last) /* read more fragments until we get the last one */
+ {
+ RPC_HDR rhdr;
+ RPC_HDR_RESP rhdr_resp;
+ int num_read;
+ prs_struct hps;
+
+ prs_init(&hps, 0x18, 4, 0, True);
+
+ num_read = cli_read(cli, cli->nt_pipe_fnum, hps.data->data, 0, 0x18);
+ DEBUG(5,("rpc_api_pipe: read header (size:%d)\n", num_read));
+
+ if (num_read != 0x18) return False;
+
+ smb_io_rpc_hdr ("rpc_hdr ", &rhdr , &hps, 0);
+ smb_io_rpc_hdr_resp("rpc_hdr_resp", &rhdr_resp, &hps, 0);
+
+ prs_mem_free(&hps);
+
+ if (cli_error(cli, NULL, &err)) return False;
+
+ first = IS_BITS_SET_ALL(rhdr.flags, RPC_FLG_FIRST);
+ last = IS_BITS_SET_ALL(rhdr.flags, RPC_FLG_LAST );
+
+ if (first)
+ {
+ DEBUG(0,("rpc_api_pipe: wierd rpc header received\n"));
+ return False;
+ }
+
+ len = rhdr.frag_len - hps.offset;
+ if (!rpc_read(cli, rdata, len, rdata->data->data_used))
+ {
+ return False;
+ }
+ }
+
+ return True;
}
/*******************************************************************
@@ -299,65 +293,65 @@ static BOOL create_rpc_bind_req(prs_struct *rhdr,
RPC_IFACE *abstract, RPC_IFACE *transfer,
char *my_name, char *domain)
{
- RPC_HDR_RB hdr_rb;
- RPC_HDR hdr;
- RPC_AUTH_NTLMSSP_REQ ntlmssp_req;
-
- /* create the bind request RPC_HDR_RB */
- make_rpc_hdr_rb(&hdr_rb, 0x1630, 0x1630, 0x0,
- 0x1, 0x0, 0x1, abstract, transfer);
-
- /* stream the bind request data */
- smb_io_rpc_hdr_rb("", &hdr_rb, rhdr_rb, 0);
- mem_realloc_data(rhdr_rb->data, rhdr_rb->offset);
-
- if (auth_req != NULL)
- {
- /*
- * I have a feeling this is broken right now... JRA.
- */
- make_rpc_auth_ntlmssp_req(&ntlmssp_req, "NTLMSSP", 0x1,
- 0x0000b2b3, my_name, domain);
- smb_io_rpc_auth_ntlmssp_req("", &ntlmssp_req, auth_req, 0);
- mem_realloc_data(auth_req->data, auth_req->offset);
- }
-
- /* create the request RPC_HDR */
- make_rpc_hdr(&hdr, RPC_BIND, 0x0, get_rpc_call_id(),
- rhdr_rb->offset + 0x10, auth_req != NULL ? auth_req->offset : 0);
-
- smb_io_rpc_hdr("hdr" , &hdr , rhdr, 0);
- mem_realloc_data(rhdr->data, rhdr->offset);
-
- if (rhdr->data == NULL || rhdr_rb->data == NULL)
- return False;
-
- /***/
- /*** link rpc header, bind acknowledgment and authentication responses ***/
- /***/
-
- rhdr->data->offset.start = 0;
- rhdr->data->offset.end = rhdr->offset;
- rhdr->data->next = rhdr_rb->data;
-
- if (auth_req != NULL)
- {
- rhdr_rb->data->offset.start = rhdr->offset;
- rhdr_rb->data->offset.end = rhdr->offset + rhdr_rb->offset;
- rhdr_rb->data->next = auth_req->data;
-
- auth_req->data->offset.start = rhdr->offset + rhdr_rb->offset;
- auth_req->data->offset.end = rhdr->offset + auth_req->offset + rhdr_rb->offset;
- auth_req->data->next = NULL;
- }
- else
- {
- rhdr_rb->data->offset.start = rhdr->offset;
- rhdr_rb->data->offset.end = rhdr->offset + rhdr_rb->offset;
- rhdr_rb->data->next = NULL;
- }
-
- return True;
+ RPC_HDR_RB hdr_rb;
+ RPC_HDR hdr;
+ RPC_AUTH_NTLMSSP_REQ ntlmssp_req;
+
+ /* create the bind request RPC_HDR_RB */
+ make_rpc_hdr_rb(&hdr_rb, 0x1630, 0x1630, 0x0,
+ 0x1, 0x0, 0x1, abstract, transfer);
+
+ /* stream the bind request data */
+ smb_io_rpc_hdr_rb("", &hdr_rb, rhdr_rb, 0);
+ mem_realloc_data(rhdr_rb->data, rhdr_rb->offset);
+
+ if (auth_req != NULL)
+ {
+ /*
+ * I have a feeling this is broken right now... JRA.
+ */
+ make_rpc_auth_ntlmssp_req(&ntlmssp_req, "NTLMSSP", 0x1,
+ 0x0000b2b3, my_name, domain);
+ smb_io_rpc_auth_ntlmssp_req("", &ntlmssp_req, auth_req, 0);
+ mem_realloc_data(auth_req->data, auth_req->offset);
+ }
+
+ /* create the request RPC_HDR */
+ make_rpc_hdr(&hdr, RPC_BIND, 0x0, get_rpc_call_id(),
+ rhdr_rb->offset + 0x10,
+ auth_req != NULL ? auth_req->offset : 0);
+
+ smb_io_rpc_hdr("hdr" , &hdr , rhdr, 0);
+ mem_realloc_data(rhdr->data, rhdr->offset);
+
+ if (rhdr->data == NULL || rhdr_rb->data == NULL) return False;
+
+ /***/
+ /*** link rpc header, bind acknowledgment and authentication responses ***/
+ /***/
+
+ rhdr->data->offset.start = 0;
+ rhdr->data->offset.end = rhdr->offset;
+ rhdr->data->next = rhdr_rb->data;
+
+ if (auth_req != NULL)
+ {
+ rhdr_rb->data->offset.start = rhdr->offset;
+ rhdr_rb->data->offset.end = rhdr->offset + rhdr_rb->offset;
+ rhdr_rb->data->next = auth_req->data;
+
+ auth_req->data->offset.start = rhdr->offset + rhdr_rb->offset;
+ auth_req->data->offset.end = rhdr->offset + auth_req->offset + rhdr_rb->offset;
+ auth_req->data->next = NULL;
+ }
+ else
+ {
+ rhdr_rb->data->offset.start = rhdr->offset;
+ rhdr_rb->data->offset.end = rhdr->offset + rhdr_rb->offset;
+ rhdr_rb->data->next = NULL;
+ }
+
+ return True;
}
@@ -372,30 +366,29 @@ static BOOL create_rpc_bind_req(prs_struct *rhdr,
static BOOL create_rpc_request(prs_struct *rhdr, uint8 op_num, int data_len)
{
- RPC_HDR_REQ hdr_req;
- RPC_HDR hdr;
+ RPC_HDR_REQ hdr_req;
+ RPC_HDR hdr;
- DEBUG(5,("create_rpc_request: opnum: 0x%x data_len: 0x%x\n",
- op_num, data_len));
+ DEBUG(5,("create_rpc_request: opnum: 0x%x data_len: 0x%x\n",
+ op_num, data_len));
- /* create the rpc header RPC_HDR */
- make_rpc_hdr(&hdr , RPC_REQUEST, RPC_FLG_FIRST | RPC_FLG_LAST,
- get_rpc_call_id(), data_len, 0);
+ /* create the rpc header RPC_HDR */
+ make_rpc_hdr(&hdr , RPC_REQUEST, RPC_FLG_FIRST | RPC_FLG_LAST,
+ get_rpc_call_id(), data_len, 0);
- /* create the rpc request RPC_HDR_REQ */
- make_rpc_hdr_req(&hdr_req, data_len, op_num);
+ /* create the rpc request RPC_HDR_REQ */
+ make_rpc_hdr_req(&hdr_req, data_len, op_num);
- /* stream-time... */
- smb_io_rpc_hdr ("hdr ", &hdr , rhdr, 0);
- smb_io_rpc_hdr_req("hdr_req", &hdr_req, rhdr, 0);
+ /* stream-time... */
+ smb_io_rpc_hdr ("hdr ", &hdr , rhdr, 0);
+ smb_io_rpc_hdr_req("hdr_req", &hdr_req, rhdr, 0);
- if (rhdr->data == NULL || rhdr->offset != 0x18)
- return False;
+ if (rhdr->data == NULL || rhdr->offset != 0x18) return False;
- rhdr->data->offset.start = 0;
- rhdr->data->offset.end = rhdr->offset;
+ rhdr->data->offset.start = 0;
+ rhdr->data->offset.end = rhdr->offset;
- return True;
+ return True;
}
@@ -405,30 +398,30 @@ static BOOL create_rpc_request(prs_struct *rhdr, uint8 op_num, int data_len)
BOOL rpc_api_pipe_req(struct cli_state *cli, uint8 op_num,
prs_struct *data, prs_struct *rdata)
{
- /* fudge this, at the moment: create the header; memcpy the data. oops. */
- prs_struct rparam;
- prs_struct hdr;
- int data_len;
- BOOL ret;
+ /* fudge this, at the moment: create the header; memcpy the data. oops. */
+ prs_struct rparam;
+ prs_struct hdr;
+ int data_len;
+ BOOL ret;
- data_len = data->offset + 0x18;
- data->data->offset.end = data->offset;
+ data_len = data->offset + 0x18;
+ data->data->offset.end = data->offset;
- prs_init(&hdr , data_len, 4, SAFETY_MARGIN, False);
- prs_init(&rparam, 0 , 4, 0 , True );
+ prs_init(&hdr , data_len, 4, SAFETY_MARGIN, False);
+ prs_init(&rparam, 0 , 4, 0 , True );
- create_rpc_request(&hdr, op_num, data_len);
+ create_rpc_request(&hdr, op_num, data_len);
- mem_realloc_data(hdr.data, data_len);
- hdr.data->offset.end = data_len;
- mem_buf_copy(mem_data(&(hdr.data), 0x18), data->data, 0, data->offset);
+ mem_realloc_data(hdr.data, data_len);
+ hdr.data->offset.end = data_len;
+ mem_buf_copy(mem_data(&(hdr.data), 0x18), data->data, 0, data->offset);
- ret = rpc_api_pipe(cli, 0x0026, NULL, &hdr, &rparam, rdata);
+ ret = rpc_api_pipe(cli, 0x0026, NULL, &hdr, &rparam, rdata);
- prs_mem_free(&rparam);
- prs_mem_free(&hdr);
+ prs_mem_free(&rparam);
+ prs_mem_free(&hdr);
- return ret;
+ return ret;
}
@@ -438,44 +431,41 @@ do an rpc bind
static BOOL rpc_pipe_set_hnd_state(struct cli_state *cli, char *pipe_name, uint16 device_state)
{
- BOOL state_set = False;
- char param[2];
- uint16 setup[2]; /* only need 2 uint16 setup parameters */
- char *rparam = NULL;
- char *rdata = NULL;
- uint32 rparam_len, rdata_len;
-
- if (pipe_name == NULL)
- return False;
-
- DEBUG(5,("Set Handle state Pipe[%x]: %s - device state:%x\n",
- cli->nt_pipe_fnum, pipe_name, device_state));
-
- /* create parameters: device state */
- SSVAL(param, 0, device_state);
-
- /* create setup parameters. */
- setup[0] = 0x0001;
- setup[1] = cli->nt_pipe_fnum; /* pipe file handle. got this from an SMBOpenX. */
-
- /* send the data on \PIPE\ */
- if (cli_api_pipe(cli, "\\PIPE\\\0\0\0", 8,
- setup, 2, 0, /* setup, length, max */
- param, 2, 0, /* param, length, max */
- NULL, 0, 1024, /* data, length, max */
- &rparam, &rparam_len, /* return param, length */
- &rdata, &rdata_len)) /* return data, length */
- {
- DEBUG(5, ("Set Handle state: return OK\n"));
- state_set = True;
- }
-
- if(rparam)
- free(rparam);
- if(rdata)
- free(rdata);
-
- return state_set;
+ BOOL state_set = False;
+ char param[2];
+ uint16 setup[2]; /* only need 2 uint16 setup parameters */
+ char *rparam = NULL;
+ char *rdata = NULL;
+ uint32 rparam_len, rdata_len;
+
+ if (pipe_name == NULL) return False;
+
+ DEBUG(5,("Set Handle state Pipe[%x]: %s - device state:%x\n",
+ cli->nt_pipe_fnum, pipe_name, device_state));
+
+ /* create parameters: device state */
+ SSVAL(param, 0, device_state);
+
+ /* create setup parameters. */
+ setup[0] = 0x0001;
+ setup[1] = cli->nt_pipe_fnum; /* pipe file handle. got this from an SMBOpenX. */
+
+ /* send the data on \PIPE\ */
+ if (cli_api_pipe(cli, "\\PIPE\\\0\0\0", 8,
+ setup, 2, 0, /* setup, length, max */
+ param, 2, 0, /* param, length, max */
+ NULL, 0, 1024, /* data, length, max */
+ &rparam, &rparam_len, /* return param, length */
+ &rdata, &rdata_len)) /* return data, length */
+ {
+ DEBUG(5, ("Set Handle state: return OK\n"));
+ state_set = True;
+ }
+
+ if (rparam) free(rparam);
+ if (rdata ) free(rdata );
+
+ return state_set;
}
/****************************************************************************
@@ -484,32 +474,32 @@ static BOOL rpc_pipe_set_hnd_state(struct cli_state *cli, char *pipe_name, uint1
static BOOL valid_pipe_name(char *pipe_name, RPC_IFACE *abstract, RPC_IFACE *transfer)
{
- int pipe_idx = 0;
-
- while (pipe_names[pipe_idx].client_pipe != NULL)
- {
- if (strequal(pipe_name, pipe_names[pipe_idx].client_pipe ))
- {
- DEBUG(5,("Bind Abstract Syntax: "));
- dump_data(5, (char*)&(pipe_names[pipe_idx].abstr_syntax),
- sizeof(pipe_names[pipe_idx].abstr_syntax));
- DEBUG(5,("Bind Transfer Syntax: "));
- dump_data(5, (char*)&(pipe_names[pipe_idx].trans_syntax),
- sizeof(pipe_names[pipe_idx].trans_syntax));
-
- /* copy the required syntaxes out so we can do the right bind */
- memcpy(transfer, &(pipe_names[pipe_idx].trans_syntax),
- sizeof(pipe_names[pipe_idx].trans_syntax));
- memcpy(abstract, &(pipe_names[pipe_idx].abstr_syntax),
- sizeof(pipe_names[pipe_idx].abstr_syntax));
-
- return True;
- }
- pipe_idx++;
- };
-
- DEBUG(5,("Bind RPC Pipe[%s] unsupported\n", pipe_name));
- return False;
+ int pipe_idx = 0;
+
+ while (pipe_names[pipe_idx].client_pipe != NULL)
+ {
+ if (strequal(pipe_name, pipe_names[pipe_idx].client_pipe ))
+ {
+ DEBUG(5,("Bind Abstract Syntax: "));
+ dump_data(5, (char*)&(pipe_names[pipe_idx].abstr_syntax),
+ sizeof(pipe_names[pipe_idx].abstr_syntax));
+ DEBUG(5,("Bind Transfer Syntax: "));
+ dump_data(5, (char*)&(pipe_names[pipe_idx].trans_syntax),
+ sizeof(pipe_names[pipe_idx].trans_syntax));
+
+ /* copy the required syntaxes out so we can do the right bind */
+ memcpy(transfer, &(pipe_names[pipe_idx].trans_syntax),
+ sizeof(pipe_names[pipe_idx].trans_syntax));
+ memcpy(abstract, &(pipe_names[pipe_idx].abstr_syntax),
+ sizeof(pipe_names[pipe_idx].abstr_syntax));
+
+ return True;
+ }
+ pipe_idx++;
+ };
+
+ DEBUG(5,("Bind RPC Pipe[%s] unsupported\n", pipe_name));
+ return False;
}
/****************************************************************************
@@ -518,58 +508,59 @@ static BOOL valid_pipe_name(char *pipe_name, RPC_IFACE *abstract, RPC_IFACE *tra
static BOOL check_bind_response(RPC_HDR_BA *hdr_ba, char *pipe_name, RPC_IFACE *transfer)
{
- int i = 0;
-
- while ((pipe_names[i].client_pipe != NULL))
- {
- DEBUG(6,("bind_rpc_pipe: searching pipe name: client:%s server:%s\n",
- pipe_names[i].client_pipe , pipe_names[i].server_pipe ));
-
- if ((strequal(pipe_name, pipe_names[i].client_pipe )))
- {
- if (strequal(hdr_ba->addr.str, pipe_names[i].server_pipe ))
- {
- DEBUG(5,("bind_rpc_pipe: server pipe_name found: %s\n",
- pipe_names[i].server_pipe ));
- break;
- }
- else
- {
- DEBUG(2,("bind_rpc_pipe: pipe_name %s != expected pipe %s\n",
- pipe_names[i].server_pipe , hdr_ba->addr.str));
- return False;
- }
- }
- else
- {
- i++;
- }
- }
-
- if (pipe_names[i].server_pipe == NULL)
- {
- DEBUG(2,("bind_rpc_pipe: pipe name %s unsupported\n", hdr_ba->addr.str));
- return False;
- }
-
- /* check the transfer syntax */
- if (!((hdr_ba->transfer.version == transfer->version) &&
- (memcmp(hdr_ba->transfer.data, transfer->data,
- sizeof(transfer->version)) ==0)))
- {
- DEBUG(0,("bind_rpc_pipe: transfer syntax differs\n"));
- return False;
- }
-
- /* lkclXXXX only accept one result: check the result(s) */
- if (hdr_ba->res.num_results != 0x1 || hdr_ba->res.result != 0)
- {
- DEBUG(2,("bind_rpc_pipe: bind denied results: %d reason: %x\n",
- hdr_ba->res.num_results, hdr_ba->res.reason));
- }
-
- DEBUG(5,("bind_rpc_pipe: accepted!\n"));
- return True;
+ int i = 0;
+
+ while ((pipe_names[i].client_pipe != NULL))
+ {
+ DEBUG(6,("bind_rpc_pipe: searching pipe name: client:%s server:%s\n",
+ pipe_names[i].client_pipe , pipe_names[i].server_pipe ));
+
+ if ((strequal(pipe_name, pipe_names[i].client_pipe )))
+ {
+ if (strequal(hdr_ba->addr.str, pipe_names[i].server_pipe ))
+ {
+ DEBUG(5,("bind_rpc_pipe: server pipe_name found: %s\n",
+ pipe_names[i].server_pipe ));
+ break;
+ }
+ else
+ {
+ DEBUG(2,("bind_rpc_pipe: pipe_name %s != expected pipe %s\n",
+ pipe_names[i].server_pipe ,
+ hdr_ba->addr.str));
+ return False;
+ }
+ }
+ else
+ {
+ i++;
+ }
+ }
+
+ if (pipe_names[i].server_pipe == NULL)
+ {
+ DEBUG(2,("bind_rpc_pipe: pipe name %s unsupported\n", hdr_ba->addr.str));
+ return False;
+ }
+
+ /* check the transfer syntax */
+ if (!((hdr_ba->transfer.version == transfer->version) &&
+ (memcmp(hdr_ba->transfer.data, transfer->data,
+ sizeof(transfer->version)) ==0)))
+ {
+ DEBUG(0,("bind_rpc_pipe: transfer syntax differs\n"));
+ return False;
+ }
+
+ /* lkclXXXX only accept one result: check the result(s) */
+ if (hdr_ba->res.num_results != 0x1 || hdr_ba->res.result != 0)
+ {
+ DEBUG(2,("bind_rpc_pipe: bind denied results: %d reason: %x\n",
+ hdr_ba->res.num_results, hdr_ba->res.reason));
+ }
+
+ DEBUG(5,("bind_rpc_pipe: accepted!\n"));
+ return True;
}
/****************************************************************************
@@ -579,58 +570,59 @@ do an rpc bind
static BOOL rpc_pipe_bind(struct cli_state *cli, char *pipe_name,
RPC_IFACE *abstract, RPC_IFACE *transfer, BOOL ntlmssp_auth)
{
- prs_struct hdr;
- prs_struct hdr_rb;
- prs_struct auth_req;
- prs_struct data;
- prs_struct rdata;
- prs_struct rparam;
+ prs_struct hdr;
+ prs_struct hdr_rb;
+ prs_struct auth_req;
+ prs_struct data;
+ prs_struct rdata;
+ prs_struct rparam;
- BOOL valid_ack = False;
+ BOOL valid_ack = False;
- if (pipe_name == NULL || abstract == NULL || transfer == NULL)
- return False;
+ if (pipe_name == NULL || abstract == NULL || transfer == NULL)
+ return False;
- DEBUG(5,("Bind RPC Pipe[%x]: %s\n", cli->nt_pipe_fnum, pipe_name));
+ DEBUG(5,("Bind RPC Pipe[%x]: %s\n", cli->nt_pipe_fnum, pipe_name));
- if (!valid_pipe_name(pipe_name, abstract, transfer))
- return False;
+ if (!valid_pipe_name(pipe_name, abstract, transfer)) return False;
- prs_init(&hdr , 0x10 , 4, 0x0 , False);
- prs_init(&hdr_rb , 1024 , 4, SAFETY_MARGIN, False);
- prs_init(&auth_req, ntlmssp_auth ? 1024 : 0, 4, SAFETY_MARGIN, False);
+ prs_init(&hdr , 0x10 , 4, 0x0 , False);
+ prs_init(&hdr_rb , 1024 , 4, SAFETY_MARGIN, False);
+ prs_init(&auth_req, ntlmssp_auth ? 1024 : 0, 4, SAFETY_MARGIN, False);
- prs_init(&rdata , 0 , 4, SAFETY_MARGIN, True );
- prs_init(&rparam, 0 , 4, SAFETY_MARGIN, True );
+ prs_init(&rdata , 0 , 4, SAFETY_MARGIN, True );
+ prs_init(&rparam, 0 , 4, SAFETY_MARGIN, True );
- create_rpc_bind_req(&hdr, &hdr_rb, ntlmssp_auth ? &auth_req : NULL,
- abstract, transfer, global_myname, global_myworkgroup);
+ create_rpc_bind_req(&hdr, &hdr_rb, ntlmssp_auth ? &auth_req : NULL,
+ abstract, transfer, global_myname, global_myworkgroup);
- /* this is a hack due to limitations in rpc_api_pipe */
- prs_init(&data, mem_buf_len(hdr.data), 4, 0x0, False);
- mem_buf_copy(data.data->data, hdr.data, 0, mem_buf_len(hdr.data));
+ /* this is a hack due to limitations in rpc_api_pipe */
+ prs_init(&data, mem_buf_len(hdr.data), 4, 0x0, False);
+ mem_buf_copy(data.data->data, hdr.data, 0, mem_buf_len(hdr.data));
- /* send data on \PIPE\. receive a response */
- if (rpc_api_pipe(cli, 0x0026, NULL, &data, &rparam, &rdata))
- {
- RPC_HDR_BA hdr_ba;
+ /* send data on \PIPE\. receive a response */
+ if (rpc_api_pipe(cli, 0x0026, NULL, &data, &rparam, &rdata))
+ {
+ RPC_HDR_BA hdr_ba;
- DEBUG(5, ("rpc_api_pipe: return OK\n"));
+ DEBUG(5, ("rpc_api_pipe: return OK\n"));
- smb_io_rpc_hdr_ba("", &hdr_ba, &rdata, 0);
+ smb_io_rpc_hdr_ba("", &hdr_ba, &rdata, 0);
- if (rdata.offset != 0)
- valid_ack = check_bind_response(&hdr_ba, pipe_name, transfer);
- }
+ if (rdata.offset != 0)
+ {
+ valid_ack = check_bind_response(&hdr_ba, pipe_name, transfer);
+ }
+ }
- prs_mem_free(&data );
- prs_mem_free(&hdr );
- prs_mem_free(&hdr_rb );
- prs_mem_free(&auth_req);
- prs_mem_free(&rdata );
- prs_mem_free(&rparam );
+ prs_mem_free(&data );
+ prs_mem_free(&hdr );
+ prs_mem_free(&hdr_rb );
+ prs_mem_free(&auth_req);
+ prs_mem_free(&rdata );
+ prs_mem_free(&rparam );
- return valid_ack;
+ return valid_ack;
}
/****************************************************************************
@@ -639,54 +631,55 @@ static BOOL rpc_pipe_bind(struct cli_state *cli, char *pipe_name,
BOOL cli_nt_session_open(struct cli_state *cli, char *pipe_name, BOOL encrypted)
{
- RPC_IFACE abstract;
- RPC_IFACE transfer;
- int fnum;
-
- /******************* open the pipe *****************/
- if ((fnum = cli_open(cli, pipe_name, O_CREAT|O_RDWR, DENY_NONE)) == -1)
- {
- DEBUG(0,("cli_nt_session_open: cli_open failed on pipe %s to machine %s. \
-Error was %s\n", pipe_name, cli->desthost, cli_errstr(cli)));
- return False;
- }
-
- cli->nt_pipe_fnum = (uint16)fnum;
-
- /**************** Set Named Pipe State ***************/
- if (!rpc_pipe_set_hnd_state(cli, pipe_name, 0x4300))
- {
- DEBUG(0,("cli_nt_session_open: pipe hnd state failed. Error was %s\n",
- cli_errstr(cli)));
- cli_close(cli, cli->nt_pipe_fnum);
- return False;
- }
-
- /******************* bind request on pipe *****************/
- if (!rpc_pipe_bind(cli, pipe_name, &abstract, &transfer, encrypted))
- {
- DEBUG(0,("cli_nt_session_open: rpc bind failed. Error was %s\n", cli_errstr(cli)));
- cli_close(cli, cli->nt_pipe_fnum);
- return False;
- }
-
- /*
- * Setup the remote server name prefixed by \ and the machine account name.
- */
-
- fstrcpy(cli->srv_name_slash, "\\\\");
- fstrcat(cli->srv_name_slash, cli->desthost);
- strupper(cli->srv_name_slash);
-
- fstrcpy(cli->clnt_name_slash, "\\\\");
- fstrcat(cli->clnt_name_slash, global_myname);
- strupper(cli->clnt_name_slash);
-
- fstrcpy(cli->mach_acct, global_myname);
- fstrcat(cli->mach_acct, "$");
- strupper(cli->mach_acct);
-
- return True;
+ RPC_IFACE abstract;
+ RPC_IFACE transfer;
+ int fnum;
+
+ /******************* open the pipe *****************/
+ if ((fnum = cli_open(cli, pipe_name, O_CREAT|O_RDWR, DENY_NONE)) == -1)
+ {
+ DEBUG(0,("cli_nt_session_open: cli_open failed on pipe %s to machine %s. Error was %s\n",
+ pipe_name, cli->desthost, cli_errstr(cli)));
+ return False;
+ }
+
+ cli->nt_pipe_fnum = (uint16)fnum;
+
+ /**************** Set Named Pipe State ***************/
+ if (!rpc_pipe_set_hnd_state(cli, pipe_name, 0x4300))
+ {
+ DEBUG(0,("cli_nt_session_open: pipe hnd state failed. Error was %s\n",
+ cli_errstr(cli)));
+ cli_close(cli, cli->nt_pipe_fnum);
+ return False;
+ }
+
+ /******************* bind request on pipe *****************/
+ if (!rpc_pipe_bind(cli, pipe_name, &abstract, &transfer, encrypted))
+ {
+ DEBUG(0,("cli_nt_session_open: rpc bind failed. Error was %s\n",
+ cli_errstr(cli)));
+ cli_close(cli, cli->nt_pipe_fnum);
+ return False;
+ }
+
+ /*
+ * Setup the remote server name prefixed by \ and the machine account name.
+ */
+
+ fstrcpy(cli->srv_name_slash, "\\\\");
+ fstrcat(cli->srv_name_slash, cli->desthost);
+ strupper(cli->srv_name_slash);
+
+ fstrcpy(cli->clnt_name_slash, "\\\\");
+ fstrcat(cli->clnt_name_slash, global_myname);
+ strupper(cli->clnt_name_slash);
+
+ fstrcpy(cli->mach_acct, global_myname);
+ fstrcat(cli->mach_acct, "$");
+ strupper(cli->mach_acct);
+
+ return True;
}
/****************************************************************************
@@ -695,5 +688,5 @@ close the session
void cli_nt_session_close(struct cli_state *cli)
{
- cli_close(cli, cli->nt_pipe_fnum);
+ cli_close(cli, cli->nt_pipe_fnum);
}
diff --git a/source3/rpc_client/cli_srvsvc.c b/source3/rpc_client/cli_srvsvc.c
index dcedeb3a54..d42a2985f0 100644
--- a/source3/rpc_client/cli_srvsvc.c
+++ b/source3/rpc_client/cli_srvsvc.c
@@ -34,7 +34,7 @@ extern int DEBUGLEVEL;
/****************************************************************************
do a server net conn enum
****************************************************************************/
-BOOL do_srv_net_srv_conn_enum(struct cli_state *cli, int t_idx, uint16 fnum,
+BOOL do_srv_net_srv_conn_enum(struct cli_state *cli,
char *server_name, char *qual_name,
uint32 switch_value, SRV_CONN_INFO_CTR *ctr,
uint32 preferred_len,
@@ -70,7 +70,7 @@ BOOL do_srv_net_srv_conn_enum(struct cli_state *cli, int t_idx, uint16 fnum,
srv_io_q_net_conn_enum("", &q_o, &data, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, t_idx, fnum, SRV_NETCONNENUM, &data, &rdata))
+ if (rpc_api_pipe_req(cli, SRV_NETCONNENUM, &data, &rdata))
{
SRV_R_NET_CONN_ENUM r_o;
BOOL p;
@@ -111,7 +111,7 @@ BOOL do_srv_net_srv_conn_enum(struct cli_state *cli, int t_idx, uint16 fnum,
/****************************************************************************
do a server net sess enum
****************************************************************************/
-BOOL do_srv_net_srv_sess_enum(struct cli_state *cli, int t_idx, uint16 fnum,
+BOOL do_srv_net_srv_sess_enum(struct cli_state *cli,
char *server_name, char *qual_name,
uint32 switch_value, SRV_SESS_INFO_CTR *ctr,
uint32 preferred_len,
@@ -147,7 +147,7 @@ BOOL do_srv_net_srv_sess_enum(struct cli_state *cli, int t_idx, uint16 fnum,
srv_io_q_net_sess_enum("", &q_o, &data, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, t_idx, fnum, SRV_NETSESSENUM, &data, &rdata))
+ if (rpc_api_pipe_req(cli, SRV_NETSESSENUM, &data, &rdata))
{
SRV_R_NET_SESS_ENUM r_o;
BOOL p;
@@ -188,7 +188,7 @@ BOOL do_srv_net_srv_sess_enum(struct cli_state *cli, int t_idx, uint16 fnum,
/****************************************************************************
do a server net share enum
****************************************************************************/
-BOOL do_srv_net_srv_share_enum(struct cli_state *cli, int t_idx, uint16 fnum,
+BOOL do_srv_net_srv_share_enum(struct cli_state *cli,
char *server_name,
uint32 switch_value, SRV_SHARE_INFO_CTR *ctr,
uint32 preferred_len,
@@ -226,7 +226,7 @@ BOOL do_srv_net_srv_share_enum(struct cli_state *cli, int t_idx, uint16 fnum,
srv_io_q_net_share_enum("", &q_o, &data, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, t_idx, fnum, SRV_NETSHAREENUM, &data, &rdata))
+ if (rpc_api_pipe_req(cli, SRV_NETSHAREENUM, &data, &rdata))
{
SRV_R_NET_SHARE_ENUM r_o;
BOOL p;
@@ -267,7 +267,7 @@ BOOL do_srv_net_srv_share_enum(struct cli_state *cli, int t_idx, uint16 fnum,
/****************************************************************************
do a server net file enum
****************************************************************************/
-BOOL do_srv_net_srv_file_enum(struct cli_state *cli, int t_idx, uint16 fnum,
+BOOL do_srv_net_srv_file_enum(struct cli_state *cli,
char *server_name, char *qual_name,
uint32 switch_value, SRV_FILE_INFO_CTR *ctr,
uint32 preferred_len,
@@ -305,7 +305,7 @@ BOOL do_srv_net_srv_file_enum(struct cli_state *cli, int t_idx, uint16 fnum,
srv_io_q_net_file_enum("", &q_o, &data, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, t_idx, fnum, SRV_NETFILEENUM, &data, &rdata))
+ if (rpc_api_pipe_req(cli, SRV_NETFILEENUM, &data, &rdata))
{
SRV_R_NET_FILE_ENUM r_o;
BOOL p;
@@ -346,7 +346,7 @@ BOOL do_srv_net_srv_file_enum(struct cli_state *cli, int t_idx, uint16 fnum,
/****************************************************************************
do a server get info
****************************************************************************/
-BOOL do_srv_net_srv_get_info(struct cli_state *cli, int t_idx, uint16 fnum,
+BOOL do_srv_net_srv_get_info(struct cli_state *cli,
char *server_name, uint32 switch_value, SRV_INFO_CTR *ctr)
{
prs_struct data;
@@ -370,7 +370,7 @@ BOOL do_srv_net_srv_get_info(struct cli_state *cli, int t_idx, uint16 fnum,
srv_io_q_net_srv_get_info("", &q_o, &data, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, t_idx, fnum, SRV_NET_SRV_GET_INFO, &data, &rdata))
+ if (rpc_api_pipe_req(cli, SRV_NET_SRV_GET_INFO, &data, &rdata))
{
SRV_R_NET_SRV_GET_INFO r_o;
BOOL p;
diff --git a/source3/rpc_client/cli_wkssvc.c b/source3/rpc_client/cli_wkssvc.c
index a9640cdb42..e45016c1b8 100644
--- a/source3/rpc_client/cli_wkssvc.c
+++ b/source3/rpc_client/cli_wkssvc.c
@@ -41,7 +41,7 @@ BOOL do_wks_query_info(struct cli_state *cli,
prs_struct rbuf;
prs_struct buf;
WKS_Q_QUERY_INFO q_o;
- BOOL valid_info = False;
+ BOOL valid_info = False;
if (server_name == 0 || wks100 == NULL) return False;
diff --git a/source3/rpc_parse/parse_srv.c b/source3/rpc_parse/parse_srv.c
index 882ad9e59d..27b1ec2257 100644
--- a/source3/rpc_parse/parse_srv.c
+++ b/source3/rpc_parse/parse_srv.c
@@ -298,6 +298,29 @@ static void srv_io_srv_share_ctr(char *desc, SRV_SHARE_INFO_CTR *ctr, prs_struc
/*******************************************************************
reads or writes a structure.
********************************************************************/
+void make_srv_q_net_share_enum(SRV_Q_NET_SHARE_ENUM *q_n,
+ char *srv_name,
+ uint32 share_level, SRV_SHARE_INFO_CTR *ctr,
+ uint32 preferred_len,
+ ENUM_HND *hnd)
+{
+ if (q_n == NULL || ctr == NULL || hnd == NULL) return;
+
+ q_n->ctr = ctr;
+
+ DEBUG(5,("make_q_net_share_enum\n"));
+
+ make_buf_unistr2(&(q_n->uni_srv_name), &(q_n->ptr_srv_name), srv_name);
+
+ q_n->share_level = share_level;
+ q_n->preferred_len = preferred_len;
+
+ memcpy(&(q_n->enum_hnd), hnd, sizeof(*hnd));
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
void srv_io_q_net_share_enum(char *desc, SRV_Q_NET_SHARE_ENUM *q_n, prs_struct *ps, int depth)
{
if (q_n == NULL) return;
@@ -603,6 +626,30 @@ static void srv_io_srv_sess_ctr(char *desc, SRV_SESS_INFO_CTR *ctr, prs_struct
/*******************************************************************
reads or writes a structure.
********************************************************************/
+void make_srv_q_net_sess_enum(SRV_Q_NET_SESS_ENUM *q_n,
+ char *srv_name, char *qual_name,
+ uint32 sess_level, SRV_SESS_INFO_CTR *ctr,
+ uint32 preferred_len,
+ ENUM_HND *hnd)
+{
+ if (q_n == NULL || ctr == NULL || hnd == NULL) return;
+
+ q_n->ctr = ctr;
+
+ DEBUG(5,("make_q_net_sess_enum\n"));
+
+ make_buf_unistr2(&(q_n->uni_srv_name), &(q_n->ptr_srv_name), srv_name);
+ make_buf_unistr2(&(q_n->uni_qual_name), &(q_n->ptr_qual_name), qual_name);
+
+ q_n->sess_level = sess_level;
+ q_n->preferred_len = preferred_len;
+
+ memcpy(&(q_n->enum_hnd), hnd, sizeof(*hnd));
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
void srv_io_q_net_sess_enum(char *desc, SRV_Q_NET_SESS_ENUM *q_n, prs_struct *ps, int depth)
{
if (q_n == NULL) return;
@@ -878,6 +925,30 @@ static void srv_io_srv_conn_ctr(char *desc, SRV_CONN_INFO_CTR *ctr, prs_struct
/*******************************************************************
reads or writes a structure.
********************************************************************/
+void make_srv_q_net_conn_enum(SRV_Q_NET_CONN_ENUM *q_n,
+ char *srv_name, char *qual_name,
+ uint32 conn_level, SRV_CONN_INFO_CTR *ctr,
+ uint32 preferred_len,
+ ENUM_HND *hnd)
+{
+ if (q_n == NULL || ctr == NULL || hnd == NULL) return;
+
+ q_n->ctr = ctr;
+
+ DEBUG(5,("make_q_net_conn_enum\n"));
+
+ make_buf_unistr2(&(q_n->uni_srv_name ), &(q_n->ptr_srv_name ), srv_name );
+ make_buf_unistr2(&(q_n->uni_qual_name), &(q_n->ptr_qual_name), qual_name);
+
+ q_n->conn_level = conn_level;
+ q_n->preferred_len = preferred_len;
+
+ memcpy(&(q_n->enum_hnd), hnd, sizeof(*hnd));
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
void srv_io_q_net_conn_enum(char *desc, SRV_Q_NET_CONN_ENUM *q_n, prs_struct *ps, int depth)
{
if (q_n == NULL) return;
@@ -1078,6 +1149,30 @@ static void srv_io_srv_file_ctr(char *desc, SRV_FILE_INFO_CTR *ctr, prs_struct
/*******************************************************************
reads or writes a structure.
********************************************************************/
+void make_srv_q_net_file_enum(SRV_Q_NET_FILE_ENUM *q_n,
+ char *srv_name, char *qual_name,
+ uint32 file_level, SRV_FILE_INFO_CTR *ctr,
+ uint32 preferred_len,
+ ENUM_HND *hnd)
+{
+ if (q_n == NULL || ctr == NULL || hnd == NULL) return;
+
+ q_n->ctr = ctr;
+
+ DEBUG(5,("make_q_net_file_enum\n"));
+
+ make_buf_unistr2(&(q_n->uni_srv_name), &(q_n->ptr_srv_name), srv_name);
+ make_buf_unistr2(&(q_n->uni_qual_name), &(q_n->ptr_qual_name), qual_name);
+
+ q_n->file_level = file_level;
+ q_n->preferred_len = preferred_len;
+
+ memcpy(&(q_n->enum_hnd), hnd, sizeof(*hnd));
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
void srv_io_q_net_file_enum(char *desc, SRV_Q_NET_FILE_ENUM *q_n, prs_struct *ps, int depth)
{
if (q_n == NULL) return;
@@ -1285,6 +1380,20 @@ static void srv_io_info_ctr(char *desc, SRV_INFO_CTR *ctr, prs_struct *ps, int
}
}
+/*******************************************************************
+ makes a SRV_Q_NET_SRV_GET_INFO structure.
+ ********************************************************************/
+void make_srv_q_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *srv,
+ char *server_name, uint32 switch_value)
+{
+ if (srv == NULL) return;
+
+ DEBUG(5,("make_srv_q_net_srv_get_info\n"));
+
+ make_buf_unistr2(&(srv->uni_srv_name), &(srv->ptr_srv_name), server_name);
+
+ srv->switch_value = switch_value;
+}
/*******************************************************************
reads or writes a structure.
diff --git a/source3/rpcclient/cmd_srvsvc.c b/source3/rpcclient/cmd_srvsvc.c
index 2964d1b54b..063174a1d1 100644
--- a/source3/rpcclient/cmd_srvsvc.c
+++ b/source3/rpcclient/cmd_srvsvc.c
@@ -34,7 +34,6 @@ extern int DEBUGLEVEL;
#define DEBUG_TESTING
extern struct cli_state *smb_cli;
-extern int smb_tidx;
extern FILE* out_hnd;
@@ -53,11 +52,11 @@ void cmd_srv_query_info(struct client_info *info)
bzero(&ctr, sizeof(ctr));
- strcpy(dest_srv, "\\\\");
- strcat(dest_srv, info->dest_host);
+ fstrcpy(dest_srv, "\\\\");
+ fstrcat(dest_srv, info->dest_host);
strupper(dest_srv);
- if (next_token(NULL, tmp, NULL))
+ if (next_token(NULL, tmp, NULL, sizeof(tmp)-1))
{
info_level = strtoul(tmp, (char**)NULL, 10);
}
@@ -68,14 +67,14 @@ void cmd_srv_query_info(struct client_info *info)
DEBUG(5, ("cmd_srv_query_info: smb_cli->fd:%d\n", smb_cli->fd));
/* open LSARPC session. */
- res = res ? do_session_open(smb_cli, smb_tidx, PIPE_SRVSVC, &(info->dom.srvsvc_fnum)) : False;
+ res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC, False) : False;
/* send info level: receive requested info. hopefully. */
- res = res ? do_srv_net_srv_get_info(smb_cli, smb_tidx, info->dom.srvsvc_fnum,
+ res = res ? do_srv_net_srv_get_info(smb_cli,
dest_srv, info_level, &ctr) : False;
/* close the session */
- do_session_close(smb_cli, smb_tidx, info->dom.srvsvc_fnum);
+ cli_nt_session_close(smb_cli);
if (res)
{
@@ -107,15 +106,15 @@ void cmd_srv_enum_conn(struct client_info *info)
bzero(&ctr, sizeof(ctr));
- strcpy(qual_srv, "\\\\");
- strcat(qual_srv, info->myhostname);
+ fstrcpy(qual_srv, "\\\\");
+ fstrcat(qual_srv, info->myhostname);
strupper(qual_srv);
- strcpy(dest_srv, "\\\\");
- strcat(dest_srv, info->dest_host);
+ fstrcpy(dest_srv, "\\\\");
+ fstrcat(dest_srv, info->dest_host);
strupper(dest_srv);
- if (next_token(NULL, tmp, NULL))
+ if (next_token(NULL, tmp, NULL, sizeof(tmp)-1))
{
info_level = strtoul(tmp, (char**)NULL, 10);
}
@@ -126,13 +125,13 @@ void cmd_srv_enum_conn(struct client_info *info)
DEBUG(5, ("cmd_srv_enum_conn: smb_cli->fd:%d\n", smb_cli->fd));
/* open srvsvc session. */
- res = res ? do_session_open(smb_cli, smb_tidx, PIPE_SRVSVC, &(info->dom.srvsvc_fnum)) : False;
+ res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC, False) : False;
hnd.ptr_hnd = 1;
hnd.handle = 0;
/* enumerate connections on server */
- res = res ? do_srv_net_srv_conn_enum(smb_cli, smb_tidx, info->dom.srvsvc_fnum,
+ res = res ? do_srv_net_srv_conn_enum(smb_cli,
dest_srv, qual_srv,
info_level, &ctr, 0xffffffff, &hnd) : False;
@@ -144,7 +143,7 @@ void cmd_srv_enum_conn(struct client_info *info)
}
/* close the session */
- do_session_close(smb_cli, smb_tidx, info->dom.srvsvc_fnum);
+ cli_nt_session_close(smb_cli);
if (res)
{
@@ -171,11 +170,11 @@ void cmd_srv_enum_shares(struct client_info *info)
bzero(&ctr, sizeof(ctr));
- strcpy(dest_srv, "\\\\");
- strcat(dest_srv, info->dest_host);
+ fstrcpy(dest_srv, "\\\\");
+ fstrcat(dest_srv, info->dest_host);
strupper(dest_srv);
- if (next_token(NULL, tmp, NULL))
+ if (next_token(NULL, tmp, NULL, sizeof(tmp)-1))
{
info_level = strtoul(tmp, (char**)NULL, 10);
}
@@ -186,13 +185,13 @@ void cmd_srv_enum_shares(struct client_info *info)
DEBUG(5, ("cmd_srv_enum_shares: smb_cli->fd:%d\n", smb_cli->fd));
/* open srvsvc session. */
- res = res ? do_session_open(smb_cli, smb_tidx, PIPE_SRVSVC, &(info->dom.srvsvc_fnum)) : False;
+ res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC, False) : False;
hnd.ptr_hnd = 0;
hnd.handle = 0;
/* enumerate shares_files on server */
- res = res ? do_srv_net_srv_share_enum(smb_cli, smb_tidx, info->dom.srvsvc_fnum,
+ res = res ? do_srv_net_srv_share_enum(smb_cli,
dest_srv,
info_level, &ctr, 0xffffffff, &hnd) : False;
@@ -204,7 +203,7 @@ void cmd_srv_enum_shares(struct client_info *info)
}
/* close the session */
- do_session_close(smb_cli, smb_tidx, info->dom.srvsvc_fnum);
+ cli_nt_session_close(smb_cli);
if (res)
{
@@ -231,11 +230,11 @@ void cmd_srv_enum_sess(struct client_info *info)
bzero(&ctr, sizeof(ctr));
- strcpy(dest_srv, "\\\\");
- strcat(dest_srv, info->dest_host);
+ fstrcpy(dest_srv, "\\\\");
+ fstrcat(dest_srv, info->dest_host);
strupper(dest_srv);
- if (next_token(NULL, tmp, NULL))
+ if (next_token(NULL, tmp, NULL, sizeof(tmp)-1))
{
info_level = strtoul(tmp, (char**)NULL, 10);
}
@@ -246,17 +245,17 @@ void cmd_srv_enum_sess(struct client_info *info)
DEBUG(5, ("cmd_srv_enum_sess: smb_cli->fd:%d\n", smb_cli->fd));
/* open srvsvc session. */
- res = res ? do_session_open(smb_cli, smb_tidx, PIPE_SRVSVC, &(info->dom.srvsvc_fnum)) : False;
+ res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC, False) : False;
hnd.ptr_hnd = 1;
hnd.handle = 0;
/* enumerate sessions on server */
- res = res ? do_srv_net_srv_sess_enum(smb_cli, smb_tidx, info->dom.srvsvc_fnum,
+ res = res ? do_srv_net_srv_sess_enum(smb_cli,
dest_srv, NULL, info_level, &ctr, 0x1000, &hnd) : False;
/* close the session */
- do_session_close(smb_cli, smb_tidx, info->dom.srvsvc_fnum);
+ cli_nt_session_close(smb_cli);
if (res)
{
@@ -283,11 +282,11 @@ void cmd_srv_enum_files(struct client_info *info)
bzero(&ctr, sizeof(ctr));
- strcpy(dest_srv, "\\\\");
- strcat(dest_srv, info->dest_host);
+ fstrcpy(dest_srv, "\\\\");
+ fstrcat(dest_srv, info->dest_host);
strupper(dest_srv);
- if (next_token(NULL, tmp, NULL))
+ if (next_token(NULL, tmp, NULL, sizeof(tmp)-1))
{
info_level = strtoul(tmp, (char**)NULL, 10);
}
@@ -298,13 +297,13 @@ void cmd_srv_enum_files(struct client_info *info)
DEBUG(5, ("cmd_srv_enum_files: smb_cli->fd:%d\n", smb_cli->fd));
/* open srvsvc session. */
- res = res ? do_session_open(smb_cli, smb_tidx, PIPE_SRVSVC, &(info->dom.srvsvc_fnum)) : False;
+ res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC, False) : False;
hnd.ptr_hnd = 1;
hnd.handle = 0;
/* enumerate files on server */
- res = res ? do_srv_net_srv_file_enum(smb_cli, smb_tidx, info->dom.srvsvc_fnum,
+ res = res ? do_srv_net_srv_file_enum(smb_cli,
dest_srv, NULL, info_level, &ctr, 0x1000, &hnd) : False;
if (res)
@@ -315,7 +314,7 @@ void cmd_srv_enum_files(struct client_info *info)
}
/* close the session */
- do_session_close(smb_cli, smb_tidx, info->dom.srvsvc_fnum);
+ cli_nt_session_close(smb_cli);
if (res)
{
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c
index 3dd53581aa..820d54e8b3 100644
--- a/source3/rpcclient/rpcclient.c
+++ b/source3/rpcclient/rpcclient.c
@@ -107,13 +107,11 @@ struct
{"ntlogin", cmd_netlogon_login_test, "<username> NT Domain login test"},
#endif
{"wksinfo", cmd_wks_query_info, "DCE/RPC - Workstation Query Info"},
-#if 0
{"srvinfo", cmd_srv_query_info, "DCE/RPC - Server Query Info"},
{"srvsessions",cmd_srv_enum_sess, "DCE/RPC - List sessions on a server"},
{"srvshares", cmd_srv_enum_shares, "DCE/RPC - List shares on a server"},
{"srvconnections",cmd_srv_enum_conn, "DCE/RPC - List connections on a server"},
{"srvfiles", cmd_srv_enum_files, "DCE/RPC - List files on a server"},
-#endif
{"lsaquery", cmd_lsa_query_info, "Query Info Policy (domain member or server)"},
{"lookupsids", cmd_lsa_lookup_sids, "Resolve names from SIDs"},
{"enumusers", cmd_sam_enum_users, "SAM User Database Query (experimental!)"},