[SCM] Samba Shared Repository - branch v3-2-test updated - initial-v3-2-test-1473-g903223b

Michael Adam obnox at samba.org
Thu Jan 17 15:51:11 GMT 2008


The branch, v3-2-test has been updated
       via  903223b160eef6ba6ff19a8bfef19e5fe7008631 (commit)
       via  81d6a1fbed5e685376637af8e8bcd70ab2701aa0 (commit)
       via  15163926a8ae1116a0f0986f35fc16bcf9ce6ce2 (commit)
       via  f986a708be15dd9b9fc28b9862f64f2d0f94accc (commit)
       via  7251a24b489a008243091279d96157cacec35b62 (commit)
       via  0cb8399d7c6f228b38c918f8c6c77fd31c346f89 (commit)
       via  4d82cc586c089a16d1d2db214f5e198062890b58 (commit)
       via  92e95fe58500dc8bf89bb43c1d65559702363767 (commit)
       via  d3c9c273740b42e5da101f53d4df3aee70cdacf7 (commit)
       via  3e661273229bcf021276cc0b71350acf8d8fed7c (commit)
       via  5c0a1d5d45948fdc483d6f9de31cea39e12722c6 (commit)
       via  36085d9004592e48b66b681f85346db15e6d9b3a (commit)
      from  48288869d314d8c91d07282b5536b231d95db159 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test


- Log -----------------------------------------------------------------
commit 903223b160eef6ba6ff19a8bfef19e5fe7008631
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jan 17 11:22:01 2008 +0100

    Add a reg_getversion() function to reg_api and use it in srv_winreg_nt.c.
    
    Michael

commit 81d6a1fbed5e685376637af8e8bcd70ab2701aa0
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jan 17 11:09:08 2008 +0100

    Add my (C) to reg_api.c - Michael

commit 15163926a8ae1116a0f0986f35fc16bcf9ce6ce2
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jan 17 11:07:28 2008 +0100

    Add a comment header comparing winreg.idl and reg_api.c.
    
    Michael

commit f986a708be15dd9b9fc28b9862f64f2d0f94accc
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jan 17 11:06:32 2008 +0100

    Use reg_[gs]etkeysecurity() instead of regkey_[gs]et_secdes().
    
    Rationale: Use reg_api instead of backend functions.
    
    Michael

commit 7251a24b489a008243091279d96157cacec35b62
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jan 17 11:02:15 2008 +0100

    Add reg_api functions reg_getkeysecurity() and reg_setkeysecurity().
    
    These are wrappers around the lower level functions regkey_get_secdesc()
    and regkey_set_secdesc(). Next step towards hiding reg_frontend from
    the surface.
    
    Michael

commit 0cb8399d7c6f228b38c918f8c6c77fd31c346f89
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jan 17 10:30:56 2008 +0100

    Comment out unused reg_create_path() and reg_delete_path().
    
    These functions are unused. Comment them out for now.
    
    Michael

commit 4d82cc586c089a16d1d2db214f5e198062890b58
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jan 17 10:19:12 2008 +0100

    Move reg_create_path() and reg_delete_path() to reg_api.c
    
    Michael

commit 92e95fe58500dc8bf89bb43c1d65559702363767
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jan 17 01:47:00 2008 +0100

    Convert sync_eventlog_params() to use reg_api instead of reg_frontend.
    
    This is a step towards untangling the registry.
    All places should use reg_api.c, reg_frontend should actually more
    appropriately be named reg_backend_dispatcher and hidden from callers.
    
    :-)
    
    Michael

commit d3c9c273740b42e5da101f53d4df3aee70cdacf7
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jan 17 00:57:53 2008 +0100

    Add some sectioning comments to reg_api.c
    
    Michael

commit 3e661273229bcf021276cc0b71350acf8d8fed7c
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jan 17 00:16:58 2008 +0100

    Make utility function reg_deletekey_recursive_internal() static.
    
    Michael

commit 5c0a1d5d45948fdc483d6f9de31cea39e12722c6
Author: Michael Adam <obnox at samba.org>
Date:   Wed Jan 16 23:19:38 2008 +0100

    Use the proper boolean constants in reg_frontend_hilvl.c
    
    Michael

commit 36085d9004592e48b66b681f85346db15e6d9b3a
Author: Michael Adam <obnox at samba.org>
Date:   Wed Jan 16 23:18:07 2008 +0100

    Reformatting: Strip trailing white spaces from reg_frontent_hilvl.c.
    
    Michael

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

Summary of changes:
 source/registry/reg_api.c            |  186 +++++++++++++++++++++++++++++++++-
 source/registry/reg_frontend.c       |   95 -----------------
 source/registry/reg_frontend_hilvl.c |   50 +++++-----
 source/rpc_server/srv_eventlog_nt.c  |   46 +++++----
 source/rpc_server/srv_winreg_nt.c    |    8 +-
 5 files changed, 235 insertions(+), 150 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/registry/reg_api.c b/source/registry/reg_api.c
index d1657c8..18435ff 100644
--- a/source/registry/reg_api.c
+++ b/source/registry/reg_api.c
@@ -2,6 +2,7 @@
  *  Unix SMB/CIFS implementation.
  *  Virtual Windows Registry Layer
  *  Copyright (C) Volker Lendecke 2006
+ *  Copyright (C) Michael Adam 2007-2008
  *
  *  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
@@ -19,11 +20,58 @@
 
 /* Attempt to wrap the existing API in a more winreg.idl-like way */
 
+/*
+ * Here is a list of winreg.idl functions and corresponding implementations
+ * provided here:
+ *
+ * 0x00		winreg_OpenHKCR
+ * 0x01		winreg_OpenHKCU
+ * 0x02		winreg_OpenHKLM
+ * 0x03		winreg_OpenHKPD
+ * 0x04		winreg_OpenHKU
+ * 0x05		winreg_CloseKey
+ * 0x06		winreg_CreateKey			reg_createkey
+ * 0x07		winreg_DeleteKey			reg_deletekey
+ * 0x08		winreg_DeleteValue			reg_deletevalue
+ * 0x09		winreg_EnumKey				reg_enumkey
+ * 0x0a		winreg_EnumValue			reg_enumvalue
+ * 0x0b		winreg_FlushKey
+ * 0x0c		winreg_GetKeySecurity			reg_getkeysecurity
+ * 0x0d		winreg_LoadKey
+ * 0x0e		winreg_NotifyChangeKeyValue
+ * 0x0f		winreg_OpenKey				reg_openkey
+ * 0x10		winreg_QueryInfoKey			reg_queryinfokey
+ * 0x11		winreg_QueryValue			reg_queryvalue
+ * 0x12		winreg_ReplaceKey
+ * 0x13		winreg_RestoreKey
+ * 0x14		winreg_SaveKey
+ * 0x15		winreg_SetKeySecurity			reg_setkeysecurity
+ * 0x16		winreg_SetValue				reg_setvalue
+ * 0x17		winreg_UnLoadKey
+ * 0x18		winreg_InitiateSystemShutdown
+ * 0x19		winreg_AbortSystemShutdown
+ * 0x1a		winreg_GetVersion			reg_getversion
+ * 0x1b		winreg_OpenHKCC
+ * 0x1c		winreg_OpenHKDD
+ * 0x1d		winreg_QueryMultipleValues
+ * 0x1e		winreg_InitiateSystemShutdownEx
+ * 0x1f		winreg_SaveKeyEx
+ * 0x20		winreg_OpenHKPT
+ * 0x21		winreg_OpenHKPN
+ * 0x22		winreg_QueryMultipleValues2
+ *
+ */
+
 #include "includes.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_REGISTRY
 
+
+/**********************************************************************
+ * Helper functions
+ **********************************************************************/
+
 static WERROR fill_value_cache(struct registry_key *key)
 {
 	if (key->values != NULL) {
@@ -186,6 +234,11 @@ WERROR reg_openhive(TALLOC_CTX *mem_ctx, const char *hive,
 				    pkey);
 }
 
+
+/**********************************************************************
+ * The API functions
+ **********************************************************************/
+
 WERROR reg_openkey(TALLOC_CTX *mem_ctx, struct registry_key *parent,
 		   const char *name, uint32 desired_access,
 		   struct registry_key **pkey)
@@ -627,6 +680,32 @@ WERROR reg_deletevalue(struct registry_key *key, const char *name)
 	return WERR_OK;
 }
 
+WERROR reg_getkeysecurity(TALLOC_CTX *mem_ctx, struct registry_key *key,
+			  struct security_descriptor **psecdesc)
+{
+	return regkey_get_secdesc(mem_ctx, key->key, psecdesc);
+}
+
+WERROR reg_setkeysecurity(struct registry_key *key,
+			  struct security_descriptor *psecdesc)
+{
+	return regkey_set_secdesc(key->key, psecdesc);
+}
+
+WERROR reg_getversion(uint32_t *version)
+{
+	if (version == NULL) {
+		return WERR_INVALID_PARAM;
+	}
+
+	*version = 0x00000005; /* Windows 2000 registry API version */
+	return WERR_OK;
+}
+
+/**********************************************************************
+ * Higher level utility functions
+ **********************************************************************/
+
 WERROR reg_deleteallvalues(struct registry_key *key)
 {
 	WERROR err;
@@ -715,10 +794,10 @@ WERROR reg_open_path(TALLOC_CTX *mem_ctx, const char *orig_path,
  * Note that reg_deletekey returns ACCESS_DENIED when called on a
  * key that has subkeys.
  */
-WERROR reg_deletekey_recursive_internal(TALLOC_CTX *ctx,
-					struct registry_key *parent,
-					const char *path,
-					bool del_key)
+static WERROR reg_deletekey_recursive_internal(TALLOC_CTX *ctx,
+					       struct registry_key *parent,
+					       const char *path,
+					       bool del_key)
 {
 	TALLOC_CTX *mem_ctx = NULL;
 	WERROR werr = WERR_OK;
@@ -779,3 +858,102 @@ WERROR reg_deletesubkeys_recursive(TALLOC_CTX *ctx,
 {
 	return reg_deletekey_recursive_internal(ctx, parent, path, false);
 }
+
+#if 0
+/* these two functions are unused. */
+
+/**
+ * Utility function to create a registry key without opening the hive
+ * before. Assumes the hive already exists.
+ */
+
+WERROR reg_create_path(TALLOC_CTX *mem_ctx, const char *orig_path,
+		       uint32 desired_access,
+		       const struct nt_user_token *token,
+		       enum winreg_CreateAction *paction,
+		       struct registry_key **pkey)
+{
+	struct registry_key *hive;
+	char *path, *p;
+	WERROR err;
+
+	if (!(path = SMB_STRDUP(orig_path))) {
+		return WERR_NOMEM;
+	}
+
+	p = strchr(path, '\\');
+
+	if ((p == NULL) || (p[1] == '\0')) {
+		/*
+		 * No key behind the hive, just return the hive
+		 */
+
+		err = reg_openhive(mem_ctx, path, desired_access, token,
+				   &hive);
+		if (!W_ERROR_IS_OK(err)) {
+			SAFE_FREE(path);
+			return err;
+		}
+		SAFE_FREE(path);
+		*pkey = hive;
+		*paction = REG_OPENED_EXISTING_KEY;
+		return WERR_OK;
+	}
+
+	*p = '\0';
+
+	err = reg_openhive(mem_ctx, path,
+			   (strchr(p+1, '\\') != NULL) ?
+			   SEC_RIGHTS_ENUM_SUBKEYS : SEC_RIGHTS_CREATE_SUBKEY,
+			   token, &hive);
+	if (!W_ERROR_IS_OK(err)) {
+		SAFE_FREE(path);
+		return err;
+	}
+
+	err = reg_createkey(mem_ctx, hive, p+1, desired_access, pkey, paction);
+	SAFE_FREE(path);
+	TALLOC_FREE(hive);
+	return err;
+}
+
+/*
+ * Utility function to create a registry key without opening the hive
+ * before. Will not delete a hive.
+ */
+
+WERROR reg_delete_path(const struct nt_user_token *token,
+		       const char *orig_path)
+{
+	struct registry_key *hive;
+	char *path, *p;
+	WERROR err;
+
+	if (!(path = SMB_STRDUP(orig_path))) {
+		return WERR_NOMEM;
+	}
+
+	p = strchr(path, '\\');
+
+	if ((p == NULL) || (p[1] == '\0')) {
+		SAFE_FREE(path);
+		return WERR_INVALID_PARAM;
+	}
+
+	*p = '\0';
+
+	err = reg_openhive(NULL, path,
+			   (strchr(p+1, '\\') != NULL) ?
+			   SEC_RIGHTS_ENUM_SUBKEYS : SEC_RIGHTS_CREATE_SUBKEY,
+			   token, &hive);
+	if (!W_ERROR_IS_OK(err)) {
+		SAFE_FREE(path);
+		return err;
+	}
+
+	err = reg_deletekey(hive, p+1);
+	SAFE_FREE(path);
+	TALLOC_FREE(hive);
+	return err;
+}
+#endif /* #if 0 */
diff --git a/source/registry/reg_frontend.c b/source/registry/reg_frontend.c
index 40d9192..9e84d3a 100644
--- a/source/registry/reg_frontend.c
+++ b/source/registry/reg_frontend.c
@@ -105,98 +105,3 @@ WERROR regkey_open_internal( TALLOC_CTX *ctx, REGISTRY_KEY **regkey,
 	TALLOC_FREE(key);
 	return WERR_OK;
 }
-
-/*
- * Utility function to create a registry key without opening the hive
- * before. Assumes the hive already exists.
- */
-
-WERROR reg_create_path(TALLOC_CTX *mem_ctx, const char *orig_path,
-		       uint32 desired_access,
-		       const struct nt_user_token *token,
-		       enum winreg_CreateAction *paction,
-		       struct registry_key **pkey)
-{
-	struct registry_key *hive;
-	char *path, *p;
-	WERROR err;
-
-	if (!(path = SMB_STRDUP(orig_path))) {
-		return WERR_NOMEM;
-	}
-
-	p = strchr(path, '\\');
-
-	if ((p == NULL) || (p[1] == '\0')) {
-		/*
-		 * No key behind the hive, just return the hive
-		 */
-
-		err = reg_openhive(mem_ctx, path, desired_access, token,
-				   &hive);
-		if (!W_ERROR_IS_OK(err)) {
-			SAFE_FREE(path);
-			return err;
-		}
-		SAFE_FREE(path);
-		*pkey = hive;
-		*paction = REG_OPENED_EXISTING_KEY;
-		return WERR_OK;
-	}
-
-	*p = '\0';
-
-	err = reg_openhive(mem_ctx, path,
-			   (strchr(p+1, '\\') != NULL) ?
-			   SEC_RIGHTS_ENUM_SUBKEYS : SEC_RIGHTS_CREATE_SUBKEY,
-			   token, &hive);
-	if (!W_ERROR_IS_OK(err)) {
-		SAFE_FREE(path);
-		return err;
-	}
-
-	err = reg_createkey(mem_ctx, hive, p+1, desired_access, pkey, paction);
-	SAFE_FREE(path);
-	TALLOC_FREE(hive);
-	return err;
-}
-
-/*
- * Utility function to create a registry key without opening the hive
- * before. Will not delete a hive.
- */
-
-WERROR reg_delete_path(const struct nt_user_token *token,
-		       const char *orig_path)
-{
-	struct registry_key *hive;
-	char *path, *p;
-	WERROR err;
-
-	if (!(path = SMB_STRDUP(orig_path))) {
-		return WERR_NOMEM;
-	}
-
-	p = strchr(path, '\\');
-
-	if ((p == NULL) || (p[1] == '\0')) {
-		SAFE_FREE(path);
-		return WERR_INVALID_PARAM;
-	}
-
-	*p = '\0';
-
-	err = reg_openhive(NULL, path,
-			   (strchr(p+1, '\\') != NULL) ?
-			   SEC_RIGHTS_ENUM_SUBKEYS : SEC_RIGHTS_CREATE_SUBKEY,
-			   token, &hive);
-	if (!W_ERROR_IS_OK(err)) {
-		SAFE_FREE(path);
-		return err;
-	}
-
-	err = reg_deletekey(hive, p+1);
-	SAFE_FREE(path);
-	TALLOC_FREE(hive);
-	return err;
-}
diff --git a/source/registry/reg_frontend_hilvl.c b/source/registry/reg_frontend_hilvl.c
index 73fcf87..cd02eee 100644
--- a/source/registry/reg_frontend_hilvl.c
+++ b/source/registry/reg_frontend_hilvl.c
@@ -1,25 +1,25 @@
-/* 
+/*
  *  Unix SMB/CIFS implementation.
  *  Virtual Windows Registry Layer
  *  Copyright (C) Gerald Carter                     2002-2005
- *  Copyright (C) Michael Adam 2006
+ *  Copyright (C) Michael Adam                      2006-2008
  *
  *  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 3 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, see <http://www.gnu.org/licenses/>.
  */
 
-/* 
- * Implementation of registry frontend view functions. 
+/*
+ * Implementation of registry frontend view functions.
  * Functions moved from reg_frontend.c to minimize linker deps.
  */
 
@@ -44,12 +44,12 @@ static SEC_DESC* construct_registry_sd( TALLOC_CTX *ctx )
 	size_t sd_size;
 
 	/* basic access for Everyone */
-	
+
 	init_sec_access(&mask, REG_KEY_READ );
 	init_sec_ace(&ace[i++], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0);
-	
+
 	/* Full Access 'BUILTIN\Administrators' */
-	
+
 	init_sec_access(&mask, REG_KEY_ALL );
 	init_sec_ace(&ace[i++], &global_sid_Builtin_Administrators, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0);
 
@@ -58,9 +58,8 @@ static SEC_DESC* construct_registry_sd( TALLOC_CTX *ctx )
 	init_sec_access(&mask, REG_KEY_ALL );
 	init_sec_ace(&ace[i++], &global_sid_System, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0);
 
-	
 	/* create the security descriptor */
-	
+
 	if ( !(acl = make_sec_acl(ctx, NT4_ACL_REVISION, i, ace)) )
 		return NULL;
 
@@ -73,29 +72,28 @@ static SEC_DESC* construct_registry_sd( TALLOC_CTX *ctx )
 /***********************************************************************
  High level wrapper function for storing registry subkeys
  ***********************************************************************/
- 
+
 bool store_reg_keys( REGISTRY_KEY *key, REGSUBKEY_CTR *subkeys )
 {
 	if ( key->hook && key->hook->ops && key->hook->ops->store_subkeys )
 		return key->hook->ops->store_subkeys( key->name, subkeys );
-		
-	return False;
 
+	return false;
 }
 
 /***********************************************************************
  High level wrapper function for storing registry values
  ***********************************************************************/
- 
+
 bool store_reg_values( REGISTRY_KEY *key, REGVAL_CTR *val )
 {
 	if ( check_dynamic_reg_values( key ) )
-		return False;
+		return false;
 
 	if ( key->hook && key->hook->ops && key->hook->ops->store_values )
 		return key->hook->ops->store_values( key->name, val );
 
-	return False;
+	return false;
 }
 
 /***********************************************************************
@@ -106,7 +104,7 @@ bool store_reg_values( REGISTRY_KEY *key, REGVAL_CTR *val )
 int fetch_reg_keys( REGISTRY_KEY *key, REGSUBKEY_CTR *subkey_ctr )
 {
 	int result = -1;
-	
+
 	if ( key->hook && key->hook->ops && key->hook->ops->fetch_subkeys )
 		result = key->hook->ops->fetch_subkeys( key->name, subkey_ctr );
 
@@ -120,23 +118,23 @@ int fetch_reg_keys( REGISTRY_KEY *key, REGSUBKEY_CTR *subkey_ctr )
 int fetch_reg_values( REGISTRY_KEY *key, REGVAL_CTR *val )
 {
 	int result = -1;
-	
+
 	if ( key->hook && key->hook->ops && key->hook->ops->fetch_values )
 		result = key->hook->ops->fetch_values( key->name, val );
-	
+
 	/* if the backend lookup returned no data, try the dynamic overlay */
-	
+
 	if ( result == 0 ) {
 		result = fetch_dynamic_reg_values( key, val );
 
 		return ( result != -1 ) ? result : 0;
 	}
-	
+
 	return result;
 }
 
 /***********************************************************************
- High level access check for passing the required access mask to the 
+ High level access check for passing the required access mask to the
  underlying registry backend
  ***********************************************************************/
 
@@ -161,21 +159,21 @@ bool regkey_access_check( REGISTRY_KEY *key, uint32 requested, uint32 *granted,
 	 */
 
 	if (!(mem_ctx = talloc_init("regkey_access_check"))) {
-		return False;
+		return false;
 	}
 
 	err = regkey_get_secdesc(mem_ctx, key, &sec_desc);
 
 	if (!W_ERROR_IS_OK(err)) {
 		TALLOC_FREE(mem_ctx);
-		return False;
+		return false;
 	}
 
 	se_map_generic( &requested, &reg_generic_map );
 
 	if (!se_access_check(sec_desc, token, requested, granted, &status)) {
 		TALLOC_FREE(mem_ctx);
-		return False;
+		return false;
 	}
 
 	TALLOC_FREE(mem_ctx);
diff --git a/source/rpc_server/srv_eventlog_nt.c b/source/rpc_server/srv_eventlog_nt.c
index 3c9c835..0ea34e5 100644


-- 
Samba Shared Repository


More information about the samba-cvs mailing list