s3-eventlog: pass down talloc context to parse_logentry().
authorGünther Deschner <gd@samba.org>
Mon, 2 Feb 2009 12:38:38 +0000 (13:38 +0100)
committerGünther Deschner <gd@samba.org>
Tue, 3 Feb 2009 14:45:09 +0000 (15:45 +0100)
Guenther

source3/include/proto.h
source3/rpc_server/srv_eventlog_lib.c
source3/utils/eventlogadm.c

index 6f9474e3fb2d170359a0928faa8d07b89368a6a5..19d131cb6311560c2890f721a208bf7749f82bc7 100644 (file)
@@ -6262,7 +6262,7 @@ 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  */
 
index 70673f73e9a8710509dcfba92fed7e150f14c0f3..2890dc952870ef95119877908849909f279fb522 100644 (file)
@@ -594,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;
@@ -667,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 ||
@@ -679,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 ||
@@ -691,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 ||
@@ -708,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);
@@ -735,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;
index 7d4077242356e984bc6850e52e287495cec0f006..fb0bc602cc6bb5fcd90b4a7f70fe8ca1d25b0635 100644 (file)
@@ -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 ) {
@@ -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 ) {