1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-19 10:03:58 +03:00

this one's a handle-based one (missed in the first round).

This commit is contained in:
Luke Leighton -
parent e4e5743a40
commit 4c3556fae7
4 changed files with 47 additions and 38 deletions

View File

@ -1804,10 +1804,10 @@ BOOL rpc_con_pipe_req(struct cli_connection *con, uint8 op_num,
/*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);
@ -2344,7 +2344,7 @@ BOOL brs_io_r_query_info(char *desc, BRS_R_QUERY_INFO *r_u, prs_struct *ps, int
/*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);

View File

@ -27,13 +27,20 @@ extern int DEBUGLEVEL;
/****************************************************************************
****************************************************************************/
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 );
@ -45,7 +52,7 @@ BOOL do_event_open(struct cli_state *cli, uint16 fnum, char *log, POLICY_HND *hn
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;
@ -55,7 +62,7 @@ BOOL do_event_open(struct cli_state *cli, uint16 fnum, char *log, POLICY_HND *hn
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;
}
@ -63,7 +70,9 @@ BOOL do_event_open(struct cli_state *cli, uint16 fnum, char *log, POLICY_HND *hn
{
/*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);
}
}
@ -75,7 +84,7 @@ BOOL do_event_open(struct cli_state *cli, uint16 fnum, char *log, POLICY_HND *hn
/****************************************************************************
****************************************************************************/
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;
@ -92,7 +101,7 @@ BOOL do_event_close(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd)
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;
@ -102,7 +111,7 @@ BOOL do_event_close(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd)
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;
}
@ -111,12 +120,14 @@ BOOL do_event_close(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd)
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;
@ -133,7 +144,7 @@ BOOL do_event_numofeventlogrec(struct cli_state *cli, uint16 fnum, POLICY_HND *h
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;
@ -143,7 +154,7 @@ BOOL do_event_numofeventlogrec(struct cli_state *cli, uint16 fnum, POLICY_HND *h
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;
}
@ -161,7 +172,7 @@ BOOL do_event_numofeventlogrec(struct cli_state *cli, uint16 fnum, POLICY_HND *h
/****************************************************************************
****************************************************************************/
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)
{
@ -181,7 +192,7 @@ BOOL do_event_readeventlog(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
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);

View File

@ -27,7 +27,7 @@ extern int DEBUGLEVEL;
/*******************************************************************
********************************************************************/
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;

View File

@ -32,7 +32,6 @@ extern int DEBUGLEVEL;
#define DEBUG_TESTING
extern struct cli_state *smb_cli;
extern FILE* out_hnd;
@ -40,9 +39,8 @@ 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;
@ -52,43 +50,43 @@ void cmd_eventlog(struct client_info *info, int argc, char *argv[])
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;
}