[SCM] Samba Shared Repository - branch v3-2-stable updated - release-3-2-0pre2-466-gbeba7a8

Karolin Seeger kseeger at samba.org
Thu Apr 10 14:17:49 GMT 2008


The branch, v3-2-stable has been updated
       via  beba7a8a2162c05ad8897a58750a12d9714875be (commit)
       via  7fc95a1639a978409ae17ee50c66ac9834da2017 (commit)
       via  10839ac8a2d989f11b1f4274ee3e4d3f996bc864 (commit)
       via  033d553763f53689b2f4088da24610554fc2616c (commit)
       via  4ed97662da37389d6633d4dbde7541821d5d643d (commit)
       via  e16fd71c136cabb5fb9493df2999ec43a58503a2 (commit)
       via  9156b8af408f67fde01e76c5b9d8bc5ce6f05dc6 (commit)
       via  f488c38432c4708341bfc3c3ec5bced6b34cb84f (commit)
       via  3d17d2f28d3af53f7f7db5fd39215894412a1d78 (commit)
       via  12c65b0f8975526104fc42039caa71db80bc6104 (commit)
       via  3743946a4c85aa71ef3802889f2b021865ff4134 (commit)
       via  01e727d7419b3c3bf7d55904eebe9b2e10f89239 (commit)
       via  185e3d0b5b52bfb441f66d3c67870ba532069991 (commit)
       via  a508570b5f0d430e34627f46a8c68a9bd5ab0ea7 (commit)
       via  779048d9f07f1103e1e64be2e49bc0402e545cd7 (commit)
       via  1addb4d44032d9737bf829cebdf8b4b8998a6b44 (commit)
      from  9c48ccb25eb7eb564ce18ea1bda51861488a7538 (commit)

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


- Log -----------------------------------------------------------------
commit beba7a8a2162c05ad8897a58750a12d9714875be
Author: Michael Adam <obnox at samba.org>
Date:   Wed Apr 9 14:30:18 2008 +0200

    net rpc registry: add getvalue command.
    
    This is the same as already implemented for "net registry".
    
    usage: net rpc registry getvalue <key> <valuename>
    
    Michael
    (cherry picked from commit ba59383437aed9058a58bdeedcf61a0076a94924)

commit 7fc95a1639a978409ae17ee50c66ac9834da2017
Author: Michael Adam <obnox at samba.org>
Date:   Wed Apr 9 12:31:05 2008 +0200

    net registry: add a getvalue subcommand that prints a single given value.
    
    usage: "net registry getvalue <keyname> <valuename>"
    
    Michael
    (cherry picked from commit 77f049943e133986dc47d25fff2415def1cec32f)

commit 10839ac8a2d989f11b1f4274ee3e4d3f996bc864
Author: Michael Adam <obnox at samba.org>
Date:   Wed Apr 9 12:29:34 2008 +0200

    net (registry util): refactor printing of value without name out.
    
    This renames print_registry_value() to print_registry_value_with_name().
    The new function is called print_registry_value().
    
    Michael
    (cherry picked from commit 88c4851ad7240bc4f72a5ef92e21629e6a4c99c6)

commit 033d553763f53689b2f4088da24610554fc2616c
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Apr 2 08:03:11 2008 +0200

    net_rpc: let get_user_sids() use wbcLookupName(), wbcGidToSid() and wbcGetGroups()
    
    metze
    (cherry picked from commit 31375c02631cb3f37a8bbd4ea17d3ef69c4d07bf)

commit 4ed97662da37389d6633d4dbde7541821d5d643d
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Apr 2 08:02:02 2008 +0200

    net_rpc: let get_user_tokens() use wbcListUsers()
    
    metze
    (cherry picked from commit 4f712452e911db1f0aa74e3ccd636c1a18bdf9ef)

commit e16fd71c136cabb5fb9493df2999ec43a58503a2
Author: Michael Adam <obnox at samba.org>
Date:   Fri Apr 4 17:52:35 2008 +0200

    net_rpc_registry: return available error code on failure in deletevalue.
    
    Michael
    (cherry picked from commit 0dc9840cefb08b2732d294eb45508ce687ded324)

commit 9156b8af408f67fde01e76c5b9d8bc5ce6f05dc6
Author: Michael Adam <obnox at samba.org>
Date:   Fri Apr 4 17:50:41 2008 +0200

    net_rpc_registry: consistently return error upon wrong use.
    
    Michael
    (cherry picked from commit 26e3d71cd0b2d1bb31c50627ea71267328d52448)

commit f488c38432c4708341bfc3c3ec5bced6b34cb84f
Author: Michael Adam <obnox at samba.org>
Date:   Fri Apr 4 17:24:53 2008 +0200

    net: change split_hive_key() to properly allocate subkeyname
    
    instead of returning a pointer into another string.
    
    Michael
    (cherry picked from commit 68d08ecf92be3444b759300237b2b7cf5238d022)

commit 3d17d2f28d3af53f7f7db5fd39215894412a1d78
Author: Michael Adam <obnox at samba.org>
Date:   Fri Apr 4 16:46:01 2008 +0200

    net_rpc_registry: use split_hive_key to normalize hive befor open.
    
    THis allows to specify keys in the form "HKLM/Software/samba",
    i.e. "/" instead of "\\".
    
    Michael
    (cherry picked from commit 61d09caef340d2fee303e429f6f25d011cb3023c)

commit 12c65b0f8975526104fc42039caa71db80bc6104
Author: Michael Adam <obnox at samba.org>
Date:   Fri Apr 4 13:30:49 2008 +0200

    net_rpc_registry: use utility function print_registry_value().
    
    Michael
    (cherry picked from commit 3d039b518f04b9dd3c87b9af2ec816e049554e27)

commit 3743946a4c85aa71ef3802889f2b021865ff4134
Author: Michael Adam <obnox at samba.org>
Date:   Fri Apr 4 13:26:03 2008 +0200

    net_rpc_registy: use function print_registry_key
    
    Michael
    (cherry picked from commit cc1da3ee2c369181efa6d150c966571d0aff0728)

commit 01e727d7419b3c3bf7d55904eebe9b2e10f89239
Author: Michael Adam <obnox at samba.org>
Date:   Fri Apr 4 13:21:03 2008 +0200

    net_registry: split utility function of common interest out into util module.
    
    Michael
    (cherry picked from commit 3bf890783fadd245c59280173627a6caca2dbefe)

commit 185e3d0b5b52bfb441f66d3c67870ba532069991
Author: Michael Adam <obnox at samba.org>
Date:   Fri Mar 28 15:49:13 2008 +0100

    Add a talloc context parameter to current_timestring() to fix memleaks.
    
    current_timestring used to return a string talloced to talloc_tos().
    When called by DEBUG from a TALLOC_FREE, this produced messages
    "no talloc stackframe around, leaking memory". For example when
    used from net conf.
    
    This also adds a temporary talloc context to alloc_sub_basic().
    For this purpose, the exit strategy is slightly altered: a common
    exit point is used for success and failure.
    
    Michael
    (cherry picked from commit 16b5800d4e3a8b88bac67b2550d14e0aaaa302a9)

commit a508570b5f0d430e34627f46a8c68a9bd5ab0ea7
Author: Michael Adam <obnox at samba.org>
Date:   Thu Mar 27 11:51:31 2008 +0100

    libwbclient: fix Coverity ID 536 remove duplicate error path (dead code).
    
    I leave the more explicit error path in the "if (cmd == 0)" block.
    
    Michael
    (cherry picked from commit 2ae19b5fb89e0a992962af14a81b641bf13b7892)

commit 779048d9f07f1103e1e64be2e49bc0402e545cd7
Author: Michael Adam <obnox at samba.org>
Date:   Thu Mar 27 11:26:33 2008 +0100

    libreplace: fix coverity ID 517 - untangle close from open in test/os2_delete.c
    
    This is not a proper bug but the code is clearer now
    and we are tracking failure of open separate from that of close.
    
    Michael
    (cherry picked from commit 451fc9ae05f841883081a334e179cf31625a772c)

commit 1addb4d44032d9737bf829cebdf8b4b8998a6b44
Author: Michael Adam <obnox at samba.org>
Date:   Thu Mar 27 10:09:24 2008 +0100

    posix_acls: clarify loop condition code, removing unneeded counter variable.
    
    Coverity ID 545 falsely classified this as a NULL dereferencing bug.
    By putting the loop of walking the list of aces more naturely not using
    additional counters, it becomes much more obvious that it is not entered
    when dir_ace == NULL.
    
    The same modifications are done for the file_ace loop.
    
    Michael
    (cherry picked from commit 6dab6cf0647d7db01e5e472f8b5cf21395b7dbf0)

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

Summary of changes:
 source/Makefile.in                                 |    1 +
 source/lib/debug.c                                 |   10 +-
 source/lib/replace/test/os2_delete.c               |    9 +-
 source/lib/substitute.c                            |   24 ++-
 source/lib/time.c                                  |    4 +-
 source/libsmb/trusts_util.c                        |    2 +-
 source/nsswitch/libwbclient/wbc_pam.c              |    3 +-
 source/rpcclient/cmd_spoolss.c                     |   12 +-
 source/smbd/change_trust_pw.c                      |    2 +-
 source/smbd/posix_acls.c                           |    9 +-
 source/utils/net_registry.c                        |  133 ++++--------
 source/utils/net_registry_util.c                   |  120 +++++++++++
 .../transfer_file.h => utils/net_registry_util.h}  |   31 ++-
 source/utils/net_rpc.c                             |  158 ++++++--------
 source/utils/net_rpc_registry.c                    |  217 +++++++++++++------
 source/web/swat.c                                  |    6 +-
 16 files changed, 451 insertions(+), 290 deletions(-)
 create mode 100644 source/utils/net_registry_util.c
 copy source/{include/transfer_file.h => utils/net_registry_util.h} (51%)


Changeset truncated at 500 lines:

diff --git a/source/Makefile.in b/source/Makefile.in
index 0ca7988..b5bc696 100644
--- a/source/Makefile.in
+++ b/source/Makefile.in
@@ -837,6 +837,7 @@ NET_OBJ1 = utils/net.o utils/net_ads.o utils/net_help.o \
 	   $(PASSWD_UTIL_OBJ) utils/net_dns.o utils/net_ads_gpo.o \
 	   utils/net_conf.o \
 	   utils/net_registry.o \
+	   utils/net_registry_util.o \
 	   auth/token_util.o utils/net_dom.o nsswitch/wb_client.o
 
 NET_OBJ = $(NET_OBJ1) $(PARAM_WITHOUT_REG_OBJ) $(SECRETS_OBJ) $(LIBSMB_OBJ) \
diff --git a/source/lib/debug.c b/source/lib/debug.c
index c4a0d1b..a76a8db 100644
--- a/source/lib/debug.c
+++ b/source/lib/debug.c
@@ -1029,12 +1029,14 @@ bool dbghdr(int level, int cls, const char *file, const char *func, int line)
 		/* Print it all out at once to prevent split syslog output. */
 		if( lp_debug_prefix_timestamp() ) {
 		    (void)Debug1( "[%s, %2d%s] ",
-			current_timestring(lp_debug_hires_timestamp()), level,
-			header_str);
+			current_timestring(debug_ctx(),
+					   lp_debug_hires_timestamp()),
+			level, header_str);
 		} else {
 		    (void)Debug1( "[%s, %2d%s] %s:%s(%d)\n",
-			current_timestring(lp_debug_hires_timestamp()), level,
-			header_str, file, func, line );
+			current_timestring(debug_ctx(),
+					   lp_debug_hires_timestamp()),
+			level, header_str, file, func, line );
 		}
 	}
 
diff --git a/source/lib/replace/test/os2_delete.c b/source/lib/replace/test/os2_delete.c
index c6ef180..b45c135 100644
--- a/source/lib/replace/test/os2_delete.c
+++ b/source/lib/replace/test/os2_delete.c
@@ -39,8 +39,15 @@ static void create_files(void)
 	int i;
 	for (i=0;i<NUM_FILES;i++) {
 		char fname[40];
+		int fd;
 		sprintf(fname, TESTDIR "/test%u.txt", i);
-		close(open(fname, O_CREAT|O_RDWR, 0600)) == 0 || FAILED("close");
+		fd = open(fname, O_CREAT|O_RDWR, 0600);
+		if (fd < 0) {
+			FAILED("open");
+		}
+		if (close(fd) != 0) {
+			FAILED("close");
+		}
 	}
 }
 
diff --git a/source/lib/substitute.c b/source/lib/substitute.c
index 6ecc3fc..62dfdb5 100644
--- a/source/lib/substitute.c
+++ b/source/lib/substitute.c
@@ -548,6 +548,7 @@ char *alloc_sub_basic(const char *smb_name, const char *domain_name,
 	fstring pidstr, vnnstr;
 	char addr[INET6_ADDRSTRLEN];
 	const char *local_machine_name = get_local_machine_name();
+	TALLOC_CTX *tmp_ctx = NULL;
 
 	/* workaround to prevent a crash while looking at bug #687 */
 	
@@ -561,12 +562,14 @@ char *alloc_sub_basic(const char *smb_name, const char *domain_name,
 		DEBUG(0, ("alloc_sub_basic: Out of memory!\n"));
 		return NULL;
 	}
-	
+
+	tmp_ctx = talloc_stackframe();
+
 	for (b = s = a_string; (p = strchr_m(s, '%')); s = a_string + (p - b)) {
 
 		r = NULL;
 		b = a_string;
-		
+
 		switch (*(p+1)) {
 		case 'U' : 
 			r = strdup_lower(smb_name);
@@ -581,7 +584,7 @@ char *alloc_sub_basic(const char *smb_name, const char *domain_name,
 			if (r == NULL) {
 				goto error;
 			}
-			pass = Get_Pwnam_alloc(talloc_tos(), r);
+			pass = Get_Pwnam_alloc(tmp_ctx, r);
 			if (pass != NULL) {
 				a_string = realloc_string_sub(
 					a_string, "%G",
@@ -631,7 +634,7 @@ char *alloc_sub_basic(const char *smb_name, const char *domain_name,
 			a_string = realloc_string_sub(a_string, "%R", remote_proto);
 			break;
 		case 'T' :
-			a_string = realloc_string_sub(a_string, "%T", current_timestring(False));
+			a_string = realloc_string_sub(a_string, "%T", current_timestring(tmp_ctx, False));
 			break;
 		case 'a' :
 			a_string = realloc_string_sub(a_string, "%a",
@@ -669,17 +672,20 @@ char *alloc_sub_basic(const char *smb_name, const char *domain_name,
 
 		p++;
 		SAFE_FREE(r);
-		
-		if ( !a_string ) {
-			return NULL;
+
+		if (a_string == NULL) {
+			goto done;
 		}
 	}
 
-	return a_string;
+	goto done;
 
 error:
 	SAFE_FREE(a_string);
-	return NULL;
+
+done:
+	TALLOC_FREE(tmp_ctx);
+	return a_string;
 }
 
 /****************************************************************************
diff --git a/source/lib/time.c b/source/lib/time.c
index f98e031..e5fd929 100644
--- a/source/lib/time.c
+++ b/source/lib/time.c
@@ -687,7 +687,7 @@ int set_server_zone_offset(time_t t)
  Return the date and time as a string
 ****************************************************************************/
 
-char *current_timestring(bool hires)
+char *current_timestring(TALLOC_CTX *ctx, bool hires)
 {
 	fstring TimeBuf;
 	struct timeval tp;
@@ -739,7 +739,7 @@ char *current_timestring(bool hires)
 		}
 #endif
 	}
-	return talloc_strdup(talloc_tos(), TimeBuf);
+	return talloc_strdup(ctx, TimeBuf);
 }
 
 
diff --git a/source/libsmb/trusts_util.c b/source/libsmb/trusts_util.c
index d67a26e..c3f5f25 100644
--- a/source/libsmb/trusts_util.c
+++ b/source/libsmb/trusts_util.c
@@ -123,7 +123,7 @@ NTSTATUS trust_pw_change_and_store_it(struct rpc_pipe_client *cli, TALLOC_CTX *m
 	
 	if (NT_STATUS_IS_OK(nt_status)) {
 		DEBUG(3,("%s : trust_pw_change_and_store_it: Changed password.\n", 
-			 current_timestring(False)));
+			 current_timestring(debug_ctx(), False)));
 		/*
 		 * Return the result of trying to write the new password
 		 * back into the trust account file.
diff --git a/source/nsswitch/libwbclient/wbc_pam.c b/source/nsswitch/libwbclient/wbc_pam.c
index c1457cc..2b33f55 100644
--- a/source/nsswitch/libwbclient/wbc_pam.c
+++ b/source/nsswitch/libwbclient/wbc_pam.c
@@ -384,8 +384,7 @@ wbcErr wbcAuthenticateUserEx(const struct wbcAuthUserParams *params,
 		}
 		break;
 	default:
-		wbc_status = WBC_ERR_INVALID_PARAM;
-		BAIL_ON_WBC_ERROR(wbc_status);
+		break;
 	}
 
 	if (cmd == 0) {
diff --git a/source/rpcclient/cmd_spoolss.c b/source/rpcclient/cmd_spoolss.c
index 5e0f694..7530ab1 100644
--- a/source/rpcclient/cmd_spoolss.c
+++ b/source/rpcclient/cmd_spoolss.c
@@ -1966,13 +1966,15 @@ static WERROR cmd_spoolss_setprinterdata(struct rpc_pipe_client *cli,
 	PRINTER_INFO_CTR ctr;
 	PRINTER_INFO_0 info;
 	REGISTRY_VALUE value;
+	TALLOC_CTX *tmp_ctx = talloc_stackframe();
 
 	/* parse the command arguements */
 	if (argc < 5) {
 		printf ("Usage: %s <printer> <string|binary|dword|multistring>"
 			" <value> <data>\n",
 			argv[0]);
-		return WERR_INVALID_PARAM;
+		result = WERR_INVALID_PARAM;
+		goto done;
 	}
 
 	slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->cli->desthost);
@@ -2000,7 +2002,8 @@ static WERROR cmd_spoolss_setprinterdata(struct rpc_pipe_client *cli,
 
 	if (value.type == REG_NONE) {
 		printf("Unknown data type: %s\n", argv[2]);
-		return WERR_INVALID_PARAM;
+		result =  WERR_INVALID_PARAM;
+		goto done;
 	}
 
 	/* get a printer handle */
@@ -2019,7 +2022,7 @@ static WERROR cmd_spoolss_setprinterdata(struct rpc_pipe_client *cli,
         if (!W_ERROR_IS_OK(result))
                 goto done;
 		
-	printf("%s\n", current_timestring(True));
+	printf("%s\n", current_timestring(tmp_ctx, True));
 	printf("\tchange_id (before set)\t:[0x%x]\n", info.change_id);
 
 	/* Set the printer data */
@@ -2105,11 +2108,12 @@ static WERROR cmd_spoolss_setprinterdata(struct rpc_pipe_client *cli,
         if (!W_ERROR_IS_OK(result))
                 goto done;
 		
-	printf("%s\n", current_timestring(True));
+	printf("%s\n", current_timestring(tmp_ctx, True));
 	printf("\tchange_id (after set)\t:[0x%x]\n", info.change_id);
 
 done:
 	/* cleanup */
+	TALLOC_FREE(tmp_ctx);
 	if (opened_hnd)
 		rpccli_spoolss_close_printer(cli, mem_ctx, &pol);
 
diff --git a/source/smbd/change_trust_pw.c b/source/smbd/change_trust_pw.c
index fc58e97..4773eef 100644
--- a/source/smbd/change_trust_pw.c
+++ b/source/smbd/change_trust_pw.c
@@ -90,7 +90,7 @@ NTSTATUS change_trust_account_password( const char *domain, const char *remote_m
 failed:
 	if (!NT_STATUS_IS_OK(nt_status)) {
 		DEBUG(0,("%s : change_trust_account_password: Failed to change password for domain %s.\n", 
-			current_timestring(False), domain));
+			current_timestring(debug_ctx(), False), domain));
 	}
 	else
 		DEBUG(5,("change_trust_account_password: sucess!\n"));
diff --git a/source/smbd/posix_acls.c b/source/smbd/posix_acls.c
index f60329a..c3c9d2e 100644
--- a/source/smbd/posix_acls.c
+++ b/source/smbd/posix_acls.c
@@ -2882,7 +2882,6 @@ static NTSTATUS posix_get_nt_acl_common(struct connection_struct *conn,
 		{
 			canon_ace *ace;
 			enum security_ace_type nt_acl_type;
-			int i;
 
 			if (nt4_compatible_acls() && dir_ace) {
 				/*
@@ -2948,9 +2947,7 @@ static NTSTATUS posix_get_nt_acl_common(struct connection_struct *conn,
 			 * Create the NT ACE list from the canonical ace lists.
 			 */
 
-			ace = file_ace;
-
-			for (i = 0; i < num_acls; i++, ace = ace->next) {
+			for (ace = file_ace; ace != NULL; ace = ace->next) {
 				SEC_ACCESS acc;
 
 				acc = map_canon_ace_perms(SNUM(conn),
@@ -2977,9 +2974,7 @@ static NTSTATUS posix_get_nt_acl_common(struct connection_struct *conn,
 						acc, 0);
 			}
 
-			ace = dir_ace;
-
-			for (i = 0; i < num_def_acls; i++, ace = ace->next) {
+			for (ace = dir_ace; ace != NULL; ace = ace->next) {
 				SEC_ACCESS acc;
 
 				acc = map_canon_ace_perms(SNUM(conn),
diff --git a/source/utils/net_registry.c b/source/utils/net_registry.c
index 3d24500..6af8236 100644
--- a/source/utils/net_registry.c
+++ b/source/utils/net_registry.c
@@ -21,6 +21,7 @@
 
 #include "includes.h"
 #include "utils/net.h"
+#include "utils/net_registry_util.h"
 
 
 /*
@@ -29,93 +30,6 @@
  *
  */
 
-static void print_registry_key(const char *keyname, NTTIME *modtime)
-{
-	d_printf("Keyname   = %s\n", keyname);
-	d_printf("Modtime   = %s\n",
-		 modtime
-		 ? http_timestring(nt_time_to_unix(*modtime))
-		 : "None");
-	d_printf("\n");
-}
-
-static void print_registry_value(const char *valname,
-				 const struct registry_value *valvalue)
-{
-	d_printf("Valuename  = %s\n", valname);
-	d_printf("Type       = %s\n",
-		 reg_type_lookup(valvalue->type));
-	switch(valvalue->type) {
-	case REG_DWORD:
-		d_printf("Value      = %d\n", valvalue->v.dword);
-		break;
-	case REG_SZ:
-	case REG_EXPAND_SZ:
-		d_printf("Value      = \"%s\"\n", valvalue->v.sz.str);
-		break;
-	case REG_MULTI_SZ: {
-		uint32 j;
-		for (j = 0; j < valvalue->v.multi_sz.num_strings; j++) {
-			d_printf("Value[%3.3d] = \"%s\"\n", j,
-				 valvalue->v.multi_sz.strings[j]);
-		}
-		break;
-	}
-	case REG_BINARY:
-		d_printf("Value      = %d bytes\n",
-			 (int)valvalue->v.binary.length);
-		break;
-	default:
-		d_printf("Value      = <unprintable>\n");
-		break;
-	}
-	d_printf("\n");
-}
-
-/**
- * Split path into hive name and subkeyname
- * normalizations performed:
- *  - convert '/' to '\\'
- *  - strip trailing '\\' chars
- */
-static WERROR split_hive_key(TALLOC_CTX *ctx, const char *path,
-			     char **hivename, const char **subkeyname)
-{
-	char *p;
-
-	if ((path == NULL) || (hivename == NULL) || (subkeyname == NULL)) {
-		return WERR_INVALID_PARAM;
-	}
-
-	if (strlen(path) == 0) {
-		return WERR_INVALID_PARAM;
-	}
-
-	*hivename = talloc_string_sub(ctx, path, "/", "\\");
-	if (*hivename == NULL) {
-		return WERR_NOMEM;
-	}
-
-	/* strip trailing '\\' chars */
-	p = strrchr(*hivename, '\\');
-	while ((p != NULL) && (p[1] == '\0')) {
-		*p = '\0';
-		p = strrchr(*hivename, '\\');
-	}
-
-	p = strchr(*hivename, '\\');
-
-	if ((p == NULL) || (*p == '\0')) {
-		/* just the hive - no subkey given */
-		*subkeyname = "";
-	} else {
-		*p = '\0';
-		*subkeyname = p+1;
-	}
-
-	return WERR_OK;
-}
-
 /**
  * split given path into hive and remaining path and open the hive key
  */
@@ -127,7 +41,7 @@ static WERROR open_hive(TALLOC_CTX *ctx, const char *path,
 	WERROR werr;
 	NT_USER_TOKEN *token = NULL;
 	char *hivename = NULL;
-	const char *tmp_subkeyname = NULL;
+	char *tmp_subkeyname = NULL;
 	TALLOC_CTX *tmp_ctx = talloc_stackframe();
 
 	if ((hive == NULL) || (subkeyname == NULL)) {
@@ -242,7 +156,7 @@ static int net_registry_enumerate(int argc, const char **argv)
 	     W_ERROR_IS_OK(werr);
 	     count++)
 	{
-		print_registry_value(valname, valvalue);
+		print_registry_value_with_name(valname, valvalue);
 	}
 	if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
 		goto done;
@@ -346,6 +260,42 @@ done:
 	return ret;
 }
 
+static int net_registry_getvalue(int argc, const char **argv)
+{
+	WERROR werr;
+	int ret = -1;
+	struct registry_key *key = NULL;
+	struct registry_value *value = NULL;
+	TALLOC_CTX *ctx = talloc_stackframe();
+
+	if (argc != 2) {
+		d_fprintf(stderr, "usage: net rpc registry getvalue <key> "
+				  "<valuename>\n");
+		goto done;
+	}
+
+	werr = open_key(ctx, argv[0], REG_KEY_READ, &key);
+	if (!W_ERROR_IS_OK(werr)) {
+		d_fprintf(stderr, "open_key failed: %s\n", dos_errstr(werr));
+		goto done;
+	}
+
+	werr = reg_queryvalue(ctx, key, argv[1], &value);
+	if (!W_ERROR_IS_OK(werr)) {
+		d_fprintf(stderr, "reg_queryvalue failed: %s\n",
+			  dos_errstr(werr));
+		goto done;
+	}
+
+	print_registry_value(value);
+
+	ret = 0;
+
+done:
+	TALLOC_FREE(ctx);
+	return ret;
+}
+
 static int net_registry_setvalue(int argc, const char **argv)
 {
 	WERROR werr;
@@ -501,6 +451,11 @@ int net_registry(int argc, const char **argv)
 			"Delete a registry key"
 		},
 		{
+			"getvalue",
+			net_registry_getvalue,
+			"Print a registry value",
+		},
+		{
 			"setvalue",
 			net_registry_setvalue,
 			"Set a new registry value"
diff --git a/source/utils/net_registry_util.c b/source/utils/net_registry_util.c
new file mode 100644
index 0000000..ca80e60
--- /dev/null
+++ b/source/utils/net_registry_util.c
@@ -0,0 +1,120 @@
+/*
+ * Samba Unix/Linux SMB client library
+ * Distributed SMB/CIFS Server Management Utility
+ * registry utility functions
+ *
+ * Copyright (C) Michael Adam 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/>.
+ */
+
+#include "includes.h"
+#include "utils/net_registry_util.h"
+
+void print_registry_key(const char *keyname, NTTIME *modtime)
+{
+	d_printf("Keyname   = %s\n", keyname);
+	d_printf("Modtime   = %s\n",
+		 modtime
+		 ? http_timestring(nt_time_to_unix(*modtime))
+		 : "None");
+	d_printf("\n");
+}
+
+void print_registry_value(const struct registry_value *valvalue)
+{


-- 
Samba Shared Repository


More information about the samba-cvs mailing list