2008-11-20 15:33:24 +03:00
/*
2005-03-24 02:26:33 +03:00
* Unix SMB / CIFS implementation .
* RPC Pipe client / server routines
2005-09-30 21:13:37 +04:00
* Copyright ( C ) Marcin Krzysztof Porwit 2005 ,
2005-10-06 21:48:03 +04:00
* Copyright ( C ) Brian Moran 2005 ,
2005-09-30 21:13:37 +04:00
* Copyright ( C ) Gerald ( Jerry ) Carter 2005.
2008-11-20 15:33:24 +03:00
*
2005-03-24 02:26:33 +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-09 23:25:36 +04:00
* the Free Software Foundation ; either version 3 of the License , or
2005-03-24 02:26:33 +03:00
* ( at your option ) any later version .
2008-11-20 15:33:24 +03:00
*
2005-03-24 02:26:33 +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 .
2008-11-20 15:33:24 +03:00
*
2005-03-24 02:26:33 +03:00
* You should have received a copy of the GNU General Public License
2007-07-10 09:23:25 +04:00
* along with this program ; if not , see < http : //www.gnu.org/licenses/>.
2005-03-24 02:26:33 +03:00
*/
2005-10-06 21:48:03 +04:00
2005-03-24 02:26:33 +03:00
# include "includes.h"
2005-10-06 21:48:03 +04:00
# undef DBGC_CLASS
2005-03-24 02:26:33 +03:00
# define DBGC_CLASS DBGC_RPC_SRV
2005-09-30 21:13:37 +04:00
typedef struct {
char * logname ;
2005-11-17 23:08:59 +03:00
ELOG_TDB * etdb ;
2005-11-17 20:41:02 +03:00
uint32 current_record ;
2005-09-30 21:13:37 +04:00
uint32 num_records ;
uint32 oldest_entry ;
uint32 flags ;
2005-10-14 20:07:00 +04:00
uint32 access_granted ;
} EVENTLOG_INFO ;
2005-09-30 21:13:37 +04:00
2005-10-14 20:07:00 +04:00
/********************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-10-06 21:48:03 +04:00
2009-01-07 19:56:08 +03:00
static int eventlog_info_destructor ( EVENTLOG_INFO * elog )
2005-10-14 20:07:00 +04:00
{
2009-01-07 19:56:08 +03:00
if ( elog - > etdb ) {
elog_close_tdb ( elog - > etdb , false ) ;
}
return 0 ;
}
2008-11-20 15:33:24 +03:00
2005-09-30 21:13:37 +04:00
/********************************************************************
2005-10-06 21:48:03 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-10-14 20:07:00 +04:00
static EVENTLOG_INFO * find_eventlog_info_by_hnd ( pipes_struct * p ,
POLICY_HND * handle )
2005-10-06 21:48:03 +04:00
{
2005-10-14 20:07:00 +04:00
EVENTLOG_INFO * info ;
2005-12-03 09:46:46 +03:00
if ( ! find_policy_by_hnd ( p , handle , ( void * * ) ( void * ) & info ) ) {
2005-10-14 20:07:00 +04:00
DEBUG ( 2 ,
( " find_eventlog_info_by_hnd: eventlog not found. \n " ) ) ;
return NULL ;
2005-10-06 21:48:03 +04:00
}
2005-10-14 20:07:00 +04:00
return info ;
2005-10-06 21:48:03 +04:00
}
/********************************************************************
2005-10-14 20:07:00 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-09-30 21:13:37 +04:00
2007-10-19 04:40:25 +04:00
static bool elog_check_access ( EVENTLOG_INFO * info , NT_USER_TOKEN * token )
2005-03-24 02:26:33 +03:00
{
2007-11-27 22:22:58 +03:00
char * tdbname = elog_tdbname ( talloc_tos ( ) , info - > logname ) ;
2005-10-14 20:07:00 +04:00
SEC_DESC * sec_desc ;
2008-10-31 20:51:45 +03:00
NTSTATUS status ;
2008-11-20 15:33:24 +03:00
if ( ! tdbname )
2005-10-14 20:07:00 +04:00
return False ;
2008-11-20 15:33:24 +03:00
2005-10-14 20:07:00 +04:00
/* get the security descriptor for the file */
2008-11-20 15:33:24 +03:00
2005-10-14 20:07:00 +04:00
sec_desc = get_nt_acl_no_snum ( info , tdbname ) ;
2008-11-12 01:38:59 +03:00
TALLOC_FREE ( tdbname ) ;
2008-11-20 15:33:24 +03:00
2005-10-14 20:07:00 +04:00
if ( ! sec_desc ) {
2008-11-20 15:33:24 +03:00
DEBUG ( 5 , ( " elog_check_access: Unable to get NT ACL for %s \n " ,
2005-10-14 20:07:00 +04:00
tdbname ) ) ;
return False ;
}
2008-11-20 15:33:24 +03:00
2005-10-19 06:50:45 +04:00
/* root free pass */
if ( geteuid ( ) = = sec_initial_uid ( ) ) {
DEBUG ( 5 , ( " elog_check_access: using root's token \n " ) ) ;
token = get_root_nt_token ( ) ;
}
2005-10-14 20:07:00 +04:00
/* run the check, try for the max allowed */
2008-11-20 15:33:24 +03:00
2008-10-31 20:51:45 +03:00
status = se_access_check ( sec_desc , token , MAXIMUM_ALLOWED_ACCESS ,
& info - > access_granted ) ;
2008-11-20 15:33:24 +03:00
2005-10-14 20:07:00 +04:00
if ( sec_desc )
TALLOC_FREE ( sec_desc ) ;
2008-11-20 15:33:24 +03:00
2008-10-31 20:51:45 +03:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
2005-10-14 20:07:00 +04:00
DEBUG ( 8 , ( " elog_check_access: se_access_check() return %s \n " ,
2008-10-31 20:51:45 +03:00
nt_errstr ( status ) ) ) ;
2005-10-14 20:07:00 +04:00
return False ;
}
2008-11-20 15:33:24 +03:00
2005-10-14 20:07:00 +04:00
/* we have to have READ permission for a successful open */
2008-11-20 15:33:24 +03:00
2005-10-14 20:07:00 +04:00
return ( info - > access_granted & SA_RIGHT_FILE_READ_DATA ) ;
}
2005-09-30 21:13:37 +04:00
2005-10-14 20:07:00 +04:00
/********************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-09-30 21:13:37 +04:00
2007-10-19 04:40:25 +04:00
static bool elog_validate_logname ( const char * name )
2005-10-14 20:07:00 +04:00
{
int i ;
const char * * elogs = lp_eventlog_list ( ) ;
2008-11-20 15:33:24 +03:00
2007-06-22 23:33:46 +04:00
if ( ! elogs ) {
return False ;
}
2005-10-14 20:07:00 +04:00
for ( i = 0 ; elogs [ i ] ; i + + ) {
if ( strequal ( name , elogs [ i ] ) )
return True ;
2005-10-06 21:48:03 +04:00
}
2008-11-20 15:33:24 +03:00
2005-10-14 20:07:00 +04:00
return False ;
}
2005-10-06 21:48:03 +04:00
2005-11-17 20:41:02 +03:00
/********************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-10-19 04:40:25 +04:00
static bool get_num_records_hook ( EVENTLOG_INFO * info )
2005-11-17 20:41:02 +03:00
{
int next_record ;
int oldest_record ;
2005-11-17 23:08:59 +03:00
if ( ! info - > etdb ) {
2005-11-17 20:41:02 +03:00
DEBUG ( 10 , ( " No open tdb for %s \n " , info - > logname ) ) ;
return False ;
}
/* lock the tdb since we have to get 2 records */
2006-04-17 15:49:06 +04:00
tdb_lock_bystring_with_timeout ( ELOG_TDB_CTX ( info - > etdb ) , EVT_NEXT_RECORD , 1 ) ;
2005-11-17 23:08:59 +03:00
next_record = tdb_fetch_int32 ( ELOG_TDB_CTX ( info - > etdb ) , EVT_NEXT_RECORD ) ;
oldest_record = tdb_fetch_int32 ( ELOG_TDB_CTX ( info - > etdb ) , EVT_OLDEST_ENTRY ) ;
tdb_unlock_bystring ( ELOG_TDB_CTX ( info - > etdb ) , EVT_NEXT_RECORD ) ;
2005-11-17 20:41:02 +03:00
DEBUG ( 8 ,
( " Oldest Record %d; Next Record %d \n " , oldest_record ,
next_record ) ) ;
info - > num_records = ( next_record - oldest_record ) ;
info - > oldest_entry = oldest_record ;
return True ;
}
/********************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-10-19 04:40:25 +04:00
static bool get_oldest_entry_hook ( EVENTLOG_INFO * info )
2005-11-17 20:41:02 +03:00
{
/* it's the same thing */
return get_num_records_hook ( info ) ;
}
2005-10-14 20:07:00 +04:00
/********************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-10-06 21:48:03 +04:00
2005-10-27 17:30:23 +04:00
static NTSTATUS elog_open ( pipes_struct * p , const char * logname , POLICY_HND * hnd )
2005-10-14 20:07:00 +04:00
{
EVENTLOG_INFO * elog ;
2008-11-20 15:33:24 +03:00
2005-10-14 20:07:00 +04:00
/* first thing is to validate the eventlog name */
2009-01-14 20:09:25 +03:00
2005-10-14 20:07:00 +04:00
if ( ! elog_validate_logname ( logname ) )
2005-10-27 17:30:23 +04:00
return NT_STATUS_OBJECT_PATH_INVALID ;
2008-11-20 15:33:24 +03:00
2005-10-14 20:07:00 +04:00
if ( ! ( elog = TALLOC_ZERO_P ( NULL , EVENTLOG_INFO ) ) )
2005-10-27 17:30:23 +04:00
return NT_STATUS_NO_MEMORY ;
2009-01-07 19:56:08 +03:00
talloc_set_destructor ( elog , eventlog_info_destructor ) ;
2008-11-20 15:33:24 +03:00
2005-10-14 20:07:00 +04:00
elog - > logname = talloc_strdup ( elog , logname ) ;
2008-11-20 15:33:24 +03:00
2005-10-14 20:07:00 +04:00
/* Open the tdb first (so that we can create any new tdbs if necessary).
2008-11-20 15:33:24 +03:00
We have to do this as root and then use an internal access check
2005-10-14 20:07:00 +04:00
on the file permissions since you can only have a tdb open once
in a single process */
become_root ( ) ;
2009-01-22 21:46:14 +03:00
elog - > etdb = elog_open_tdb ( elog - > logname , False , False ) ;
2005-10-14 20:07:00 +04:00
unbecome_root ( ) ;
2005-11-17 23:08:59 +03:00
if ( ! elog - > etdb ) {
2005-10-14 20:07:00 +04:00
/* according to MSDN, if the logfile cannot be found, we should
default to the " Application " log */
2008-11-20 15:33:24 +03:00
2005-10-14 20:07:00 +04:00
if ( ! strequal ( logname , ELOG_APPL ) ) {
2008-11-20 15:33:24 +03:00
2005-10-14 20:07:00 +04:00
TALLOC_FREE ( elog - > logname ) ;
2008-11-20 15:33:24 +03:00
elog - > logname = talloc_strdup ( elog , ELOG_APPL ) ;
2005-10-14 20:07:00 +04:00
/* do the access check */
2008-11-24 01:48:17 +03:00
if ( ! elog_check_access ( elog , p - > server_info - > ptok ) ) {
2005-10-14 20:07:00 +04:00
TALLOC_FREE ( elog ) ;
2005-10-27 17:30:23 +04:00
return NT_STATUS_ACCESS_DENIED ;
2005-10-06 21:48:03 +04:00
}
2008-11-20 15:33:24 +03:00
2005-10-14 20:07:00 +04:00
become_root ( ) ;
2009-01-22 21:46:14 +03:00
elog - > etdb = elog_open_tdb ( elog - > logname , False , False ) ;
2005-10-14 20:07:00 +04:00
unbecome_root ( ) ;
2008-11-20 15:33:24 +03:00
}
2005-11-17 23:08:59 +03:00
if ( ! elog - > etdb ) {
2005-10-14 20:07:00 +04:00
TALLOC_FREE ( elog ) ;
2008-11-20 15:33:24 +03:00
return NT_STATUS_ACCESS_DENIED ; /* ??? */
2005-10-06 21:48:03 +04:00
}
}
2008-11-20 15:33:24 +03:00
2005-10-14 20:07:00 +04:00
/* now do the access check. Close the tdb if we fail here */
2005-09-30 21:13:37 +04:00
2008-11-24 01:48:17 +03:00
if ( ! elog_check_access ( elog , p - > server_info - > ptok ) ) {
2005-10-14 20:07:00 +04:00
TALLOC_FREE ( elog ) ;
2005-10-27 17:30:23 +04:00
return NT_STATUS_ACCESS_DENIED ;
2005-10-14 20:07:00 +04:00
}
2008-11-20 15:33:24 +03:00
2005-10-14 20:07:00 +04:00
/* create the policy handle */
2008-11-20 15:33:24 +03:00
2009-01-07 20:44:52 +03:00
if ( ! create_policy_hnd ( p , hnd , elog ) ) {
TALLOC_FREE ( elog ) ;
2005-10-27 17:30:23 +04:00
return NT_STATUS_NO_MEMORY ;
2005-10-06 21:48:03 +04:00
}
2005-10-14 20:07:00 +04:00
2005-11-17 20:41:02 +03:00
/* set the initial current_record pointer */
if ( ! get_oldest_entry_hook ( elog ) ) {
DEBUG ( 3 , ( " elog_open: Successfully opened eventlog but can't "
" get any information on internal records! \n " ) ) ;
2008-11-20 15:33:24 +03:00
}
2005-11-17 20:41:02 +03:00
elog - > current_record = elog - > oldest_entry ;
2005-10-27 17:30:23 +04:00
return NT_STATUS_OK ;
2005-09-30 21:13:37 +04:00
}
/********************************************************************
2005-10-06 21:48:03 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-03-24 02:26:33 +03:00
2005-10-27 17:30:23 +04:00
static NTSTATUS elog_close ( pipes_struct * p , POLICY_HND * hnd )
2005-10-06 21:48:03 +04:00
{
2005-10-14 20:07:00 +04:00
if ( ! ( close_policy_hnd ( p , hnd ) ) ) {
2005-10-27 17:30:23 +04:00
return NT_STATUS_INVALID_HANDLE ;
2005-10-14 20:07:00 +04:00
}
2005-10-06 21:48:03 +04:00
2005-10-27 17:30:23 +04:00
return NT_STATUS_OK ;
2005-10-14 20:07:00 +04:00
}
2005-10-06 21:48:03 +04:00
2005-10-14 20:07:00 +04:00
/*******************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-10-06 21:48:03 +04:00
2005-10-14 20:07:00 +04:00
static int elog_size ( EVENTLOG_INFO * info )
{
2005-11-17 23:08:59 +03:00
if ( ! info | | ! info - > etdb ) {
2005-10-14 20:07:00 +04:00
DEBUG ( 0 , ( " elog_size: Invalid info* structure! \n " ) ) ;
return 0 ;
2005-10-06 21:48:03 +04:00
}
2005-11-17 23:08:59 +03:00
return elog_tdb_size ( ELOG_TDB_CTX ( info - > etdb ) , NULL , NULL ) ;
2005-10-06 21:48:03 +04:00
}
/********************************************************************
2007-11-27 22:22:58 +03:00
For the given tdb , get the next eventlog record into the passed
2005-10-06 21:48:03 +04:00
Eventlog_entry . returns NULL if it can ' t get the record for some reason .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-11-20 12:55:03 +03:00
static Eventlog_entry * get_eventlog_record ( TALLOC_CTX * mem_ctx ,
2007-11-27 22:22:58 +03:00
TDB_CONTEXT * tdb ,
int recno )
2005-10-06 21:48:03 +04:00
{
2007-11-27 22:22:58 +03:00
Eventlog_entry * ee = NULL ;
2005-10-06 21:48:03 +04:00
TDB_DATA ret , key ;
2008-11-20 03:49:03 +03:00
int32_t srecno ;
int32_t reclen ;
2005-10-06 21:48:03 +04:00
int len ;
2007-11-27 22:22:58 +03:00
char * wpsource = NULL ;
char * wpcomputer = NULL ;
char * wpsid = NULL ;
char * wpstrs = NULL ;
char * puserdata = NULL ;
2005-10-06 21:48:03 +04:00
2008-11-20 03:49:03 +03:00
key . dsize = sizeof ( int32_t ) ;
2005-10-06 21:48:03 +04:00
srecno = recno ;
2008-11-20 03:49:03 +03:00
key . dptr = ( unsigned char * ) & srecno ;
2005-10-06 21:48:03 +04:00
ret = tdb_fetch ( tdb , key ) ;
if ( ret . dsize = = 0 ) {
DEBUG ( 8 ,
( " Can't find a record for the key, record %d \n " ,
recno ) ) ;
return NULL ;
}
len = tdb_unpack ( ret . dptr , ret . dsize , " d " , & reclen ) ;
DEBUG ( 10 , ( " Unpacking record %d, size is %d \n " , srecno , len ) ) ;
if ( ! len )
return NULL ;
2008-11-20 12:55:03 +03:00
ee = TALLOC_ARRAY ( mem_ctx , Eventlog_entry , 1 ) ;
2007-11-27 22:22:58 +03:00
if ( ! ee ) {
2005-10-06 21:48:03 +04:00
return NULL ;
2007-11-27 22:22:58 +03:00
}
ZERO_STRUCTP ( ee ) ;
2005-10-06 21:48:03 +04:00
len = tdb_unpack ( ret . dptr , ret . dsize , " ddddddwwwwddddddBBdBBBd " ,
& ee - > record . length , & ee - > record . reserved1 ,
& ee - > record . record_number ,
& ee - > record . time_generated ,
& ee - > record . time_written , & ee - > record . event_id ,
& ee - > record . event_type , & ee - > record . num_strings ,
& ee - > record . event_category , & ee - > record . reserved2 ,
& ee - > record . closing_record_number ,
& ee - > record . string_offset ,
& ee - > record . user_sid_length ,
& ee - > record . user_sid_offset ,
& ee - > record . data_length , & ee - > record . data_offset ,
& ee - > data_record . source_name_len , & wpsource ,
& ee - > data_record . computer_name_len , & wpcomputer ,
& ee - > data_record . sid_padding ,
& ee - > record . user_sid_length , & wpsid ,
& ee - > data_record . strings_len , & wpstrs ,
& ee - > data_record . user_data_len , & puserdata ,
& ee - > data_record . data_padding ) ;
DEBUG ( 10 ,
( " Read record %d, len in tdb was %d \n " ,
ee - > record . record_number , len ) ) ;
/* have to do the following because the tdb_unpack allocs a buff, stuffs a pointer to the buff
into it ' s 2 nd argment for ' B ' */
2007-11-27 22:22:58 +03:00
if ( wpcomputer ) {
2007-12-01 13:43:12 +03:00
ee - > data_record . computer_name = ( smb_ucs2_t * ) TALLOC_MEMDUP (
ee , wpcomputer , ee - > data_record . computer_name_len ) ;
2007-11-27 22:22:58 +03:00
if ( ! ee - > data_record . computer_name ) {
TALLOC_FREE ( ee ) ;
goto out ;
}
}
if ( wpsource ) {
2007-12-01 13:43:12 +03:00
ee - > data_record . source_name = ( smb_ucs2_t * ) TALLOC_MEMDUP (
ee , wpsource , ee - > data_record . source_name_len ) ;
2007-11-27 22:22:58 +03:00
if ( ! ee - > data_record . source_name ) {
TALLOC_FREE ( ee ) ;
goto out ;
}
}
if ( wpsid ) {
2007-12-01 13:43:12 +03:00
ee - > data_record . sid = ( smb_ucs2_t * ) TALLOC_MEMDUP (
ee , wpsid , ee - > record . user_sid_length ) ;
2007-11-27 22:22:58 +03:00
if ( ! ee - > data_record . sid ) {
TALLOC_FREE ( ee ) ;
goto out ;
}
}
if ( wpstrs ) {
2007-12-01 13:43:12 +03:00
ee - > data_record . strings = ( smb_ucs2_t * ) TALLOC_MEMDUP (
ee , wpstrs , ee - > data_record . strings_len ) ;
2007-11-27 22:22:58 +03:00
if ( ! ee - > data_record . strings ) {
TALLOC_FREE ( ee ) ;
goto out ;
}
}
if ( puserdata ) {
2007-12-01 13:43:12 +03:00
ee - > data_record . user_data = ( char * ) TALLOC_MEMDUP (
ee , puserdata , ee - > data_record . user_data_len ) ;
2007-11-27 22:22:58 +03:00
if ( ! ee - > data_record . user_data ) {
TALLOC_FREE ( ee ) ;
goto out ;
}
}
out :
SAFE_FREE ( wpcomputer ) ;
SAFE_FREE ( wpsource ) ;
SAFE_FREE ( wpsid ) ;
SAFE_FREE ( wpstrs ) ;
SAFE_FREE ( puserdata ) ;
2005-10-06 21:48:03 +04:00
DEBUG ( 10 , ( " get_eventlog_record: read back %d \n " , len ) ) ;
DEBUG ( 10 ,
( " get_eventlog_record: computer_name %d is " ,
ee - > data_record . computer_name_len ) ) ;
2007-11-27 22:22:58 +03:00
SAFE_FREE ( ret . dptr ) ;
2005-10-06 21:48:03 +04:00
return ee ;
}
2005-09-30 21:13:37 +04:00
/********************************************************************
2008-11-20 15:33:24 +03:00
note that this can only be called AFTER the table is constructed ,
2005-10-06 21:48:03 +04:00
since it uses the table to find the tdb handle
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-09-30 21:13:37 +04:00
2007-10-19 04:40:25 +04:00
static bool sync_eventlog_params ( EVENTLOG_INFO * info )
2005-03-24 02:26:33 +03:00
{
2007-11-27 22:22:58 +03:00
char * path = NULL ;
2005-10-06 21:48:03 +04:00
uint32 uiMaxSize ;
uint32 uiRetention ;
2008-01-17 03:47:00 +03:00
struct registry_key * key ;
struct registry_value * value ;
2005-09-30 21:13:37 +04:00
WERROR wresult ;
2005-10-14 20:07:00 +04:00
char * elogname = info - > logname ;
2008-11-20 18:31:44 +03:00
TALLOC_CTX * ctx = talloc_stackframe ( ) ;
2008-01-17 03:47:00 +03:00
bool ret = false ;
2005-10-06 21:48:03 +04:00
DEBUG ( 4 , ( " sync_eventlog_params with %s \n " , elogname ) ) ;
2005-09-30 21:13:37 +04:00
2005-11-17 23:08:59 +03:00
if ( ! info - > etdb ) {
2005-10-14 20:07:00 +04:00
DEBUG ( 4 , ( " No open tdb! (%s) \n " , info - > logname ) ) ;
2008-11-20 21:56:14 +03:00
goto done ;
2005-09-30 21:13:37 +04:00
}
/* set resonable defaults. 512Kb on size and 1 week on time */
2005-10-06 21:48:03 +04:00
2005-09-30 21:13:37 +04:00
uiMaxSize = 0x80000 ;
uiRetention = 604800 ;
2005-10-06 21:48:03 +04:00
2008-11-20 15:33:24 +03:00
/* the general idea is to internally open the registry
key and retrieve the values . That way we can continue
to use the same fetch / store api that we use in
2005-09-30 21:13:37 +04:00
srv_reg_nt . c */
2007-11-27 22:22:58 +03:00
path = talloc_asprintf ( ctx , " %s/%s " , KEY_EVENTLOG , elogname ) ;
if ( ! path ) {
2008-11-20 21:56:14 +03:00
goto done ;
2007-11-27 22:22:58 +03:00
}
2005-10-06 21:48:03 +04:00
2008-01-17 03:47:00 +03:00
wresult = reg_open_path ( ctx , path , REG_KEY_READ , get_root_nt_token ( ) ,
& key ) ;
2005-10-06 21:48:03 +04:00
2005-09-30 21:13:37 +04:00
if ( ! W_ERROR_IS_OK ( wresult ) ) {
2005-10-06 21:48:03 +04:00
DEBUG ( 4 ,
( " sync_eventlog_params: Failed to open key [%s] (%s) \n " ,
2008-11-01 19:19:26 +03:00
path , win_errstr ( wresult ) ) ) ;
2008-11-20 21:56:14 +03:00
goto done ;
2005-09-30 21:13:37 +04:00
}
2005-10-06 21:48:03 +04:00
2008-01-17 03:47:00 +03:00
wresult = reg_queryvalue ( key , key , " Retention " , & value ) ;
if ( ! W_ERROR_IS_OK ( wresult ) ) {
DEBUG ( 4 , ( " Failed to query value \" Retention \" : %s \n " ,
2008-11-01 19:19:26 +03:00
win_errstr ( wresult ) ) ) ;
2008-01-17 03:47:00 +03:00
goto done ;
2005-09-30 21:13:37 +04:00
}
2008-01-17 03:47:00 +03:00
uiRetention = value - > v . dword ;
wresult = reg_queryvalue ( key , key , " MaxSize " , & value ) ;
if ( ! W_ERROR_IS_OK ( wresult ) ) {
DEBUG ( 4 , ( " Failed to query value \" MaxSize \" : %s \n " ,
2008-11-01 19:19:26 +03:00
win_errstr ( wresult ) ) ) ;
2008-01-17 03:47:00 +03:00
goto done ;
}
uiMaxSize = value - > v . dword ;
2005-09-30 21:13:37 +04:00
2005-11-17 23:08:59 +03:00
tdb_store_int32 ( ELOG_TDB_CTX ( info - > etdb ) , EVT_MAXSIZE , uiMaxSize ) ;
tdb_store_int32 ( ELOG_TDB_CTX ( info - > etdb ) , EVT_RETENTION , uiRetention ) ;
2005-09-30 21:13:37 +04:00
2008-01-17 03:47:00 +03:00
ret = true ;
done :
TALLOC_FREE ( ctx ) ;
2008-01-30 00:06:59 +03:00
return ret ;
2005-03-24 02:26:33 +03:00
}
2005-09-30 21:13:37 +04:00
/********************************************************************
2005-10-06 21:48:03 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-09-30 21:13:37 +04:00
2008-11-20 12:55:03 +03:00
static Eventlog_entry * read_package_entry ( TALLOC_CTX * mem_ctx ,
2005-10-06 21:48:03 +04:00
Eventlog_entry * entry )
2005-03-24 02:26:33 +03:00
{
2005-09-30 21:13:37 +04:00
uint8 * offset ;
Eventlog_entry * ee_new = NULL ;
2005-05-09 17:51:44 +04:00
2008-11-20 12:55:03 +03:00
ee_new = TALLOC_ZERO_ARRAY ( mem_ctx , Eventlog_entry , 1 ) ;
2005-10-06 21:48:03 +04:00
if ( ee_new = = NULL ) {
2005-09-30 21:13:37 +04:00
return NULL ;
}
2005-10-06 21:48:03 +04:00
entry - > data_record . sid_padding =
( ( 4 -
( ( entry - > data_record . source_name_len +
entry - > data_record . computer_name_len ) % 4 ) ) % 4 ) ;
entry - > data_record . data_padding =
( 4 -
( ( entry - > data_record . strings_len +
entry - > data_record . user_data_len ) % 4 ) ) % 4 ;
entry - > record . length = sizeof ( Eventlog_record ) ;
2005-09-30 21:13:37 +04:00
entry - > record . length + = entry - > data_record . source_name_len ;
entry - > record . length + = entry - > data_record . computer_name_len ;
2005-10-06 21:48:03 +04:00
if ( entry - > record . user_sid_length = = 0 ) {
2005-09-30 21:13:37 +04:00
/* Should not pad to a DWORD boundary for writing out the sid if there is
no SID , so just propagate the padding to pad the data */
2005-10-06 21:48:03 +04:00
entry - > data_record . data_padding + =
entry - > data_record . sid_padding ;
2005-09-30 21:13:37 +04:00
entry - > data_record . sid_padding = 0 ;
}
2005-10-06 21:48:03 +04:00
DEBUG ( 10 ,
( " sid_padding is [%d]. \n " , entry - > data_record . sid_padding ) ) ;
DEBUG ( 10 ,
( " data_padding is [%d]. \n " ,
entry - > data_record . data_padding ) ) ;
2005-09-30 21:13:37 +04:00
entry - > record . length + = entry - > data_record . sid_padding ;
entry - > record . length + = entry - > record . user_sid_length ;
entry - > record . length + = entry - > data_record . strings_len ;
entry - > record . length + = entry - > data_record . user_data_len ;
entry - > record . length + = entry - > data_record . data_padding ;
/* need another copy of length at the end of the data */
2005-10-06 21:48:03 +04:00
entry - > record . length + = sizeof ( entry - > record . length ) ;
DEBUG ( 10 ,
( " entry->record.length is [%d]. \n " , entry - > record . length ) ) ;
entry - > data =
2008-11-20 12:55:03 +03:00
TALLOC_ZERO_ARRAY ( mem_ctx , uint8_t ,
entry - > record . length -
sizeof ( Eventlog_record ) -
sizeof ( entry - > record . length ) ) ;
2005-10-06 21:48:03 +04:00
if ( entry - > data = = NULL ) {
2005-09-30 21:13:37 +04:00
return NULL ;
}
offset = entry - > data ;
2009-01-24 04:10:47 +03:00
memcpy ( offset , entry - > data_record . source_name ,
2005-10-06 21:48:03 +04:00
entry - > data_record . source_name_len ) ;
2005-09-30 21:13:37 +04:00
offset + = entry - > data_record . source_name_len ;
2009-01-24 04:10:47 +03:00
memcpy ( offset , entry - > data_record . computer_name ,
2005-10-06 21:48:03 +04:00
entry - > data_record . computer_name_len ) ;
2005-09-30 21:13:37 +04:00
offset + = entry - > data_record . computer_name_len ;
/* SID needs to be DWORD-aligned */
offset + = entry - > data_record . sid_padding ;
2005-10-06 21:48:03 +04:00
entry - > record . user_sid_offset =
sizeof ( Eventlog_record ) + ( offset - entry - > data ) ;
2009-01-24 04:10:47 +03:00
memcpy ( offset , entry - > data_record . sid ,
2005-10-06 21:48:03 +04:00
entry - > record . user_sid_length ) ;
2005-09-30 21:13:37 +04:00
offset + = entry - > record . user_sid_length ;
/* Now do the strings */
2005-10-06 21:48:03 +04:00
entry - > record . string_offset =
sizeof ( Eventlog_record ) + ( offset - entry - > data ) ;
2009-01-24 04:10:47 +03:00
memcpy ( offset , entry - > data_record . strings ,
2005-10-06 21:48:03 +04:00
entry - > data_record . strings_len ) ;
2005-09-30 21:13:37 +04:00
offset + = entry - > data_record . strings_len ;
/* Now do the data */
entry - > record . data_length = entry - > data_record . user_data_len ;
2005-10-06 21:48:03 +04:00
entry - > record . data_offset =
sizeof ( Eventlog_record ) + ( offset - entry - > data ) ;
2009-01-24 04:10:47 +03:00
memcpy ( offset , entry - > data_record . user_data ,
2005-10-06 21:48:03 +04:00
entry - > data_record . user_data_len ) ;
2005-09-30 21:13:37 +04:00
offset + = entry - > data_record . user_data_len ;
2005-10-06 21:48:03 +04:00
memcpy ( & ( ee_new - > record ) , & entry - > record ,
sizeof ( Eventlog_record ) ) ;
memcpy ( & ( ee_new - > data_record ) , & entry - > data_record ,
sizeof ( Eventlog_data_record ) ) ;
2005-09-30 21:13:37 +04:00
ee_new - > data = entry - > data ;
return ee_new ;
2005-03-24 02:26:33 +03:00
}
2005-09-30 21:13:37 +04:00
/********************************************************************
2005-10-06 21:48:03 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-09-30 21:13:37 +04:00
2009-01-24 04:59:24 +03:00
static bool add_record_to_resp ( EVENTLOG_R_READ_EVENTLOG * r_u ,
2005-10-06 21:48:03 +04:00
Eventlog_entry * ee_new )
2005-03-24 02:26:33 +03:00
{
2005-09-30 21:13:37 +04:00
Eventlog_entry * insert_point ;
2009-01-24 04:59:24 +03:00
insert_point = r_u - > entry ;
2005-09-30 21:13:37 +04:00
2005-10-06 21:48:03 +04:00
if ( NULL = = insert_point ) {
2009-01-24 04:59:24 +03:00
r_u - > entry = ee_new ;
2005-09-30 21:13:37 +04:00
ee_new - > next = NULL ;
} else {
2005-10-06 21:48:03 +04:00
while ( ( NULL ! = insert_point - > next ) ) {
insert_point = insert_point - > next ;
2005-05-09 17:51:44 +04:00
}
2005-09-30 21:13:37 +04:00
ee_new - > next = NULL ;
insert_point - > next = ee_new ;
}
2009-01-24 04:59:24 +03:00
r_u - > num_records + + ;
r_u - > num_bytes_in_resp + = ee_new - > record . length ;
2005-09-30 21:13:37 +04:00
return True ;
2005-03-24 02:26:33 +03:00
}
2005-09-30 21:13:37 +04:00
2005-10-06 21:48:03 +04:00
/********************************************************************
2008-02-04 13:10:18 +03:00
_eventlog_OpenEventLogW
2005-10-06 21:48:03 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-09-30 21:13:37 +04:00
2008-02-04 13:10:18 +03:00
NTSTATUS _eventlog_OpenEventLogW ( pipes_struct * p ,
struct eventlog_OpenEventLogW * r )
2005-09-30 21:13:37 +04:00
{
2005-10-14 20:07:00 +04:00
EVENTLOG_INFO * info ;
2005-10-27 17:30:23 +04:00
NTSTATUS result ;
2005-09-30 21:13:37 +04:00
2009-01-14 20:09:25 +03:00
DEBUG ( 10 , ( " _eventlog_OpenEventLogW: Server [%s], Log [%s] \n " ,
r - > in . servername - > string , r - > in . logname - > string ) ) ;
2008-11-20 15:33:24 +03:00
2005-10-14 20:07:00 +04:00
/* according to MSDN, if the logfile cannot be found, we should
default to the " Application " log */
2008-11-20 15:33:24 +03:00
2009-01-14 20:09:25 +03:00
if ( ! NT_STATUS_IS_OK ( result = elog_open ( p , r - > in . logname - > string , r - > out . handle ) ) )
2005-10-27 17:30:23 +04:00
return result ;
2005-10-14 20:07:00 +04:00
2008-02-04 13:10:18 +03:00
if ( ! ( info = find_eventlog_info_by_hnd ( p , r - > out . handle ) ) ) {
2009-01-14 20:09:25 +03:00
DEBUG ( 0 , ( " _eventlog_OpenEventLogW: eventlog (%s) opened but unable to find handle! \n " ,
r - > in . logname - > string ) ) ;
2008-02-04 13:10:18 +03:00
elog_close ( p , r - > out . handle ) ;
2005-10-27 17:30:23 +04:00
return NT_STATUS_INVALID_HANDLE ;
2005-09-30 21:13:37 +04:00
}
2005-10-06 21:48:03 +04:00
2009-01-14 20:09:25 +03:00
DEBUG ( 10 , ( " _eventlog_OpenEventLogW: Size [%d] \n " , elog_size ( info ) ) ) ;
2005-10-06 21:48:03 +04:00
2005-10-14 20:07:00 +04:00
sync_eventlog_params ( info ) ;
2005-11-17 23:08:59 +03:00
prune_eventlog ( ELOG_TDB_CTX ( info - > etdb ) ) ;
2005-10-06 21:48:03 +04:00
2005-10-27 17:30:23 +04:00
return NT_STATUS_OK ;
2005-03-24 02:26:33 +03:00
}
2005-09-30 21:13:37 +04:00
/********************************************************************
2008-02-04 12:53:59 +03:00
_eventlog_ClearEventLogW
2005-10-14 20:07:00 +04:00
This call still needs some work
2005-10-06 21:48:03 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-04 12:55:14 +03:00
/** The windows client seems to be doing something funny with the file name
A call like
ClearEventLog ( handle , " backup_file " )
on the client side will result in the backup file name looking like this on the
server side :
\ ? ? \ $ { CWD of client } \ backup_file
If an absolute path gets specified , such as
ClearEventLog ( handle , " C: \\ temp \\ backup_file " )
then it is still mangled by the client into this :
\ ? ? \ C : \ temp \ backup_file
when it is on the wire .
I ' m not sure where the \ ? ? is coming from , or why the $ { CWD } of the client process
would be added in given that the backup file gets written on the server side . */
2005-09-30 21:13:37 +04:00
2008-02-04 12:53:59 +03:00
NTSTATUS _eventlog_ClearEventLogW ( pipes_struct * p ,
struct eventlog_ClearEventLogW * r )
2005-03-24 02:26:33 +03:00
{
2008-02-04 12:53:59 +03:00
EVENTLOG_INFO * info = find_eventlog_info_by_hnd ( p , r - > in . handle ) ;
2005-03-24 02:26:33 +03:00
2005-10-14 20:07:00 +04:00
if ( ! info )
2005-10-27 17:30:23 +04:00
return NT_STATUS_INVALID_HANDLE ;
2005-03-24 02:26:33 +03:00
2008-02-04 12:53:59 +03:00
if ( r - > in . backupfile & & r - > in . backupfile - > string ) {
2009-01-14 20:09:25 +03:00
DEBUG ( 8 , ( " _eventlog_ClearEventLogW: Using [%s] as the backup "
2005-11-17 23:08:59 +03:00
" file name for log [%s]. " ,
2009-01-14 20:09:25 +03:00
r - > in . backupfile - > string , info - > logname ) ) ;
2005-10-14 20:07:00 +04:00
}
2005-03-24 02:26:33 +03:00
2005-11-17 23:08:59 +03:00
/* check for WRITE access to the file */
if ( ! ( info - > access_granted & SA_RIGHT_FILE_WRITE_DATA ) )
return NT_STATUS_ACCESS_DENIED ;
2005-09-30 21:13:37 +04:00
2005-11-17 23:08:59 +03:00
/* Force a close and reopen */
2005-10-14 20:07:00 +04:00
2007-11-27 22:22:58 +03:00
elog_close_tdb ( info - > etdb , True ) ;
2005-11-17 23:08:59 +03:00
become_root ( ) ;
2009-01-22 21:46:14 +03:00
info - > etdb = elog_open_tdb ( info - > logname , True , False ) ;
2005-11-17 23:08:59 +03:00
unbecome_root ( ) ;
2005-10-14 20:07:00 +04:00
2005-11-17 23:08:59 +03:00
if ( ! info - > etdb )
2005-10-27 17:30:23 +04:00
return NT_STATUS_ACCESS_DENIED ;
2005-09-30 21:13:37 +04:00
2005-10-27 17:30:23 +04:00
return NT_STATUS_OK ;
2005-09-30 21:13:37 +04:00
}
/********************************************************************
2009-01-08 21:12:59 +03:00
_eventlog_CloseEventLog
2005-10-06 21:48:03 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-09-30 21:13:37 +04:00
2009-01-08 21:12:59 +03:00
NTSTATUS _eventlog_CloseEventLog ( pipes_struct * p ,
struct eventlog_CloseEventLog * r )
2005-09-30 21:13:37 +04:00
{
2009-01-16 04:59:05 +03:00
NTSTATUS status ;
status = elog_close ( p , r - > in . handle ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
return status ;
}
ZERO_STRUCTP ( r - > out . handle ) ;
return NT_STATUS_OK ;
2005-03-24 02:26:33 +03:00
}
2005-09-30 21:13:37 +04:00
/********************************************************************
2005-10-06 21:48:03 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-10-27 17:30:23 +04:00
NTSTATUS _eventlog_read_eventlog ( pipes_struct * p ,
2005-10-06 21:48:03 +04:00
EVENTLOG_Q_READ_EVENTLOG * q_u ,
EVENTLOG_R_READ_EVENTLOG * r_u )
2005-09-30 21:13:37 +04:00
{
2005-10-14 20:07:00 +04:00
EVENTLOG_INFO * info = find_eventlog_info_by_hnd ( p , & q_u - > handle ) ;
2007-11-27 22:22:58 +03:00
Eventlog_entry * entry = NULL , * ee_new = NULL ;
2005-09-30 21:13:37 +04:00
uint32 num_records_read = 0 ;
2005-10-06 21:48:03 +04:00
int bytes_left , record_number ;
2005-11-18 00:03:22 +03:00
uint32 elog_read_type , elog_read_dir ;
2006-06-20 13:16:53 +04:00
if ( info = = NULL ) {
return NT_STATUS_INVALID_HANDLE ;
}
2005-09-30 21:13:37 +04:00
info - > flags = q_u - > flags ;
2005-10-06 21:48:03 +04:00
bytes_left = q_u - > max_read_size ;
2005-11-17 20:41:02 +03:00
2007-11-27 22:22:58 +03:00
if ( ! info - > etdb )
2005-10-27 17:30:23 +04:00
return NT_STATUS_ACCESS_DENIED ;
2007-11-27 22:22:58 +03:00
2005-11-17 20:41:02 +03:00
/* check for valid flags. Can't use the sequential and seek flags together */
elog_read_type = q_u - > flags & ( EVENTLOG_SEQUENTIAL_READ | EVENTLOG_SEEK_READ ) ;
elog_read_dir = q_u - > flags & ( EVENTLOG_FORWARDS_READ | EVENTLOG_BACKWARDS_READ ) ;
2009-01-14 20:09:25 +03:00
if ( elog_read_type = = ( EVENTLOG_SEQUENTIAL_READ | EVENTLOG_SEEK_READ )
2005-11-17 20:41:02 +03:00
| | elog_read_dir = = ( EVENTLOG_FORWARDS_READ | EVENTLOG_BACKWARDS_READ ) )
{
DEBUG ( 3 , ( " _eventlog_read_eventlog: Invalid flags [0x%x] for ReadEventLog \n " , q_u - > flags ) ) ;
return NT_STATUS_INVALID_PARAMETER ;
2005-09-30 21:13:37 +04:00
}
2005-10-06 21:48:03 +04:00
2005-11-17 20:41:02 +03:00
/* a sequential read should ignore the offset */
2005-10-06 21:48:03 +04:00
2005-11-17 20:41:02 +03:00
if ( elog_read_type & EVENTLOG_SEQUENTIAL_READ )
record_number = info - > current_record ;
2007-11-27 22:22:58 +03:00
else
2005-11-17 20:41:02 +03:00
record_number = q_u - > offset ;
2005-10-06 21:48:03 +04:00
while ( bytes_left > 0 ) {
2005-11-17 20:41:02 +03:00
/* assume that when the record fetch fails, that we are done */
2009-01-13 13:04:45 +03:00
entry = get_eventlog_record ( p - > mem_ctx , ELOG_TDB_CTX ( info - > etdb ) , record_number ) ;
2007-11-27 22:22:58 +03:00
if ( ! entry ) {
2005-11-17 20:41:02 +03:00
break ;
2007-11-27 22:22:58 +03:00
}
2005-11-17 20:41:02 +03:00
DEBUG ( 8 , ( " Retrieved record %d \n " , record_number ) ) ;
2007-11-27 22:22:58 +03:00
2005-11-17 20:41:02 +03:00
/* Now see if there is enough room to add */
2009-01-13 13:04:45 +03:00
if ( ! ( ee_new = read_package_entry ( p - > mem_ctx , entry ) ) )
2005-11-17 20:41:02 +03:00
return NT_STATUS_NO_MEMORY ;
if ( r_u - > num_bytes_in_resp + ee_new - > record . length > q_u - > max_read_size ) {
r_u - > bytes_in_next_record = ee_new - > record . length ;
/* response would be too big to fit in client-size buffer */
2007-11-27 22:22:58 +03:00
2005-11-17 20:41:02 +03:00
bytes_left = 0 ;
break ;
}
2007-11-27 22:22:58 +03:00
2009-01-24 04:59:24 +03:00
add_record_to_resp ( r_u , ee_new ) ;
2005-11-17 20:41:02 +03:00
bytes_left - = ee_new - > record . length ;
2007-11-27 22:22:58 +03:00
TALLOC_FREE ( entry ) ;
2005-11-17 20:41:02 +03:00
num_records_read = r_u - > num_records - num_records_read ;
2007-11-27 22:22:58 +03:00
2005-11-17 20:41:02 +03:00
DEBUG ( 10 , ( " _eventlog_read_eventlog: read [%d] records for a total "
" of [%d] records using [%d] bytes out of a max of [%d]. \n " ,
num_records_read , r_u - > num_records ,
r_u - > num_bytes_in_resp ,
q_u - > max_read_size ) ) ;
2005-10-06 21:48:03 +04:00
2005-10-14 20:07:00 +04:00
if ( info - > flags & EVENTLOG_FORWARDS_READ )
2005-10-06 21:48:03 +04:00
record_number + + ;
2005-10-14 20:07:00 +04:00
else
2005-10-06 21:48:03 +04:00
record_number - - ;
2007-11-27 22:22:58 +03:00
2005-11-17 20:41:02 +03:00
/* update the eventlog record pointer */
2007-11-27 22:22:58 +03:00
2005-11-17 20:41:02 +03:00
info - > current_record = record_number ;
2005-10-06 21:48:03 +04:00
}
2005-11-17 20:41:02 +03:00
2007-11-27 22:22:58 +03:00
/* crazy by WinXP uses NT_STATUS_BUFFER_TOO_SMALL to
2005-11-17 20:41:02 +03:00
say when there are no more records */
return ( num_records_read ? NT_STATUS_OK : NT_STATUS_BUFFER_TOO_SMALL ) ;
2005-09-30 21:13:37 +04:00
}
/********************************************************************
2008-02-04 12:44:51 +03:00
_eventlog_GetOldestRecord
2005-10-06 21:48:03 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-09-30 21:13:37 +04:00
2008-02-04 12:44:51 +03:00
NTSTATUS _eventlog_GetOldestRecord ( pipes_struct * p ,
struct eventlog_GetOldestRecord * r )
2005-09-30 21:13:37 +04:00
{
2008-02-04 12:44:51 +03:00
EVENTLOG_INFO * info = find_eventlog_info_by_hnd ( p , r - > in . handle ) ;
2005-09-30 21:13:37 +04:00
2006-06-20 13:16:53 +04:00
if ( info = = NULL ) {
return NT_STATUS_INVALID_HANDLE ;
}
2005-10-06 21:48:03 +04:00
if ( ! ( get_oldest_entry_hook ( info ) ) )
2005-10-27 17:30:23 +04:00
return NT_STATUS_ACCESS_DENIED ;
2005-09-30 21:13:37 +04:00
2008-02-04 12:44:51 +03:00
* r - > out . oldest_entry = info - > oldest_entry ;
2005-09-30 21:13:37 +04:00
2005-10-27 17:30:23 +04:00
return NT_STATUS_OK ;
2005-09-30 21:13:37 +04:00
}
/********************************************************************
2008-02-04 12:10:12 +03:00
_eventlog_GetNumRecords
2005-10-06 21:48:03 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-09-30 21:13:37 +04:00
2008-02-04 12:10:12 +03:00
NTSTATUS _eventlog_GetNumRecords ( pipes_struct * p ,
struct eventlog_GetNumRecords * r )
2005-09-30 21:13:37 +04:00
{
2008-02-04 12:10:12 +03:00
EVENTLOG_INFO * info = find_eventlog_info_by_hnd ( p , r - > in . handle ) ;
2005-09-30 21:13:37 +04:00
2006-06-20 13:16:53 +04:00
if ( info = = NULL ) {
return NT_STATUS_INVALID_HANDLE ;
}
2005-10-06 21:48:03 +04:00
if ( ! ( get_num_records_hook ( info ) ) )
2005-10-27 17:30:23 +04:00
return NT_STATUS_ACCESS_DENIED ;
2005-09-30 21:13:37 +04:00
2008-02-04 12:10:12 +03:00
* r - > out . number = info - > num_records ;
2005-09-30 21:13:37 +04:00
2005-10-27 17:30:23 +04:00
return NT_STATUS_OK ;
2005-09-30 21:13:37 +04:00
}
2007-05-31 21:59:04 +04:00
NTSTATUS _eventlog_BackupEventLogW ( pipes_struct * p , struct eventlog_BackupEventLogW * r )
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
NTSTATUS _eventlog_DeregisterEventSource ( pipes_struct * p , struct eventlog_DeregisterEventSource * r )
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
NTSTATUS _eventlog_ChangeNotify ( pipes_struct * p , struct eventlog_ChangeNotify * r )
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
NTSTATUS _eventlog_RegisterEventSourceW ( pipes_struct * p , struct eventlog_RegisterEventSourceW * r )
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
NTSTATUS _eventlog_OpenBackupEventLogW ( pipes_struct * p , struct eventlog_OpenBackupEventLogW * r )
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
NTSTATUS _eventlog_ReadEventLogW ( pipes_struct * p , struct eventlog_ReadEventLogW * r )
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
NTSTATUS _eventlog_ReportEventW ( pipes_struct * p , struct eventlog_ReportEventW * r )
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
NTSTATUS _eventlog_ClearEventLogA ( pipes_struct * p , struct eventlog_ClearEventLogA * r )
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
NTSTATUS _eventlog_BackupEventLogA ( pipes_struct * p , struct eventlog_BackupEventLogA * r )
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
NTSTATUS _eventlog_OpenEventLogA ( pipes_struct * p , struct eventlog_OpenEventLogA * r )
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
NTSTATUS _eventlog_RegisterEventSourceA ( pipes_struct * p , struct eventlog_RegisterEventSourceA * r )
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
NTSTATUS _eventlog_OpenBackupEventLogA ( pipes_struct * p , struct eventlog_OpenBackupEventLogA * r )
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
NTSTATUS _eventlog_ReadEventLogA ( pipes_struct * p , struct eventlog_ReadEventLogA * r )
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
NTSTATUS _eventlog_ReportEventA ( pipes_struct * p , struct eventlog_ReportEventA * r )
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
NTSTATUS _eventlog_RegisterClusterSvc ( pipes_struct * p , struct eventlog_RegisterClusterSvc * r )
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
NTSTATUS _eventlog_DeregisterClusterSvc ( pipes_struct * p , struct eventlog_DeregisterClusterSvc * r )
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
NTSTATUS _eventlog_WriteClusterEvents ( pipes_struct * p , struct eventlog_WriteClusterEvents * r )
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
NTSTATUS _eventlog_GetLogIntormation ( pipes_struct * p , struct eventlog_GetLogIntormation * r )
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
NTSTATUS _eventlog_FlushEventLog ( pipes_struct * p , struct eventlog_FlushEventLog * r )
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2009-01-22 21:35:33 +03:00
NTSTATUS _eventlog_ReportEventAndSourceW ( pipes_struct * p , struct eventlog_ReportEventAndSourceW * r )
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}