| 1 | /*
|
|---|
| 2 | * Unix SMB/CIFS implementation.
|
|---|
| 3 | * RPC Pipe client / server routines
|
|---|
| 4 | * Copyright (C) Marcin Krzysztof Porwit 2005.
|
|---|
| 5 | * Copyright (C) Gerald Carter 2005 - 2007
|
|---|
| 6 | *
|
|---|
| 7 | * This program is free software; you can redistribute it and/or modify
|
|---|
| 8 | * it under the terms of the GNU General Public License as published by
|
|---|
| 9 | * the Free Software Foundation; either version 3 of the License, or
|
|---|
| 10 | * (at your option) any later version.
|
|---|
| 11 | *
|
|---|
| 12 | * This program is distributed in the hope that it will be useful,
|
|---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 15 | * GNU General Public License for more details.
|
|---|
| 16 | *
|
|---|
| 17 | * You should have received a copy of the GNU General Public License
|
|---|
| 18 | * along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|---|
| 19 | */
|
|---|
| 20 |
|
|---|
| 21 | #include "includes.h"
|
|---|
| 22 |
|
|---|
| 23 | #undef DBGC_CLASS
|
|---|
| 24 | #define DBGC_CLASS DBGC_RPC_SRV
|
|---|
| 25 |
|
|---|
| 26 | static bool proxy_eventlog_call(pipes_struct *p, uint8 opnum)
|
|---|
| 27 | {
|
|---|
| 28 | struct api_struct *fns;
|
|---|
| 29 | int n_fns;
|
|---|
| 30 |
|
|---|
| 31 | eventlog_get_pipe_fns(&fns, &n_fns);
|
|---|
| 32 |
|
|---|
| 33 | if (opnum >= n_fns)
|
|---|
| 34 | return False;
|
|---|
| 35 |
|
|---|
| 36 | if (fns[opnum].opnum != opnum) {
|
|---|
| 37 | smb_panic("EVENTLOG function table not sorted\n");
|
|---|
| 38 | }
|
|---|
| 39 |
|
|---|
| 40 | return fns[opnum].fn(p);
|
|---|
| 41 | }
|
|---|
| 42 |
|
|---|
| 43 | static bool api_eventlog_open_eventlog(pipes_struct *p)
|
|---|
| 44 | {
|
|---|
| 45 | return proxy_eventlog_call(p, NDR_EVENTLOG_OPENEVENTLOGW);
|
|---|
| 46 | }
|
|---|
| 47 |
|
|---|
| 48 | static bool api_eventlog_close_eventlog(pipes_struct *p)
|
|---|
| 49 | {
|
|---|
| 50 | return proxy_eventlog_call( p, NDR_EVENTLOG_CLOSEEVENTLOG );
|
|---|
| 51 | }
|
|---|
| 52 |
|
|---|
| 53 | static bool api_eventlog_get_num_records(pipes_struct *p)
|
|---|
| 54 | {
|
|---|
| 55 | return proxy_eventlog_call(p, NDR_EVENTLOG_GETNUMRECORDS);
|
|---|
| 56 | }
|
|---|
| 57 |
|
|---|
| 58 | static bool api_eventlog_get_oldest_entry(pipes_struct *p)
|
|---|
| 59 | {
|
|---|
| 60 | return proxy_eventlog_call(p, NDR_EVENTLOG_GETOLDESTRECORD);
|
|---|
| 61 | }
|
|---|
| 62 |
|
|---|
| 63 | static bool api_eventlog_read_eventlog(pipes_struct *p)
|
|---|
| 64 | {
|
|---|
| 65 | EVENTLOG_Q_READ_EVENTLOG q_u;
|
|---|
| 66 | EVENTLOG_R_READ_EVENTLOG r_u;
|
|---|
| 67 | prs_struct *data = &p->in_data.data;
|
|---|
| 68 | prs_struct *rdata = &p->out_data.rdata;
|
|---|
| 69 |
|
|---|
| 70 | ZERO_STRUCT(q_u);
|
|---|
| 71 | ZERO_STRUCT(r_u);
|
|---|
| 72 |
|
|---|
| 73 | if (!(eventlog_io_q_read_eventlog("", &q_u, data, 0))) {
|
|---|
| 74 | DEBUG(0, ("eventlog_io_q_read_eventlog: unable to unmarshall EVENTLOG_Q_READ_EVENTLOG.\n"));
|
|---|
| 75 | return False;
|
|---|
| 76 | }
|
|---|
| 77 |
|
|---|
| 78 | r_u.status = _eventlog_read_eventlog(p, &q_u, &r_u);
|
|---|
| 79 |
|
|---|
| 80 | if (!(eventlog_io_r_read_eventlog("", &q_u, &r_u, rdata, 0))) {
|
|---|
| 81 | DEBUG(0, ("eventlog_io_r_read_eventlog: unable to marshall EVENTLOG_R_READ_EVENTLOG.\n"));
|
|---|
| 82 | return False;
|
|---|
| 83 | }
|
|---|
| 84 |
|
|---|
| 85 | return True;
|
|---|
| 86 | }
|
|---|
| 87 |
|
|---|
| 88 | static bool api_eventlog_clear_eventlog(pipes_struct *p)
|
|---|
| 89 | {
|
|---|
| 90 | return proxy_eventlog_call(p, NDR_EVENTLOG_CLEAREVENTLOGW);
|
|---|
| 91 | }
|
|---|
| 92 |
|
|---|
| 93 | /*
|
|---|
| 94 | \pipe\eventlog commands
|
|---|
| 95 | */
|
|---|
| 96 | struct api_struct api_eventlog_cmds[] =
|
|---|
| 97 | {
|
|---|
| 98 | {"EVENTLOG_OPENEVENTLOG", EVENTLOG_OPENEVENTLOG, api_eventlog_open_eventlog },
|
|---|
| 99 | {"EVENTLOG_CLOSEEVENTLOG", EVENTLOG_CLOSEEVENTLOG, api_eventlog_close_eventlog },
|
|---|
| 100 | {"EVENTLOG_GETNUMRECORDS", EVENTLOG_GETNUMRECORDS, api_eventlog_get_num_records },
|
|---|
| 101 | {"EVENTLOG_GETOLDESTENTRY", EVENTLOG_GETOLDESTENTRY, api_eventlog_get_oldest_entry },
|
|---|
| 102 | {"EVENTLOG_READEVENTLOG", EVENTLOG_READEVENTLOG, api_eventlog_read_eventlog },
|
|---|
| 103 | {"EVENTLOG_CLEAREVENTLOG", EVENTLOG_CLEAREVENTLOG, api_eventlog_clear_eventlog }
|
|---|
| 104 | };
|
|---|
| 105 |
|
|---|
| 106 | NTSTATUS rpc_eventlog2_init(void)
|
|---|
| 107 | {
|
|---|
| 108 | return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION,
|
|---|
| 109 | "eventlog", "eventlog", api_eventlog_cmds,
|
|---|
| 110 | sizeof(api_eventlog_cmds)/sizeof(struct api_struct));
|
|---|
| 111 | }
|
|---|
| 112 |
|
|---|
| 113 | void eventlog2_get_pipe_fns(struct api_struct **fns, int *n_fns)
|
|---|
| 114 | {
|
|---|
| 115 | *fns = api_eventlog_cmds;
|
|---|
| 116 | *n_fns = sizeof(api_eventlog_cmds) / sizeof(struct api_struct);
|
|---|
| 117 | }
|
|---|