2 Unix SMB/CIFS implementation.
3 test suite for eventlog rpc operations
5 Copyright (C) Tim Potter 2003
6 Copyright (C) Jelmer Vernooij 2004
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include "librpc/gen_ndr/ndr_eventlog.h"
26 static void init_eventlog_String(struct eventlog_String
*name
, const char *s
)
29 name
->name_len
= 2*strlen_m(s
);
30 name
->name_size
= name
->name_len
;
33 static BOOL
test_GetNumRecords(struct dcerpc_pipe
*p
, TALLOC_CTX
*mem_ctx
, struct policy_handle
*handle
)
36 struct eventlog_GetNumRecords r
;
38 printf("\ntesting GetNumRecords\n");
42 status
= dcerpc_eventlog_GetNumRecords(p
, mem_ctx
, &r
);
44 if (!NT_STATUS_IS_OK(status
)) {
45 printf("GetNumRecords failed - %s\n", nt_errstr(status
));
49 printf("%d records\n", r
.out
.number
);
54 static BOOL
test_ReadEventLog(struct dcerpc_pipe
*p
, TALLOC_CTX
*mem_ctx
, struct policy_handle
*handle
, uint32_t offset
)
57 struct eventlog_ReadEventLogW r
;
59 printf("\ntesting ReadEventLog\n");
64 r
.in
.number_of_bytes
= 0x0;
66 status
= dcerpc_eventlog_ReadEventLogW(p
, mem_ctx
, &r
);
68 if (!NT_STATUS_IS_OK(status
)) {
69 printf("ReadEventLog failed - %s\n", nt_errstr(status
));
73 if (NT_STATUS_IS_OK(r
.out
.result
)) {
78 if (!NT_STATUS_EQUAL(r
.out
.result
, NT_STATUS_BUFFER_TOO_SMALL
)) {
79 printf("ReadEventLog failed - %s\n", nt_errstr(r
.out
.result
));
83 r
.in
.number_of_bytes
= r
.out
.real_size
;
85 status
= dcerpc_eventlog_ReadEventLogW(p
, mem_ctx
, &r
);
87 if (!NT_STATUS_IS_OK(status
)) {
88 printf("ReadEventLog failed - %s\n", nt_errstr(status
));
96 static BOOL
test_CloseEventLog(struct dcerpc_pipe
*p
, TALLOC_CTX
*mem_ctx
,
97 struct policy_handle
*handle
)
100 struct eventlog_CloseEventLog r
;
102 r
.in
.handle
= r
.out
.handle
= handle
;
104 printf("Testing CloseEventLog\n");
106 status
= dcerpc_eventlog_CloseEventLog(p
, mem_ctx
, &r
);
107 if (!NT_STATUS_IS_OK(status
)) {
108 printf("CloseEventLog failed - %s\n", nt_errstr(status
));
115 static BOOL
test_OpenEventLog(struct dcerpc_pipe
*p
, TALLOC_CTX
*mem_ctx
, struct policy_handle
*handle
)
118 struct eventlog_OpenEventLogW r
;
119 struct eventlog_OpenUnknown0 unknown0
;
121 printf("\ntesting OpenEventLog\n");
123 unknown0
.unknown0
= 0x005c;
124 unknown0
.unknown1
= 0x0001;
126 r
.in
.unknown0
= &unknown0
;
127 init_eventlog_String(&r
.in
.source
, "system");
128 init_eventlog_String(&r
.in
.unknown1
, NULL
);
129 r
.in
.unknown2
= 0x00000001;
130 r
.in
.unknown3
= 0x00000001;
131 r
.out
.handle
= handle
;
133 status
= dcerpc_eventlog_OpenEventLogW(p
, mem_ctx
, &r
);
135 if (!NT_STATUS_IS_OK(status
)) {
136 printf("OpenEventLog failed - %s\n", nt_errstr(status
));
140 if (!NT_STATUS_IS_OK(r
.out
.result
)) {
141 printf("OpenEventLog failed - %s\n", nt_errstr(r
.out
.result
));
148 BOOL
torture_rpc_eventlog(void)
151 struct dcerpc_pipe
*p
;
152 struct policy_handle handle
;
156 mem_ctx
= talloc_init("torture_rpc_atsvc");
158 status
= torture_rpc_connection(&p
,
159 DCERPC_EVENTLOG_NAME
,
160 DCERPC_EVENTLOG_UUID
,
161 DCERPC_EVENTLOG_VERSION
);
162 if (!NT_STATUS_IS_OK(status
)) {
166 if (!test_OpenEventLog(p
, mem_ctx
, &handle
)) {
170 test_GetNumRecords(p
, mem_ctx
, &handle
);
172 test_ReadEventLog(p
, mem_ctx
, &handle
, 0);
174 test_CloseEventLog(p
, mem_ctx
, &handle
);
176 talloc_destroy(mem_ctx
);
178 torture_rpc_close(p
);