The branch, master has been updated
       via  b94946697dc1d2915f6330f3a02cca7d69bc7cff (commit)
       via  4976777e3b0f3d8c18182a822937f62c082027c7 (commit)
       via  8fb6b18bac436d4babdafc4d8b97de70881c1238 (commit)
      from  35f1e02ca4c31214e85b7c25d8f695eb035871d7 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit b94946697dc1d2915f6330f3a02cca7d69bc7cff
Author: Günther Deschner <g...@samba.org>
Date:   Mon Feb 2 13:38:38 2009 +0100

    s3-eventlog: pass down talloc context to parse_logentry().
    
    Guenther

commit 4976777e3b0f3d8c18182a822937f62c082027c7
Author: Günther Deschner <g...@samba.org>
Date:   Mon Feb 2 14:00:01 2009 +0100

    s3-eventlog: make logname in elog_open_tdb const.
    
    Guenther

commit 8fb6b18bac436d4babdafc4d8b97de70881c1238
Author: Günther Deschner <g...@samba.org>
Date:   Thu Jan 22 19:46:14 2009 +0100

    s3-eventlog: allow to open eventlog tdbs readonly.
    
    Guenther

-----------------------------------------------------------------------

Summary of changes:
 source3/include/proto.h               |    4 ++--
 source3/rpc_server/srv_eventlog_lib.c |   26 ++++++++++++++++----------
 source3/rpc_server/srv_eventlog_nt.c  |    6 +++---
 source3/utils/eventlogadm.c           |    5 +++--
 4 files changed, 24 insertions(+), 17 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/proto.h b/source3/include/proto.h
index dfe42db..19d131c 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -6258,11 +6258,11 @@ 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( const 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 );
-bool parse_logentry( char *line, Eventlog_entry * entry, bool * eor );
+bool parse_logentry( TALLOC_CTX *mem_ctx, char *line, Eventlog_entry * entry, 
bool * eor );
 
 /* The following definitions come from rpc_server/srv_eventlog_nt.c  */
 
diff --git a/source3/rpc_server/srv_eventlog_lib.c 
b/source3/rpc_server/srv_eventlog_lib.c
index 8cbb319..2890dc9 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( const 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 );
 
@@ -587,9 +594,8 @@ void fixup_eventlog_entry( Eventlog_entry * ee )
  going in.
 ********************************************************************/
 
-bool parse_logentry( char *line, Eventlog_entry * entry, bool * eor )
+bool parse_logentry( TALLOC_CTX *mem_ctx, char *line, Eventlog_entry * entry, 
bool * eor )
 {
-       TALLOC_CTX *ctx = talloc_tos();
        char *start = NULL, *stop = NULL;
 
        start = line;
@@ -660,7 +666,7 @@ bool parse_logentry( char *line, Eventlog_entry * entry, 
bool * eor )
                while ( isspace( stop[0] ) ) {
                        stop++;
                }
-               entry->data_record.source_name_len = rpcstr_push_talloc(ctx,
+               entry->data_record.source_name_len = rpcstr_push_talloc(mem_ctx,
                                &entry->data_record.source_name,
                                stop);
                if (entry->data_record.source_name_len == (uint32_t)-1 ||
@@ -672,7 +678,7 @@ bool parse_logentry( char *line, Eventlog_entry * entry, 
bool * eor )
                while ( isspace( stop[0] ) ) {
                        stop++;
                }
-               entry->data_record.computer_name_len = rpcstr_push_talloc(ctx,
+               entry->data_record.computer_name_len = 
rpcstr_push_talloc(mem_ctx,
                                &entry->data_record.computer_name,
                                stop);
                if (entry->data_record.computer_name_len == (uint32_t)-1 ||
@@ -684,7 +690,7 @@ bool parse_logentry( char *line, Eventlog_entry * entry, 
bool * eor )
                while ( isspace( stop[0] ) ) {
                        stop++;
                }
-               entry->record.user_sid_length = rpcstr_push_talloc(ctx,
+               entry->record.user_sid_length = rpcstr_push_talloc(mem_ctx,
                                &entry->data_record.sid,
                                stop);
                if (entry->record.user_sid_length == (uint32_t)-1 ||
@@ -701,14 +707,14 @@ bool parse_logentry( char *line, Eventlog_entry * entry, 
bool * eor )
                while ( isspace(stop[0])) {
                        stop++;
                }
-               tmp_len = rpcstr_push_talloc(ctx,
+               tmp_len = rpcstr_push_talloc(mem_ctx,
                                                &temp,
                                                stop);
                if (tmp_len == (size_t)-1 || !temp) {
                        return false;
                }
                old_len = entry->data_record.strings_len;
-               entry->data_record.strings = (smb_ucs2_t 
*)TALLOC_REALLOC_ARRAY(ctx,
+               entry->data_record.strings = (smb_ucs2_t 
*)TALLOC_REALLOC_ARRAY(mem_ctx,
                                                entry->data_record.strings,
                                                char,
                                                old_len + tmp_len);
@@ -728,7 +734,7 @@ bool parse_logentry( char *line, Eventlog_entry * entry, 
bool * eor )
                        stop++;
                }
                entry->data_record.user_data_len = strlen(stop);
-               entry->data_record.user_data = talloc_strdup(ctx,
+               entry->data_record.user_data = talloc_strdup(mem_ctx,
                                                stop);
                if (!entry->data_record.user_data) {
                        return false;
diff --git a/source3/rpc_server/srv_eventlog_nt.c 
b/source3/rpc_server/srv_eventlog_nt.c
index a687025..990b03a 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 5fed4d1..fb0bc60 100644
--- a/source3/utils/eventlogadm.c
+++ b/source3/utils/eventlogadm.c
@@ -89,6 +89,7 @@ static int DoWriteCommand( int argc, char **argv, bool 
debugflag, char *exename
        bool is_eor;
        Eventlog_entry ee;
        int rcnum;
+       TALLOC_CTX *mem_ctx = talloc_tos();
 
        f1 = stdin;
        if ( !f1 ) {
@@ -103,7 +104,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;
        }
@@ -122,7 +123,7 @@ static int DoWriteCommand( int argc, char **argv, bool 
debugflag, char *exename
                is_eor = False;
 
 
-               parse_logentry( ( char * ) &linein, &ee, &is_eor );
+               parse_logentry( mem_ctx, ( char * ) &linein, &ee, &is_eor );
                /* should we do something with the return code? */
 
                if ( is_eor ) {


-- 
Samba Shared Repository

Reply via email to