summaryrefslogtreecommitdiff
path: root/source3/registry
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2005-10-06 17:48:03 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:04:53 -0500
commit0bf72b6e330a76bee502cb36c1cb80c46d47d33c (patch)
tree565aaccd5faf27918b3fad5b3ac553cd14cec835 /source3/registry
parent6de37ee5f5d015904e650df3112cf725ab0f1cb8 (diff)
downloadsamba-0bf72b6e330a76bee502cb36c1cb80c46d47d33c.tar.gz
samba-0bf72b6e330a76bee502cb36c1cb80c46d47d33c.tar.bz2
samba-0bf72b6e330a76bee502cb36c1cb80c46d47d33c.zip
r10781: merging eventlog and svcctl code from trunk
(This used to be commit f10aa9fb84bfac4f1a22b74d63999668700ffaac)
Diffstat (limited to 'source3/registry')
-rw-r--r--source3/registry/reg_eventlog.c273
-rw-r--r--source3/registry/reg_frontend.c8
2 files changed, 121 insertions, 160 deletions
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 <logname>/<logname> 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;
+}
diff --git a/source3/registry/reg_frontend.c b/source3/registry/reg_frontend.c
index f41c5885bc..f5284e9e88 100644
--- a/source3/registry/reg_frontend.c
+++ b/source3/registry/reg_frontend.c
@@ -38,7 +38,6 @@ REGISTRY_HOOK reg_hooks[] = {
{ KEY_PRINTING, &printing_ops },
{ KEY_PRINTING_2K, &printing_ops },
{ KEY_PRINTING_PORTS, &printing_ops },
- { KEY_EVENTLOG, &eventlog_ops },
{ KEY_SHARES, &shares_reg_ops },
#endif
{ NULL, NULL }
@@ -128,13 +127,10 @@ BOOL init_registry( void )
if ( DEBUGLEVEL >= 20 )
reghook_dump_cache(20);
- /* inform the external eventlog machinery of the change */
-
- eventlog_refresh_external_parameters( get_root_nt_token() );
-
- /* add any services keys */
+ /* add any keys for other services */
svcctl_init_keys();
+ eventlog_init_keys();
return True;
}