summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2009-01-22 19:46:14 +0100
committerGünther Deschner <gd@samba.org>2009-02-03 15:44:06 +0100
commit8fb6b18bac436d4babdafc4d8b97de70881c1238 (patch)
treed74bd2572e2e9e71f7e4561d6e7553b11f1bc96c
parent35f1e02ca4c31214e85b7c25d8f695eb035871d7 (diff)
downloadsamba-8fb6b18bac436d4babdafc4d8b97de70881c1238.tar.gz
samba-8fb6b18bac436d4babdafc4d8b97de70881c1238.tar.xz
samba-8fb6b18bac436d4babdafc4d8b97de70881c1238.zip
s3-eventlog: allow to open eventlog tdbs readonly.
Guenther
-rw-r--r--source3/include/proto.h2
-rw-r--r--source3/rpc_server/srv_eventlog_lib.c11
-rw-r--r--source3/rpc_server/srv_eventlog_nt.c6
-rw-r--r--source3/utils/eventlogadm.c2
4 files changed, 14 insertions, 7 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index dfe42db2454..f68c3546422 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 8cbb319e9b0..88e246a94f3 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 a687025ba68..990b03a570c 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 5fed4d1a399..7d407724235 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;
}