From 5d1cb8e79edea9e8581d3c2c9dd297310cd9a98c Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 23 Mar 2005 23:26:33 +0000 Subject: r6014: rather large change set.... pulling back all recent rpc changes from trunk into 3.0. I've tested a compile and so don't think I've missed any files. But if so, just mail me and I'll clean backup in a couple of hours. Changes include \winreg, \eventlog, \svcctl, and general parse_misc.c updates. I am planning on bracketing the event code with an #ifdef ENABLE_EVENTLOG until I finish merging Marcin's changes (very soon). (This used to be commit 4e0ac63c36527cd8c52ef720cae17e84f67e7221) --- source3/registry/reg_eventlog.c | 302 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 302 insertions(+) create mode 100644 source3/registry/reg_eventlog.c (limited to 'source3/registry/reg_eventlog.c') diff --git a/source3/registry/reg_eventlog.c b/source3/registry/reg_eventlog.c new file mode 100644 index 0000000000..cc2ffb5a05 --- /dev/null +++ b/source3/registry/reg_eventlog.c @@ -0,0 +1,302 @@ +/* + * Unix SMB/CIFS implementation. + * RPC Pipe client / server routines + * Copyright (C) Marcin Krzysztof Porwit 2005. + * + * 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 + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "includes.h" + +/********************************************************************** + handle enumeration of values AT KEY_EVENTLOG + *********************************************************************/ + +static int eventlog_topkey_values( char *key, REGVAL_CTR *val ) +{ + int num_values = 0; + char *keystr, *key2 = NULL; + char *base, *new_path; + fstring evtlogname; + UNISTR2 data; + int iDisplayNameId; + int iMaxSize; + + /* + * TODO - callout to get these values... + */ + + if ( key ) + { + key2 = strdup( key ); + keystr = key2; + reg_split_path( keystr, &base, &new_path ); + + iDisplayNameId = 0x00000100; + iMaxSize= 0x00080000; + + fstrcpy( evtlogname, base ); + DEBUG(10,("eventlog_topkey_values: subkey root=> [%s] subkey path=>[%s]\n", base,new_path)); + + if ( !new_path ) + { + iDisplayNameId = 0x01; + regval_ctr_addvalue( val, "ErrorControl", REG_DWORD, (char*)&iDisplayNameId, sizeof(int) ); + + init_unistr2( &data, "EventLog", UNI_STR_TERMINATE); + regval_ctr_addvalue( val, "DisplayName", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) ); + + num_values = regval_ctr_numvals( val ); + + + num_values = 0; + } + } + + SAFE_FREE( key2 ); + return num_values; +} + +/********************************************************************** + handle enumeration of values below KEY_EVENTLOG\ + *********************************************************************/ + +static int eventlog_subkey_values( char *key, REGVAL_CTR *val ) +{ + int num_values = 0; + char *keystr, *key2 = NULL; + char *base, *new_path; + fstring evtlogname; + UNISTR2 data; + int iDisplayNameId; + int iMaxSize; + int iRetention; + + /* + * TODO - callout to get these values... + */ + + if ( !key ) + return num_values; + + key2 = SMB_STRDUP( key ); + keystr = key2; + reg_split_path( keystr, &base, &new_path ); + + iDisplayNameId = 0x00000100; + /* MaxSize is limited to 0xFFFF0000 (UINT_MAX - USHRT_MAX) as per MSDN documentation */ + iMaxSize= 0xFFFF0000; + /* records in the samba log are not overwritten */ + iRetention = 0xFFFFFFFF; + + fstrcpy( evtlogname, base ); + DEBUG(10,("eventlog_subpath_values_printer: eventlogname [%s]\n", base)); + DEBUG(10,("eventlog_subpath_values_printer: new_path [%s]\n", new_path)); + if ( !new_path ) + { +#if 0 + regval_ctr_addvalue( val, "DisplayNameId", REG_DWORD, (char*)&iDisplayNameId, sizeof(int) ); + + init_unistr2( &data, "%SystemRoot%\\system32\\els.dll", UNI_STR_TERMINATE); + regval_ctr_addvalue( val, "DisplayNameFile", REG_EXPAND_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) ); +#endif + regval_ctr_addvalue( val, "MaxSize", REG_DWORD, (char*)&iMaxSize, sizeof(int)); + regval_ctr_addvalue( val, "Retention", REG_DWORD, (char *)&iRetention, sizeof(int)); +#if 0 + init_unistr2( &data, lp_logfile(), UNI_STR_TERMINATE); + regval_ctr_addvalue( val, "File", REG_EXPAND_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) ); +#endif + init_unistr2( &data, base, UNI_STR_TERMINATE); + regval_ctr_addvalue( val, "PrimaryModule", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) ); + + init_unistr2( &data, base, UNI_STR_TERMINATE); + regval_ctr_addvalue( val, "Sources", REG_MULTI_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) ); + + num_values = regval_ctr_numvals( val ); + + } + else + { + iDisplayNameId = 0x07; + regval_ctr_addvalue( val, "CategoryCount", REG_DWORD, (char*)&iDisplayNameId, sizeof(int) ); + + init_unistr2( &data, "%SystemRoot%\\system32\\eventlog.dll", UNI_STR_TERMINATE); + regval_ctr_addvalue( val, "CategoryMessageFile", REG_EXPAND_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) ); + + num_values = regval_ctr_numvals( val ); + + num_values = 0; + } + + SAFE_FREE( key2 ); + return num_values; +} + + +/********************************************************************** + It is safe to assume that every registry path passed into on of + the exported functions here begins with KEY_EVENTLOG else + these functions would have never been called. This is a small utility + function to strip the beginning of the path and make a copy that the + caller can modify. Note that the caller is responsible for releasing + the memory allocated here. + **********************************************************************/ + +static char* trim_eventlog_reg_path( char *path ) +{ + char *p; + uint16 key_len = strlen(KEY_EVENTLOG); + + /* + * sanity check...this really should never be True. + * It is only here to prevent us from accessing outside + * the path buffer in the extreme case. + */ + + if ( strlen(path) < key_len ) { + DEBUG(0,("trim_reg_path: Registry path too short! [%s]\n", path)); + DEBUG(0,("trim_reg_path: KEY_EVENTLOG => [%s]!\n", KEY_EVENTLOG)); + return NULL; + } + + + p = path + strlen( KEY_EVENTLOG ); + + if ( *p == '\\' ) + p++; + + if ( *p ) + return SMB_STRDUP(p); + else + return NULL; +} +/********************************************************************** + Enumerate registry subkey names given a registry path. + Caller is responsible for freeing memory to **subkeys + *********************************************************************/ +int eventlog_subkey_info( char *key, REGSUBKEY_CTR *subkey_ctr ) +{ + char *path; + BOOL top_level = False; + int num_subkeys = 0; + const char **evtlog_list; + + path = trim_eventlog_reg_path( key ); + DEBUG(10,("eventlog_subkey_info: entire key=>[%s] SUBkey=>[%s]\n", key,path)); + + /* check to see if we are dealing with the top level key */ + num_subkeys = 0; + + if ( !path ) + top_level = True; + + evtlog_list = lp_eventlog_list(); + num_subkeys = 0; + + if ( top_level ) + { + /* todo - get the eventlog subkey values from the smb.conf file + for ( num_subkeys=0; num_subkeys[%s]\n",*evtlog_list)); + regsubkey_ctr_addkey( subkey_ctr, *evtlog_list); + evtlog_list++; + num_subkeys++; + } + } + else + { + while (*evtlog_list && (0==num_subkeys) ) + { + if (0 == StrCaseCmp(path,*evtlog_list)) + { + DEBUG(10,("eventlog_subkey_info: Adding subkey [%s] for key =>[%s]\n",path,*evtlog_list)); + regsubkey_ctr_addkey( subkey_ctr, *evtlog_list); + num_subkeys = 1; + } + evtlog_list++; + } + + if (0==num_subkeys) + DEBUG(10,("eventlog_subkey_info: No match on SUBkey=>[%s]\n", path)); + } + + SAFE_FREE( path ); + return num_subkeys; +} + +/********************************************************************** + Enumerate registry values given a registry path. + Caller is responsible for freeing memory + *********************************************************************/ + +int eventlog_value_info( char *key, REGVAL_CTR *val ) +{ + char *path; + BOOL top_level = False; + int num_values = 0; + + DEBUG(10,("eventlog_value_info: key=>[%s]\n", key)); + + path = trim_eventlog_reg_path( key ); + + /* check to see if we are dealing with the top level key */ + + if ( !path ) + top_level = True; + if ( top_level ) + num_values = eventlog_topkey_values(path,val); + else + { + DEBUG(10,("eventlog_value_info: SUBkey=>[%s]\n", path)); + num_values = eventlog_subkey_values(path,val); + } + return num_values; +} + +/********************************************************************** + Stub function which always returns failure since we don't want + people storing eventlog information directly via registry calls + (for now at least) + *********************************************************************/ +BOOL eventlog_store_subkey( char *key, REGSUBKEY_CTR *subkeys ) +{ + return False; +} + +/********************************************************************** + Stub function which always returns failure since we don't want + people storing eventlog information directly via registry calls + (for now at least) + *********************************************************************/ +BOOL eventlog_store_value( char *key, REGVAL_CTR *val ) +{ + return False; +} + +/* + * Table of function pointers for accessing eventlog data + */ +REGISTRY_OPS eventlog_ops = { + eventlog_subkey_info, + eventlog_value_info, + eventlog_store_subkey, + eventlog_store_value +}; -- cgit From 2e0cac8e3eb021aa8f5cad4ce8b72f98036af639 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 23 Apr 2005 18:07:01 +0000 Subject: r6445: Make us survive the PARANOID_MALLOC_CHECKER. Should we enable that for --enable-developer=yes? Volker (This used to be commit 61d40ac60dd9c8c9bbcf92e4fc57fe1d706bc721) --- source3/registry/reg_eventlog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/registry/reg_eventlog.c') diff --git a/source3/registry/reg_eventlog.c b/source3/registry/reg_eventlog.c index cc2ffb5a05..ccac7a190e 100644 --- a/source3/registry/reg_eventlog.c +++ b/source3/registry/reg_eventlog.c @@ -40,7 +40,7 @@ static int eventlog_topkey_values( char *key, REGVAL_CTR *val ) if ( key ) { - key2 = strdup( key ); + key2 = SMB_STRDUP( key ); keystr = key2; reg_split_path( keystr, &base, &new_path ); -- cgit From f0c650a38286c07b9f3e83139c15bfbadc70ad5f Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 23 May 2005 16:25:31 +0000 Subject: r6942: * merging the registry changes back to the 3.0 tree * removing the testprns tool (This used to be commit 81ffb0dbbbd244623507880c323a3c37e2b8dc4d) --- source3/registry/reg_eventlog.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'source3/registry/reg_eventlog.c') diff --git a/source3/registry/reg_eventlog.c b/source3/registry/reg_eventlog.c index ccac7a190e..50e4995b9e 100644 --- a/source3/registry/reg_eventlog.c +++ b/source3/registry/reg_eventlog.c @@ -1,6 +1,6 @@ /* * Unix SMB/CIFS implementation. - * RPC Pipe client / server routines + * Virtual Windows Registry Layer * Copyright (C) Marcin Krzysztof Porwit 2005. * * This program is free software; you can redistribute it and/or modify @@ -186,7 +186,7 @@ static char* trim_eventlog_reg_path( char *path ) Enumerate registry subkey names given a registry path. Caller is responsible for freeing memory to **subkeys *********************************************************************/ -int eventlog_subkey_info( char *key, REGSUBKEY_CTR *subkey_ctr ) +static int eventlog_subkey_info( char *key, REGSUBKEY_CTR *subkey_ctr ) { char *path; BOOL top_level = False; @@ -202,10 +202,14 @@ int eventlog_subkey_info( char *key, REGSUBKEY_CTR *subkey_ctr ) if ( !path ) top_level = True; - evtlog_list = lp_eventlog_list(); num_subkeys = 0; + if ( !(evtlog_list = lp_eventlog_list()) ) { + SAFE_FREE(path); + return num_subkeys; + } + - if ( top_level ) + if ( top_level ) { /* todo - get the eventlog subkey values from the smb.conf file for ( num_subkeys=0; num_subkeys Date: Thu, 16 Jun 2005 20:45:55 +0000 Subject: r7648: adding REGISTRY_HOOK->reg_access_check() for authprization checks on RegOpenKey(); passing it off to the backend code for a given path (This used to be commit 867fd3052bbfdd45856886999619e2ebc6552675) --- source3/registry/reg_eventlog.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/registry/reg_eventlog.c') diff --git a/source3/registry/reg_eventlog.c b/source3/registry/reg_eventlog.c index 50e4995b9e..4c3f144980 100644 --- a/source3/registry/reg_eventlog.c +++ b/source3/registry/reg_eventlog.c @@ -302,5 +302,6 @@ REGISTRY_OPS eventlog_ops = { eventlog_subkey_info, eventlog_value_info, eventlog_store_subkey, - eventlog_store_value + eventlog_store_value, + NULL }; -- cgit From bd509a81cb6c295988a1626adfe394c9778c005e Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 25 Jun 2005 17:31:40 +0000 Subject: r7908: * change REGISTRY_HOOK api to use const (fix compiler warning in init_registry_data() * Add means of storing registry values in registry.tdb * add builtin_registry_values[] array for REG_DWORD and REG_SZ values needed during startup * Finish up RegDeleteValue() and RegSetValue() * Finish up regdb_store_reg_values() and regdb_fetch_reg_values() I can now create and retrieve values using regedit.exe on Win2k. bin/net -S rain -U% rpc registry enumerate 'hklm\software\samba' Valuename = Version Type = REG_SZ Data = 3.0.20 Next is to do the virtual writes in reg_printing.c and I'll be done with Print Migrator (yeah! finally) (This used to be commit 3d837e58db9ded64d6b85f047012c7d487be4627) --- source3/registry/reg_eventlog.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source3/registry/reg_eventlog.c') diff --git a/source3/registry/reg_eventlog.c b/source3/registry/reg_eventlog.c index 4c3f144980..b20eb046db 100644 --- a/source3/registry/reg_eventlog.c +++ b/source3/registry/reg_eventlog.c @@ -154,9 +154,9 @@ static int eventlog_subkey_values( char *key, REGVAL_CTR *val ) the memory allocated here. **********************************************************************/ -static char* trim_eventlog_reg_path( char *path ) +static char* trim_eventlog_reg_path( const char *path ) { - char *p; + const char *p; uint16 key_len = strlen(KEY_EVENTLOG); /* @@ -186,7 +186,7 @@ static char* trim_eventlog_reg_path( char *path ) Enumerate registry subkey names given a registry path. Caller is responsible for freeing memory to **subkeys *********************************************************************/ -static int eventlog_subkey_info( char *key, REGSUBKEY_CTR *subkey_ctr ) +static int eventlog_subkey_info( const char *key, REGSUBKEY_CTR *subkey_ctr ) { char *path; BOOL top_level = False; @@ -251,7 +251,7 @@ static int eventlog_subkey_info( char *key, REGSUBKEY_CTR *subkey_ctr ) Caller is responsible for freeing memory *********************************************************************/ -static int eventlog_value_info( char *key, REGVAL_CTR *val ) +static int eventlog_value_info( const char *key, REGVAL_CTR *val ) { char *path; BOOL top_level = False; @@ -280,7 +280,7 @@ static int eventlog_value_info( char *key, REGVAL_CTR *val ) people storing eventlog information directly via registry calls (for now at least) *********************************************************************/ -static BOOL eventlog_store_subkey( char *key, REGSUBKEY_CTR *subkeys ) +static BOOL eventlog_store_subkey( const char *key, REGSUBKEY_CTR *subkeys ) { return False; } @@ -290,7 +290,7 @@ static BOOL eventlog_store_subkey( char *key, REGSUBKEY_CTR *subkeys ) people storing eventlog information directly via registry calls (for now at least) *********************************************************************/ -static BOOL eventlog_store_value( char *key, REGVAL_CTR *val ) +static BOOL eventlog_store_value( const char *key, REGVAL_CTR *val ) { return False; } -- cgit From 54abd2aa66069e6baf7769c496f46d9dba18db39 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 30 Sep 2005 17:13:37 +0000 Subject: r10656: BIG merge from trunk. Features not copied over * \PIPE\unixinfo * winbindd's {group,alias}membership new functions * winbindd's lookupsids() functionality * swat (trunk changes to be reverted as per discussion with Deryck) (This used to be commit 939c3cb5d78e3a2236209b296aa8aba8bdce32d3) --- source3/registry/reg_eventlog.c | 375 ++++++++++++++-------------------------- 1 file changed, 128 insertions(+), 247 deletions(-) (limited to 'source3/registry/reg_eventlog.c') diff --git a/source3/registry/reg_eventlog.c b/source3/registry/reg_eventlog.c index b20eb046db..bed9e1d59a 100644 --- a/source3/registry/reg_eventlog.c +++ b/source3/registry/reg_eventlog.c @@ -1,7 +1,8 @@ /* * Unix SMB/CIFS implementation. * Virtual Windows Registry Layer - * Copyright (C) Marcin Krzysztof Porwit 2005. + * Copyright (C) Marcin Krzysztof Porwit 2005, + * Copyright (C) Gerald (Jerry) Carter 2005. * * 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 @@ -20,288 +21,168 @@ #include "includes.h" + /********************************************************************** - handle enumeration of values AT KEY_EVENTLOG - *********************************************************************/ - -static int eventlog_topkey_values( char *key, REGVAL_CTR *val ) + Enumerate registry subkey names given a registry path. +*********************************************************************/ + +static int elog_fetch_keys( const char *key, REGSUBKEY_CTR *subkeys ) { - int num_values = 0; - char *keystr, *key2 = NULL; - char *base, *new_path; - fstring evtlogname; - UNISTR2 data; - int iDisplayNameId; - int iMaxSize; - - /* - * TODO - callout to get these values... - */ + const char **elogs = lp_eventlog_list(); + char *path; + int i; - if ( key ) - { - key2 = SMB_STRDUP( key ); - keystr = key2; - reg_split_path( keystr, &base, &new_path ); + path = reg_remaining_path( key + strlen(KEY_EVENTLOG) ); - iDisplayNameId = 0x00000100; - iMaxSize= 0x00080000; - - fstrcpy( evtlogname, base ); - DEBUG(10,("eventlog_topkey_values: subkey root=> [%s] subkey path=>[%s]\n", base,new_path)); - - if ( !new_path ) - { - iDisplayNameId = 0x01; - regval_ctr_addvalue( val, "ErrorControl", REG_DWORD, (char*)&iDisplayNameId, sizeof(int) ); - - init_unistr2( &data, "EventLog", UNI_STR_TERMINATE); - regval_ctr_addvalue( val, "DisplayName", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) ); - - num_values = regval_ctr_numvals( val ); - - - num_values = 0; - } - } + DEBUG(10,("elog_fetch_keys: entire key => [%s], subkey => [%s]\n", + key, path)); - SAFE_FREE( key2 ); - return num_values; -} + if ( !path ) { + + if ( !elogs || !*elogs ) + return 0; -/********************************************************************** - handle enumeration of values below KEY_EVENTLOG\ - *********************************************************************/ - -static int eventlog_subkey_values( char *key, REGVAL_CTR *val ) -{ - int num_values = 0; - char *keystr, *key2 = NULL; - char *base, *new_path; - fstring evtlogname; - UNISTR2 data; - int iDisplayNameId; - int iMaxSize; - int iRetention; - - /* - * TODO - callout to get these values... - */ - - if ( !key ) - return num_values; - - key2 = SMB_STRDUP( key ); - keystr = key2; - reg_split_path( keystr, &base, &new_path ); - - iDisplayNameId = 0x00000100; - /* MaxSize is limited to 0xFFFF0000 (UINT_MAX - USHRT_MAX) as per MSDN documentation */ - iMaxSize= 0xFFFF0000; - /* records in the samba log are not overwritten */ - iRetention = 0xFFFFFFFF; - - fstrcpy( evtlogname, base ); - DEBUG(10,("eventlog_subpath_values_printer: eventlogname [%s]\n", base)); - DEBUG(10,("eventlog_subpath_values_printer: new_path [%s]\n", new_path)); - if ( !new_path ) - { -#if 0 - regval_ctr_addvalue( val, "DisplayNameId", REG_DWORD, (char*)&iDisplayNameId, sizeof(int) ); - - init_unistr2( &data, "%SystemRoot%\\system32\\els.dll", UNI_STR_TERMINATE); - regval_ctr_addvalue( val, "DisplayNameFile", REG_EXPAND_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) ); -#endif - regval_ctr_addvalue( val, "MaxSize", REG_DWORD, (char*)&iMaxSize, sizeof(int)); - regval_ctr_addvalue( val, "Retention", REG_DWORD, (char *)&iRetention, sizeof(int)); -#if 0 - init_unistr2( &data, lp_logfile(), UNI_STR_TERMINATE); - regval_ctr_addvalue( val, "File", REG_EXPAND_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) ); -#endif - init_unistr2( &data, base, UNI_STR_TERMINATE); - regval_ctr_addvalue( val, "PrimaryModule", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) ); - - init_unistr2( &data, base, UNI_STR_TERMINATE); - regval_ctr_addvalue( val, "Sources", REG_MULTI_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) ); - - num_values = regval_ctr_numvals( val ); - - } - else - { - iDisplayNameId = 0x07; - regval_ctr_addvalue( val, "CategoryCount", REG_DWORD, (char*)&iDisplayNameId, sizeof(int) ); - - init_unistr2( &data, "%SystemRoot%\\system32\\eventlog.dll", UNI_STR_TERMINATE); - regval_ctr_addvalue( val, "CategoryMessageFile", REG_EXPAND_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) ); - - num_values = regval_ctr_numvals( val ); + DEBUG(10,("elog_fetch_keys: Adding eventlog subkeys from smb.conf\n")); + + for ( i=0; elogs[i]; i++ ) + regsubkey_ctr_addkey( subkeys, elogs[i] ); + + return regsubkey_ctr_numkeys( subkeys ); + } - num_values = 0; - } - - SAFE_FREE( key2 ); - return num_values; -} + /* if we get / then we don't add anymore */ + if ( strchr( path, '\\' ) ) { + DEBUG(10,("elog_fetch_keys: Not adding subkey to %s\n",path)); + return 0; + } -/********************************************************************** - It is safe to assume that every registry path passed into on of - the exported functions here begins with KEY_EVENTLOG else - these functions would have never been called. This is a small utility - function to strip the beginning of the path and make a copy that the - caller can modify. Note that the caller is responsible for releasing - the memory allocated here. - **********************************************************************/ + /* add in a subkey with the same name as the eventlog... */ -static char* trim_eventlog_reg_path( const char *path ) -{ - const char *p; - uint16 key_len = strlen(KEY_EVENTLOG); - - /* - * sanity check...this really should never be True. - * It is only here to prevent us from accessing outside - * the path buffer in the extreme case. - */ - - if ( strlen(path) < key_len ) { - DEBUG(0,("trim_reg_path: Registry path too short! [%s]\n", path)); - DEBUG(0,("trim_reg_path: KEY_EVENTLOG => [%s]!\n", KEY_EVENTLOG)); - return NULL; - } - - - p = path + strlen( KEY_EVENTLOG ); - - if ( *p == '\\' ) - p++; - - if ( *p ) - return SMB_STRDUP(p); - else - return NULL; -} -/********************************************************************** - Enumerate registry subkey names given a registry path. - Caller is responsible for freeing memory to **subkeys - *********************************************************************/ -static int eventlog_subkey_info( const char *key, REGSUBKEY_CTR *subkey_ctr ) -{ - char *path; - BOOL top_level = False; - int num_subkeys = 0; - const char **evtlog_list; - - path = trim_eventlog_reg_path( key ); - DEBUG(10,("eventlog_subkey_info: entire key=>[%s] SUBkey=>[%s]\n", key,path)); - - /* check to see if we are dealing with the top level key */ - num_subkeys = 0; - - if ( !path ) - top_level = True; - - num_subkeys = 0; - if ( !(evtlog_list = lp_eventlog_list()) ) { - SAFE_FREE(path); - return num_subkeys; - } + DEBUG(10,("elog_fetch_keys: Looking to add eventlog subkey to %s\n",path)); - - if ( top_level ) - { - /* todo - get the eventlog subkey values from the smb.conf file - for ( num_subkeys=0; num_subkeys[%s]\n",*evtlog_list)); - regsubkey_ctr_addkey( subkey_ctr, *evtlog_list); - evtlog_list++; - num_subkeys++; - } - } - else - { - while (*evtlog_list && (0==num_subkeys) ) - { - if (0 == StrCaseCmp(path,*evtlog_list)) - { - DEBUG(10,("eventlog_subkey_info: Adding subkey [%s] for key =>[%s]\n",path,*evtlog_list)); - regsubkey_ctr_addkey( subkey_ctr, *evtlog_list); - num_subkeys = 1; - } - evtlog_list++; + /* look for a match */ + + if ( !elogs ) + return -1; + + for ( i=0; elogs[i]; i++ ) { + /* just verify that the keyname is a valid log name */ + if ( strequal( path, elogs[i] ) ) + return 0; } - if (0==num_subkeys) - DEBUG(10,("eventlog_subkey_info: No match on SUBkey=>[%s]\n", path)); - } - - SAFE_FREE( path ); - return num_subkeys; + return -1; } /********************************************************************** Enumerate registry values given a registry path. Caller is responsible for freeing memory - *********************************************************************/ +*********************************************************************/ -static int eventlog_value_info( const char *key, REGVAL_CTR *val ) +static int elog_fetch_values( const char *key, REGVAL_CTR *values ) { - char *path; - BOOL top_level = False; - int num_values = 0; + char *path; + uint32 uiDisplayNameId, uiMaxSize, uiRetention; + char *base, *new_path; + UNISTR2 data; - DEBUG(10,("eventlog_value_info: key=>[%s]\n", key)); + DEBUG(10,("elog_fetch_values: key=>[%s]\n", key)); - path = trim_eventlog_reg_path( key ); + path = reg_remaining_path( key + strlen(KEY_EVENTLOG) ); /* check to see if we are dealing with the top level key */ - if ( !path ) - top_level = True; - if ( top_level ) - num_values = eventlog_topkey_values(path,val); - else - { - DEBUG(10,("eventlog_value_info: SUBkey=>[%s]\n", path)); - num_values = eventlog_subkey_values(path,val); - } - return num_values; + if ( !path ) + return regdb_fetch_values( KEY_EVENTLOG, values ); + + /* deal with a log name */ + + reg_split_path( path, &base, &new_path ); + + /* MaxSize is limited to 0xFFFF0000 (UINT_MAX - USHRT_MAX) as per MSDN documentation */ + + + if ( !new_path ) { + + /* try to fetch from the registry */ + + regdb_fetch_values( key, values ); + + /* just verify one of the important keys. If this + fails, then assume the values have not been initialized */ + + if ( regval_ctr_getvalue( values, "Retention" ) ) + return regval_ctr_numvals( values ); + + /* hard code some initial values */ + + 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, base, UNI_STR_TERMINATE); + regval_ctr_addvalue( values, "PrimaryModule", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) ); + + init_unistr2( &data, base, UNI_STR_TERMINATE); + regval_ctr_addvalue( values, "Sources", REG_MULTI_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) ); + + /* store them for later updates. Complain if this fails but continue on */ + + if ( !regdb_store_values( key, values ) ) { + DEBUG(0,("elog_fetch_values: Failed to store initial values for log [%s]\n", + base )); + } + + return regval_ctr_numvals( values ); + } + +#if 0 + /* hmmm....what to do here? A subkey underneath the log name ? */ + + uiDisplayNameId = 0x07; + regval_ctr_addvalue( values, "CategoryCount", REG_DWORD, (char*)&uiDisplayNameId, sizeof(uint32) ); + + init_unistr2( &data, "%SystemRoot%\\system32\\eventlog.dll", UNI_STR_TERMINATE); + regval_ctr_addvalue( values, "CategoryMessageFile", REG_EXPAND_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) ); +#endif + + return regval_ctr_numvals( values ); } /********************************************************************** - Stub function which always returns failure since we don't want - people storing eventlog information directly via registry calls - (for now at least) - *********************************************************************/ -static BOOL eventlog_store_subkey( const char *key, REGSUBKEY_CTR *subkeys ) +*********************************************************************/ + +static BOOL elog_store_keys( const char *key, REGSUBKEY_CTR *subkeys ) { + /* cannot create any subkeys here */ + return False; } /********************************************************************** - Stub function which always returns failure since we don't want - people storing eventlog information directly via registry calls - (for now at least) - *********************************************************************/ -static BOOL eventlog_store_value( const char *key, REGVAL_CTR *val ) + Allow storing of particular values related to eventlog operation. +*********************************************************************/ + +static BOOL elog_store_value( const char *key, REGVAL_CTR *values ) { - return False; + /* the client had to have a valid handle to get here + so just hand off to the registry tdb */ + + return regdb_store_values( key, values ); } -/* - * Table of function pointers for accessing eventlog data - */ +/******************************************************************** + Table of function pointers for accessing eventlog data + *******************************************************************/ + REGISTRY_OPS eventlog_ops = { - eventlog_subkey_info, - eventlog_value_info, - eventlog_store_subkey, - eventlog_store_value, + elog_fetch_keys, + elog_fetch_values, + elog_store_keys, + elog_store_value, NULL }; -- cgit From 0bf72b6e330a76bee502cb36c1cb80c46d47d33c Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 6 Oct 2005 17:48:03 +0000 Subject: r10781: merging eventlog and svcctl code from trunk (This used to be commit f10aa9fb84bfac4f1a22b74d63999668700ffaac) --- source3/registry/reg_eventlog.c | 273 ++++++++++++++++++---------------------- 1 file changed, 119 insertions(+), 154 deletions(-) (limited to 'source3/registry/reg_eventlog.c') diff --git a/source3/registry/reg_eventlog.c b/source3/registry/reg_eventlog.c index bed9e1d59a..204c4c6e1c 100644 --- a/source3/registry/reg_eventlog.c +++ b/source3/registry/reg_eventlog.c @@ -2,6 +2,7 @@ * Unix SMB/CIFS implementation. * Virtual Windows Registry Layer * Copyright (C) Marcin Krzysztof Porwit 2005, + * Copyright (C) Brian Moran 2005. * Copyright (C) Gerald (Jerry) Carter 2005. * * This program is free software; you can redistribute it and/or modify @@ -18,171 +19,135 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - + #include "includes.h" /********************************************************************** - Enumerate registry subkey names given a registry path. + for an eventlog, add in the default values *********************************************************************/ -static int elog_fetch_keys( const char *key, REGSUBKEY_CTR *subkeys ) +BOOL eventlog_init_keys( void ) { - const char **elogs = lp_eventlog_list(); - char *path; - int i; - - path = reg_remaining_path( key + strlen(KEY_EVENTLOG) ); - - DEBUG(10,("elog_fetch_keys: entire key => [%s], subkey => [%s]\n", - key, path)); - - if ( !path ) { - - if ( !elogs || !*elogs ) - return 0; - - DEBUG(10,("elog_fetch_keys: Adding eventlog subkeys from smb.conf\n")); - - for ( i=0; elogs[i]; i++ ) - regsubkey_ctr_addkey( subkeys, elogs[i] ); - - return regsubkey_ctr_numkeys( subkeys ); - } - - /* if we get / then we don't add anymore */ - - if ( strchr( path, '\\' ) ) { - DEBUG(10,("elog_fetch_keys: Not adding subkey to %s\n",path)); - return 0; - } - - /* add in a subkey with the same name as the eventlog... */ - - DEBUG(10,("elog_fetch_keys: Looking to add eventlog subkey to %s\n",path)); - - /* look for a match */ - - if ( !elogs ) - return -1; - - for ( i=0; elogs[i]; i++ ) { - /* just verify that the keyname is a valid log name */ - if ( strequal( path, elogs[i] ) ) - return 0; - } - - return -1; -} - -/********************************************************************** - Enumerate registry values given a registry path. - Caller is responsible for freeing memory -*********************************************************************/ - -static int elog_fetch_values( const char *key, REGVAL_CTR *values ) -{ - char *path; - uint32 uiDisplayNameId, uiMaxSize, uiRetention; - char *base, *new_path; + /* Find all of the eventlogs, add keys for each of them */ + const char **elogs = lp_eventlog_list( ); + pstring evtlogpath; + REGSUBKEY_CTR *subkeys; + REGVAL_CTR *values; + uint32 uiDisplayNameId; + uint32 uiMaxSize; + uint32 uiRetention; + uint32 uiCategoryCount; UNISTR2 data; - - DEBUG(10,("elog_fetch_values: key=>[%s]\n", key)); - - path = reg_remaining_path( key + strlen(KEY_EVENTLOG) ); - - /* check to see if we are dealing with the top level key */ - - if ( !path ) - return regdb_fetch_values( KEY_EVENTLOG, values ); - - /* deal with a log name */ - - reg_split_path( path, &base, &new_path ); - - /* MaxSize is limited to 0xFFFF0000 (UINT_MAX - USHRT_MAX) as per MSDN documentation */ - - - if ( !new_path ) { - - /* try to fetch from the registry */ - - regdb_fetch_values( key, values ); - - /* just verify one of the important keys. If this - fails, then assume the values have not been initialized */ - - if ( regval_ctr_getvalue( values, "Retention" ) ) - return regval_ctr_numvals( values ); - - /* hard code some initial values */ - - 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, base, UNI_STR_TERMINATE); - regval_ctr_addvalue( values, "PrimaryModule", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) ); - - init_unistr2( &data, base, UNI_STR_TERMINATE); - regval_ctr_addvalue( values, "Sources", REG_MULTI_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) ); - - /* store them for later updates. Complain if this fails but continue on */ - - if ( !regdb_store_values( key, values ) ) { - DEBUG(0,("elog_fetch_values: Failed to store initial values for log [%s]\n", - base )); + + while ( elogs && *elogs ) { + if ( !( subkeys = TALLOC_ZERO_P( NULL, REGSUBKEY_CTR ) ) ) { + DEBUG( 0, ( "talloc() failure!\n" ) ); + return False; } - - return regval_ctr_numvals( values ); - } - -#if 0 - /* hmmm....what to do here? A subkey underneath the log name ? */ - - uiDisplayNameId = 0x07; - regval_ctr_addvalue( values, "CategoryCount", REG_DWORD, (char*)&uiDisplayNameId, sizeof(uint32) ); - - init_unistr2( &data, "%SystemRoot%\\system32\\eventlog.dll", UNI_STR_TERMINATE); - regval_ctr_addvalue( values, "CategoryMessageFile", REG_EXPAND_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) ); -#endif - - return regval_ctr_numvals( values ); -} + regdb_fetch_keys( KEY_EVENTLOG, subkeys ); + regsubkey_ctr_addkey( subkeys, *elogs ); + if ( !regdb_store_keys( KEY_EVENTLOG, subkeys ) ) + return False; + TALLOC_FREE( subkeys ); + + /* add in the key of form KEY_EVENTLOG/Application */ + DEBUG( 5, + ( "Adding key of [%s] to path of [%s]\n", *elogs, + KEY_EVENTLOG ) ); + + slprintf( evtlogpath, sizeof( evtlogpath ) - 1, "%s\\%s", + KEY_EVENTLOG, *elogs ); + /* add in the key of form KEY_EVENTLOG/Application/Application */ + DEBUG( 5, + ( "Adding key of [%s] to path of [%s]\n", *elogs, + evtlogpath ) ); + if ( !( subkeys = TALLOC_ZERO_P( NULL, REGSUBKEY_CTR ) ) ) { + DEBUG( 0, ( "talloc() failure!\n" ) ); + return False; + } + regdb_fetch_keys( evtlogpath, subkeys ); + regsubkey_ctr_addkey( subkeys, *elogs ); -/********************************************************************** -*********************************************************************/ + if ( !regdb_store_keys( evtlogpath, subkeys ) ) + return False; + TALLOC_FREE( subkeys ); -static BOOL elog_store_keys( const char *key, REGSUBKEY_CTR *subkeys ) -{ - /* cannot create any subkeys here */ - - return False; -} + /* now add the values to the KEY_EVENTLOG/Application form key */ + if ( !( values = TALLOC_ZERO_P( NULL, REGVAL_CTR ) ) ) { + DEBUG( 0, ( "talloc() failure!\n" ) ); + return False; + } + DEBUG( 5, + ( "Storing values to eventlog path of [%s]\n", + evtlogpath ) ); + regdb_fetch_values( evtlogpath, values ); + + if ( !regval_ctr_key_exists( values, "MaxSize" ) ) { + /* assume we have none, add them all */ + + /* hard code some initial values */ + + 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 * + sizeof( uint16 ) ); + init_unistr2( &data, *elogs, UNI_STR_TERMINATE ); + + regval_ctr_addvalue( values, "Sources", REG_MULTI_SZ, + ( char * ) data.buffer, + data.uni_str_len * + sizeof( uint16 ) ); + regdb_store_values( evtlogpath, values ); -/********************************************************************** - Allow storing of particular values related to eventlog operation. -*********************************************************************/ + } -static BOOL elog_store_value( const char *key, REGVAL_CTR *values ) -{ - /* the client had to have a valid handle to get here - so just hand off to the registry tdb */ - - return regdb_store_values( key, values ); -} + TALLOC_FREE( values ); -/******************************************************************** - Table of function pointers for accessing eventlog data - *******************************************************************/ - -REGISTRY_OPS eventlog_ops = { - elog_fetch_keys, - elog_fetch_values, - elog_store_keys, - elog_store_value, - NULL -}; + /* now do the values under KEY_EVENTLOG/Application/Application */ + slprintf( evtlogpath, sizeof( evtlogpath ) - 1, "%s\\%s\\%s", + KEY_EVENTLOG, *elogs, *elogs ); + if ( !( values = TALLOC_ZERO_P( NULL, REGVAL_CTR ) ) ) { + DEBUG( 0, ( "talloc() failure!\n" ) ); + return False; + } + DEBUG( 5, + ( "Storing values to eventlog path of [%s]\n", + evtlogpath ) ); + regdb_fetch_values( evtlogpath, values ); + if ( !regval_ctr_key_exists( values, "CategoryCount" ) ) { + + /* hard code some initial values */ + + uiCategoryCount = 0x00000007; + regval_ctr_addvalue( values, "CategoryCount", + REG_DWORD, + ( char * ) &uiCategoryCount, + sizeof( uint32 ) ); + init_unistr2( &data, + "%SystemRoot%\\system32\\eventlog.dll", + UNI_STR_TERMINATE ); + + regval_ctr_addvalue( values, "CategoryMessageFile", + REG_EXPAND_SZ, + ( char * ) data.buffer, + data.uni_str_len * + sizeof( uint16 ) ); + regdb_store_values( evtlogpath, values ); + } + TALLOC_FREE( values ); + elogs++; + } + return True; +} -- cgit From c246649e3d7fb828b6d1c9531dfea40c92e2e368 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 17 Oct 2005 15:53:12 +0000 Subject: r11123: * patches from Brian Moran for creating new eventlog source keys * my patches to get registry utility functions linking with eventlogadm tool (This used to be commit 24e7663086f5d15c7e3fd8069667169b91d1acda) --- source3/registry/reg_eventlog.c | 192 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 192 insertions(+) (limited to 'source3/registry/reg_eventlog.c') diff --git a/source3/registry/reg_eventlog.c b/source3/registry/reg_eventlog.c index 204c4c6e1c..bf843e5518 100644 --- a/source3/registry/reg_eventlog.c +++ b/source3/registry/reg_eventlog.c @@ -1,3 +1,4 @@ + /* * Unix SMB/CIFS implementation. * Virtual Windows Registry Layer @@ -84,6 +85,7 @@ BOOL eventlog_init_keys( void ) regdb_fetch_values( evtlogpath, values ); if ( !regval_ctr_key_exists( values, "MaxSize" ) ) { + /* assume we have none, add them all */ /* hard code some initial values */ @@ -149,5 +151,195 @@ BOOL eventlog_init_keys( void ) TALLOC_FREE( values ); elogs++; } + + return True; +} + +/********************************************************************* + for an eventlog, add in a source name. If the eventlog doesn't + exist (not in the list) do nothing. If a source for the log + already exists, change the information (remove, replace) +*********************************************************************/ + +BOOL eventlog_add_source( const char *eventlog, const char *sourcename, + const char *messagefile ) +{ + /* Find all of the eventlogs, add keys for each of them */ + /* need to add to the value KEY_EVENTLOG//Sources string (Creating if necessary) + need to add KEY of source to KEY_EVENTLOG// */ + + const char **elogs = lp_eventlog_list( ); + char **wrklist, **wp; + pstring evtlogpath; + REGSUBKEY_CTR *subkeys; + REGVAL_CTR *values; + REGISTRY_VALUE *rval; + UNISTR2 data; + uint16 *msz_wp; + int mbytes, ii; + BOOL already_in; + int i; + int numsources; + + for ( i=0; elogs[i]; i++ ) { + if ( strequal( elogs[i], eventlog ) ) + break; + } + + if ( !elogs[i] ) { + DEBUG( 0, + ( "Eventlog [%s] not found in list of valid event logs\n", + eventlog ) ); + return False; /* invalid named passed in */ + } + + /* have to assume that the evenlog key itself exists at this point */ + /* add in a key of [sourcename] under the eventlog key */ + + /* todo add to Sources */ + + if ( !( values = TALLOC_ZERO_P( NULL, REGVAL_CTR ) ) ) { + DEBUG( 0, ( "talloc() failure!\n" ) ); + return False; + } + + pstr_sprintf( evtlogpath, "%s\\%s", KEY_EVENTLOG, eventlog ); + + regdb_fetch_values( evtlogpath, values ); + + if ( !( rval = regval_ctr_getvalue( values, "Sources" ) ) ) { + DEBUG( 0, ( "No Sources value for [%s]!\n", eventlog ) ); + return False; + } + + /* perhaps this adding a new string to a multi_sz should be a fn? */ + /* check to see if it's there already */ + + if ( rval->type != REG_MULTI_SZ ) { + DEBUG( 0, + ( "Wrong type for Sources, should be REG_MULTI_SZ\n" ) ); + return False; + } + + /* convert to a 'regulah' chars to do some comparisons */ + + DEBUG( 0, ( "Rval size is %d\n", rval->size ) ); + + already_in = False; + wrklist = NULL; + dump_data( 1, rval->data_p, rval->size ); + if ( ( numsources = + regval_convert_multi_sz( ( uint16 * ) rval->data_p, rval->size, + &wrklist ) ) > 0 ) { + + DEBUG( 10, ( "numsources is %d\n", numsources ) ); + ii = numsources; + /* see if it's in there already */ + wp = wrklist; + while ( ii && wp && *wp ) { + DEBUG( 5, + ( "Comparing [%s] to [%s]\n", sourcename, + *wp ) ); + if ( strequal( *wp, sourcename ) ) { + DEBUG( 5, + ( "Source name %s already exists, \n", + sourcename ) ); + already_in = True; + break; + } + wp++; + ii--; + } + } else { + if ( numsources < 0 ) { + DEBUG( 3, ( "problem in getting the sources\n" ) ); + return False; + } + DEBUG( 3, + ( "Nothing in the sources list, this might be a problem\n" ) ); + } + + wp = wrklist; + + if ( !already_in ) { + /* make a new list with an additional entry; copy values, add another */ + wp = TALLOC_ARRAY( NULL, char *, numsources + 2 ); + + if ( !wp ) { + DEBUG( 0, ( "talloc() failed \n" ) ); + return False; + } + DEBUG( 0, ( "Number of sources [%d]\n", numsources ) ); + memcpy( wp, wrklist, sizeof( char * ) * numsources ); + *( wp + numsources ) = ( char * ) sourcename; + *( wp + numsources + 1 ) = NULL; + mbytes = regval_build_multi_sz( wp, &msz_wp ); + DEBUG( 0, ( "Number of mbytes [%d]\n", mbytes ) ); + dump_data( 1, (char*)msz_wp, mbytes ); + regval_ctr_addvalue( values, "Sources", REG_MULTI_SZ, + ( char * ) msz_wp, mbytes ); + regdb_store_values( evtlogpath, values ); + TALLOC_FREE( msz_wp ); + } else { + DEBUG( 0, + ( "Source name [%s] found in existing list of sources\n", + sourcename ) ); + } + TALLOC_FREE( values ); + + DEBUG( 5, + ( "Added source to sources string, now adding subkeys\n" ) ); + + if ( !( subkeys = TALLOC_ZERO_P( NULL, REGSUBKEY_CTR ) ) ) { + DEBUG( 0, ( "talloc() failure!\n" ) ); + return False; + } + pstr_sprintf( evtlogpath, "%s\\%s", KEY_EVENTLOG, eventlog ); + + regdb_fetch_keys( evtlogpath, subkeys ); + + if ( !regsubkey_ctr_key_exists( subkeys, sourcename ) ) { + DEBUG( 5, + ( " Source name [%s] for eventlog [%s] didn't exist, adding \n", + sourcename, eventlog ) ); + regsubkey_ctr_addkey( subkeys, sourcename ); + if ( !regdb_store_keys( evtlogpath, subkeys ) ) + return False; + } + TALLOC_FREE( subkeys ); + + /* at this point KEY_EVENTLOG// key is in there. Now need to add EventLogMessageFile */ + + /* now allocate room for the source's subkeys */ + + if ( !( subkeys = TALLOC_ZERO_P( NULL, REGSUBKEY_CTR ) ) ) { + DEBUG( 0, ( "talloc() failure!\n" ) ); + return False; + } + slprintf( evtlogpath, sizeof( evtlogpath ) - 1, "%s\\%s\\%s", + KEY_EVENTLOG, eventlog, sourcename ); + + regdb_fetch_keys( evtlogpath, subkeys ); + + /* now add the values to the KEY_EVENTLOG/Application form key */ + if ( !( values = TALLOC_ZERO_P( NULL, REGVAL_CTR ) ) ) { + DEBUG( 0, ( "talloc() failure!\n" ) ); + return False; + } + DEBUG( 5, + ( "Storing EventLogMessageFile [%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, + ( char * ) data.buffer, + data.uni_str_len * sizeof( uint16 ) ); + regdb_store_values( evtlogpath, values ); + + TALLOC_FREE( values ); + return True; } -- cgit From afca439d19e3d9e67b127d7060df630e2218bcb2 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 18 Oct 2005 03:21:59 +0000 Subject: r11136: patches from Brian Moran for eventlogadm utility (This used to be commit 47b626a8f72629fd1bbabf35b68e24d202df2555) --- source3/registry/reg_eventlog.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) (limited to 'source3/registry/reg_eventlog.c') diff --git a/source3/registry/reg_eventlog.c b/source3/registry/reg_eventlog.c index bf843e5518..69d8f2f9aa 100644 --- a/source3/registry/reg_eventlog.c +++ b/source3/registry/reg_eventlog.c @@ -84,6 +84,7 @@ BOOL eventlog_init_keys( void ) evtlogpath ) ); regdb_fetch_values( evtlogpath, values ); + if ( !regval_ctr_key_exists( values, "MaxSize" ) ) { /* assume we have none, add them all */ @@ -153,6 +154,7 @@ BOOL eventlog_init_keys( void ) } return True; + } /********************************************************************* @@ -181,7 +183,7 @@ BOOL eventlog_add_source( const char *eventlog, const char *sourcename, int i; int numsources; - for ( i=0; elogs[i]; i++ ) { + for ( i = 0; elogs[i]; i++ ) { if ( strequal( elogs[i], eventlog ) ) break; } @@ -207,11 +209,11 @@ BOOL eventlog_add_source( const char *eventlog, const char *sourcename, regdb_fetch_values( evtlogpath, values ); + if ( !( rval = regval_ctr_getvalue( values, "Sources" ) ) ) { DEBUG( 0, ( "No Sources value for [%s]!\n", eventlog ) ); return False; } - /* perhaps this adding a new string to a multi_sz should be a fn? */ /* check to see if it's there already */ @@ -220,11 +222,8 @@ BOOL eventlog_add_source( const char *eventlog, const char *sourcename, ( "Wrong type for Sources, should be REG_MULTI_SZ\n" ) ); return False; } - /* convert to a 'regulah' chars to do some comparisons */ - DEBUG( 0, ( "Rval size is %d\n", rval->size ) ); - already_in = False; wrklist = NULL; dump_data( 1, rval->data_p, rval->size ); @@ -232,18 +231,15 @@ BOOL eventlog_add_source( const char *eventlog, const char *sourcename, regval_convert_multi_sz( ( uint16 * ) rval->data_p, rval->size, &wrklist ) ) > 0 ) { - DEBUG( 10, ( "numsources is %d\n", numsources ) ); ii = numsources; /* see if it's in there already */ wp = wrklist; + while ( ii && wp && *wp ) { - DEBUG( 5, - ( "Comparing [%s] to [%s]\n", sourcename, - *wp ) ); if ( strequal( *wp, sourcename ) ) { DEBUG( 5, - ( "Source name %s already exists, \n", - sourcename ) ); + ( "Source name [%s] already in list for [%s] \n", + sourcename, eventlog ) ); already_in = True; break; } @@ -269,26 +265,23 @@ BOOL eventlog_add_source( const char *eventlog, const char *sourcename, DEBUG( 0, ( "talloc() failed \n" ) ); return False; } - DEBUG( 0, ( "Number of sources [%d]\n", numsources ) ); memcpy( wp, wrklist, sizeof( char * ) * numsources ); *( wp + numsources ) = ( char * ) sourcename; *( wp + numsources + 1 ) = NULL; mbytes = regval_build_multi_sz( wp, &msz_wp ); - DEBUG( 0, ( "Number of mbytes [%d]\n", mbytes ) ); - dump_data( 1, (char*)msz_wp, mbytes ); + dump_data( 1, ( char * ) msz_wp, mbytes ); regval_ctr_addvalue( values, "Sources", REG_MULTI_SZ, ( char * ) msz_wp, mbytes ); regdb_store_values( evtlogpath, values ); TALLOC_FREE( msz_wp ); } else { - DEBUG( 0, + DEBUG( 3, ( "Source name [%s] found in existing list of sources\n", sourcename ) ); } TALLOC_FREE( values ); - - DEBUG( 5, - ( "Added source to sources string, now adding subkeys\n" ) ); + if ( wrklist ) + TALLOC_FREE( wrklist ); /* */ if ( !( subkeys = TALLOC_ZERO_P( NULL, REGSUBKEY_CTR ) ) ) { DEBUG( 0, ( "talloc() failure!\n" ) ); -- cgit From 8d7c88667190fe286971ac4fffb64ee5bd9eeeb0 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 18 Oct 2005 03:24:00 +0000 Subject: r11137: Compile with only 2 warnings (I'm still working on that code) on a gcc4 x86_64 box. Jeremy. (This used to be commit d720867a788c735e56d53d63265255830ec21208) --- source3/registry/reg_eventlog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/registry/reg_eventlog.c') diff --git a/source3/registry/reg_eventlog.c b/source3/registry/reg_eventlog.c index 69d8f2f9aa..61c73abd4b 100644 --- a/source3/registry/reg_eventlog.c +++ b/source3/registry/reg_eventlog.c @@ -226,7 +226,7 @@ BOOL eventlog_add_source( const char *eventlog, const char *sourcename, already_in = False; wrklist = NULL; - dump_data( 1, rval->data_p, rval->size ); + dump_data( 1, (const char *)rval->data_p, rval->size ); if ( ( numsources = regval_convert_multi_sz( ( uint16 * ) rval->data_p, rval->size, &wrklist ) ) > 0 ) { -- cgit From f1195329a7f4401af730033c4d8d5570b42c2780 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 20 Oct 2005 14:29:24 +0000 Subject: r11227: patch from brian moran to fix typo in eventlog message file registry value name (This used to be commit 34c3fd77b320d4fe5e0f1452aa09ea5ec2797494) --- source3/registry/reg_eventlog.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/registry/reg_eventlog.c') diff --git a/source3/registry/reg_eventlog.c b/source3/registry/reg_eventlog.c index 61c73abd4b..d802b18aca 100644 --- a/source3/registry/reg_eventlog.c +++ b/source3/registry/reg_eventlog.c @@ -301,7 +301,7 @@ BOOL eventlog_add_source( const char *eventlog, const char *sourcename, } TALLOC_FREE( subkeys ); - /* at this point KEY_EVENTLOG// key is in there. Now need to add EventLogMessageFile */ + /* at this point KEY_EVENTLOG// key is in there. Now need to add EventMessageFile */ /* now allocate room for the source's subkeys */ @@ -320,14 +320,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 ); -- cgit From 15615dc1f6d3578fc4f14a19babb265be37bf576 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 1 Dec 2005 23:10:27 +0000 Subject: r12002: patch from marcin to allow for the creation of a File value in the eventlog registry keys so that file properties can be displayed (This used to be commit 270fef5175559ba6345bb2c3e264c527a6a084c5) --- source3/registry/reg_eventlog.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source3/registry/reg_eventlog.c') diff --git a/source3/registry/reg_eventlog.c b/source3/registry/reg_eventlog.c index d802b18aca..1c65c9b217 100644 --- a/source3/registry/reg_eventlog.c +++ b/source3/registry/reg_eventlog.c @@ -33,6 +33,7 @@ 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; @@ -98,10 +99,12 @@ BOOL eventlog_init_keys( void ) 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 +115,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 ); } -- cgit From 6a9b101dd66eebbc8dc65c971d30a73e34b622b9 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 28 Jun 2006 18:18:23 +0000 Subject: r16634: Fix bug #3883 reported by jason@ncac.gwu.edu. Jeremy. (This used to be commit d04462f1d8cf009985b9112f093306a64689af64) --- source3/registry/reg_eventlog.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/registry/reg_eventlog.c') diff --git a/source3/registry/reg_eventlog.c b/source3/registry/reg_eventlog.c index 1c65c9b217..ea2b274f88 100644 --- a/source3/registry/reg_eventlog.c +++ b/source3/registry/reg_eventlog.c @@ -36,7 +36,6 @@ BOOL eventlog_init_keys( void ) pstring evtfilepath; REGSUBKEY_CTR *subkeys; REGVAL_CTR *values; - uint32 uiDisplayNameId; uint32 uiMaxSize; uint32 uiRetention; uint32 uiCategoryCount; @@ -92,7 +91,7 @@ BOOL eventlog_init_keys( void ) /* hard code some initial values */ - uiDisplayNameId = 0x00000100; + /* uiDisplayNameId = 0x00000100; */ uiMaxSize = 0x00080000; uiRetention = 0x93A80; -- cgit From 5ee2748106e426bd8789a934dbecac0a3869f9e8 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 16 Dec 2006 09:33:17 +0000 Subject: r20209: Fix two memleaks (This used to be commit 92bc870768a2ff839b3b10897a4f09a3ece92704) --- source3/registry/reg_eventlog.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'source3/registry/reg_eventlog.c') diff --git a/source3/registry/reg_eventlog.c b/source3/registry/reg_eventlog.c index ea2b274f88..90d9a24437 100644 --- a/source3/registry/reg_eventlog.c +++ b/source3/registry/reg_eventlog.c @@ -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 */ @@ -287,8 +291,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" ) ); -- cgit From 56ba44766854ed7cda265bdaf85913f2a1008282 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 28 Mar 2007 13:34:59 +0000 Subject: r22001: change prototype of dump_data(), so that it takes unsigned char * now, which matches what samba4 has. also fix all the callers to prevent compiler warnings metze (This used to be commit fa322f0cc9c26a9537ba3f0a7d4e4a25941317e7) --- source3/registry/reg_eventlog.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/registry/reg_eventlog.c') diff --git a/source3/registry/reg_eventlog.c b/source3/registry/reg_eventlog.c index 90d9a24437..d0da12637a 100644 --- a/source3/registry/reg_eventlog.c +++ b/source3/registry/reg_eventlog.c @@ -237,7 +237,7 @@ BOOL eventlog_add_source( const char *eventlog, const char *sourcename, already_in = False; wrklist = NULL; - dump_data( 1, (const char *)rval->data_p, rval->size ); + dump_data( 1, rval->data_p, rval->size ); if ( ( numsources = regval_convert_multi_sz( ( uint16 * ) rval->data_p, rval->size, &wrklist ) ) > 0 ) { @@ -280,7 +280,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 ); -- cgit From d1d2157153d7a4b3e7918bcc91c50445bf9a6771 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 22 Jun 2007 19:33:46 +0000 Subject: r23591: Fix bug #4725. Don't crash when no eventlogs specified. Needs merging for 3.0.25b. Jeremy. (This used to be commit ae239fec6faa79018c818506b391b829ccd685f8) --- source3/registry/reg_eventlog.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3/registry/reg_eventlog.c') diff --git a/source3/registry/reg_eventlog.c b/source3/registry/reg_eventlog.c index d0da12637a..b70b79f1e3 100644 --- a/source3/registry/reg_eventlog.c +++ b/source3/registry/reg_eventlog.c @@ -194,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; -- cgit From d824b98f80ba186030cbb70b3a1e5daf80469ecd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Jul 2007 19:25:36 +0000 Subject: r23779: Change from v2 or later to v3 or later. Jeremy. (This used to be commit 407e6e695b8366369b7c76af1ff76869b45347b3) --- source3/registry/reg_eventlog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/registry/reg_eventlog.c') diff --git a/source3/registry/reg_eventlog.c b/source3/registry/reg_eventlog.c index b70b79f1e3..8d93cee7dc 100644 --- a/source3/registry/reg_eventlog.c +++ b/source3/registry/reg_eventlog.c @@ -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, -- cgit From 153cfb9c83534b09f15cc16205d7adb19b394928 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 05:23:25 +0000 Subject: r23801: The FSF has moved around a lot. This fixes their Mass Ave address. (This used to be commit 87c91e4362c51819032bfbebbb273c52e203b227) --- source3/registry/reg_eventlog.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/registry/reg_eventlog.c') diff --git a/source3/registry/reg_eventlog.c b/source3/registry/reg_eventlog.c index 8d93cee7dc..e1b4f7b49e 100644 --- a/source3/registry/reg_eventlog.c +++ b/source3/registry/reg_eventlog.c @@ -17,8 +17,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program; if not, see . */ #include "includes.h" -- cgit From 6334c7cc5f686a6c13063190986914482f54784f Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 28 Sep 2007 23:05:52 +0000 Subject: r25417: Use DBGC_REGISTRY class. Guenther (This used to be commit 43ca04918a5a1b2379083dc624b346ceb8476a38) --- source3/registry/reg_eventlog.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/registry/reg_eventlog.c') diff --git a/source3/registry/reg_eventlog.c b/source3/registry/reg_eventlog.c index e1b4f7b49e..e995ed2e96 100644 --- a/source3/registry/reg_eventlog.c +++ b/source3/registry/reg_eventlog.c @@ -22,6 +22,8 @@ #include "includes.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_REGISTRY /********************************************************************** for an eventlog, add in the default values -- cgit From 30191d1a5704ad2b158386b511558972d539ce47 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 18 Oct 2007 17:40:25 -0700 Subject: RIP BOOL. Convert BOOL -> bool. I found a few interesting bugs in various places whilst doing this (places that assumed BOOL == int). I also need to fix the Samba4 pidl generation (next checkin). Jeremy. (This used to be commit f35a266b3cbb3e5fa6a86be60f34fe340a3ca71f) --- source3/registry/reg_eventlog.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/registry/reg_eventlog.c') diff --git a/source3/registry/reg_eventlog.c b/source3/registry/reg_eventlog.c index e995ed2e96..a9369b9ddf 100644 --- a/source3/registry/reg_eventlog.c +++ b/source3/registry/reg_eventlog.c @@ -29,7 +29,7 @@ for an eventlog, add in the default values *********************************************************************/ -BOOL eventlog_init_keys( void ) +bool eventlog_init_keys( void ) { /* Find all of the eventlogs, add keys for each of them */ const char **elogs = lp_eventlog_list( ); @@ -175,7 +175,7 @@ BOOL eventlog_init_keys( void ) already exists, change the information (remove, replace) *********************************************************************/ -BOOL eventlog_add_source( const char *eventlog, const char *sourcename, +bool eventlog_add_source( const char *eventlog, const char *sourcename, const char *messagefile ) { /* Find all of the eventlogs, add keys for each of them */ @@ -191,7 +191,7 @@ BOOL eventlog_add_source( const char *eventlog, const char *sourcename, UNISTR2 data; uint16 *msz_wp; int mbytes, ii; - BOOL already_in; + bool already_in; int i; int numsources; -- cgit From 80c2446321c519797a57b8006942a983f8481d79 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 26 Nov 2007 17:24:56 -0800 Subject: Remove pstrings from nsswitch/ and registry/ Jeremy. (This used to be commit 331c0d6216e1a1607a49ed7eb4078e10138ec16a) --- source3/registry/reg_eventlog.c | 151 +++++++++++++++++++++++----------------- 1 file changed, 89 insertions(+), 62 deletions(-) (limited to 'source3/registry/reg_eventlog.c') diff --git a/source3/registry/reg_eventlog.c b/source3/registry/reg_eventlog.c index a9369b9ddf..be47d13140 100644 --- a/source3/registry/reg_eventlog.c +++ b/source3/registry/reg_eventlog.c @@ -29,44 +29,48 @@ for an eventlog, add in the default values *********************************************************************/ -bool eventlog_init_keys( void ) +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; + const char **elogs = lp_eventlog_list(); + char *evtlogpath = NULL; + char *evtfilepath = NULL; REGSUBKEY_CTR *subkeys; REGVAL_CTR *values; uint32 uiMaxSize; uint32 uiRetention; uint32 uiCategoryCount; UNISTR2 data; + TALLOC_CTX *ctx = talloc_tos(); - while ( elogs && *elogs ) { - if ( !( subkeys = TALLOC_ZERO_P( NULL, REGSUBKEY_CTR ) ) ) { + while (elogs && *elogs) { + if (!(subkeys = TALLOC_ZERO_P(ctx, REGSUBKEY_CTR ) ) ) { DEBUG( 0, ( "talloc() failure!\n" ) ); return False; } - regdb_fetch_keys( KEY_EVENTLOG, subkeys ); + regdb_fetch_keys(KEY_EVENTLOG, subkeys); regsubkey_ctr_addkey( subkeys, *elogs ); if ( !regdb_store_keys( KEY_EVENTLOG, subkeys ) ) { TALLOC_FREE(subkeys); return False; } - TALLOC_FREE( subkeys ); + TALLOC_FREE(subkeys); /* add in the key of form KEY_EVENTLOG/Application */ DEBUG( 5, ( "Adding key of [%s] to path of [%s]\n", *elogs, KEY_EVENTLOG ) ); - slprintf( evtlogpath, sizeof( evtlogpath ) - 1, "%s\\%s", - KEY_EVENTLOG, *elogs ); + evtlogpath = talloc_asprintf(ctx, "%s\\%s", + KEY_EVENTLOG, *elogs); + if (!evtlogpath) { + return false; + } /* add in the key of form KEY_EVENTLOG/Application/Application */ DEBUG( 5, ( "Adding key of [%s] to path of [%s]\n", *elogs, evtlogpath ) ); - if ( !( subkeys = TALLOC_ZERO_P( NULL, REGSUBKEY_CTR ) ) ) { + if (!(subkeys = TALLOC_ZERO_P(ctx, REGSUBKEY_CTR))) { DEBUG( 0, ( "talloc() failure!\n" ) ); return False; } @@ -80,7 +84,7 @@ bool eventlog_init_keys( void ) TALLOC_FREE( subkeys ); /* now add the values to the KEY_EVENTLOG/Application form key */ - if ( !( values = TALLOC_ZERO_P( NULL, REGVAL_CTR ) ) ) { + if (!(values = TALLOC_ZERO_P(ctx, REGVAL_CTR))) { DEBUG( 0, ( "talloc() failure!\n" ) ); return False; } @@ -90,7 +94,7 @@ bool eventlog_init_keys( void ) regdb_fetch_values( evtlogpath, values ); - if ( !regval_ctr_key_exists( values, "MaxSize" ) ) { + if (!regval_ctr_key_exists(values, "MaxSize")) { /* assume we have none, add them all */ @@ -100,48 +104,57 @@ bool eventlog_init_keys( void ) uiMaxSize = 0x00080000; uiRetention = 0x93A80; - regval_ctr_addvalue( values, "MaxSize", REG_DWORD, - ( char * ) &uiMaxSize, - sizeof( uint32 ) ); + 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, "Retention", REG_DWORD, + (char *)&uiRetention, + sizeof(uint32)); + init_unistr2(&data, *elogs, UNI_STR_TERMINATE); - regval_ctr_addvalue( values, "PrimaryModule", REG_SZ, - ( char * ) data.buffer, + regval_ctr_addvalue(values, "PrimaryModule", REG_SZ, + (char *)data.buffer, data.uni_str_len * - sizeof( uint16 ) ); - init_unistr2( &data, *elogs, UNI_STR_TERMINATE ); + sizeof(uint16)); + init_unistr2(&data, *elogs, UNI_STR_TERMINATE); - regval_ctr_addvalue( values, "Sources", REG_MULTI_SZ, - ( char * ) data.buffer, + regval_ctr_addvalue(values, "Sources", REG_MULTI_SZ, + (char *)data.buffer, data.uni_str_len * - sizeof( uint16 ) ); + 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 ); + evtfilepath = talloc_asprintf(ctx, + "%%SystemRoot%%\\system32\\config\\%s.tdb", + *elogs); + if (!evtfilepath) { + TALLOC_FREE(values); + } + 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); } - TALLOC_FREE( values ); + TALLOC_FREE(values); /* now do the values under KEY_EVENTLOG/Application/Application */ - slprintf( evtlogpath, sizeof( evtlogpath ) - 1, "%s\\%s\\%s", - KEY_EVENTLOG, *elogs, *elogs ); - if ( !( values = TALLOC_ZERO_P( NULL, REGVAL_CTR ) ) ) { + TALLOC_FREE(evtlogpath); + evtlogpath = talloc_asprintf("%s\\%s\\%s", + KEY_EVENTLOG, *elogs, *elogs); + if (!evtlogpath) { + return false; + } + if (!(values = TALLOC_ZERO_P(ctx, REGVAL_CTR))) { DEBUG( 0, ( "talloc() failure!\n" ) ); return False; } DEBUG( 5, ( "Storing values to eventlog path of [%s]\n", - evtlogpath ) ); - regdb_fetch_values( evtlogpath, values ); - if ( !regval_ctr_key_exists( values, "CategoryCount" ) ) { + evtlogpath)); + regdb_fetch_values(evtlogpath, values); + if (!regval_ctr_key_exists( values, "CategoryCount")) { /* hard code some initial values */ @@ -161,17 +174,16 @@ bool eventlog_init_keys( void ) sizeof( uint16 ) ); regdb_store_values( evtlogpath, values ); } - TALLOC_FREE( values ); + TALLOC_FREE(values); elogs++; } - return True; - + return true; } /********************************************************************* - for an eventlog, add in a source name. If the eventlog doesn't - exist (not in the list) do nothing. If a source for the log + for an eventlog, add in a source name. If the eventlog doesn't + exist (not in the list) do nothing. If a source for the log already exists, change the information (remove, replace) *********************************************************************/ @@ -184,7 +196,7 @@ bool eventlog_add_source( const char *eventlog, const char *sourcename, const char **elogs = lp_eventlog_list( ); char **wrklist, **wp; - pstring evtlogpath; + char *evtlogpath = NULL; REGSUBKEY_CTR *subkeys; REGVAL_CTR *values; REGISTRY_VALUE *rval; @@ -194,6 +206,7 @@ bool eventlog_add_source( const char *eventlog, const char *sourcename, bool already_in; int i; int numsources; + TALLOC_CTX *ctx = talloc_tos(); if (!elogs) { return False; @@ -208,7 +221,7 @@ bool eventlog_add_source( const char *eventlog, const char *sourcename, DEBUG( 0, ( "Eventlog [%s] not found in list of valid event logs\n", eventlog ) ); - return False; /* invalid named passed in */ + return false; /* invalid named passed in */ } /* have to assume that the evenlog key itself exists at this point */ @@ -216,12 +229,16 @@ bool eventlog_add_source( const char *eventlog, const char *sourcename, /* todo add to Sources */ - if ( !( values = TALLOC_ZERO_P( NULL, REGVAL_CTR ) ) ) { - DEBUG( 0, ( "talloc() failure!\n" ) ); - return False; + if (!( values = TALLOC_ZERO_P(ctx, REGVAL_CTR))) { + DEBUG( 0, ( "talloc() failure!\n" )); + return false; } - pstr_sprintf( evtlogpath, "%s\\%s", KEY_EVENTLOG, eventlog ); + evtlogpath = talloc_asprintf("%s\\%s", KEY_EVENTLOG, eventlog); + if (!evtlogpath) { + TALLOC_FREE(values); + return false; + } regdb_fetch_values( evtlogpath, values ); @@ -275,7 +292,7 @@ bool eventlog_add_source( const char *eventlog, const char *sourcename, if ( !already_in ) { /* make a new list with an additional entry; copy values, add another */ - wp = TALLOC_ARRAY( NULL, char *, numsources + 2 ); + wp = TALLOC_ARRAY(ctx, char *, numsources + 2 ); if ( !wp ) { DEBUG( 0, ( "talloc() failed \n" ) ); @@ -289,20 +306,25 @@ bool eventlog_add_source( const char *eventlog, const char *sourcename, regval_ctr_addvalue( values, "Sources", REG_MULTI_SZ, ( char * ) msz_wp, mbytes ); regdb_store_values( evtlogpath, values ); - TALLOC_FREE( msz_wp ); + TALLOC_FREE(msz_wp); } else { DEBUG( 3, ( "Source name [%s] found in existing list of sources\n", sourcename ) ); } - TALLOC_FREE( values ); - TALLOC_FREE( wrklist ); /* */ + TALLOC_FREE(values); + TALLOC_FREE(wrklist); /* */ - if ( !( subkeys = TALLOC_ZERO_P( NULL, REGSUBKEY_CTR ) ) ) { + if ( !( subkeys = TALLOC_ZERO_P(ctx, REGSUBKEY_CTR ) ) ) { DEBUG( 0, ( "talloc() failure!\n" ) ); return False; } - pstr_sprintf( evtlogpath, "%s\\%s", KEY_EVENTLOG, eventlog ); + TALLOC_FREE(evtlogpath); + evtlogpath = talloc_asprintf("%s\\%s", KEY_EVENTLOG, eventlog ); + if (!evtlogpath) { + TALLOC_FREE(subkeys); + return false; + } regdb_fetch_keys( evtlogpath, subkeys ); @@ -314,23 +336,28 @@ bool eventlog_add_source( const char *eventlog, const char *sourcename, if ( !regdb_store_keys( evtlogpath, subkeys ) ) return False; } - TALLOC_FREE( subkeys ); + TALLOC_FREE(subkeys); /* at this point KEY_EVENTLOG// key is in there. Now need to add EventMessageFile */ /* now allocate room for the source's subkeys */ - if ( !( subkeys = TALLOC_ZERO_P( NULL, REGSUBKEY_CTR ) ) ) { + if ( !( subkeys = TALLOC_ZERO_P(ctx, REGSUBKEY_CTR ) ) ) { DEBUG( 0, ( "talloc() failure!\n" ) ); return False; } - slprintf( evtlogpath, sizeof( evtlogpath ) - 1, "%s\\%s\\%s", - KEY_EVENTLOG, eventlog, sourcename ); + TALLOC_FREE(evtlogpath); + evtlogpath = talloc_asprintf("%s\\%s\\%s", + KEY_EVENTLOG, eventlog, sourcename); + if (!evtlogpath) { + TALLOC_FREE(subkeys); + return false; + } regdb_fetch_keys( evtlogpath, subkeys ); /* now add the values to the KEY_EVENTLOG/Application form key */ - if ( !( values = TALLOC_ZERO_P( NULL, REGVAL_CTR ) ) ) { + if ( !( values = TALLOC_ZERO_P(ctx, REGVAL_CTR ) ) ) { DEBUG( 0, ( "talloc() failure!\n" ) ); return False; } @@ -347,7 +374,7 @@ bool eventlog_add_source( const char *eventlog, const char *sourcename, data.uni_str_len * sizeof( uint16 ) ); regdb_store_values( evtlogpath, values ); - TALLOC_FREE( values ); + TALLOC_FREE(values); return True; } -- cgit From 9d42af0d2447f8b344d79a67bf7181336c077ad0 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 27 Nov 2007 18:01:56 +0100 Subject: Unless talloc has some new magic there is a ctx missing here. Guenther (This used to be commit 172f7ce96dc12cfc7d2209d8ed56aeebefd6207b) --- source3/registry/reg_eventlog.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/registry/reg_eventlog.c') diff --git a/source3/registry/reg_eventlog.c b/source3/registry/reg_eventlog.c index be47d13140..8994acf107 100644 --- a/source3/registry/reg_eventlog.c +++ b/source3/registry/reg_eventlog.c @@ -141,7 +141,7 @@ bool eventlog_init_keys(void) /* now do the values under KEY_EVENTLOG/Application/Application */ TALLOC_FREE(evtlogpath); - evtlogpath = talloc_asprintf("%s\\%s\\%s", + evtlogpath = talloc_asprintf(ctx, "%s\\%s\\%s", KEY_EVENTLOG, *elogs, *elogs); if (!evtlogpath) { return false; @@ -234,7 +234,7 @@ bool eventlog_add_source( const char *eventlog, const char *sourcename, return false; } - evtlogpath = talloc_asprintf("%s\\%s", KEY_EVENTLOG, eventlog); + evtlogpath = talloc_asprintf(ctx, "%s\\%s", KEY_EVENTLOG, eventlog); if (!evtlogpath) { TALLOC_FREE(values); return false; @@ -320,7 +320,7 @@ bool eventlog_add_source( const char *eventlog, const char *sourcename, return False; } TALLOC_FREE(evtlogpath); - evtlogpath = talloc_asprintf("%s\\%s", KEY_EVENTLOG, eventlog ); + evtlogpath = talloc_asprintf(ctx, "%s\\%s", KEY_EVENTLOG, eventlog ); if (!evtlogpath) { TALLOC_FREE(subkeys); return false; @@ -347,7 +347,7 @@ bool eventlog_add_source( const char *eventlog, const char *sourcename, return False; } TALLOC_FREE(evtlogpath); - evtlogpath = talloc_asprintf("%s\\%s\\%s", + evtlogpath = talloc_asprintf(ctx, "%s\\%s\\%s", KEY_EVENTLOG, eventlog, sourcename); if (!evtlogpath) { TALLOC_FREE(subkeys); -- cgit