summaryrefslogtreecommitdiff
path: root/source3/rpc_client
diff options
context:
space:
mode:
Diffstat (limited to 'source3/rpc_client')
-rw-r--r--source3/rpc_client/cli_connect.c162
-rw-r--r--source3/rpc_client/cli_lsarpc.c34
-rw-r--r--source3/rpc_client/cli_pipe.c22
-rw-r--r--source3/rpc_client/cli_reg.c43
-rw-r--r--source3/rpc_client/cli_samr.c40
-rw-r--r--source3/rpc_client/cli_svcctl.c63
6 files changed, 208 insertions, 156 deletions
diff --git a/source3/rpc_client/cli_connect.c b/source3/rpc_client/cli_connect.c
index 39a7e50bc5..0b5d20d913 100644
--- a/source3/rpc_client/cli_connect.c
+++ b/source3/rpc_client/cli_connect.c
@@ -31,22 +31,92 @@ extern int DEBUGLEVEL;
extern pstring scope;
extern pstring global_myname;
+struct cli_connection
+{
+ struct cli_state *cli;
+ uint16 fnum;
+};
+
+
+/****************************************************************************
+terminate client connection
+****************************************************************************/
+void cli_connection_free(struct cli_connection *con)
+{
+ cli_nt_session_close(con->cli, con->fnum);
+ cli_shutdown(con->cli);
+ free(con->cli);
+ free(con);
+}
+
/****************************************************************************
terminate client state
****************************************************************************/
-void cli_state_free(struct cli_state *cli, uint16 fnum)
+void cli_connection_unlink(struct cli_connection *con)
{
- cli_nt_session_close(cli, fnum);
- cli_shutdown(cli);
- free(cli);
+ if (con != NULL)
+ {
+ cli_connection_free(con);
+ }
+ return;
+}
+
+/****************************************************************************
+init client state
+****************************************************************************/
+BOOL cli_connection_init_list(char* servers, const char* pipe_name,
+ struct cli_connection **con)
+{
+ BOOL res = True;
+
+ /*
+ * allocate
+ */
+
+ (*con) = (struct cli_connection*)malloc(sizeof(**con));
+
+ if ((*con) == NULL)
+ {
+ return False;
+ }
+
+ (*con)->cli = cli_initialise(NULL);
+ (*con)->fnum = 0xffff;
+
+ if ((*con)->cli == NULL)
+ {
+ return False;
+ }
+
+ /*
+ * initialise
+ */
+
+ (*con)->cli->capabilities |= CAP_NT_SMBS | CAP_STATUS32;
+ cli_init_creds((*con)->cli, usr_creds);
+
+ (*con)->cli->use_ntlmv2 = lp_client_ntlmv2();
+
+ if (!cli_connect_serverlist((*con)->cli, servers))
+ {
+ DEBUG(0,("cli_state_init: connection failed\n"));
+ cli_connection_free((*con));
+ return False;
+ }
+
+ (*con)->cli->ntlmssp_cli_flgs = 0x0;
+
+ res = res ? cli_nt_session_open((*con)->cli, pipe_name,
+ &(*con)->fnum) : False;
+
+ return res;
}
/****************************************************************************
init client state
****************************************************************************/
-BOOL cli_state_init(const char* server_name, const char* pipe_name,
- struct cli_state **cli,
- uint16 *fnum)
+BOOL cli_connection_init(const char* server_name, const char* pipe_name,
+ struct cli_connection **con)
{
struct nmb_name calling;
struct nmb_name called;
@@ -60,9 +130,17 @@ BOOL cli_state_init(const char* server_name, const char* pipe_name,
* allocate
*/
- *cli = cli_initialise(NULL);
+ (*con) = (struct cli_connection*)malloc(sizeof(**con));
- if ((*cli) == NULL)
+ if ((*con) == NULL)
+ {
+ return False;
+ }
+
+ (*con)->cli = cli_initialise(NULL);
+ (*con)->fnum = 0xffff;
+
+ if ((*con)->cli == NULL)
{
return False;
}
@@ -71,10 +149,10 @@ BOOL cli_state_init(const char* server_name, const char* pipe_name,
* initialise
*/
- (*cli)->capabilities |= CAP_NT_SMBS | CAP_STATUS32;
- cli_init_creds(*cli, usr_creds);
+ (*con)->cli->capabilities |= CAP_NT_SMBS | CAP_STATUS32;
+ cli_init_creds((*con)->cli, usr_creds);
- (*cli)->use_ntlmv2 = lp_client_ntlmv2();
+ (*con)->cli->use_ntlmv2 = lp_client_ntlmv2();
if (resolve_srv_name(server_name, dest_host, &ip))
{
@@ -92,21 +170,21 @@ BOOL cli_state_init(const char* server_name, const char* pipe_name,
* connect
*/
- if (!cli_establish_connection((*cli),
+ if (!cli_establish_connection((*con)->cli,
dest_host, dest_ip,
&calling, &called,
"IPC$", "IPC",
False, True))
{
DEBUG(0,("cli_state_init: connection failed\n"));
- cli_shutdown((*cli));
- free(*cli);
+ cli_connection_free((*con));
return False;
}
- (*cli)->ntlmssp_cli_flgs = 0x0;
+ (*con)->cli->ntlmssp_cli_flgs = 0x0;
- res = res ? cli_nt_session_open(*cli, pipe_name, fnum) : False;
+ res = res ? cli_nt_session_open((*con)->cli, pipe_name,
+ &(*con)->fnum) : False;
return res;
}
@@ -114,11 +192,9 @@ BOOL cli_state_init(const char* server_name, const char* pipe_name,
/****************************************************************************
obtain client state
****************************************************************************/
-BOOL cli_state_get(const POLICY_HND *pol,
- struct cli_state **cli,
- uint16 *fnum)
+BOOL cli_connection_get(const POLICY_HND *pol, struct cli_connection **con)
{
- return get_policy_cli_state(pol, cli, fnum);
+ return get_policy_con(pol, con);
}
/****************************************************************************
@@ -126,29 +202,55 @@ link a child policy handle to a parent one
****************************************************************************/
BOOL cli_pol_link(POLICY_HND *to, const POLICY_HND *from)
{
- struct cli_state *cli = NULL;
- uint16 fnum = 0xffff;
+ struct cli_connection *con = NULL;
- if (!cli_state_get(from, &cli, &fnum))
+ if (!cli_connection_get(from, &con))
{
return False;
}
- return register_policy_hnd(to) &&
- set_policy_cli_state(to, cli, fnum, NULL);
+ return register_policy_hnd(to) && set_policy_con(to, con, NULL);
}
+/****************************************************************************
+get a user session key associated with a connection associated with a
+policy handle.
+****************************************************************************/
BOOL cli_get_usr_sesskey(const POLICY_HND *pol, uchar sess_key[16])
{
- struct cli_state *cli = NULL;
- uint16 fnum = 0xffff;
+ struct cli_connection *con = NULL;
- if (!cli_state_get(pol, &cli, &fnum))
+ if (!cli_connection_get(pol, &con))
{
return False;
}
- memcpy(sess_key, cli->sess_key, sizeof(cli->sess_key));
+ memcpy(sess_key, con->cli->sess_key, sizeof(con->cli->sess_key));
return True;
}
+
+/****************************************************************************
+ send a request on an rpc pipe.
+ ****************************************************************************/
+BOOL rpc_hnd_pipe_req(const POLICY_HND *hnd, uint8 op_num,
+ prs_struct *data, prs_struct *rdata)
+{
+ struct cli_connection *con = NULL;
+
+ if (!cli_connection_get(hnd, &con))
+ {
+ return False;
+ }
+
+ return rpc_con_pipe_req(con, op_num, data, rdata);
+}
+
+/****************************************************************************
+ send a request on an rpc pipe.
+ ****************************************************************************/
+BOOL rpc_con_pipe_req(struct cli_connection *con, uint8 op_num,
+ prs_struct *data, prs_struct *rdata)
+{
+ return rpc_api_pipe_req(con->cli, con->fnum, op_num, data, rdata);
+}
diff --git a/source3/rpc_client/cli_lsarpc.c b/source3/rpc_client/cli_lsarpc.c
index 7706d0cd83..c8240a3299 100644
--- a/source3/rpc_client/cli_lsarpc.c
+++ b/source3/rpc_client/cli_lsarpc.c
@@ -39,7 +39,7 @@ BOOL get_domain_sids(const char *myname,
{
POLICY_HND pol;
fstring srv_name;
- struct cli_state cli;
+ struct cli_connection *con = NULL;
BOOL res = True;
fstring dom3;
fstring dom5;
@@ -56,7 +56,7 @@ BOOL get_domain_sids(const char *myname,
return False;
}
- if (!cli_connect_serverlist(&cli, servers))
+ if (!cli_connection_init_list(servers, PIPE_LSARPC, &con))
{
DEBUG(0,("get_domain_sids: unable to initialise client connection.\n"));
return False;
@@ -101,8 +101,7 @@ BOOL get_domain_sids(const char *myname,
res = res ? lsa_close(&pol) : False;
/* close the session */
- cli_ulogoff(&cli);
- cli_shutdown(&cli);
+ cli_connection_unlink(con);
if (res)
{
@@ -136,7 +135,7 @@ BOOL get_trust_sid_and_domain(const char* myname, char *server,
{
POLICY_HND pol;
fstring srv_name;
- struct cli_state cli;
+ struct cli_connection *con = NULL;
BOOL res = True;
BOOL res1 = True;
DOM_SID sid3;
@@ -151,7 +150,7 @@ BOOL get_trust_sid_and_domain(const char* myname, char *server,
ZERO_STRUCT(usr);
pwd_set_nullpwd(&usr.pwd);
- if (!cli_connect_serverlist(&cli, server))
+ if (!cli_connection_init_list(server, PIPE_LSARPC, &con))
{
DEBUG(0,("get_trust_sid: unable to initialise client connection.\n"));
return False;
@@ -179,8 +178,7 @@ BOOL get_trust_sid_and_domain(const char* myname, char *server,
res = res ? lsa_close(&pol) : False;
/* close the session */
- cli_ulogoff(&cli);
- cli_shutdown(&cli);
+ cli_connection_unlink(con);
if (res1)
{
@@ -224,10 +222,9 @@ BOOL lsa_open_policy(const char *server_name, POLICY_HND *hnd,
LSA_Q_OPEN_POL q_o;
LSA_SEC_QOS qos;
BOOL valid_pol = False;
- struct cli_state *cli = NULL;
- uint16 fnum = 0xffff;
+ struct cli_connection *con = NULL;
- if (!cli_state_init(server_name, PIPE_LSARPC, &cli, &fnum))
+ if (!cli_connection_init(server_name, PIPE_LSARPC, &con))
{
return False;
}
@@ -256,7 +253,7 @@ BOOL lsa_open_policy(const char *server_name, POLICY_HND *hnd,
lsa_io_q_open_pol("", &q_o, &buf, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, fnum, LSA_OPENPOLICY, &buf, &rbuf))
+ if (rpc_con_pipe_req(con, LSA_OPENPOLICY, &buf, &rbuf))
{
LSA_R_OPEN_POL r_o;
BOOL p;
@@ -277,8 +274,8 @@ BOOL lsa_open_policy(const char *server_name, POLICY_HND *hnd,
memcpy(hnd, r_o.pol.data, sizeof(hnd->data));
valid_pol = register_policy_hnd(hnd) &&
- set_policy_cli_state(hnd, cli, fnum,
- cli_state_free);
+ set_policy_con(hnd, con,
+ cli_connection_unlink);
}
}
@@ -300,10 +297,9 @@ BOOL lsa_open_policy2( const char *server_name, POLICY_HND *hnd,
LSA_SEC_QOS qos;
BOOL valid_pol = False;
- struct cli_state *cli = NULL;
- uint16 fnum = 0xffff;
+ struct cli_connection *con = NULL;
- if (!cli_state_init(server_name, PIPE_LSARPC, &cli, &fnum))
+ if (!cli_connection_init(server_name, PIPE_LSARPC, &con))
{
return False;
}
@@ -352,8 +348,8 @@ BOOL lsa_open_policy2( const char *server_name, POLICY_HND *hnd,
/* ok, at last: we're happy. return the policy handle */
memcpy(hnd, r_o.pol.data, sizeof(hnd->data));
valid_pol = register_policy_hnd(hnd) &&
- set_policy_cli_state(hnd, cli, fnum,
- cli_state_free);
+ set_policy_con(hnd, con,
+ cli_connection_unlink);
}
}
diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c
index 08d7e42270..8ca5255203 100644
--- a/source3/rpc_client/cli_pipe.c
+++ b/source3/rpc_client/cli_pipe.c
@@ -628,23 +628,6 @@ static BOOL create_rpc_request(prs_struct *rhdr, uint8 op_num, int data_len,
/****************************************************************************
send a request on an rpc pipe.
****************************************************************************/
-BOOL rpc_hnd_pipe_req(const POLICY_HND *hnd, uint8 op_num,
- prs_struct *data, prs_struct *rdata)
-{
- struct cli_state *cli = NULL;
- uint16 fnum = 0xffff;
-
- if (!cli_state_get(hnd, &cli, &fnum))
- {
- return False;
- }
-
- return rpc_api_pipe_req(cli, fnum, op_num, data, rdata);
-}
-
-/****************************************************************************
- send a request on an rpc pipe.
- ****************************************************************************/
BOOL rpc_api_pipe_req(struct cli_state *cli, uint16 fnum, uint8 op_num,
prs_struct *data, prs_struct *rdata)
{
@@ -1163,5 +1146,8 @@ close the session
void cli_nt_session_close(struct cli_state *cli, uint16 fnum)
{
- cli_close(cli, fnum);
+ if (fnum != 0xffff)
+ {
+ cli_close(cli, fnum);
+ }
}
diff --git a/source3/rpc_client/cli_reg.c b/source3/rpc_client/cli_reg.c
index 9242d5587c..4f1c28a701 100644
--- a/source3/rpc_client/cli_reg.c
+++ b/source3/rpc_client/cli_reg.c
@@ -42,10 +42,9 @@ BOOL reg_connect( const char* srv_name,
BOOL res = True;
uint32 reg_type = 0;
- struct cli_state *cli = NULL;
- uint16 fnum = 0xffff;
+ struct cli_connection *con = NULL;
- if (!cli_state_init(srv_name, PIPE_WINREG, &cli, &fnum))
+ if (!cli_connection_init(srv_name, PIPE_WINREG, &con))
{
return False;
}
@@ -72,7 +71,7 @@ BOOL reg_connect( const char* srv_name,
{
case HKEY_CLASSES_ROOT:
{
- res = res ? reg_open_hkcr(cli, fnum,
+ res = res ? reg_open_hkcr(con,
0x5428, 0x02000000,
reg_hnd) : False;
break;
@@ -80,7 +79,7 @@ BOOL reg_connect( const char* srv_name,
case HKEY_LOCAL_MACHINE:
{
- res = res ? reg_open_hklm(cli, fnum,
+ res = res ? reg_open_hklm(con,
0x84E0, 0x02000000,
reg_hnd) : False;
break;
@@ -88,7 +87,7 @@ BOOL reg_connect( const char* srv_name,
case HKEY_USERS:
{
- res = res ? reg_open_hku(cli, fnum,
+ res = res ? reg_open_hku(con,
0x84E0, 0x02000000,
reg_hnd) : False;
break;
@@ -103,10 +102,10 @@ BOOL reg_connect( const char* srv_name,
if (res)
{
if (!register_policy_hnd(reg_hnd) ||
- !set_policy_cli_state(reg_hnd, cli, fnum,
- cli_state_free))
+ !set_policy_con(reg_hnd, con,
+ cli_connection_unlink))
{
- cli_state_free(cli, fnum);
+ cli_connection_unlink(con);
return False;
}
}
@@ -117,7 +116,7 @@ BOOL reg_connect( const char* srv_name,
/****************************************************************************
do a REG Open Policy
****************************************************************************/
-BOOL reg_open_hkcr( struct cli_state *cli, uint16 fnum,
+BOOL reg_open_hkcr( struct cli_connection *con,
uint16 unknown_0, uint32 level,
POLICY_HND *hnd)
{
@@ -141,7 +140,7 @@ BOOL reg_open_hkcr( struct cli_state *cli, uint16 fnum,
reg_io_q_open_hkcr("", &q_o, &buf, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, fnum, REG_OPEN_HKCR, &buf, &rbuf))
+ if (rpc_con_pipe_req(con, REG_OPEN_HKCR, &buf, &rbuf))
{
REG_R_OPEN_HKCR r_o;
BOOL p;
@@ -175,7 +174,7 @@ BOOL reg_open_hkcr( struct cli_state *cli, uint16 fnum,
/****************************************************************************
do a REG Open Policy
****************************************************************************/
-BOOL reg_open_hklm( struct cli_state *cli, uint16 fnum,
+BOOL reg_open_hklm( struct cli_connection *con,
uint16 unknown_0, uint32 level,
POLICY_HND *hnd)
{
@@ -199,7 +198,7 @@ BOOL reg_open_hklm( struct cli_state *cli, uint16 fnum,
reg_io_q_open_hklm("", &q_o, &buf, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, fnum, REG_OPEN_HKLM, &buf, &rbuf))
+ if (rpc_con_pipe_req(con, REG_OPEN_HKLM, &buf, &rbuf))
{
REG_R_OPEN_HKLM r_o;
BOOL p;
@@ -233,7 +232,7 @@ BOOL reg_open_hklm( struct cli_state *cli, uint16 fnum,
/****************************************************************************
do a REG Open HKU
****************************************************************************/
-BOOL reg_open_hku( struct cli_state *cli, uint16 fnum,
+BOOL reg_open_hku( struct cli_connection *con,
uint16 unknown_0, uint32 level,
POLICY_HND *hnd)
{
@@ -257,7 +256,7 @@ BOOL reg_open_hku( struct cli_state *cli, uint16 fnum,
reg_io_q_open_hku("", &q_o, &buf, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, fnum, REG_OPEN_HKU, &buf, &rbuf))
+ if (rpc_con_pipe_req(con, REG_OPEN_HKU, &buf, &rbuf))
{
REG_R_OPEN_HKU r_o;
BOOL p;
@@ -1053,10 +1052,9 @@ BOOL reg_open_entry( POLICY_HND *hnd,
if (p)
{
- struct cli_state *cli = NULL;
- uint16 fnum = 0xffff;
+ struct cli_connection *con = NULL;
- if (!cli_state_get(hnd, &cli, &fnum))
+ if (!cli_connection_get(hnd, &con))
{
return False;
}
@@ -1155,10 +1153,9 @@ BOOL reg_shutdown(const char *srv_name,
REG_Q_SHUTDOWN q_o;
BOOL valid_shutdown = False;
- struct cli_state *cli = NULL;
- uint16 fnum = 0xffff;
+ struct cli_connection *con = NULL;
- if (!cli_state_init(srv_name, PIPE_LSARPC, &cli, &fnum))
+ if (!cli_connection_init(srv_name, PIPE_LSARPC, &con))
{
return False;
}
@@ -1178,7 +1175,7 @@ BOOL reg_shutdown(const char *srv_name,
reg_io_q_shutdown("", &q_o, &buf, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, fnum, REG_SHUTDOWN, &buf, &rbuf))
+ if (rpc_con_pipe_req(con, REG_SHUTDOWN, &buf, &rbuf))
{
REG_R_SHUTDOWN r_o;
BOOL p;
@@ -1204,7 +1201,7 @@ BOOL reg_shutdown(const char *srv_name,
prs_mem_free(&rbuf);
prs_mem_free(&buf );
- cli_state_free(cli, fnum);
+ cli_connection_unlink(con);
return valid_shutdown;
}
diff --git a/source3/rpc_client/cli_samr.c b/source3/rpc_client/cli_samr.c
index 86f78d1816..f4308c2107 100644
--- a/source3/rpc_client/cli_samr.c
+++ b/source3/rpc_client/cli_samr.c
@@ -31,29 +31,10 @@
extern int DEBUGLEVEL;
-#if 0
- if (p)
- {
- /* ok, at last: we're happy. return the policy handle */
- memcpy(hnd, r_o.pol.data, sizeof(hnd->data));
- valid_pol = register_policy_hnd(hnd) &&
- set_policy_cli_state(hnd, cli, fnum,
- cli_state_free);
- }
-
- struct cli_state *cli = NULL;
- uint16 fnum = 0xffff;
-
- if (!cli_state_get(connect_pol, &cli, &fnum))
- {
- return False;
- }
-#endif
-
/****************************************************************************
do a SAMR change user password command
****************************************************************************/
-BOOL samr_chgpasswd_user( struct cli_state *cli, uint16 fnum,
+BOOL samr_chgpasswd_user( struct cli_connection *con,
char *srv_name, char *user_name,
char nt_newpass[516], uchar nt_oldhash[16],
char lm_newpass[516], uchar lm_oldhash[16])
@@ -80,7 +61,7 @@ BOOL samr_chgpasswd_user( struct cli_state *cli, uint16 fnum,
samr_io_q_chgpasswd_user("", &q_e, &data, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, fnum, SAMR_CHGPASSWD_USER, &data, &rdata))
+ if (rpc_con_pipe_req(con, SAMR_CHGPASSWD_USER, &data, &rdata))
{
SAMR_R_CHGPASSWD_USER r_e;
BOOL p;
@@ -104,7 +85,7 @@ BOOL samr_chgpasswd_user( struct cli_state *cli, uint16 fnum,
prs_mem_free(&data );
prs_mem_free(&rdata );
- cli_state_free(cli, fnum);
+ cli_connection_unlink(con);
return valid_pwc;
}
@@ -113,7 +94,7 @@ BOOL samr_chgpasswd_user( struct cli_state *cli, uint16 fnum,
/****************************************************************************
do a SAMR unknown 0x38 command
****************************************************************************/
-BOOL samr_unknown_38(struct cli_state *cli, uint16 fnum, char *srv_name)
+BOOL samr_unknown_38(struct cli_connection *con, char *srv_name)
{
prs_struct data;
prs_struct rdata;
@@ -134,7 +115,7 @@ BOOL samr_unknown_38(struct cli_state *cli, uint16 fnum, char *srv_name)
samr_io_q_unknown_38("", &q_e, &data, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, fnum, SAMR_GET_DOM_PWINFO, &data, &rdata))
+ if (rpc_con_pipe_req(con, SAMR_GET_DOM_PWINFO, &data, &rdata))
{
SAMR_R_UNKNOWN_38 r_e;
BOOL p;
@@ -639,10 +620,9 @@ BOOL samr_connect( const char *srv_name, uint32 unknown_0,
SAMR_Q_CONNECT q_o;
BOOL valid_pol = False;
- struct cli_state *cli = NULL;
- uint16 fnum = 0xffff;
+ struct cli_connection *con = NULL;
- if (!cli_state_init(srv_name, PIPE_SAMR, &cli, &fnum))
+ if (!cli_connection_init(srv_name, PIPE_SAMR, &con))
{
return False;
}
@@ -664,7 +644,7 @@ BOOL samr_connect( const char *srv_name, uint32 unknown_0,
samr_io_q_connect("", &q_o, &data, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, fnum, SAMR_CONNECT, &data, &rdata))
+ if (rpc_con_pipe_req(con, SAMR_CONNECT, &data, &rdata))
{
SAMR_R_CONNECT r_o;
BOOL p;
@@ -683,8 +663,8 @@ BOOL samr_connect( const char *srv_name, uint32 unknown_0,
{
memcpy(connect_pol, &r_o.connect_pol, sizeof(r_o.connect_pol));
valid_pol = register_policy_hnd(connect_pol) &&
- set_policy_cli_state(connect_pol, cli, fnum,
- cli_state_free);
+ set_policy_con(connect_pol, con,
+ cli_connection_unlink);
}
}
diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c
index ed470f5758..b284b2661e 100644
--- a/source3/rpc_client/cli_svcctl.c
+++ b/source3/rpc_client/cli_svcctl.c
@@ -43,10 +43,9 @@ BOOL svc_open_sc_man( const char *srv_name, char *db_name,
SVC_Q_OPEN_SC_MAN q_o;
BOOL valid_pol = False;
- struct cli_state *cli = NULL;
- uint16 fnum = 0xffff;
+ struct cli_connection *con = NULL;
- if (!cli_state_init(srv_name, PIPE_SVCCTL, &cli, &fnum))
+ if (!cli_connection_init(srv_name, PIPE_SVCCTL, &con))
{
return False;
}
@@ -66,7 +65,7 @@ BOOL svc_open_sc_man( const char *srv_name, char *db_name,
svc_io_q_open_sc_man("", &q_o, &buf, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, fnum, SVC_OPEN_SC_MAN, &buf, &rbuf))
+ if (rpc_con_pipe_req(con, SVC_OPEN_SC_MAN, &buf, &rbuf))
{
SVC_R_OPEN_SC_MAN r_o;
BOOL p;
@@ -89,8 +88,8 @@ BOOL svc_open_sc_man( const char *srv_name, char *db_name,
memcpy(hnd, r_o.pol.data, sizeof(hnd->data));
valid_pol = True;
valid_pol = register_policy_hnd(hnd) &&
- set_policy_cli_state(hnd, cli, fnum,
- cli_state_free);
+ set_policy_con(hnd, con,
+ cli_connection_unlink);
}
}
@@ -114,10 +113,9 @@ BOOL svc_open_service( POLICY_HND *scm_hnd,
SVC_Q_OPEN_SERVICE q_o;
BOOL valid_pol = False;
- struct cli_state *cli = NULL;
- uint16 fnum = 0xffff;
+ struct cli_connection *con = NULL;
- if (!cli_state_get(scm_hnd, &cli, &fnum))
+ if (!cli_connection_get(scm_hnd, &con))
{
return False;
}
@@ -137,7 +135,7 @@ BOOL svc_open_service( POLICY_HND *scm_hnd,
svc_io_q_open_service("", &q_o, &buf, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, fnum, SVC_OPEN_SERVICE, &buf, &rbuf))
+ if (rpc_con_pipe_req(con, SVC_OPEN_SERVICE, &buf, &rbuf))
{
SVC_R_OPEN_SERVICE r_o;
BOOL p;
@@ -159,8 +157,7 @@ BOOL svc_open_service( POLICY_HND *scm_hnd,
/* ok, at last: we're happy. return the policy handle */
memcpy(hnd, r_o.pol.data, sizeof(hnd->data));
valid_pol = register_policy_hnd(hnd) &&
- set_policy_cli_state(hnd, cli, fnum,
- NULL);
+ set_policy_con(hnd, con, NULL);
}
}
@@ -185,10 +182,9 @@ BOOL svc_enum_svcs( POLICY_HND *hnd,
SVC_Q_ENUM_SVCS_STATUS q_o;
BOOL valid_pol = False;
- struct cli_state *cli = NULL;
- uint16 fnum = 0xffff;
+ struct cli_connection *con = NULL;
- if (!cli_state_get(hnd, &cli, &fnum))
+ if (!cli_connection_get(hnd, &con))
{
return False;
}
@@ -213,7 +209,7 @@ BOOL svc_enum_svcs( POLICY_HND *hnd,
svc_io_q_enum_svcs_status("", &q_o, &buf, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, fnum, SVC_ENUM_SVCS_STATUS, &buf, &rbuf))
+ if (rpc_con_pipe_req(con, SVC_ENUM_SVCS_STATUS, &buf, &rbuf))
{
SVC_R_ENUM_SVCS_STATUS r_o;
BOOL p;
@@ -266,10 +262,9 @@ BOOL svc_stop_service( POLICY_HND *hnd,
SVC_Q_STOP_SERVICE q_c;
BOOL valid_cfg = False;
- struct cli_state *cli = NULL;
- uint16 fnum = 0xffff;
+ struct cli_connection *con = NULL;
- if (!cli_state_get(hnd, &cli, &fnum))
+ if (!cli_connection_get(hnd, &con))
{
return False;
}
@@ -290,7 +285,7 @@ BOOL svc_stop_service( POLICY_HND *hnd,
svc_io_q_stop_service("", &q_c, &buf, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, fnum, SVC_STOP_SERVICE, &buf, &rbuf))
+ if (rpc_con_pipe_req(con, SVC_STOP_SERVICE, &buf, &rbuf))
{
SVC_R_STOP_SERVICE r_c;
BOOL p;
@@ -332,10 +327,9 @@ BOOL svc_start_service( POLICY_HND *hnd,
SVC_Q_START_SERVICE q_c;
BOOL valid_cfg = False;
- struct cli_state *cli = NULL;
- uint16 fnum = 0xffff;
+ struct cli_connection *con = NULL;
- if (!cli_state_get(hnd, &cli, &fnum))
+ if (!cli_connection_get(hnd, &con))
{
return False;
}
@@ -356,7 +350,7 @@ BOOL svc_start_service( POLICY_HND *hnd,
svc_io_q_start_service("", &q_c, &buf, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, fnum, SVC_START_SERVICE, &buf, &rbuf))
+ if (rpc_con_pipe_req(con, SVC_START_SERVICE, &buf, &rbuf))
{
SVC_R_START_SERVICE r_c;
BOOL p;
@@ -398,10 +392,9 @@ BOOL svc_query_svc_cfg( POLICY_HND *hnd,
SVC_Q_QUERY_SVC_CONFIG q_c;
BOOL valid_cfg = False;
- struct cli_state *cli = NULL;
- uint16 fnum = 0xffff;
+ struct cli_connection *con = NULL;
- if (!cli_state_get(hnd, &cli, &fnum))
+ if (!cli_connection_get(hnd, &con))
{
return False;
}
@@ -422,7 +415,7 @@ BOOL svc_query_svc_cfg( POLICY_HND *hnd,
svc_io_q_query_svc_config("", &q_c, &buf, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, fnum, SVC_QUERY_SVC_CONFIG, &buf, &rbuf))
+ if (rpc_con_pipe_req(con, SVC_QUERY_SVC_CONFIG, &buf, &rbuf))
{
SVC_R_QUERY_SVC_CONFIG r_c;
BOOL p;
@@ -465,10 +458,9 @@ BOOL svc_close(POLICY_HND *hnd)
SVC_Q_CLOSE q_c;
BOOL valid_close = False;
- struct cli_state *cli = NULL;
- uint16 fnum = 0xffff;
+ struct cli_connection *con = NULL;
- if (!cli_state_get(hnd, &cli, &fnum))
+ if (!cli_connection_get(hnd, &con))
{
return False;
}
@@ -489,7 +481,7 @@ BOOL svc_close(POLICY_HND *hnd)
svc_io_q_close("", &q_c, &buf, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, fnum, SVC_CLOSE, &buf, &rbuf))
+ if (rpc_con_pipe_req(con, SVC_CLOSE, &buf, &rbuf))
{
SVC_R_CLOSE r_c;
BOOL p;
@@ -553,10 +545,9 @@ BOOL svc_change_svc_cfg( POLICY_HND *hnd,
SVC_Q_CHANGE_SVC_CONFIG q_c;
BOOL valid_cfg = False;
- struct cli_state *cli = NULL;
- uint16 fnum = 0xffff;
+ struct cli_connection *con = NULL;
- if (!cli_state_get(hnd, &cli, &fnum))
+ if (!cli_connection_get(hnd, &con))
{
return False;
}
@@ -583,7 +574,7 @@ BOOL svc_change_svc_cfg( POLICY_HND *hnd,
svc_io_q_change_svc_config("", &q_c, &buf, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, fnum, SVC_CHANGE_SVC_CONFIG, &buf, &rbuf))
+ if (rpc_con_pipe_req(con, SVC_CHANGE_SVC_CONFIG, &buf, &rbuf))
{
SVC_R_CHANGE_SVC_CONFIG r_c;
BOOL p;