uint16 max_recv_frag;
};
+struct cli_connection;
+
#endif /* _CLIENT_H */
uint32 get_policy_samr_rid(POLICY_HND *hnd);
BOOL set_policy_reg_name(POLICY_HND *hnd, fstring name);
BOOL get_policy_reg_name(POLICY_HND *hnd, fstring name);
-BOOL set_policy_cli_state(POLICY_HND *hnd, struct cli_state *cli, uint16 fnum,
- void (*free_fn)(struct cli_state *, uint16));
-BOOL get_policy_cli_state(const POLICY_HND *hnd, struct cli_state **cli,
- uint16 *fnum);
+BOOL set_policy_con(POLICY_HND *hnd, struct cli_connection *con,
+ void (*free_fn)(struct cli_connection *));
+BOOL get_policy_con(const POLICY_HND *hnd, struct cli_connection **con);
BOOL close_policy_hnd(POLICY_HND *hnd);
/*The following definitions come from lib/util_pwdb.c */
/*The following definitions come from rpc_client/cli_connect.c */
-void cli_state_free(struct cli_state *cli, uint16 fnum);
-BOOL cli_state_init(const char* server_name, const char* pipe_name,
- struct cli_state **cli,
- uint16 *fnum);
-BOOL cli_state_get(const POLICY_HND *pol,
- struct cli_state **cli,
- uint16 *fnum);
+void cli_connection_free(struct cli_connection *con);
+void cli_connection_unlink(struct cli_connection *con);
+BOOL cli_connection_init_list(char* servers, const char* pipe_name,
+ struct cli_connection **con);
+BOOL cli_connection_init(const char* server_name, const char* pipe_name,
+ struct cli_connection **con);
+BOOL cli_connection_get(const POLICY_HND *pol, struct cli_connection **con);
BOOL cli_pol_link(POLICY_HND *to, const POLICY_HND *from);
BOOL cli_get_usr_sesskey(const POLICY_HND *pol, uchar sess_key[16]);
+BOOL rpc_hnd_pipe_req(const POLICY_HND *hnd, uint8 op_num,
+ prs_struct *data, prs_struct *rdata);
+BOOL rpc_con_pipe_req(struct cli_connection *con, uint8 op_num,
+ prs_struct *data, prs_struct *rdata);
/*The following definitions come from rpc_client/cli_eventlog.c */
prs_struct *rhdr,
prs_struct *rhdr_autha,
prs_struct *auth_resp);
-BOOL rpc_hnd_pipe_req(const POLICY_HND *hnd, uint8 op_num,
- prs_struct *data, prs_struct *rdata);
BOOL rpc_api_pipe_req(struct cli_state *cli, uint16 fnum, uint8 op_num,
prs_struct *data, prs_struct *rdata);
void cli_nt_set_ntlmssp_flgs(struct cli_state *cli, uint32 ntlmssp_flgs);
const char *full_keyname,
char *key_name,
POLICY_HND *reg_hnd);
-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);
-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);
-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);
BOOL reg_flush_key( POLICY_HND *hnd);
/*The following definitions come from rpc_client/cli_samr.c */
-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]);
-BOOL samr_unknown_38(struct cli_state *cli, uint16 fnum, char *srv_name);
+BOOL samr_unknown_38(struct cli_connection *con, char *srv_name);
BOOL samr_query_dom_info( POLICY_HND *domain_pol, uint16 switch_value,
SAM_UNK_CTR *ctr);
uint32 samr_enum_domains( POLICY_HND *pol,
/************** \PIPE\lsarpc stuff ********************/
- POLICY_HND lsa_info_pol;
-
/* domain member */
DOM_SID level3_sid;
DOM_SID level5_sid;
enum action_type {ACTION_HEADER, ACTION_ENUMERATE, ACTION_FOOTER};
+/****************************************************************************
+ This defines the commands supported by this client
+ ****************************************************************************/
+struct command_set
+{
+ char *name;
+ void (*fn)(struct client_info*, int, char*[]);
+ char *description;
+ char compl_args[2];
+
+};
+
#endif /* _RPCCLIENT_H */
uint32 status; /* some sort of flag. best to record it. comes from opnum 0x39 */
};
-struct cli_info
+struct con_info
{
- struct cli_state *cli;
- uint16 fnum;
- void (*free)(struct cli_state*, uint16 fnum);
+ struct cli_connection *con;
+ void (*free)(struct cli_connection*);
};
static struct policy
union {
struct samr_info *samr;
struct reg_info *reg;
- struct cli_info *cli;
+ struct con_info *con;
} dev;
}
/****************************************************************************
- set cli state
+ set con state
****************************************************************************/
-BOOL set_policy_cli_state(POLICY_HND *hnd, struct cli_state *cli, uint16 fnum,
- void (*free_fn)(struct cli_state *, uint16))
+BOOL set_policy_con(POLICY_HND *hnd, struct cli_connection *con,
+ void (*free_fn)(struct cli_connection *))
{
struct policy *p = find_policy(hnd);
if (p && p->open)
{
- DEBUG(3,("Setting policy cli state pnum=%x\n", p->pnum));
+ DEBUG(3,("Setting policy con state pnum=%x\n", p->pnum));
- if (p->dev.cli == NULL)
+ if (p->dev.con == NULL)
{
p->type = POL_CLI_INFO;
- p->dev.cli = (struct cli_info*)malloc(sizeof(*p->dev.cli));
+ p->dev.con = (struct con_info*)malloc(sizeof(*p->dev.con));
}
- if (p->dev.cli == NULL)
+ if (p->dev.con == NULL)
{
return False;
}
- p->dev.cli->cli = cli;
- p->dev.cli->free = free_fn;
- p->dev.cli->fnum = fnum;
+ p->dev.con->con = con;
+ p->dev.con->free = free_fn;
return True;
}
- DEBUG(3,("Error setting policy cli state\n"));
+ DEBUG(3,("Error setting policy con state\n"));
return False;
}
/****************************************************************************
- get cli state
+ get con state
****************************************************************************/
-BOOL get_policy_cli_state(const POLICY_HND *hnd, struct cli_state **cli,
- uint16 *fnum)
+BOOL get_policy_con(const POLICY_HND *hnd, struct cli_connection **con)
{
struct policy *p = find_policy(hnd);
if (p != NULL && p->open)
{
- DEBUG(3,("Getting cli state pnum=%x\n", p->pnum));
+ DEBUG(3,("Getting con state pnum=%x\n", p->pnum));
- if (cli != NULL)
+ if (con != NULL)
{
- (*cli ) = p->dev.cli->cli;
- }
- if (fnum != NULL)
- {
- (*fnum) = p->dev.cli->fnum;
+ (*con ) = p->dev.con->con;
}
return True;
}
case POL_CLI_INFO:
{
- if (p->dev.cli->free != NULL)
+ if (p->dev.con->free != NULL)
{
- p->dev.cli->free(p->dev.cli->cli,
- p->dev.cli->fnum);
+ p->dev.con->free(p->dev.con->con);
}
- free(p->dev.cli);
+ free(p->dev.con);
break;
}
}
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;
* 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;
}
* 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))
{
* 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;
}
/****************************************************************************
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);
}
/****************************************************************************
****************************************************************************/
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);
+}
{
POLICY_HND pol;
fstring srv_name;
- struct cli_state cli;
+ struct cli_connection *con = NULL;
BOOL res = True;
fstring dom3;
fstring dom5;
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;
res = res ? lsa_close(&pol) : False;
/* close the session */
- cli_ulogoff(&cli);
- cli_shutdown(&cli);
+ cli_connection_unlink(con);
if (res)
{
{
POLICY_HND pol;
fstring srv_name;
- struct cli_state cli;
+ struct cli_connection *con = NULL;
BOOL res = True;
BOOL res1 = True;
DOM_SID sid3;
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;
res = res ? lsa_close(&pol) : False;
/* close the session */
- cli_ulogoff(&cli);
- cli_shutdown(&cli);
+ cli_connection_unlink(con);
if (res1)
{
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;
}
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;
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);
}
}
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;
}
/* 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);
}
}
}
-/****************************************************************************
- 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.
****************************************************************************/
void cli_nt_session_close(struct cli_state *cli, uint16 fnum)
{
- cli_close(cli, fnum);
+ if (fnum != 0xffff)
+ {
+ cli_close(cli, fnum);
+ }
}
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;
}
{
case HKEY_CLASSES_ROOT:
{
- res = res ? reg_open_hkcr(cli, fnum,
+ res = res ? reg_open_hkcr(con,
0x5428, 0x02000000,
reg_hnd) : False;
break;
case HKEY_LOCAL_MACHINE:
{
- res = res ? reg_open_hklm(cli, fnum,
+ res = res ? reg_open_hklm(con,
0x84E0, 0x02000000,
reg_hnd) : False;
break;
case HKEY_USERS:
{
- res = res ? reg_open_hku(cli, fnum,
+ res = res ? reg_open_hku(con,
0x84E0, 0x02000000,
reg_hnd) : False;
break;
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;
}
}
/****************************************************************************
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)
{
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;
/****************************************************************************
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)
{
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;
/****************************************************************************
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)
{
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;
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;
}
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;
}
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;
prs_mem_free(&rbuf);
prs_mem_free(&buf );
- cli_state_free(cli, fnum);
+ cli_connection_unlink(con);
return valid_shutdown;
}
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])
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;
prs_mem_free(&data );
prs_mem_free(&rdata );
- cli_state_free(cli, fnum);
+ cli_connection_unlink(con);
return valid_pwc;
}
/****************************************************************************
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;
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;
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;
}
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;
{
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);
}
}
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;
}
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;
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);
}
}
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;
}
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;
/* 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);
}
}
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;
}
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;
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;
}
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;
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;
}
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;
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;
}
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;
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;
}
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;
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;
}
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;
uint32 status; /* some sort of flag. best to record it. comes from opnum 0x39 */
};
-struct cli_info
+struct con_info
{
- struct cli_state *cli;
- uint16 fnum;
- void (*free)(struct cli_state*, uint16 fnum);
+ struct cli_connection *con;
+ void (*free)(struct cli_connection*);
};
static struct policy
union {
struct samr_info *samr;
struct reg_info *reg;
- struct cli_info *cli;
+ struct con_info *con;
} dev;
}
/****************************************************************************
- set cli state
+ set con state
****************************************************************************/
-BOOL set_policy_cli_state(POLICY_HND *hnd, struct cli_state *cli, uint16 fnum,
- void (*free_fn)(struct cli_state *, uint16))
+BOOL set_policy_con(POLICY_HND *hnd, struct cli_connection *con,
+ void (*free_fn)(struct cli_connection *))
{
struct policy *p = find_policy(hnd);
if (p && p->open)
{
- DEBUG(3,("Setting policy cli state pnum=%x\n", p->pnum));
+ DEBUG(3,("Setting policy con state pnum=%x\n", p->pnum));
- if (p->dev.cli == NULL)
+ if (p->dev.con == NULL)
{
p->type = POL_CLI_INFO;
- p->dev.cli = (struct cli_info*)malloc(sizeof(*p->dev.cli));
+ p->dev.con = (struct con_info*)malloc(sizeof(*p->dev.con));
}
- if (p->dev.cli == NULL)
+ if (p->dev.con == NULL)
{
return False;
}
- p->dev.cli->cli = cli;
- p->dev.cli->free = free_fn;
- p->dev.cli->fnum = fnum;
+ p->dev.con->con = con;
+ p->dev.con->free = free_fn;
return True;
}
- DEBUG(3,("Error setting policy cli state\n"));
+ DEBUG(3,("Error setting policy con state\n"));
return False;
}
/****************************************************************************
- get cli state
+ get con state
****************************************************************************/
-BOOL get_policy_cli_state(const POLICY_HND *hnd, struct cli_state **cli,
- uint16 *fnum)
+BOOL get_policy_con(const POLICY_HND *hnd, struct cli_connection **con)
{
struct policy *p = find_policy(hnd);
if (p != NULL && p->open)
{
- DEBUG(3,("Getting cli state pnum=%x\n", p->pnum));
+ DEBUG(3,("Getting con state pnum=%x\n", p->pnum));
- if (cli != NULL)
+ if (con != NULL)
{
- (*cli ) = p->dev.cli->cli;
- }
- if (fnum != NULL)
- {
- (*fnum) = p->dev.cli->fnum;
+ (*con ) = p->dev.con->con;
}
return True;
}
case POL_CLI_INFO:
{
- if (p->dev.cli->free != NULL)
+ if (p->dev.con->free != NULL)
{
- p->dev.cli->free(p->dev.cli->cli,
- p->dev.cli->fnum);
+ p->dev.con->free(p->dev.con->con);
}
- free(p->dev.cli);
+ free(p->dev.con);
break;
}
}
#define DEBUG_TESTING
-extern struct cli_state *smb_cli;
extern struct user_credentials *usr_creds;
extern FILE* out_hnd;
****************************************************************************/
void cmd_sam_ntchange_pwd(struct client_info *info, int argc, char *argv[])
{
- uint16 fnum;
fstring srv_name;
fstring domain;
fstring sid;
uchar lm_hshhash[16];
uchar lm_oldhash[16];
+ struct cli_connection *con = NULL;
+
sid_to_string(sid, &info->dom.level5_sid);
fstrcpy(domain, info->dom.level5_dom);
E_old_pw_hash(lm_newhash, lm_oldhash, lm_hshhash);
E_old_pw_hash(lm_newhash, nt_oldhash, nt_hshhash);
- cli_nt_set_ntlmssp_flgs(smb_cli,
- NTLMSSP_NEGOTIATE_UNICODE |
+ usr_creds->ntlmssp_flags = NTLMSSP_NEGOTIATE_UNICODE |
NTLMSSP_NEGOTIATE_OEM |
NTLMSSP_NEGOTIATE_SIGN |
NTLMSSP_NEGOTIATE_SEAL |
NTLMSSP_NEGOTIATE_NTLM |
NTLMSSP_NEGOTIATE_ALWAYS_SIGN |
NTLMSSP_NEGOTIATE_00001000 |
- NTLMSSP_NEGOTIATE_00002000);
+ NTLMSSP_NEGOTIATE_00002000;
/* open SAMR session. */
- res = res ? cli_nt_session_open(smb_cli, PIPE_SAMR, &fnum) : False;
+ res = res ? cli_connection_init(srv_name, PIPE_SAMR, &con) : False;
/* establish a connection. */
- res = res ? samr_unknown_38(smb_cli, fnum, srv_name) : False;
+ res = res ? samr_unknown_38(con, srv_name) : False;
/* establish a connection. */
- res = res ? samr_chgpasswd_user(smb_cli, fnum,
+ res = res ? samr_chgpasswd_user(con,
srv_name, usr_creds->user_name,
nt_newpass, nt_hshhash,
lm_newpass, lm_hshhash) : False;
/* close the session */
- cli_nt_session_close(smb_cli, fnum);
+ cli_connection_unlink(con);
if (res)
{
****************************************************************************/
void cmd_sam_test(struct client_info *info, int argc, char *argv[])
{
- uint16 fnum;
+ struct cli_connection *con = NULL;
fstring srv_name;
fstring domain;
fstring sid;
report(out_hnd, "SAM Encryption Test\n");
- cli_nt_set_ntlmssp_flgs(smb_cli,
- NTLMSSP_NEGOTIATE_UNICODE |
+ usr_creds->ntlmssp_flags = NTLMSSP_NEGOTIATE_UNICODE |
NTLMSSP_NEGOTIATE_OEM |
NTLMSSP_NEGOTIATE_SIGN |
NTLMSSP_NEGOTIATE_SEAL |
NTLMSSP_NEGOTIATE_NTLM |
NTLMSSP_NEGOTIATE_ALWAYS_SIGN |
NTLMSSP_NEGOTIATE_00001000 |
- NTLMSSP_NEGOTIATE_00002000);
+ NTLMSSP_NEGOTIATE_00002000;
/* open SAMR session. */
- res = res ? cli_nt_session_open(smb_cli, PIPE_SAMR, &fnum) : False;
-
- /* establish a connection. */
- res = res ? samr_unknown_38(smb_cli, fnum, srv_name) : False;
+ res = res ? cli_connection_init(srv_name, PIPE_SAMR, &con) : False;
/* close the session */
- cli_nt_session_close(smb_cli, fnum);
+ cli_connection_unlink(con);
if (res)
{
/****************************************************************************
This defines the commands supported by this client
****************************************************************************/
-struct
-{
- char *name;
- void (*fn)(struct client_info*, int, char*[]);
- char *description;
- char compl_args[2];
-}
-commands[] =
+struct command_set commands[] =
{
/*
* eventlog