r23779: Change from v2 or later to v3 or later.
[amitay/samba.git] / source3 / registry / reg_eventlog.c
index 69d8f2f9aab5c56bb4d58825f3fcc33019d1b9e3..8d93cee7dc516c7e4cfba0123f37fad2e9cf270b 100644 (file)
@@ -8,7 +8,7 @@
  *  
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
+ *  the Free Software Foundation; either version 3 of the License, or
  *  (at your option) any later version.
  *  
  *  This program is distributed in the hope that it will be useful,
@@ -33,9 +33,9 @@ BOOL eventlog_init_keys( void )
        /* Find all of the eventlogs, add keys for each of them */
        const char **elogs = lp_eventlog_list(  );
        pstring evtlogpath;
+       pstring evtfilepath;
        REGSUBKEY_CTR *subkeys;
        REGVAL_CTR *values;
-       uint32 uiDisplayNameId;
        uint32 uiMaxSize;
        uint32 uiRetention;
        uint32 uiCategoryCount;
@@ -48,8 +48,10 @@ BOOL eventlog_init_keys( void )
                }
                regdb_fetch_keys( KEY_EVENTLOG, subkeys );
                regsubkey_ctr_addkey( subkeys, *elogs );
-               if ( !regdb_store_keys( KEY_EVENTLOG, subkeys ) )
+               if ( !regdb_store_keys( KEY_EVENTLOG, subkeys ) ) {
+                       TALLOC_FREE(subkeys);
                        return False;
+               }
                TALLOC_FREE( subkeys );
 
                /* add in the key of form KEY_EVENTLOG/Application */
@@ -70,8 +72,10 @@ BOOL eventlog_init_keys( void )
                regdb_fetch_keys( evtlogpath, subkeys );
                regsubkey_ctr_addkey( subkeys, *elogs );
 
-               if ( !regdb_store_keys( evtlogpath, subkeys ) )
+               if ( !regdb_store_keys( evtlogpath, subkeys ) ) {
+                       TALLOC_FREE(subkeys);
                        return False;
+               }
                TALLOC_FREE( subkeys );
 
                /* now add the values to the KEY_EVENTLOG/Application form key */
@@ -91,17 +95,19 @@ BOOL eventlog_init_keys( void )
 
                        /* hard code some initial values */
 
-                       uiDisplayNameId = 0x00000100;
+                       /* uiDisplayNameId = 0x00000100; */
                        uiMaxSize = 0x00080000;
                        uiRetention = 0x93A80;
 
                        regval_ctr_addvalue( values, "MaxSize", REG_DWORD,
                                             ( char * ) &uiMaxSize,
                                             sizeof( uint32 ) );
+
                        regval_ctr_addvalue( values, "Retention", REG_DWORD,
                                             ( char * ) &uiRetention,
                                             sizeof( uint32 ) );
                        init_unistr2( &data, *elogs, UNI_STR_TERMINATE );
+
                        regval_ctr_addvalue( values, "PrimaryModule", REG_SZ,
                                             ( char * ) data.buffer,
                                             data.uni_str_len *
@@ -112,6 +118,11 @@ BOOL eventlog_init_keys( void )
                                             ( char * ) data.buffer,
                                             data.uni_str_len *
                                             sizeof( uint16 ) );
+
+                       pstr_sprintf( evtfilepath, "%%SystemRoot%%\\system32\\config\\%s.tdb", *elogs );
+                       init_unistr2( &data, evtfilepath, UNI_STR_TERMINATE );
+                       regval_ctr_addvalue( values, "File", REG_EXPAND_SZ, ( char * ) data.buffer,
+                                            data.uni_str_len * sizeof( uint16 ) );
                        regdb_store_values( evtlogpath, values );
 
                }
@@ -183,6 +194,10 @@ BOOL eventlog_add_source( const char *eventlog, const char *sourcename,
        int i;
        int numsources;
 
+       if (!elogs) {
+               return False;
+       }
+
        for ( i = 0; elogs[i]; i++ ) {
                if ( strequal( elogs[i], eventlog ) )
                        break;
@@ -269,7 +284,7 @@ BOOL eventlog_add_source( const char *eventlog, const char *sourcename,
                *( wp + numsources ) = ( char * ) sourcename;
                *( wp + numsources + 1 ) = NULL;
                mbytes = regval_build_multi_sz( wp, &msz_wp );
-               dump_data( 1, ( char * ) msz_wp, mbytes );
+               dump_data( 1, ( uint8 * ) msz_wp, mbytes );
                regval_ctr_addvalue( values, "Sources", REG_MULTI_SZ,
                                     ( char * ) msz_wp, mbytes );
                regdb_store_values( evtlogpath, values );
@@ -280,8 +295,7 @@ BOOL eventlog_add_source( const char *eventlog, const char *sourcename,
                         sourcename ) );
        }
        TALLOC_FREE( values );
-       if ( wrklist )
-               TALLOC_FREE( wrklist ); /*  */
+       TALLOC_FREE( wrklist ); /*  */
 
        if ( !( subkeys = TALLOC_ZERO_P( NULL, REGSUBKEY_CTR ) ) ) {
                DEBUG( 0, ( "talloc() failure!\n" ) );
@@ -301,7 +315,7 @@ BOOL eventlog_add_source( const char *eventlog, const char *sourcename,
        }
        TALLOC_FREE( subkeys );
 
-       /* at this point KEY_EVENTLOG/<eventlog>/<sourcename> key is in there. Now need to add EventLogMessageFile */
+       /* at this point KEY_EVENTLOG/<eventlog>/<sourcename> key is in there. Now need to add EventMessageFile */
 
        /* now allocate room for the source's subkeys */
 
@@ -320,14 +334,14 @@ BOOL eventlog_add_source( const char *eventlog, const char *sourcename,
                return False;
        }
        DEBUG( 5,
-              ( "Storing EventLogMessageFile [%s] to eventlog path of [%s]\n",
+              ( "Storing EventMessageFile [%s] to eventlog path of [%s]\n",
                 messagefile, evtlogpath ) );
 
        regdb_fetch_values( evtlogpath, values );
 
        init_unistr2( &data, messagefile, UNI_STR_TERMINATE );
 
-       regval_ctr_addvalue( values, "EventLogMessageFile", REG_EXPAND_SZ,
+       regval_ctr_addvalue( values, "EventMessageFile", REG_SZ,
                             ( char * ) data.buffer,
                             data.uni_str_len * sizeof( uint16 ) );
        regdb_store_values( evtlogpath, values );