/*The following definitions come from rpc_client/cli_eventlog.c */
-BOOL do_event_open(struct cli_state *cli, uint16 fnum, char *log, POLICY_HND *hnd);
-BOOL do_event_close(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd);
-BOOL do_event_numofeventlogrec(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd, uint32 *number);
-BOOL do_event_readeventlog(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
+BOOL event_open(const char* srv_name, const char *log, POLICY_HND *hnd);
+BOOL event_close( POLICY_HND *hnd);
+BOOL event_numofeventlogrec( POLICY_HND *hnd, uint32 *number);
+BOOL event_readeventlog(POLICY_HND *hnd,
uint32 number, uint32 flags, uint32 offset,
uint32 *number_of_bytes, EVENTLOGRECORD *ev);
/*The following definitions come from rpc_parse/parse_eventlog.c */
-BOOL make_eventlog_q_open(EVENTLOG_Q_OPEN *q_u, char *journal, char *unk);
+BOOL make_eventlog_q_open(EVENTLOG_Q_OPEN *q_u, const char *journal, char *unk);
BOOL eventlog_io_q_open(char *desc, EVENTLOG_Q_OPEN *q_u, prs_struct *ps, int depth);
BOOL eventlog_io_r_open(char *desc, EVENTLOG_R_OPEN *r_u, prs_struct *ps, int depth);
BOOL make_eventlog_q_close(EVENTLOG_Q_CLOSE *q_u, POLICY_HND *pol);
/****************************************************************************
****************************************************************************/
-BOOL do_event_open(struct cli_state *cli, uint16 fnum, char *log, POLICY_HND *hnd)
+BOOL event_open(const char* srv_name, const char *log, POLICY_HND *hnd)
{
prs_struct rbuf;
prs_struct buf;
EVENTLOG_Q_OPEN q;
BOOL p = False;
BOOL valid_pol = False;
+
+ struct cli_connection *con = NULL;
+
+ if (!cli_connection_init(srv_name, PIPE_EVENTLOG, &con))
+ {
+ return False;
+ }
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
eventlog_io_q_open("", &q, &buf, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, fnum, EVENTLOG_OPEN, &buf, &rbuf))
+ if (rpc_con_pipe_req(con, EVENTLOG_OPEN, &buf, &rbuf))
{
EVENTLOG_R_OPEN r;
if (p && r.status != 0)
{
/* report error code */
- DEBUG(0,("do_event_open: %s\n", get_nt_error_msg(r.status)));
+ DEBUG(0,("event_open: %s\n", get_nt_error_msg(r.status)));
p = False;
}
{
/*copy handle */
memcpy(hnd->data, r.pol.data, sizeof(hnd->data));
- valid_pol = True;
+ valid_pol = register_policy_hnd(hnd) &&
+ set_policy_con(hnd, con,
+ cli_connection_unlink);
}
}
/****************************************************************************
****************************************************************************/
-BOOL do_event_close(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd)
+BOOL event_close( POLICY_HND *hnd)
{
prs_struct rbuf;
prs_struct buf;
eventlog_io_q_close("", &q, &buf, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, fnum, EVENTLOG_CLOSE, &buf, &rbuf))
+ if (rpc_hnd_pipe_req(hnd, EVENTLOG_CLOSE, &buf, &rbuf))
{
EVENTLOG_R_CLOSE r;
if (p && r.status != 0)
{
/* report error code */
- DEBUG(0,("do_event_close: %s\n", get_nt_error_msg(r.status)));
+ DEBUG(0,("event_close: %s\n", get_nt_error_msg(r.status)));
p = False;
}
prs_mem_free(&rbuf);
prs_mem_free(&buf );
+ close_policy_hnd(hnd);
+
return p;
}
/****************************************************************************
****************************************************************************/
-BOOL do_event_numofeventlogrec(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd, uint32 *number)
+BOOL event_numofeventlogrec( POLICY_HND *hnd, uint32 *number)
{
prs_struct rbuf;
prs_struct buf;
eventlog_io_q_numofeventlogrec("", &q, &buf, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, fnum, EVENTLOG_NUMOFEVENTLOGRECORDS, &buf, &rbuf))
+ if (rpc_hnd_pipe_req(hnd, EVENTLOG_NUMOFEVENTLOGRECORDS, &buf, &rbuf))
{
EVENTLOG_R_NUMOFEVENTLOGREC r;
if (p && r.status != 0)
{
/* report error code */
- DEBUG(0,("do_event_close: %s\n", get_nt_error_msg(r.status)));
+ DEBUG(0,("event_close: %s\n", get_nt_error_msg(r.status)));
p = False;
}
/****************************************************************************
****************************************************************************/
-BOOL do_event_readeventlog(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
+BOOL event_readeventlog(POLICY_HND *hnd,
uint32 number, uint32 flags, uint32 offset,
uint32 *number_of_bytes, EVENTLOGRECORD *ev)
{
eventlog_io_q_readeventlog("", &q, &buf, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, fnum, EVENTLOG_READEVENTLOG, &buf, &rbuf))
+ if (rpc_hnd_pipe_req(hnd, EVENTLOG_READEVENTLOG, &buf, &rbuf))
{
r.event=ev;
eventlog_io_r_readeventlog("", &r, &rbuf, 0);
/*******************************************************************
********************************************************************/
-BOOL make_eventlog_q_open(EVENTLOG_Q_OPEN *q_u, char *journal, char *unk)
+BOOL make_eventlog_q_open(EVENTLOG_Q_OPEN *q_u, const char *journal, char *unk)
{
int len_journal = journal != NULL ? strlen(journal) : 0;
int len_unk = unk != NULL ? strlen(unk) : 0;
#define DEBUG_TESTING
-extern struct cli_state *smb_cli;
extern FILE* out_hnd;
****************************************************************************/
void cmd_eventlog(struct client_info *info, int argc, char *argv[])
{
- uint16 nt_pipe_fnum;
- BOOL res = True;
- BOOL res1 = True;
+ BOOL res1 = True;
+ BOOL res = True;
POLICY_HND hnd;
uint32 number = 0;
uint32 flags;
char *journal = NULL;
- flags=EVENTLOG_READ_SEQUENTIAL|EVENTLOG_READ_BACKWARD;
+ fstring srv_name;
+ fstrcpy(srv_name, "\\\\");
+ fstrcat(srv_name, info->dest_host);
+ strupper(srv_name);
+
+ flags = EVENTLOG_READ_SEQUENTIAL|EVENTLOG_READ_BACKWARD;
if (argc > 1)
{
journal = argv[1];
}
- /* open scheduler session. */
- res1 = res1 ? cli_nt_session_open(smb_cli, PIPE_EVENTLOG, &nt_pipe_fnum) : False;
-
- res1 = res1 ? do_event_open(smb_cli, nt_pipe_fnum, journal, &hnd) : False;
-
- res = res1 ? do_event_numofeventlogrec(smb_cli, nt_pipe_fnum, &hnd, &number) : False;
+ res = res ? event_open(srv_name, journal, &hnd) : False;
+ res1 = res ? event_numofeventlogrec(&hnd, &number) : False;
fprintf(out_hnd, "Number of events: %d\n", number);
display_eventlog_eventrecord(out_hnd, ACTION_HEADER, &ev);
- for (offset = 0; offset < number && res; offset++)
+ for (offset = 0; offset < number && res1; offset++)
{
num_of_bytes=0;
/* try once with a empty buffer */
- res = res ? do_event_readeventlog(smb_cli, nt_pipe_fnum, &hnd, number,
- flags, offset, &num_of_bytes, &ev) : False;
+ res1 = res1 ? event_readeventlog(&hnd, number,
+ flags, offset,
+ &num_of_bytes, &ev) : False;
/* and try again with the correct size */
- res = res ? do_event_readeventlog(smb_cli, nt_pipe_fnum, &hnd, number,
- flags, offset, &num_of_bytes, &ev) : False;
+ res1 = res1 ? event_readeventlog(&hnd, number,
+ flags, offset,
+ &num_of_bytes, &ev) : False;
display_eventlog_eventrecord(out_hnd, ACTION_ENUMERATE, &ev);
}
display_eventlog_eventrecord(out_hnd, ACTION_FOOTER, &ev);
- res1 = res1 ? do_event_close(smb_cli, nt_pipe_fnum, &hnd): False;
-
- /* close the session */
- cli_nt_session_close(smb_cli, nt_pipe_fnum);
+ res = res ? event_close(&hnd): False;
}