summaryrefslogtreecommitdiff
path: root/source3/rpc_server
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/rpc_server
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/rpc_server')
-rw-r--r--source3/rpc_server/srv_eventlog_lib.c11
-rw-r--r--source3/rpc_server/srv_eventlog_nt.c6
2 files changed, 12 insertions, 5 deletions
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 )