r25068: Older samba3 DCs will return DCERPC_FAULT_OP_RNG_ERROR for every opcode on the
[Samba.git] / source / rpc_server / srv_eventlog.c
blob1492e671093d01ffdfea966febfa8868eb7e180c
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 2 of the License, or
10 * (at your option) any later version.
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.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include "includes.h"
24 #undef DBGC_CLASS
25 #define DBGC_CLASS DBGC_RPC_SRV
27 static BOOL proxy_eventlog_call(pipes_struct *p, uint8 opnum)
29 struct api_struct *fns;
30 int n_fns;
32 eventlog_get_pipe_fns(&fns, &n_fns);
34 if (opnum >= n_fns)
35 return False;
37 if (fns[opnum].opnum != opnum) {
38 smb_panic("EVENTLOG function table not sorted\n");
41 return fns[opnum].fn(p);
44 static BOOL api_eventlog_open_eventlog(pipes_struct *p)
46 EVENTLOG_Q_OPEN_EVENTLOG q_u;
47 EVENTLOG_R_OPEN_EVENTLOG r_u;
48 prs_struct *data = &p->in_data.data;
49 prs_struct *rdata = &p->out_data.rdata;
51 ZERO_STRUCT(q_u);
52 ZERO_STRUCT(r_u);
54 if (!(eventlog_io_q_open_eventlog("", &q_u, data, 0))) {
55 DEBUG(0, ("eventlog_io_q_open_eventlog: unable to unmarshall EVENTLOG_Q_OPEN_EVENTLOG.\n"));
56 return False;
59 r_u.status = _eventlog_open_eventlog(p, &q_u, &r_u);
61 if (!(eventlog_io_r_open_eventlog("", &r_u, rdata, 0))) {
62 DEBUG(0, ("eventlog_io_r_open_eventlog: unable to marshall EVENTLOG_R_OPEN_EVENTLOG.\n"));
63 return False;
66 return True;
69 static BOOL api_eventlog_close_eventlog(pipes_struct *p)
71 return proxy_eventlog_call( p, DCERPC_EVENTLOG_CLOSEEVENTLOG );
74 static BOOL api_eventlog_get_num_records(pipes_struct *p)
76 EVENTLOG_Q_GET_NUM_RECORDS q_u;
77 EVENTLOG_R_GET_NUM_RECORDS r_u;
78 prs_struct *data = &p->in_data.data;
79 prs_struct *rdata = &p->out_data.rdata;
81 ZERO_STRUCT(q_u);
82 ZERO_STRUCT(r_u);
84 if (!(eventlog_io_q_get_num_records("", &q_u, data, 0))) {
85 DEBUG(0, ("eventlog_io_q_get_num_records: unable to unmarshall EVENTLOG_Q_GET_NUM_RECORDS.\n"));
86 return False;
89 r_u.status = _eventlog_get_num_records(p, &q_u, &r_u);
91 if (!(eventlog_io_r_get_num_records("", &r_u, rdata, 0))) {
92 DEBUG(0, ("eventlog_io_r_get_num_records: unable to marshall EVENTLOG_R_GET_NUM_RECORDS.\n"));
93 return False;
96 return True;
99 static BOOL api_eventlog_get_oldest_entry(pipes_struct *p)
101 EVENTLOG_Q_GET_OLDEST_ENTRY q_u;
102 EVENTLOG_R_GET_OLDEST_ENTRY r_u;
103 prs_struct *data = &p->in_data.data;
104 prs_struct *rdata = &p->out_data.rdata;
106 ZERO_STRUCT(q_u);
107 ZERO_STRUCT(r_u);
109 if (!(eventlog_io_q_get_oldest_entry("", &q_u, data, 0))) {
110 DEBUG(0, ("eventlog_io_q_get_oldest_entry: unable to unmarshall EVENTLOG_Q_GET_OLDEST_ENTRY.\n"));
111 return False;
114 r_u.status = _eventlog_get_oldest_entry(p, &q_u, &r_u);
116 if (!(eventlog_io_r_get_oldest_entry("", &r_u, rdata, 0))) {
117 DEBUG(0, ("eventlog_io_r_get_oldest_entry: unable to marshall EVENTLOG_R_GET_OLDEST_ENTRY.\n"));
118 return False;
121 return True;
124 static BOOL api_eventlog_read_eventlog(pipes_struct *p)
126 EVENTLOG_Q_READ_EVENTLOG q_u;
127 EVENTLOG_R_READ_EVENTLOG r_u;
128 prs_struct *data = &p->in_data.data;
129 prs_struct *rdata = &p->out_data.rdata;
131 ZERO_STRUCT(q_u);
132 ZERO_STRUCT(r_u);
134 if (!(eventlog_io_q_read_eventlog("", &q_u, data, 0))) {
135 DEBUG(0, ("eventlog_io_q_read_eventlog: unable to unmarshall EVENTLOG_Q_READ_EVENTLOG.\n"));
136 return False;
139 r_u.status = _eventlog_read_eventlog(p, &q_u, &r_u);
141 if (!(eventlog_io_r_read_eventlog("", &q_u, &r_u, rdata, 0))) {
142 DEBUG(0, ("eventlog_io_r_read_eventlog: unable to marshall EVENTLOG_R_READ_EVENTLOG.\n"));
143 return False;
146 return True;
149 static BOOL api_eventlog_clear_eventlog(pipes_struct *p)
151 EVENTLOG_Q_CLEAR_EVENTLOG q_u;
152 EVENTLOG_R_CLEAR_EVENTLOG r_u;
153 prs_struct *data = &p->in_data.data;
154 prs_struct *rdata = &p->out_data.rdata;
156 ZERO_STRUCT(q_u);
157 ZERO_STRUCT(r_u);
159 if (!(eventlog_io_q_clear_eventlog("", &q_u, data, 0))) {
160 DEBUG(0, ("eventlog_io_q_clear_eventlog: unable to unmarshall EVENTLOG_Q_CLEAR_EVENTLOG.\n"));
161 return False;
164 r_u.status = _eventlog_clear_eventlog(p, &q_u, &r_u);
166 if (!(eventlog_io_r_clear_eventlog("", &r_u, rdata, 0))) {
167 DEBUG(0, ("eventlog_io_q_clear_eventlog: unable to marshall EVENTLOG_Q_CLEAR_EVENTLOG.\n"));
168 return False;
171 return True;
175 \pipe\eventlog commands
177 struct api_struct api_eventlog_cmds[] =
179 {"EVENTLOG_OPENEVENTLOG", EVENTLOG_OPENEVENTLOG, api_eventlog_open_eventlog },
180 {"EVENTLOG_CLOSEEVENTLOG", EVENTLOG_CLOSEEVENTLOG, api_eventlog_close_eventlog },
181 {"EVENTLOG_GETNUMRECORDS", EVENTLOG_GETNUMRECORDS, api_eventlog_get_num_records },
182 {"EVENTLOG_GETOLDESTENTRY", EVENTLOG_GETOLDESTENTRY, api_eventlog_get_oldest_entry },
183 {"EVENTLOG_READEVENTLOG", EVENTLOG_READEVENTLOG, api_eventlog_read_eventlog },
184 {"EVENTLOG_CLEAREVENTLOG", EVENTLOG_CLEAREVENTLOG, api_eventlog_clear_eventlog }
187 NTSTATUS rpc_eventlog2_init(void)
189 return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION,
190 "eventlog", "eventlog", api_eventlog_cmds,
191 sizeof(api_eventlog_cmds)/sizeof(struct api_struct));
194 void eventlog2_get_pipe_fns(struct api_struct **fns, int *n_fns)
196 *fns = api_eventlog_cmds;
197 *n_fns = sizeof(api_eventlog_cmds) / sizeof(struct api_struct);