2009-01-12 20:21:20 +03:00
/*
2003-11-21 00:52:40 +03:00
Unix SMB / CIFS implementation .
test suite for eventlog rpc operations
2005-08-06 04:47:17 +04:00
Copyright ( C ) Tim Potter 2003 , 2005
2004-05-14 22:59:00 +04:00
Copyright ( C ) Jelmer Vernooij 2004
2009-01-21 02:33:01 +03:00
Copyright ( C ) Guenther Deschner 2009
2009-01-12 20:21:20 +03:00
2003-11-21 00:52:40 +03:00
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
2007-07-10 06:07:03 +04:00
the Free Software Foundation ; either version 3 of the License , or
2003-11-21 00:52:40 +03:00
( at your option ) any later version .
2009-01-12 20:21:20 +03:00
2003-11-21 00:52:40 +03:00
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
2009-01-12 20:21:20 +03:00
2003-11-21 00:52:40 +03:00
You should have received a copy of the GNU General Public License
2007-07-10 06:07:03 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2003-11-21 00:52:40 +03:00
*/
# include "includes.h"
2004-11-01 13:30:34 +03:00
# include "librpc/gen_ndr/ndr_eventlog.h"
2006-03-15 02:35:30 +03:00
# include "librpc/gen_ndr/ndr_eventlog_c.h"
2006-03-14 18:02:05 +03:00
# include "torture/rpc/rpc.h"
2007-12-14 00:46:27 +03:00
# include "param/param.h"
2003-11-21 00:52:40 +03:00
2009-01-21 02:25:50 +03:00
# define TEST_BACKUP_NAME "samrtorturetest"
2005-08-06 02:57:47 +04:00
static void init_lsa_String ( struct lsa_String * name , const char * s )
2003-11-21 06:07:02 +03:00
{
2005-08-06 02:57:47 +04:00
name - > string = s ;
name - > length = 2 * strlen_m ( s ) ;
name - > size = name - > length ;
2003-11-21 06:07:02 +03:00
}
2009-01-12 20:21:20 +03:00
static bool get_policy_handle ( struct torture_context * tctx ,
2010-03-15 12:55:00 +03:00
struct dcerpc_binding_handle * b ,
2009-01-12 20:21:20 +03:00
struct policy_handle * handle )
2006-10-16 17:06:41 +04:00
{
struct eventlog_OpenEventLogW r ;
struct eventlog_OpenUnknown0 unknown0 ;
2008-10-15 18:37:27 +04:00
struct lsa_String logname , servername ;
2006-10-16 17:06:41 +04:00
unknown0 . unknown0 = 0x005c ;
unknown0 . unknown1 = 0x0001 ;
r . in . unknown0 = & unknown0 ;
2008-11-20 02:01:41 +03:00
init_lsa_String ( & logname , " dns server " ) ;
init_lsa_String ( & servername , NULL ) ;
2008-10-15 18:37:27 +04:00
r . in . logname = & logname ;
r . in . servername = & servername ;
2008-11-20 15:29:44 +03:00
r . in . major_version = 0x00000001 ;
r . in . minor_version = 0x00000001 ;
2006-10-16 17:06:41 +04:00
r . out . handle = handle ;
2009-01-12 20:21:20 +03:00
torture_assert_ntstatus_ok ( tctx ,
2010-03-15 12:55:00 +03:00
dcerpc_eventlog_OpenEventLogW_r ( b , tctx , & r ) ,
2006-10-16 17:06:41 +04:00
" OpenEventLog failed " ) ;
torture_assert_ntstatus_ok ( tctx , r . out . result , " OpenEventLog failed " ) ;
return true ;
}
static bool test_GetNumRecords ( struct torture_context * tctx , struct dcerpc_pipe * p )
2004-05-14 22:59:00 +04:00
{
struct eventlog_GetNumRecords r ;
2006-10-16 17:06:41 +04:00
struct eventlog_CloseEventLog cr ;
struct policy_handle handle ;
2008-02-13 16:52:53 +03:00
uint32_t number = 0 ;
2010-03-15 12:55:00 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2004-05-14 22:59:00 +04:00
2010-03-15 12:55:00 +03:00
if ( ! get_policy_handle ( tctx , b , & handle ) )
2006-10-16 17:06:41 +04:00
return false ;
2004-05-14 22:59:00 +04:00
2008-02-13 16:52:53 +03:00
ZERO_STRUCT ( r ) ;
2006-10-16 17:06:41 +04:00
r . in . handle = & handle ;
2008-02-13 16:52:53 +03:00
r . out . number = & number ;
2004-05-14 22:59:00 +04:00
2009-01-12 20:21:20 +03:00
torture_assert_ntstatus_ok ( tctx ,
2010-03-15 12:55:00 +03:00
dcerpc_eventlog_GetNumRecords_r ( b , tctx , & r ) ,
2006-10-16 17:06:41 +04:00
" GetNumRecords failed " ) ;
2010-03-19 14:57:54 +03:00
torture_assert_ntstatus_ok ( tctx , r . out . result ,
" GetNumRecords failed " ) ;
2007-04-12 15:24:51 +04:00
torture_comment ( tctx , " %d records \n " , * r . out . number ) ;
2004-05-14 22:59:00 +04:00
2006-10-16 17:06:41 +04:00
cr . in . handle = cr . out . handle = & handle ;
2004-05-14 22:59:00 +04:00
2009-01-12 20:21:20 +03:00
torture_assert_ntstatus_ok ( tctx ,
2010-03-15 12:55:00 +03:00
dcerpc_eventlog_CloseEventLog_r ( b , tctx , & cr ) ,
2009-01-12 20:21:20 +03:00
" CloseEventLog failed " ) ;
2010-03-19 14:57:54 +03:00
torture_assert_ntstatus_ok ( tctx , cr . out . result ,
" CloseEventLog failed " ) ;
2006-10-16 17:06:41 +04:00
return true ;
2004-05-14 22:59:00 +04:00
}
2009-01-12 20:21:20 +03:00
static bool test_ReadEventLog ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
2004-05-14 22:59:00 +04:00
{
NTSTATUS status ;
2004-08-13 05:31:11 +04:00
struct eventlog_ReadEventLogW r ;
2006-10-16 17:06:41 +04:00
struct eventlog_CloseEventLog cr ;
struct policy_handle handle ;
2010-03-15 12:55:00 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2004-05-14 22:59:00 +04:00
2009-01-14 18:59:42 +03:00
uint32_t sent_size = 0 ;
uint32_t real_size = 0 ;
2010-03-15 12:55:00 +03:00
if ( ! get_policy_handle ( tctx , b , & handle ) )
2006-10-16 17:06:41 +04:00
return false ;
2004-05-14 22:59:00 +04:00
2008-02-13 16:52:53 +03:00
ZERO_STRUCT ( r ) ;
2005-08-09 07:09:47 +04:00
r . in . offset = 0 ;
2006-10-16 17:06:41 +04:00
r . in . handle = & handle ;
2009-01-13 16:44:29 +03:00
r . in . flags = 0 ;
2009-01-14 18:59:42 +03:00
r . out . data = NULL ;
r . out . sent_size = & sent_size ;
r . out . real_size = & real_size ;
2009-01-13 16:44:29 +03:00
2010-03-19 14:57:54 +03:00
torture_assert_ntstatus_ok ( tctx , dcerpc_eventlog_ReadEventLogW_r ( b , tctx , & r ) ,
" ReadEventLog failed " ) ;
2009-01-13 16:44:29 +03:00
torture_assert_ntstatus_equal ( tctx , r . out . result , NT_STATUS_INVALID_PARAMETER ,
" ReadEventLog failed " ) ;
2005-08-06 02:57:47 +04:00
2005-08-09 07:09:47 +04:00
while ( 1 ) {
2005-08-11 08:04:16 +04:00
DATA_BLOB blob ;
2009-01-16 20:04:11 +03:00
struct EVENTLOGRECORD rec ;
2007-11-09 21:24:51 +03:00
enum ndr_err_code ndr_err ;
2009-01-16 20:04:11 +03:00
uint32_t size = 0 ;
uint32_t pos = 0 ;
2005-08-11 08:04:16 +04:00
/* Read first for number of bytes in record */
2005-08-09 07:09:47 +04:00
r . in . number_of_bytes = 0 ;
2009-01-13 16:44:29 +03:00
r . in . flags = EVENTLOG_BACKWARDS_READ | EVENTLOG_SEQUENTIAL_READ ;
2005-08-09 07:09:47 +04:00
r . out . data = NULL ;
2008-02-13 16:52:53 +03:00
r . out . sent_size = & sent_size ;
r . out . real_size = & real_size ;
2004-05-14 22:59:00 +04:00
2010-03-19 14:57:54 +03:00
torture_assert_ntstatus_ok ( tctx , dcerpc_eventlog_ReadEventLogW_r ( b , tctx , & r ) ,
" ReadEventLogW failed " ) ;
2004-05-14 22:59:00 +04:00
2005-08-09 07:09:47 +04:00
if ( NT_STATUS_EQUAL ( r . out . result , NT_STATUS_END_OF_FILE ) ) {
2009-01-16 20:04:11 +03:00
/* FIXME: still need to decode then */
2005-08-09 07:09:47 +04:00
break ;
}
2004-05-14 22:59:00 +04:00
2006-10-16 17:06:41 +04:00
torture_assert_ntstatus_equal ( tctx , r . out . result , NT_STATUS_BUFFER_TOO_SMALL ,
" ReadEventLog failed " ) ;
2009-01-12 20:21:20 +03:00
2005-08-11 08:04:16 +04:00
/* Now read the actual record */
2006-11-23 03:34:31 +03:00
r . in . number_of_bytes = * r . out . real_size ;
2007-09-08 20:46:30 +04:00
r . out . data = talloc_array ( tctx , uint8_t , r . in . number_of_bytes ) ;
2004-05-14 22:59:00 +04:00
2010-03-19 14:57:54 +03:00
torture_assert_ntstatus_ok ( tctx , dcerpc_eventlog_ReadEventLogW_r ( b , tctx , & r ) ,
" ReadEventLogW failed " ) ;
2004-05-14 22:59:00 +04:00
2010-03-19 14:57:54 +03:00
torture_assert_ntstatus_ok ( tctx , r . out . result , " ReadEventLog failed " ) ;
2009-01-12 20:21:20 +03:00
2005-08-11 08:04:16 +04:00
/* Decode a user-marshalled record */
2009-01-16 20:04:11 +03:00
size = IVAL ( r . out . data , pos ) ;
2005-08-11 08:04:16 +04:00
2009-01-16 20:04:11 +03:00
while ( size > 0 ) {
2005-08-11 08:04:16 +04:00
2009-01-16 20:04:11 +03:00
blob = data_blob_const ( r . out . data + pos , size ) ;
dump_data ( 0 , blob . data , blob . length ) ;
2005-08-11 08:04:16 +04:00
2009-01-16 20:04:11 +03:00
ndr_err = ndr_pull_struct_blob_all ( & blob , tctx ,
lp_iconv_convenience ( tctx - > lp_ctx ) , & rec ,
( ndr_pull_flags_fn_t ) ndr_pull_EVENTLOGRECORD ) ;
if ( ! NDR_ERR_CODE_IS_SUCCESS ( ndr_err ) ) {
status = ndr_map_error2ntstatus ( ndr_err ) ;
torture_assert_ntstatus_ok ( tctx , status ,
" ReadEventLog failed parsing event log record " ) ;
}
2005-08-11 08:04:16 +04:00
2009-01-16 20:04:11 +03:00
NDR_PRINT_DEBUG ( EVENTLOGRECORD , & rec ) ;
pos + = size ;
if ( pos + 4 > * r . out . sent_size ) {
break ;
}
size = IVAL ( r . out . data , pos ) ;
}
2005-08-11 08:04:16 +04:00
2010-03-19 14:57:54 +03:00
torture_assert_ntstatus_ok ( tctx , r . out . result ,
2006-10-16 17:06:41 +04:00
" ReadEventLog failed parsing event log record " ) ;
2005-08-11 08:04:16 +04:00
2005-08-09 07:09:47 +04:00
r . in . offset + + ;
2004-05-14 22:59:00 +04:00
}
2006-10-16 17:06:41 +04:00
cr . in . handle = cr . out . handle = & handle ;
2003-11-21 00:52:40 +03:00
2009-01-12 20:21:20 +03:00
torture_assert_ntstatus_ok ( tctx ,
2010-03-15 12:55:00 +03:00
dcerpc_eventlog_CloseEventLog_r ( b , tctx , & cr ) ,
2009-01-12 20:21:20 +03:00
" CloseEventLog failed " ) ;
2010-03-19 14:57:54 +03:00
torture_assert_ntstatus_ok ( tctx , cr . out . result ,
" CloseEventLog failed " ) ;
2003-11-21 00:52:40 +03:00
2006-10-16 17:06:41 +04:00
return true ;
2003-11-21 00:52:40 +03:00
}
2009-01-20 20:42:47 +03:00
static bool test_ReportEventLog ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct eventlog_ReportEventW r ;
struct eventlog_CloseEventLog cr ;
struct policy_handle handle ;
2010-03-15 12:55:00 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2009-01-20 20:42:47 +03:00
uint32_t record_number = 0 ;
time_t time_written = 0 ;
struct lsa_String servername , * strings ;
2010-03-15 12:55:00 +03:00
if ( ! get_policy_handle ( tctx , b , & handle ) )
2009-01-20 20:42:47 +03:00
return false ;
init_lsa_String ( & servername , NULL ) ;
strings = talloc_array ( tctx , struct lsa_String , 1 ) ;
init_lsa_String ( & strings [ 0 ] , " Currently tortured by samba 4 " ) ;
ZERO_STRUCT ( r ) ;
r . in . handle = & handle ;
r . in . timestamp = time ( NULL ) ;
r . in . event_type = EVENTLOG_INFORMATION_TYPE ;
r . in . event_category = 0 ;
r . in . event_id = 0 ;
r . in . num_of_strings = 1 ;
r . in . data_size = 0 ;
r . in . servername = & servername ;
r . in . user_sid = NULL ;
r . in . strings = & strings ;
r . in . data = NULL ;
r . in . flags = 0 ;
2009-04-08 23:29:16 +04:00
r . in . record_number = r . out . record_number = & record_number ;
r . in . time_written = r . out . time_written = & time_written ;
2009-01-20 20:42:47 +03:00
2009-04-08 21:18:49 +04:00
torture_assert_ntstatus_ok ( tctx ,
2010-03-15 12:55:00 +03:00
dcerpc_eventlog_ReportEventW_r ( b , tctx , & r ) ,
2009-04-08 21:18:49 +04:00
" ReportEventW failed " ) ;
2009-01-20 20:42:47 +03:00
torture_assert_ntstatus_ok ( tctx , r . out . result , " ReportEventW failed " ) ;
cr . in . handle = cr . out . handle = & handle ;
torture_assert_ntstatus_ok ( tctx ,
2010-03-15 12:55:00 +03:00
dcerpc_eventlog_CloseEventLog_r ( b , tctx , & cr ) ,
2009-01-20 20:42:47 +03:00
" CloseEventLog failed " ) ;
2010-03-19 14:57:54 +03:00
torture_assert_ntstatus_ok ( tctx , cr . out . result ,
" CloseEventLog failed " ) ;
2009-01-20 20:42:47 +03:00
return true ;
}
2009-01-12 20:21:20 +03:00
static bool test_FlushEventLog ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
2005-08-06 04:58:06 +04:00
{
struct eventlog_FlushEventLog r ;
2006-10-16 17:06:41 +04:00
struct eventlog_CloseEventLog cr ;
struct policy_handle handle ;
2010-03-15 12:55:00 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2005-08-06 04:58:06 +04:00
2010-03-15 12:55:00 +03:00
if ( ! get_policy_handle ( tctx , b , & handle ) )
2006-10-16 17:06:41 +04:00
return false ;
2005-08-06 04:58:06 +04:00
2006-10-16 17:06:41 +04:00
r . in . handle = & handle ;
2005-08-06 04:58:06 +04:00
/* Huh? Does this RPC always return access denied? */
2010-03-19 14:57:54 +03:00
torture_assert_ntstatus_ok ( tctx ,
2010-03-15 12:55:00 +03:00
dcerpc_eventlog_FlushEventLog_r ( b , tctx , & r ) ,
2010-03-19 14:57:54 +03:00
" FlushEventLog failed " ) ;
torture_assert_ntstatus_equal ( tctx ,
r . out . result ,
2009-01-12 20:21:20 +03:00
NT_STATUS_ACCESS_DENIED ,
2006-10-16 17:06:41 +04:00
" FlushEventLog failed " ) ;
2005-08-06 04:58:06 +04:00
2006-10-16 17:06:41 +04:00
cr . in . handle = cr . out . handle = & handle ;
2009-01-12 20:21:20 +03:00
torture_assert_ntstatus_ok ( tctx ,
2010-03-15 12:55:00 +03:00
dcerpc_eventlog_CloseEventLog_r ( b , tctx , & cr ) ,
2009-01-12 20:21:20 +03:00
" CloseEventLog failed " ) ;
2010-03-19 14:57:54 +03:00
torture_assert_ntstatus_ok ( tctx , cr . out . result ,
" CloseEventLog failed " ) ;
2005-08-06 04:58:06 +04:00
2006-10-16 17:06:41 +04:00
return true ;
2005-08-06 04:58:06 +04:00
}
2009-01-12 20:21:20 +03:00
static bool test_ClearEventLog ( struct torture_context * tctx ,
2007-04-12 15:24:51 +04:00
struct dcerpc_pipe * p )
2005-08-06 02:57:47 +04:00
{
struct eventlog_ClearEventLogW r ;
2006-10-16 17:06:41 +04:00
struct eventlog_CloseEventLog cr ;
struct policy_handle handle ;
2010-03-15 12:55:00 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2005-08-06 02:57:47 +04:00
2010-03-15 12:55:00 +03:00
if ( ! get_policy_handle ( tctx , b , & handle ) )
2006-10-16 17:06:41 +04:00
return false ;
r . in . handle = & handle ;
2008-10-15 18:37:27 +04:00
r . in . backupfile = NULL ;
2005-08-06 02:57:47 +04:00
2009-01-12 20:21:20 +03:00
torture_assert_ntstatus_ok ( tctx ,
2010-03-15 12:55:00 +03:00
dcerpc_eventlog_ClearEventLogW_r ( b , tctx , & r ) ,
2006-10-16 17:06:41 +04:00
" ClearEventLog failed " ) ;
2010-03-19 14:57:54 +03:00
torture_assert_ntstatus_ok ( tctx , r . out . result ,
" ClearEventLog failed " ) ;
2005-08-06 02:57:47 +04:00
2006-10-16 17:06:41 +04:00
cr . in . handle = cr . out . handle = & handle ;
2005-08-06 04:58:06 +04:00
2009-01-12 20:21:20 +03:00
torture_assert_ntstatus_ok ( tctx ,
2010-03-15 12:55:00 +03:00
dcerpc_eventlog_CloseEventLog_r ( b , tctx , & cr ) ,
2009-01-12 20:21:20 +03:00
" CloseEventLog failed " ) ;
2010-03-19 14:57:54 +03:00
torture_assert_ntstatus_ok ( tctx , cr . out . result ,
" CloseEventLog failed " ) ;
2005-08-06 02:57:47 +04:00
2006-10-16 17:06:41 +04:00
return true ;
2005-08-06 02:57:47 +04:00
}
2009-01-20 21:01:43 +03:00
static bool test_GetLogInformation ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
2009-02-20 16:22:39 +03:00
struct eventlog_GetLogInformation r ;
2009-01-20 21:01:43 +03:00
struct eventlog_CloseEventLog cr ;
struct policy_handle handle ;
uint32_t bytes_needed = 0 ;
2010-03-15 12:55:00 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2009-01-20 21:01:43 +03:00
2010-03-15 12:55:00 +03:00
if ( ! get_policy_handle ( tctx , b , & handle ) )
2009-01-20 21:01:43 +03:00
return false ;
r . in . handle = & handle ;
r . in . level = 1 ;
r . in . buf_size = 0 ;
r . out . buffer = NULL ;
r . out . bytes_needed = & bytes_needed ;
2010-03-19 14:57:54 +03:00
torture_assert_ntstatus_ok ( tctx , dcerpc_eventlog_GetLogInformation_r ( b , tctx , & r ) ,
" GetLogInformation failed " ) ;
2009-01-20 21:01:43 +03:00
2010-03-19 14:57:54 +03:00
torture_assert_ntstatus_equal ( tctx , r . out . result , NT_STATUS_INVALID_LEVEL ,
2009-01-20 21:01:43 +03:00
" GetLogInformation failed " ) ;
r . in . level = 0 ;
2010-03-19 14:57:54 +03:00
torture_assert_ntstatus_ok ( tctx , dcerpc_eventlog_GetLogInformation_r ( b , tctx , & r ) ,
" GetLogInformation failed " ) ;
2009-01-20 21:01:43 +03:00
2010-03-19 14:57:54 +03:00
torture_assert_ntstatus_equal ( tctx , r . out . result , NT_STATUS_BUFFER_TOO_SMALL ,
2009-01-20 21:01:43 +03:00
" GetLogInformation failed " ) ;
r . in . buf_size = bytes_needed ;
r . out . buffer = talloc_array ( tctx , uint8_t , bytes_needed ) ;
2010-03-19 14:57:54 +03:00
torture_assert_ntstatus_ok ( tctx , dcerpc_eventlog_GetLogInformation_r ( b , tctx , & r ) ,
" GetLogInformation failed " ) ;
2009-01-20 21:01:43 +03:00
2010-03-19 14:57:54 +03:00
torture_assert_ntstatus_ok ( tctx , r . out . result , " GetLogInformation failed " ) ;
2009-01-20 21:01:43 +03:00
cr . in . handle = cr . out . handle = & handle ;
torture_assert_ntstatus_ok ( tctx ,
2010-03-15 12:55:00 +03:00
dcerpc_eventlog_CloseEventLog_r ( b , tctx , & cr ) ,
2009-01-20 21:01:43 +03:00
" CloseEventLog failed " ) ;
2010-03-19 14:57:54 +03:00
torture_assert_ntstatus_ok ( tctx , cr . out . result ,
" CloseEventLog failed " ) ;
2009-01-20 21:01:43 +03:00
return true ;
}
2009-01-12 20:21:20 +03:00
static bool test_OpenEventLog ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
2003-11-21 00:52:40 +03:00
{
2006-10-16 17:06:41 +04:00
struct policy_handle handle ;
struct eventlog_CloseEventLog cr ;
2010-03-15 12:55:00 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2003-11-21 00:52:40 +03:00
2010-03-15 12:55:00 +03:00
if ( ! get_policy_handle ( tctx , b , & handle ) )
2006-10-16 17:06:41 +04:00
return false ;
2003-11-21 00:52:40 +03:00
2006-10-16 17:06:41 +04:00
cr . in . handle = cr . out . handle = & handle ;
2003-11-21 00:52:40 +03:00
2009-01-12 20:21:20 +03:00
torture_assert_ntstatus_ok ( tctx ,
2010-03-15 12:55:00 +03:00
dcerpc_eventlog_CloseEventLog_r ( b , tctx , & cr ) ,
2009-01-12 20:21:20 +03:00
" CloseEventLog failed " ) ;
2010-03-19 14:57:54 +03:00
torture_assert_ntstatus_ok ( tctx , cr . out . result ,
" CloseEventLog failed " ) ;
2003-11-21 00:52:40 +03:00
2006-10-16 17:06:41 +04:00
return true ;
2003-11-21 00:52:40 +03:00
}
2009-01-21 02:25:50 +03:00
static bool test_BackupLog ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct policy_handle handle , backup_handle ;
struct eventlog_BackupEventLogW r ;
2010-03-15 12:53:50 +03:00
struct eventlog_OpenBackupEventLogW br ;
2009-01-21 02:25:50 +03:00
struct eventlog_CloseEventLog cr ;
const char * tmp ;
struct lsa_String backup_filename ;
struct eventlog_OpenUnknown0 unknown0 ;
2010-03-15 12:55:00 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2009-01-21 02:25:50 +03:00
2010-03-18 00:44:44 +03:00
if ( torture_setting_bool ( tctx , " samba3 " , false ) ) {
torture_skip ( tctx , " skipping BackupLog test against samba " ) ;
}
2010-03-15 12:55:00 +03:00
if ( ! get_policy_handle ( tctx , b , & handle ) )
2009-01-21 02:25:50 +03:00
return false ;
tmp = talloc_asprintf ( tctx , " C: \\ %s " , TEST_BACKUP_NAME ) ;
init_lsa_String ( & backup_filename , tmp ) ;
r . in . handle = & handle ;
r . in . backup_filename = & backup_filename ;
2010-03-19 14:57:54 +03:00
torture_assert_ntstatus_ok ( tctx , dcerpc_eventlog_BackupEventLogW_r ( b , tctx , & r ) ,
" BackupEventLogW failed " ) ;
torture_assert_ntstatus_equal ( tctx , r . out . result ,
2009-01-21 02:25:50 +03:00
NT_STATUS_OBJECT_PATH_SYNTAX_BAD , " BackupEventLogW failed " ) ;
tmp = talloc_asprintf ( tctx , " \\ ?? \\ C: \\ %s " , TEST_BACKUP_NAME ) ;
init_lsa_String ( & backup_filename , tmp ) ;
r . in . handle = & handle ;
r . in . backup_filename = & backup_filename ;
2010-03-19 14:57:54 +03:00
torture_assert_ntstatus_ok ( tctx , dcerpc_eventlog_BackupEventLogW_r ( b , tctx , & r ) ,
" BackupEventLogW failed " ) ;
torture_assert_ntstatus_ok ( tctx , r . out . result , " BackupEventLogW failed " ) ;
2009-01-21 02:25:50 +03:00
2010-03-19 14:57:54 +03:00
torture_assert_ntstatus_ok ( tctx , dcerpc_eventlog_BackupEventLogW_r ( b , tctx , & r ) ,
" BackupEventLogW failed " ) ;
torture_assert_ntstatus_equal ( tctx , r . out . result ,
2009-01-21 02:25:50 +03:00
NT_STATUS_OBJECT_NAME_COLLISION , " BackupEventLogW failed " ) ;
cr . in . handle = cr . out . handle = & handle ;
torture_assert_ntstatus_ok ( tctx ,
2010-03-15 12:55:00 +03:00
dcerpc_eventlog_CloseEventLog_r ( b , tctx , & cr ) ,
2009-01-21 02:25:50 +03:00
" BackupLog failed " ) ;
2010-03-19 14:57:54 +03:00
torture_assert_ntstatus_ok ( tctx , cr . out . result ,
" BackupLog failed " ) ;
2009-01-21 02:25:50 +03:00
unknown0 . unknown0 = 0x005c ;
unknown0 . unknown1 = 0x0001 ;
2010-03-15 12:53:50 +03:00
br . in . unknown0 = & unknown0 ;
br . in . backup_logname = & backup_filename ;
br . in . major_version = 1 ;
br . in . minor_version = 1 ;
br . out . handle = & backup_handle ;
2009-01-21 02:25:50 +03:00
2010-03-19 14:57:54 +03:00
torture_assert_ntstatus_ok ( tctx , dcerpc_eventlog_OpenBackupEventLogW_r ( b , tctx , & br ) ,
" OpenBackupEventLogW failed " ) ;
2009-01-21 02:25:50 +03:00
2010-03-19 14:57:54 +03:00
torture_assert_ntstatus_ok ( tctx , br . out . result , " OpenBackupEventLogW failed " ) ;
2009-01-21 02:25:50 +03:00
cr . in . handle = cr . out . handle = & backup_handle ;
torture_assert_ntstatus_ok ( tctx ,
2010-03-15 12:55:00 +03:00
dcerpc_eventlog_CloseEventLog_r ( b , tctx , & cr ) ,
2009-01-21 02:25:50 +03:00
" CloseEventLog failed " ) ;
2010-03-19 14:57:54 +03:00
torture_assert_ntstatus_ok ( tctx , cr . out . result ,
" CloseEventLog failed " ) ;
2009-01-21 02:25:50 +03:00
return true ;
}
2007-09-01 02:34:52 +04:00
struct torture_suite * torture_rpc_eventlog ( TALLOC_CTX * mem_ctx )
2003-11-21 00:52:40 +03:00
{
2006-10-16 17:06:41 +04:00
struct torture_suite * suite ;
2007-08-28 20:24:18 +04:00
struct torture_rpc_tcase * tcase ;
2007-08-31 19:43:03 +04:00
struct torture_test * test ;
2003-11-21 00:52:40 +03:00
2007-09-01 02:34:52 +04:00
suite = torture_suite_create ( mem_ctx , " EVENTLOG " ) ;
2009-01-12 20:21:20 +03:00
tcase = torture_suite_add_rpc_iface_tcase ( suite , " eventlog " ,
2007-08-20 01:23:03 +04:00
& ndr_table_eventlog ) ;
2005-08-06 04:58:06 +04:00
2006-10-16 17:06:41 +04:00
torture_rpc_tcase_add_test ( tcase , " OpenEventLog " , test_OpenEventLog ) ;
2009-01-12 20:21:20 +03:00
test = torture_rpc_tcase_add_test ( tcase , " ClearEventLog " ,
2007-08-31 19:43:03 +04:00
test_ClearEventLog ) ;
test - > dangerous = true ;
2006-10-16 17:06:41 +04:00
torture_rpc_tcase_add_test ( tcase , " GetNumRecords " , test_GetNumRecords ) ;
torture_rpc_tcase_add_test ( tcase , " ReadEventLog " , test_ReadEventLog ) ;
2009-01-20 20:42:47 +03:00
torture_rpc_tcase_add_test ( tcase , " ReportEventLog " , test_ReportEventLog ) ;
2006-10-16 17:06:41 +04:00
torture_rpc_tcase_add_test ( tcase , " FlushEventLog " , test_FlushEventLog ) ;
2009-01-20 21:01:43 +03:00
torture_rpc_tcase_add_test ( tcase , " GetLogIntormation " , test_GetLogInformation ) ;
2009-01-21 02:25:50 +03:00
torture_rpc_tcase_add_test ( tcase , " BackupLog " , test_BackupLog ) ;
2003-11-22 11:11:32 +03:00
2006-10-16 17:06:41 +04:00
return suite ;
2003-11-21 00:52:40 +03:00
}