summaryrefslogtreecommitdiff
path: root/source3
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 /source3
parent35f1e02ca4c31214e85b7c25d8f695eb035871d7 (diff)
downloadsamba-8fb6b18bac436d4babdafc4d8b97de70881c1238.tar.gz
samba-8fb6b18bac436d4babdafc4d8b97de70881c1238.tar.bz2
samba-8fb6b18bac436d4babdafc4d8b97de70881c1238.zip
s3-eventlog: allow to open eventlog tdbs readonly.
Guenther
Diffstat (limited to 'source3')
-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 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;
}