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

Karolin Seeger kseeger at samba.org
Fri Apr 4 10:37:26 GMT 2008


The branch, v3-2-stable has been updated
       via  43b13356dfbfde17223084329eefd4002f9c68c8 (commit)
       via  464c08b4108568c63d8f1e4eb156ac7b4817d465 (commit)
       via  16b59da58567a22d19c3bb94572aa26e287e12a2 (commit)
       via  06892ff81e88558a3d9f9af422fd3cbd96d30b8d (commit)
       via  71eb2e6e43502b30054a2e9210584296c9ba8aed (commit)
       via  f090cd063352a68c5f5407e8fda7a7fee75711fd (commit)
       via  03d9006948bc34a47ffe7b3d6b02bb043bc2b6ea (commit)
       via  561849f1f0dc7c376bed3e586a64b68a1e6d733c (commit)
       via  0e4ce6a0738bc4028b9e213fbd346fb9bb19ed73 (commit)
       via  26240bfa6c000619e462b89f72f9c9db48e67780 (commit)
       via  265aa100ba6dcab64e5545b690a08b2a7a22c522 (commit)
       via  b5c08a6fbab8ae1fbed20e7f62ca79efb22899bb (commit)
       via  edef65d4de98aee266488f8e120cd03ab14a5a5d (commit)
       via  52ace2340ee58bf0c8995356856a12668bd276fb (commit)
       via  d6fe1fa542d826277dbba2d33a14cd3480c5811e (commit)
       via  e2513258d3ecbc422c23b797ddaf9518d220082a (commit)
       via  bffa0914496d6a6aba6bfc96f03abf0d76af4e73 (commit)
       via  40a90477d2dfe419b26c2cb7cae44aae8d2b032d (commit)
       via  db5cff5991c900d94411e4236d55f69f5679f686 (commit)
      from  2075ce26d4f6dcb70c125e87a10d752681aa6150 (commit)

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


- Log -----------------------------------------------------------------
commit 43b13356dfbfde17223084329eefd4002f9c68c8
Author: Michael Adam <obnox at samba.org>
Date:   Tue Apr 1 15:51:51 2008 +0200

    test: add diagnostic message to net_registry test.
    
    Michael
    (cherry picked from commit c04a234f8f6fbdf8e54c69414024d84aa71fec45)

commit 464c08b4108568c63d8f1e4eb156ac7b4817d465
Author: Michael Adam <obnox at samba.org>
Date:   Tue Apr 1 15:50:24 2008 +0200

    test: fix net_registry test "set value to different type" to track error count
    
    missing backslash in call... :-}
    
    Michael
    (cherry picked from commit 8f0c25f01f11857d24556346dc2758549919eba3)

commit 16b59da58567a22d19c3bb94572aa26e287e12a2
Author: Michael Adam <obnox at samba.org>
Date:   Tue Apr 1 15:43:35 2008 +0200

    test: some cosmetics to net_registry tests.
    
    Michael
    (cherry picked from commit dba9db5ae6581df18591eebd19d3649bed0d9367)

commit 06892ff81e88558a3d9f9af422fd3cbd96d30b8d
Author: Michael Adam <obnox at samba.org>
Date:   Tue Apr 1 15:35:12 2008 +0200

    test: fix net_registry tests to correctly capture output of commands inside one test
    
    so that failure output is not clobbered by  output of previous
    successful commands.
    
    Michael
    (cherry picked from commit cb3dafe5fd8867b000e01979d4232968d994d376)

commit 71eb2e6e43502b30054a2e9210584296c9ba8aed
Author: Michael Adam <obnox at samba.org>
Date:   Tue Apr 1 15:19:05 2008 +0200

    test: fix use of printf in net_registry tests.
    
    actually 'printf "%s\n"' is the proper replacement of 'echo -e'
    
    Michael
    (cherry picked from commit 388a40931f1559b134317ef0c85c7cf2598e17fe)

commit f090cd063352a68c5f5407e8fda7a7fee75711fd
Author: Michael Adam <obnox at samba.org>
Date:   Tue Apr 1 15:55:59 2008 +0200

    po/genmsg: be more portable, use 'printf "%s"' instead of 'echo -n'
    
    Michael
    (cherry picked from commit 0bd50e450baf633ea9d653341f3ce9d81bfdd83f)

commit 03d9006948bc34a47ffe7b3d6b02bb043bc2b6ea
Author: Michael Adam <obnox at samba.org>
Date:   Tue Apr 1 15:54:34 2008 +0200

    mkversion: be more portable, use 'print "%s"' instead of 'echo -n'
    
    Michael
    (cherry picked from commit 7a23dab1eaf3116079a89cdf348cabc659608031)

commit 561849f1f0dc7c376bed3e586a64b68a1e6d733c
Author: Michael Adam <obnox at samba.org>
Date:   Tue Apr 1 15:53:54 2008 +0200

    installswat: be more portable, use 'printf "%s"' instead of 'echo -n'
    
    Michael
    (cherry picked from commit 8b015c91c9b10c208fe61cefd71ddc9f4fcbec61)

commit 0e4ce6a0738bc4028b9e213fbd346fb9bb19ed73
Author: Michael Adam <obnox at samba.org>
Date:   Tue Apr 1 15:52:54 2008 +0200

    configure: be more portable, use 'printf "%s"' instead of "echo -n"
    
    Michael
    (cherry picked from commit 06dfb0cf7cd39e1072534fc32e79a4b4f6e49cb6)

commit 26240bfa6c000619e462b89f72f9c9db48e67780
Author: Michael Adam <obnox at samba.org>
Date:   Tue Apr 1 13:45:55 2008 +0200

    test: be more portable. replace 'echo -n' by 'printf "%s"' in test_functions.sh
    
    Michael
    (cherry picked from commit c0c41184277044eb856f91c025f645c198cac188)

commit 265aa100ba6dcab64e5545b690a08b2a7a22c522
Author: Michael Adam <obnox at samba.org>
Date:   Tue Apr 1 13:43:20 2008 +0200

    test: be more portable: replace 'echo -n' by 'printf "%s"' in selftest.sh
    
    Michael
    (cherry picked from commit b6122406fe938fdaf373ff45214db79de06eb989)

commit b5c08a6fbab8ae1fbed20e7f62ca79efb22899bb
Author: Michael Adam <obnox at samba.org>
Date:   Tue Apr 1 12:48:25 2008 +0200

    test: make registry tests more portable: protect some grep patterns in ' '.
    
    Michael
    (cherry picked from commit 1cb3b2f065566f981f6cfb8b5efdfad7db49c719)

commit edef65d4de98aee266488f8e120cd03ab14a5a5d
Author: Michael Adam <obnox at samba.org>
Date:   Tue Apr 1 12:45:06 2008 +0200

    test: make registry tests more portable: use 'printf "%s"' instead of 'echo -e'
    
    Michael
    (cherry picked from commit 5c1b7ee5c17489da90192309853aa1ecacc15512)

commit 52ace2340ee58bf0c8995356856a12668bd276fb
Author: Michael Adam <obnox at samba.org>
Date:   Mon Mar 31 13:54:39 2008 +0200

    test: add test script for testing "net registry".
    
    Michael
    (cherry picked from commit fa5968a26b552d7f13574a826e506ed2d6630feb)

commit d6fe1fa542d826277dbba2d33a14cd3480c5811e
Author: Michael Adam <obnox at samba.org>
Date:   Mon Mar 31 13:51:49 2008 +0200

    test: add (and unify) sectioning output of subtests in tests_all.sh
    
    Michael
    (cherry picked from commit d775194e9c7b75182c485fba427b20ec2bfcf16c)

commit e2513258d3ecbc422c23b797ddaf9518d220082a
Author: Michael Adam <obnox at samba.org>
Date:   Mon Mar 31 13:33:12 2008 +0200

    test: add possibility to select tests to run via tests_all.sh (make test)
    
    This allows to select the tests to run with tests_all.sh by setting
    the environment variable "RUNTESTS". Example:
    
    RUNTESTS="smbclient_s3_encrypted wbinfo_s3" make test
    
    Michael
    (cherry picked from commit bf4af79f050cceb6611a8aa3d893b59b816a41ce)

commit bffa0914496d6a6aba6bfc96f03abf0d76af4e73
Author: Michael Adam <obnox at samba.org>
Date:   Mon Mar 31 13:20:08 2008 +0200

    test: in tests_all.sh, wrap calls to test scripts into shell functions.
    
    This is in preparation for enabling running only selected test scripts
    through "make test".
    
    Michael
    (cherry picked from commit ad1fbadf81c915425301ec495744c11f3103169f)

commit 40a90477d2dfe419b26c2cb7cae44aae8d2b032d
Author: Michael Adam <obnox at samba.org>
Date:   Mon Mar 31 17:20:07 2008 +0200

    registry: reg_deletevalue should return error, when the value does not exist.
    
    Michael
    (cherry picked from commit 04b48984bbf84c55bb41a74a11cbcc7358377fed)

commit db5cff5991c900d94411e4236d55f69f5679f686
Author: Michael Adam <obnox at samba.org>
Date:   Fri Mar 28 01:21:49 2008 +0100

    net: add a "net registry" subcommand to locally access the registry.
    
    The interface is like that of net rpc registry.
    Access is direct local access to the registry tdb through reg_api.
    
    Michael
    (cherry picked from commit 3250068eb980bd0489f814f702401cdc9c925a8d)

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

Summary of changes:
 source/Makefile.in                       |    4 +-
 source/configure.in                      |    2 +-
 source/po/genmsg                         |    2 +-
 source/registry/reg_api.c                |   18 +
 source/script/installswat.sh             |    4 +-
 source/script/mkversion.sh               |    8 +-
 source/script/tests/selftest.sh          |    2 +-
 source/script/tests/test_functions.sh    |    6 +-
 source/script/tests/test_net_registry.sh |  393 ++++++++++++++++++++++
 source/script/tests/tests_all.sh         |   98 +++++-
 source/utils/net.c                       |    1 +
 source/utils/net_registry.c              |  530 ++++++++++++++++++++++++++++++
 12 files changed, 1037 insertions(+), 31 deletions(-)
 create mode 100755 source/script/tests/test_net_registry.sh
 create mode 100644 source/utils/net_registry.c


Changeset truncated at 500 lines:

diff --git a/source/Makefile.in b/source/Makefile.in
index c492f44..74c869b 100644
--- a/source/Makefile.in
+++ b/source/Makefile.in
@@ -833,7 +833,9 @@ NET_OBJ1 = utils/net.o utils/net_ads.o utils/net_help.o \
 	   utils/netlookup.o utils/net_sam.o utils/net_rpc_shell.o \
 	   utils/net_util.o utils/net_rpc_sh_acct.o utils/net_rpc_audit.o \
 	   $(PASSWD_UTIL_OBJ) utils/net_dns.o utils/net_ads_gpo.o \
-	   utils/net_conf.o auth/token_util.o utils/net_dom.o nsswitch/wb_client.o
+	   utils/net_conf.o \
+	   utils/net_registry.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) \
 	  $(RPC_PARSE_OBJ) $(PASSDB_OBJ) $(GROUPDB_OBJ) \
diff --git a/source/configure.in b/source/configure.in
index b204978..8487bbc 100644
--- a/source/configure.in
+++ b/source/configure.in
@@ -1075,7 +1075,7 @@ AC_CHECK_HEADERS(execinfo.h libexc.h libunwind.h)
 AC_CHECK_FUNCS(backtrace_symbols)
 AC_CHECK_LIB(exc, trace_back_stack)
 
-echo -n "checking for GPFS GPL libs... "
+printf "%s" "checking for GPFS GPL libs... "
 save_LIBS="$LIBS"
 LIBS="$LIBS -lgpfs_gpl"
 AC_TRY_LINK([#include <gpfs_gpl.h>],
diff --git a/source/po/genmsg b/source/po/genmsg
index 14bfa97..543200a 100755
--- a/source/po/genmsg
+++ b/source/po/genmsg
@@ -30,7 +30,7 @@ $XGETTEXT --default-domain="i18n_swat" \
   $FILES
 
 for lang in $LANGS; do
-  echo -n $lang
+  printf "%s" "$lang"
   mv ${lang}.msg ${lang}.msg.old
   $MSGMERGE --width=${WIDTH} ${lang}.msg.old i18n_swat.po -o ${lang}.msg
 done
diff --git a/source/registry/reg_api.c b/source/registry/reg_api.c
index e52aaac..1a0bf2b 100644
--- a/source/registry/reg_api.c
+++ b/source/registry/reg_api.c
@@ -653,6 +653,19 @@ WERROR reg_setvalue(struct registry_key *key, const char *name,
 	return WERR_OK;
 }
 
+static WERROR reg_value_exists(struct registry_key *key, const char *name)
+{
+	int i;
+
+	for (i=0; i<key->values->num_values; i++) {
+		if (strequal(key->values->values[i]->valuename, name)) {
+			return WERR_OK;
+		}
+	}
+
+	return WERR_BADFILE;
+}
+
 WERROR reg_deletevalue(struct registry_key *key, const char *name)
 {
 	WERROR err;
@@ -665,6 +678,11 @@ WERROR reg_deletevalue(struct registry_key *key, const char *name)
 		return err;
 	}
 
+	err = reg_value_exists(key, name);
+	if (!W_ERROR_IS_OK(err)) {
+		return err;
+	}
+
 	regval_ctr_delvalue(key->values, name);
 
 	if (!store_reg_values(key->key, key->values)) {
diff --git a/source/script/installswat.sh b/source/script/installswat.sh
index 567bfa1..40596f3 100755
--- a/source/script/installswat.sh
+++ b/source/script/installswat.sh
@@ -10,13 +10,13 @@ case $0 in
 	*uninstall*)
 		echo "Removing SWAT from $DESTDIR/$SWATDIR "
 		echo "Removing the Samba Web Administration Tool "
-		echo -n "Removed "
+		printf "%s" "Removed "
 		mode='uninstall'
 		;;
 	*)
 		echo "Installing SWAT in $DESTDIR/$SWATDIR "
 		echo "Installing the Samba Web Administration Tool "
-		echo -n "Installing "
+		printf "%s" "Installing "
 		mode='install'
 		;;
 esac
diff --git a/source/script/mkversion.sh b/source/script/mkversion.sh
index 877138f..b678476 100755
--- a/source/script/mkversion.sh
+++ b/source/script/mkversion.sh
@@ -73,10 +73,10 @@ if test x"${SAMBA_VERSION_IS_GIT_SNAPSHOT}" = x"yes";then
     if test x"${HAVEVER}" != x"yes" -a -d "${SOURCE_DIR}../.git";then
 	HAVEGIT=no
 	GIT_INFO=`git show --pretty=format:"%h%n%ct%n%H%n%cd" --stat HEAD 2>/dev/null`
-	GIT_COMMIT_ABBREV=`echo -e "${GIT_INFO}" | sed -n 1p`
-	GIT_COMMIT_TIME=`echo -e "${GIT_INFO}" | sed -n 2p`
-	GIT_COMMIT_FULLREV=`echo -e "${GIT_INFO}" | sed -n 3p`
-	GIT_COMMIT_DATE=`echo -e "${GIT_INFO}" | sed -n 4p`
+	GIT_COMMIT_ABBREV=`printf "%s" "${GIT_INFO}" | sed -n 1p`
+	GIT_COMMIT_TIME=`printf "%s" "${GIT_INFO}" | sed -n 2p`
+	GIT_COMMIT_FULLREV=`printf "%s" "${GIT_INFO}" | sed -n 3p`
+	GIT_COMMIT_DATE=`printf "%s" "${GIT_INFO}" | sed -n 4p`
 	if test -n "${GIT_COMMIT_ABBREV}";then
 	    HAVEGIT=yes
             HAVEVER=yes
diff --git a/source/script/tests/selftest.sh b/source/script/tests/selftest.sh
index 2f2cb7b..492a2c3 100755
--- a/source/script/tests/selftest.sh
+++ b/source/script/tests/selftest.sh
@@ -107,7 +107,7 @@ fi
 ## 
 ## create the test directory layout
 ##
-echo -n "CREATE TEST ENVIRONMENT IN '$PREFIX'"...
+printf "%s" "CREATE TEST ENVIRONMENT IN '$PREFIX'"...
 /bin/rm -rf $PREFIX/*
 mkdir -p $PRIVATEDIR $LIBDIR $PIDDIR $LOCKDIR $LOGDIR
 mkdir -p $SOCKET_WRAPPER_DIR
diff --git a/source/script/tests/test_functions.sh b/source/script/tests/test_functions.sh
index d707c30..407d46a 100644
--- a/source/script/tests/test_functions.sh
+++ b/source/script/tests/test_functions.sh
@@ -42,7 +42,7 @@ samba3_check_or_start() {
 		mkfifo $SERVER_TEST_FIFO
 
 		rm -f $NMBD_TEST_LOG
-		echo -n "STARTING NMBD..."
+		printf "%s" "STARTING NMBD..."
 		((
 			if test x"$NMBD_MAXTIME" = x; then
 			    NMBD_MAXTIME=2700
@@ -74,7 +74,7 @@ samba3_check_or_start() {
 		echo  "DONE"
 
 		rm -f $WINBINDD_TEST_LOG
-		echo -n "STARTING WINBINDD..."
+		printf "%s" "STARTING WINBINDD..."
 		((
 			if test x"$WINBINDD_MAXTIME" = x; then
 			    WINBINDD_MAXTIME=2700
@@ -106,7 +106,7 @@ samba3_check_or_start() {
 		echo  "DONE"
 
 		rm -f $SMBD_TEST_LOG
-		echo -n "STARTING SMBD..."
+		printf "%s" "STARTING SMBD..."
 		((
 			if test x"$SMBD_MAXTIME" = x; then
 			    SMBD_MAXTIME=2700
diff --git a/source/script/tests/test_net_registry.sh b/source/script/tests/test_net_registry.sh
new file mode 100755
index 0000000..9ea78cf
--- /dev/null
+++ b/source/script/tests/test_net_registry.sh
@@ -0,0 +1,393 @@
+#!/bin/sh
+
+# tests for the "net registry" command - local access to the registry db
+
+
+NET="$VALGRIND ${NET:-$BINDIR/net} $CONFIGURATION"
+
+NETREG="${NET} registry"
+
+incdir=`dirname $0`
+. $incdir/test_functions.sh
+
+failed=0
+
+test_enumerate()
+{
+	KEY="$1"
+
+	${NETREG} enumerate ${KEY}
+}
+
+test_getsd()
+{
+	KEY="$1"
+
+	${NETREG} getsd ${KEY}
+}
+
+test_enumerate_nonexisting()
+{
+	KEY="$1"
+	${NETREG} enumerate ${KEY}
+
+	if test "x$?" = "x0" ; then
+		echo "ERROR: enumerate succeeded with key '${KEY}'"
+		false
+	else
+		true
+	fi
+}
+
+test_enumerate_no_key()
+{
+	${NETREG} enumerate
+	if test "x$?" = "x0" ; then
+		echo "ERROR: enumerate succeeded without any key spcified"
+		false
+	else
+		true
+	fi
+}
+
+test_create_existing()
+{
+	KEY="HKLM"
+	EXPECTED="createkey opened existing ${KEY}"
+
+	OUTPUT=`${NETREG} createkey ${KEY}`
+	if test "x$?" = "x0" ; then
+		if test "$OUTPUT" = "$EXPECTED" ; then
+			true
+		else
+			echo "got '$OUTPUT', expected '$EXPECTED'"
+			false
+		fi
+	else
+		printf "%s\n" "$OUTPUT"
+		false
+	fi
+}
+
+test_createkey()
+{
+	KEY="$1"
+	BASEKEY=`dirname $KEY`
+	SUBKEY=`basename $KEY`
+
+	OUTPUT=`${NETREG} createkey ${KEY}`
+	if test "x$?" != "x0" ; then
+		echo "ERROR: createkey ${KEY} failed"
+		echo "output:"
+		printf "%s\n" "$OUTPUT"
+		false
+		return
+	fi
+
+	# check enumerate of basekey lists new key:
+	OUTPUT=`${NETREG} enumerate ${BASEKEY}`
+	if test "x$?" != "x0" ; then
+		echo "ERROR: failed to enumerate key '${BASEKEY}'"
+		echo "output:"
+		printf "%s\n" "$OUTPUT"
+		false
+		return
+	fi
+
+	EXPECTED="Keyname = ${SUBKEY}"
+	printf "%s\n" "$OUTPUT" | grep '^Keyname' | grep ${SUBKEY}
+	if test "x$?" != "x0" ; then
+		echo "ERROR: did not find expexted '$EXPECTED' in output"
+		echo "output:"
+		printf "%s\n" "$OUTPUT"
+		false
+	fi
+
+	# check enumerate of new key works:
+	${NETREG} enumerate ${KEY}
+}
+
+test_deletekey()
+{
+	KEY="$1"
+	BASEKEY=`dirname ${KEY}`
+	SUBKEY=`basename ${KEY}`
+
+	OUTPUT=`test_createkey "${KEY}"`
+	if test "x$?" != "x0" ; then
+		printf "%s\n" "${OUTPUT}"
+		false
+		return
+	fi
+
+	OUTPUT=`${NETREG} deletekey ${KEY}`
+	if test "x$?" != "x0" ; then
+		printf "%s\n" "${OUTPUT}"
+		false
+		return
+	fi
+
+	# check enumerate of basekey does not show key anymore:
+	OUTPUT=`${NETREG} enumerate ${BASEKEY}`
+	if test "x$?" != "x0" ; then
+		printf "%s\n" "$OUTPUT"
+		false
+		return
+	fi
+
+	UNEXPECTED="Keyname = ${SUBKEY}"
+	printf "%s\n" "$OUTPUT" | 'grep ^Keyname' | grep ${SUBKEY}
+	if test "x$?" = "x0" ; then
+		echo "ERROR: found '$UNEXPECTED' after delete in output"
+		echo "output:"
+		printf "%s\n" "$OUTPUT"
+		false
+	fi
+
+	# check enumerate of key itself does not work anymore:
+	${NETREG} enumerate ${KEY}
+	if test "x$?" = "x0" ; then
+		echo "ERROR: 'enumerate ${KEY}' works after 'deletekey ${KEY}'"
+		false
+	else
+		true
+	fi
+}
+
+test_deletekey_nonexisting()
+{
+	KEY="$1"
+
+	OUTPUT=`test_deletekey "${KEY}"`
+	if test "x$?" != "x0" ; then
+		printf "%s\n" "${OUTPUT}"
+		false
+		return
+	fi
+
+	${NETREG} deletekey "${KEY}"
+	if test "x$?" = "x0" ; then
+		echo "ERROR: delete after delete succeeded for key '${KEY}'"
+		false
+	fi
+}
+
+test_createkey_with_subkey()
+{
+	KEY="$1"
+	KEY2=`dirname ${KEY}`
+	SUBKEYNAME2=`basename ${KEY}`
+	BASENAME=`dirname ${KEY2}`
+	SUBKEYNAME1=`basename ${KEY2}`
+
+	OUTPUT=`${NETREG} createkey ${KEY}`
+	if test "x$?" != "x0" ; then
+		echo "ERROR: createkey ${KEY} failed"
+		printf "%s\n" "${OUTPUT}"
+		false
+		return
+	fi
+
+	# check we can enumerate to level key
+	OUTPUT=`${NETREG} enumerate ${KEY}`
+	if test "x$?" != "x0" ; then
+		echo "ERROR: failed to enumerate '${KEY}' after creation"
+		printf "%s\n" "${OUTPUT}"
+		false
+		return
+	fi
+
+	# clear:
+	${NETREG} deletekey ${KEY} && ${NETREG} deletekey ${KEY2}
+}
+
+test_deletekey_with_subkey()
+{
+	KEY="$1"
+	KEY2=`dirname ${KEY}`
+
+	OUTPUT=`${NETREG} createkey ${KEY}`
+	if test "x$?" != "x0" ; then
+		printf "%s\n" "${OUTPUT}"
+		false
+		return
+	fi
+
+	OUTPUT=`${NETREG} deletekey ${KEY2}`
+
+	if test "x$?" = "x0" ; then
+		echo "ERROR: delete of key with subkey succeeded"
+		echo "output:"
+		printf "%s\n" "$OUTPUT"
+		false
+		return
+	fi
+
+	${NETREG} deletekey ${KEY} && ${NETREG} deletekey ${KEY2}
+}
+
+test_setvalue()
+{
+	KEY="$1"
+	VALNAME="$2"
+	VALTYPE="$3"
+	VALVALUE="$4"
+
+	OUTPUT=`test_createkey ${KEY}`
+	if test "x$?" != "x0" ; then
+		printf "%s\n" "${OUTPUT}"
+		false
+		return
+	fi
+
+	OUTPUT=`${NETREG} setvalue ${KEY} ${VALNAME} ${VALTYPE} ${VALVALUE}`
+	if test "x$?" != "x0" ; then
+		echo "ERROR: failed to set value testval in key ${KEY}"
+		printf "%s\n" "${OUTPUT}"
+		false
+		return
+	fi
+
+	OUTPUT=`${NETREG} enumerate ${KEY}`
+	if test "x$?" != "x0" ; then
+		echo "ERROR: failure calling enumerate for key ${KEY}"
+		echo output:
+		printf "%s\n" "${OUTPUT}"
+		false
+		return
+	fi
+
+	printf "%s\n" "$OUTPUT" | {
+	FOUND=0
+	while read LINE ; do
+		SEARCH1=`echo $LINE | grep '^Valuename' | grep ${VALNAME}`
+		if test "x$?" = "x0" ; then
+			read LINE
+			read LINE
+			SEARCH2=`echo $LINE | grep '^Value ' | grep ${VALVALUE}`
+			if test "x$?" = "x0" ; then
+				FOUND=1
+				break
+			fi
+		fi
+	done
+
+	if test "x$FOUND" != "x1" ; then
+		echo "ERROR: did not find value '${VALNAME}' with enumerate"
+		echo "enumerate output:"
+		printf "%s\n" "$OUTPUT"
+		false
+		return
+	fi
+	}
+}
+
+test_deletevalue()
+{
+	KEY="$1"
+	VALNAME="$2"
+
+	${NETREG} deletevalue ${KEY} ${VALNAME}
+}
+
+test_deletevalue_nonexisting()
+{
+	KEY="$1"
+	VALNAME="$2"
+
+	${NETREG} deletevalue ${KEY} ${VALNAME}
+	if test "x$?" = "x0" ; then
+		echo "ERROR: succeeded deleting value ${VALNAME}"
+		false
+	else
+		true
+	fi
+}
+
+test_setvalue_twice()
+{
+	KEY="$1"
+	VALNAME="$2"
+	VALTYPE1="$3"
+	VALVALUE1="$4"
+	VALTYPE2="$5"
+	VALVALUE2="$6"
+
+	OUTPUT=`test_setvalue ${KEY} ${VALNAME} ${VALTYPE1} ${VALVALUE1}`
+	if test "x$?" != "x0" ; then
+		echo "ERROR: first setvalue call failed"
+		printf "%s\n" "$OUTPUT"
+		false
+		return
+	fi
+
+	${NETREG} setvalue ${KEY} ${VALNAME} ${VALTYPE2} ${VALVALUE2}
+}
+
+
+testit "enumerate HKLM" \
+	test_enumerate HKLM || \
+	failed=`expr $failed + 1`
+
+testit "enumerate nonexisting hive" \
+	test_enumerate_nonexisting XYZ || \
+	failed=`expr $failed + 1`


-- 
Samba Shared Repository


More information about the samba-cvs mailing list