diff options
-rw-r--r-- | source3/include/proto.h | 2 | ||||
-rw-r--r-- | source3/rpc_server/srv_eventlog_lib.c | 11 | ||||
-rw-r--r-- | source3/rpc_server/srv_eventlog_nt.c | 6 | ||||
-rw-r--r-- | source3/utils/eventlogadm.c | 2 |
4 files changed, 14 insertions, 7 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index dfe42db245..f68c354642 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -6258,7 +6258,7 @@ char *elog_tdbname(TALLOC_CTX *ctx, const char *name ); int elog_tdb_size( TDB_CONTEXT * tdb, int *MaxSize, int *Retention ); bool prune_eventlog( TDB_CONTEXT * tdb ); bool can_write_to_eventlog( TDB_CONTEXT * tdb, int32 needed ); -ELOG_TDB *elog_open_tdb( char *logname, bool force_clear ); +ELOG_TDB *elog_open_tdb( char *logname, bool force_clear, bool read_only ); int elog_close_tdb( ELOG_TDB *etdb, bool force_close ); int write_eventlog_tdb( TDB_CONTEXT * the_tdb, Eventlog_entry * ee ); void fixup_eventlog_entry( Eventlog_entry * ee ); diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c index 8cbb319e9b..88e246a94f 100644 --- a/source3/rpc_server/srv_eventlog_lib.c +++ b/source3/rpc_server/srv_eventlog_lib.c @@ -312,7 +312,7 @@ bool can_write_to_eventlog( TDB_CONTEXT * tdb, int32_t needed ) /******************************************************************* *******************************************************************/ -ELOG_TDB *elog_open_tdb( char *logname, bool force_clear ) +ELOG_TDB *elog_open_tdb( char *logname, bool force_clear, bool read_only ) { TDB_CONTEXT *tdb = NULL; uint32_t vers_id; @@ -322,6 +322,13 @@ ELOG_TDB *elog_open_tdb( char *logname, bool force_clear ) char *eventlogdir; TALLOC_CTX *ctx = talloc_tos(); + /* check for invalid options */ + + if (force_clear && read_only) { + DEBUG(1,("elog_open_tdb: Invalid flags\n")); + return NULL; + } + /* first see if we have an open context */ for ( ptr=open_elog_list; ptr; ptr=ptr->next ) { @@ -363,7 +370,7 @@ ELOG_TDB *elog_open_tdb( char *logname, bool force_clear ) if ( !force_clear ) { - tdb = tdb_open_log( tdbpath, 0, TDB_DEFAULT, O_RDWR , 0 ); + tdb = tdb_open_log( tdbpath, 0, TDB_DEFAULT, read_only ? O_RDONLY : O_RDWR , 0 ); if ( tdb ) { vers_id = tdb_fetch_int32( tdb, EVT_VERSION ); diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index a687025ba6..990b03a570 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -194,7 +194,7 @@ static NTSTATUS elog_open( pipes_struct * p, const char *logname, POLICY_HND *hn in a single process */ become_root(); - elog->etdb = elog_open_tdb( elog->logname, False ); + elog->etdb = elog_open_tdb( elog->logname, False, False ); unbecome_root(); if ( !elog->etdb ) { @@ -214,7 +214,7 @@ static NTSTATUS elog_open( pipes_struct * p, const char *logname, POLICY_HND *hn } become_root(); - elog->etdb = elog_open_tdb( elog->logname, False ); + elog->etdb = elog_open_tdb( elog->logname, False, False ); unbecome_root(); } @@ -677,7 +677,7 @@ NTSTATUS _eventlog_ClearEventLogW(pipes_struct *p, elog_close_tdb( info->etdb, True ); become_root(); - info->etdb = elog_open_tdb( info->logname, True ); + info->etdb = elog_open_tdb( info->logname, True, False ); unbecome_root(); if ( !info->etdb ) diff --git a/source3/utils/eventlogadm.c b/source3/utils/eventlogadm.c index 5fed4d1a39..7d40772423 100644 --- a/source3/utils/eventlogadm.c +++ b/source3/utils/eventlogadm.c @@ -103,7 +103,7 @@ static int DoWriteCommand( int argc, char **argv, bool debugflag, char *exename argfname = argv[0]; - if ( !( etdb = elog_open_tdb( argfname, False ) ) ) { + if ( !( etdb = elog_open_tdb( argfname, False, False ) ) ) { printf( "can't open the eventlog TDB (%s)\n", argfname ); return -1; } |