[SCM] Samba Shared Repository - branch master updated

Andrew Bartlett abartlet at samba.org
Wed Aug 15 18:56:02 MDT 2012


The branch, master has been updated
       via  97e7c3b s3-selftest: convert xattr-tdb-1 vfstest driver into a subunit test
       via  748d8f5 s3-selftest: convert stream_depot vfstest driver into a subunit test
       via  08baa11 fix printf warning in net connections
       via  31980cf s3:utils: remove standalone cclean tool
       via  37ed821 s3:doc manpage for "net connections cleanup"
       via  1c2bae0 s3:net add command "connections cleanup"
      from  65976d6 s3-vfs: Set errno in xattr emulation

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 97e7c3b8bd84edd69f6344249b24ae64e2a8b0fe
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Aug 16 08:55:43 2012 +1000

    s3-selftest: convert xattr-tdb-1 vfstest driver into a subunit test
    
    We don't use the simple smb.conf because we need to override all the
    paths for this to work as non-root without a panic, so we use the s3dc
    environment, which already loads this module.
    
    Andrew Bartlett
    
    Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date(master): Thu Aug 16 02:55:19 CEST 2012 on sn-devel-104

commit 748d8f5310501bb585c9be1b261554ec690a3132
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Aug 16 08:37:54 2012 +1000

    s3-selftest: convert stream_depot vfstest driver into a subunit test
    
    This gives us our first automated coverage of the vfstest binary.
    
    We don't use the simple smb.conf because we need to override all the
    paths for this to work as non-root without a panic, so we use the s3dc
    environment, which already loads this module.
    
    Andrew Bartlett

commit 08baa11ab869551f61dc7a7d363587b70582ffeb
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Aug 16 07:47:57 2012 +1000

    fix printf warning in net connections

commit 31980cf5cb9fd6238d1ed096e885410e85d5ac00
Author: Gregor Beck <gbeck at sernet.de>
Date:   Fri Jul 13 15:31:16 2012 +0200

    s3:utils: remove standalone cclean tool
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>

commit 37ed821798a0c141efe01096f3669f8fb9a62928
Author: Gregor Beck <gbeck at sernet.de>
Date:   Mon Jul 16 15:10:46 2012 +0200

    s3:doc manpage for "net connections cleanup"
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>

commit 1c2bae062d202c69d5b92b634f6b9ced3ea2a0ba
Author: Gregor Beck <gbeck at sernet.de>
Date:   Mon Jul 16 09:34:15 2012 +0200

    s3:net add command "connections cleanup"
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>

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

Summary of changes:
 docs-xml/manpages-3/net.8.xml                 |   39 +++++++
 packaging/RHEL-CTDB/samba.spec.tmpl           |    1 -
 source3/Makefile.in                           |   14 +--
 source3/script/tests/stream-depot/run.sh      |   37 ++++++-
 source3/script/tests/stream-depot/smb.conf    |    5 -
 source3/script/tests/xattr-tdb-1/run.sh       |   55 +++++++++-
 source3/script/tests/xattr-tdb-1/smb.conf     |    5 -
 source3/selftest/tests.py                     |    5 +
 source3/utils/net.c                           |    7 ++
 source3/utils/{cclean.c => net_connections.c} |  144 ++++++++++---------------
 source3/utils/net_proto.h                     |    4 +
 source3/wscript_build                         |   14 +---
 12 files changed, 196 insertions(+), 134 deletions(-)
 delete mode 100644 source3/script/tests/stream-depot/smb.conf
 delete mode 100644 source3/script/tests/xattr-tdb-1/smb.conf
 rename source3/utils/{cclean.c => net_connections.c} (64%)


Changeset truncated at 500 lines:

diff --git a/docs-xml/manpages-3/net.8.xml b/docs-xml/manpages-3/net.8.xml
index c85f87f..7a7ca6d 100644
--- a/docs-xml/manpages-3/net.8.xml
+++ b/docs-xml/manpages-3/net.8.xml
@@ -2112,6 +2112,45 @@ string.</member>
 </refsect2>
 
 <refsect2>
+<title>CONNECTIONS</title>
+<para>
+Manipulate Samba's connections database.
+</para>
+
+<para>The registry commands are:
+<simplelist>
+<member>net connections cleanup - Remove orphaned entries from the connections database.</member>
+</simplelist>
+</para>
+
+<refsect3>
+  <title>CONNECTIONS CLEANUP [-avT]</title>
+  <para> Remove orphaned entries from the connections database. This may be necessary if restarting smbd isn't an option.
+  <variablelist>
+    <varlistentry><term>-a|--auto</term>
+    <listitem><para>
+      Noninteractive mode, don't ask.
+    </para></listitem>
+    </varlistentry>
+
+    <varlistentry><term>-v|--verbose</term>
+      <listitem><para>
+	Produce more output.
+      </para></listitem>
+    </varlistentry>
+
+    <varlistentry><term>-T|--test</term>
+      <listitem><para>
+	Dry run, show what changes would be made but don't touch anything.
+      </para></listitem>
+    </varlistentry>
+  </variablelist>
+  </para>
+</refsect3>
+
+</refsect2>
+
+<refsect2>
 <title>EVENTLOG</title>
 
 <para>Starting with version 3.4.0 net can read, dump, import and export native
diff --git a/packaging/RHEL-CTDB/samba.spec.tmpl b/packaging/RHEL-CTDB/samba.spec.tmpl
index 7d68d27..a9111d2 100644
--- a/packaging/RHEL-CTDB/samba.spec.tmpl
+++ b/packaging/RHEL-CTDB/samba.spec.tmpl
@@ -399,7 +399,6 @@ exit 0
 %{_bindir}/tdbdump
 %{_bindir}/tdbrestore
 %{_bindir}/eventlogadm
-%{_bindir}/cclean
 
 %{_libarchdir}/samba/auth/script.so
 %{_libarchdir}/samba/vfs/acl_tdb.so
diff --git a/source3/Makefile.in b/source3/Makefile.in
index 2635cfa..38e8bb1 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -212,7 +212,7 @@ SBIN_PROGS = bin/smbd bin/nmbd @SWAT_SBIN_TARGETS@ @EXTRA_SBIN_PROGS@
 
 BIN_PROGS1 = bin/smbclient bin/net bin/smbspool \
 	bin/testparm bin/smbstatus bin/smbget \
-	bin/smbta-util bin/cclean
+	bin/smbta-util
 BIN_PROGS2 = bin/smbcontrol bin/smbtree $(TDBBACKUP) \
 	bin/nmblookup bin/pdbedit $(TDBDUMP) \
 	$(TDBRESTORE) $(TDBTOOL) bin/dbwrap_tool
@@ -1055,11 +1055,6 @@ STATUS_OBJ = utils/status.o utils/status_profile.o \
              $(PROFILE_OBJ) $(LIB_NONSMBD_OBJ) $(POPT_LIB_OBJ) \
 	     $(LIBSMB_ERR_OBJ) $(FNAME_UTIL_OBJ)
 
-CCLEAN_OBJ = utils/cclean.o utils/interact.o \
-	$(LOCKING_OBJ) $(PARAM_OBJ) \
-        $(PROFILE_OBJ) $(LIB_NONSMBD_OBJ) $(POPT_LIB_OBJ) \
-        $(LIBSMB_ERR_OBJ) $(FNAME_UTIL_OBJ)
-
 
 SMBCONTROL_OBJ = utils/smbcontrol.o $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) \
 	$(LIBSMB_ERR_OBJ) $(POPT_LIB_OBJ) $(PRINTBASE_OBJ)
@@ -1226,7 +1221,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_join.o utils/net_user.o \
 	   utils/net_group.o utils/net_file.o utils/net_registry.o utils/net_registry_check.o\
-	   auth/token_util.o utils/net_dom.o utils/net_share.o \
+	   auth/token_util.o utils/net_dom.o utils/net_share.o utils/net_connections.o\
 	   utils/net_g_lock.o \
 	   utils/net_serverid.o \
 	   utils/net_eventlog.o \
@@ -1953,11 +1948,6 @@ bin/smbstatus: $(BINARY_PREREQS) $(STATUS_OBJ) @BUILD_POPT@ $(LIBTALLOC) $(LIBTD
 	@$(CC) -o $@ $(STATUS_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \
 		$(LDAP_LIBS) $(POPT_LIBS) $(LIBTALLOC_LIBS) $(LIBTDB_LIBS)
 
-bin/cclean: $(BINARY_PREREQS) $(CCLEAN_OBJ) @BUILD_POPT@ $(LIBTALLOC) $(LIBTDB)
-	@echo Linking $@
-	@$(CC) -o $@ $(CCLEAN_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \
-		$(LDAP_LIBS) $(POPT_LIBS) $(LIBTALLOC_LIBS) $(LIBTDB_LIBS)
-
 bin/smbcontrol: $(BINARY_PREREQS) $(SMBCONTROL_OBJ) @BUILD_POPT@ $(LIBTALLOC) $(LIBTDB)
 	@echo Linking $@
 	@$(CC) -DUSING_SMBCONTROL -o $@ \
diff --git a/source3/script/tests/stream-depot/run.sh b/source3/script/tests/stream-depot/run.sh
index f1e75fb..38ef283 100755
--- a/source3/script/tests/stream-depot/run.sh
+++ b/source3/script/tests/stream-depot/run.sh
@@ -1,9 +1,36 @@
 #!/bin/sh
-rm -r .streams
-../../../bin/vfstest -s smb.conf -f vfstest.cmd
+if [ $# -lt 2 ]; then
+cat <<EOF
+Usage: run.sh VFSTEST PREFIX
+EOF
+exit 1;
+fi
+
+TESTBASE=`dirname $0`
+VFSTEST=$1
+PREFIX=$2
+shift 2
+ADDARGS="$*"
+
+VFSTEST_PREFIX=vfstest
+VFSTEST_TMPDIR=$(mktemp -d ${PREFIX}/${VFSTEST_PREFIX}_XXXXXX)
+
+incdir=`dirname $0`/../../../../testprogs/blackbox
+. $incdir/subunit.sh
+
+failed=0
+
+cd $VFSTEST_TMPDIR || exit 1
+
+testit "vfstest" $VFSTEST -f $TESTBASE/vfstest.cmd $ADDARGS || failed=`expr $failed + 1`
+testname=".streams check"
+subunit_start_test $testname
 NUM=`find .streams | wc -l`
 if [ $NUM -ne 3 ] ; then
-    echo "streams_depot left ${NUM} in .streams, expected 3"
-    exit 1
+echo "streams_depot left ${NUM} in .streams, expected 3" | subunit_fail_test $testname
+    failed=`expr $failed + 1`
+else 
+    subunit_pass_test $testname
 fi
-exit 0
+
+exit $failed
diff --git a/source3/script/tests/stream-depot/smb.conf b/source3/script/tests/stream-depot/smb.conf
deleted file mode 100644
index 426d23c..0000000
--- a/source3/script/tests/stream-depot/smb.conf
+++ /dev/null
@@ -1,5 +0,0 @@
-[tmp]
-# "path" is ignored by vfstest, it's always set to $(pwd)
-path = /tmp
-writable = yes
-vfs objects =  streams_depot xattr_tdb
diff --git a/source3/script/tests/xattr-tdb-1/run.sh b/source3/script/tests/xattr-tdb-1/run.sh
index 2a1b6af..ea7a4cb 100755
--- a/source3/script/tests/xattr-tdb-1/run.sh
+++ b/source3/script/tests/xattr-tdb-1/run.sh
@@ -1,7 +1,52 @@
 #!/bin/sh
-if ../../../bin/vfstest -s smb.conf -f vfstest.cmd |
-    grep "NT_STATUS_ACCESS_DENIED" > /dev/null 2>&1
-then
-    exit 1
+if [ $# -lt 2 ]; then
+cat <<EOF
+Usage: run.sh VFSTEST PREFIX
+EOF
+exit 1;
 fi
-exit 0
+
+TESTBASE=`dirname $0`
+VFSTEST=$1
+PREFIX=$2
+shift 2
+ADDARGS="$*"
+
+VFSTEST_PREFIX=vfstest
+VFSTEST_TMPDIR=$(mktemp -d ${PREFIX}/${VFSTEST_PREFIX}_XXXXXX)
+
+incdir=`dirname $0`/../../../../testprogs/blackbox
+. $incdir/subunit.sh
+
+failed=0
+
+cd $VFSTEST_TMPDIR || exit 1
+
+test_vfstest() 
+{
+    cmd='$VFSTEST -f $TESTBASE/vfstest.cmd $ADDARGS '
+    out=`eval $cmd`
+    ret=$?
+    rm -f $tmpfile
+
+    if [ $ret != 0 ] ; then
+	echo "$out"
+	echo "command failed"
+	false
+	return
+    fi
+
+    echo "$out" | grep "NT_STATUS_ACCESS_DENIED" >/dev/null 2>&1
+
+    if [ $? = 0 ] ; then
+	# got ACCESS_DENIED .. fail
+	echo vfstest got NT_STATUS_ACCESS_DENIED
+	false
+    else
+	true
+    fi
+}
+
+testit "vfstest" test_vfstest || failed=`expr $failed + 1`
+
+exit $failed
diff --git a/source3/script/tests/xattr-tdb-1/smb.conf b/source3/script/tests/xattr-tdb-1/smb.conf
deleted file mode 100644
index 259b630..0000000
--- a/source3/script/tests/xattr-tdb-1/smb.conf
+++ /dev/null
@@ -1,5 +0,0 @@
-[tmp]
-# "path" is ignored by vfstest, it's always set to $(pwd)
-path = /tmp
-writable = yes
-vfs objects = xattr_tdb
diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
index 945d26a..84e8d1e 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -33,6 +33,7 @@ net = binpath('net')
 smbtorture3 = binpath('smbtorture3')
 ntlm_auth = binpath('ntlm_auth3')
 dbwrap_tool = binpath('dbwrap_tool')
+vfstest = binpath('vfstest')
 
 torture_options = [configuration, "--maximum-runtime=$SELFTEST_MAXTIME", 
                    "--basedir=$SELFTEST_TMPDIR",
@@ -154,6 +155,10 @@ tests=["--ping", "--separator",
        "--allocate-uid",
        "--allocate-gid"]
 
+plantestsuite("samba.vfstest.stream_depot", "s3dc:local", [os.path.join(samba3srcdir, "script/tests/stream-depot/run.sh"), binpath("vfstest"), "$PREFIX", configuration])
+
+plantestsuite("samba.vfstest.xattr-tdb-1", "s3dc:local", [os.path.join(samba3srcdir, "script/tests/xattr-tdb-1/run.sh"), binpath("vfstest"), "$PREFIX", configuration])
+
 for options in ["--option=clientusespnego=no", " --option=clientntlmv2auth=no --option=clientlanmanauth=yes --max-protocol=LANMAN2", ""]:
     env = "s3dc"
     plantestsuite("samba3.blackbox.smbclient_auth.plain (%s) %s" % (env, options), env, [os.path.join(samba3srcdir, "script/tests/test_smbclient_auth.sh"), '$SERVER', '$SERVER_IP', '$DC_USERNAME', '$DC_PASSWORD', smbclient, configuration, options])
diff --git a/source3/utils/net.c b/source3/utils/net.c
index eccb522..075ccc1 100644
--- a/source3/utils/net.c
+++ b/source3/utils/net.c
@@ -715,6 +715,13 @@ static struct functable net_func[] = {
 		N_("  Use 'net help registry' to get more information about "
 		   "'net registry' commands.")
 	},
+	{	"connections",
+		net_connections,
+		NET_TRANSPORT_LOCAL,
+		N_("Fiddle with connectinos tdb"),
+		N_("  Use 'net help connections' to get more information about "
+		   "'net connections' commands.")
+	},
 	{	"eventlog",
 		net_eventlog,
 		NET_TRANSPORT_LOCAL,
diff --git a/source3/utils/cclean.c b/source3/utils/net_connections.c
similarity index 64%
rename from source3/utils/cclean.c
rename to source3/utils/net_connections.c
index 2084117..b713ed9 100644
--- a/source3/utils/cclean.c
+++ b/source3/utils/net_connections.c
@@ -1,23 +1,26 @@
 /*
-   Unix SMB/CIFS implementation.
-   cleanup connections tdb
-   Copyright (C) Gregor Beck 2012
-
-   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/>.
-*/
+ * Samba Unix/Linux SMB client library
+ * Distributed SMB/CIFS Server Management Utility
+ * fiddle with connections tdb
+ *
+ * Copyright (C) Gregor Beck 2012
+ *
+ * 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 "net.h"
 #include "serverid.h"
 #include "popt_common.h"
 #include "dbwrap/dbwrap.h"
@@ -27,10 +30,6 @@
 #include "interact.h"
 #include "lib/conn_tdb.h"
 
-static bool verbose = false;
-static bool dry_run = false;
-static bool automatic = false;
-
 struct cclean_ctx {
 	struct server_id *ids;
 	int *cnums;
@@ -39,6 +38,9 @@ struct cclean_ctx {
 
 	bool *exists;
 	unsigned num_orphans;
+
+	bool verbose;
+	bool dry_run;
 };
 
 
@@ -93,7 +95,7 @@ static int read_connections_fn(const struct connections_key *key,
 		ctx->names = (const char **)tmp;
 	}
 
-	if (verbose) {
+	if (ctx->verbose) {
 		print_record("Read", key, data);
 	}
 
@@ -176,7 +178,7 @@ static int delete_orphans(struct cclean_ctx *ctx)
 				     (struct connections_key *)key.dptr,
 				     (struct connections_data *)value.dptr);
 
-			if (!dry_run) {
+			if (!ctx->dry_run) {
 				status = dbwrap_record_delete(conn);
 				if (!NT_STATUS_IS_OK(status)) {
 					DEBUG(0, ("Failed to delete record: %s\n",
@@ -190,10 +192,17 @@ static int delete_orphans(struct cclean_ctx *ctx)
 	return ret;
 }
 
-static int cclean(void)
+static int cclean(bool verbose, bool dry_run, bool automatic)
 {
 	int ret;
 	struct cclean_ctx *ctx = talloc_zero(talloc_tos(), struct cclean_ctx);
+	if (ctx == NULL) {
+		d_printf("Out of memory\n");
+		goto done;
+	}
+
+	ctx->verbose = verbose;
+	ctx->dry_run = dry_run;
 
 	ret = read_connections(ctx);
 	if (ret != 0) {
@@ -229,77 +238,36 @@ done:
 	return ret;
 }
 
-int main(int argc, const char *argv[])
+static int net_connections_cleanup(struct net_context *c,
+				   int argc, const char **argv)
 {
-	int ret = -1;
-	TALLOC_CTX *frame = talloc_stackframe();
-	poptContext pc;
-	char opt;
-	struct poptOption long_options[] = {
-		POPT_AUTOHELP
-		{"verbose",	'v', POPT_ARG_NONE, NULL, 'v', "Be verbose" },
-		{"auto",	'a', POPT_ARG_NONE, NULL, 'a', "Don't ask" },
-		{"test",	'T', POPT_ARG_NONE, NULL, 'T', "Dry run" },
-		POPT_COMMON_SAMBA
-		POPT_TABLEEND
-	};
-	struct tevent_context *evt_ctx = NULL;
-	struct messaging_context *msg_ctx = NULL;
-
-	load_case_tables();
-	setup_logging(argv[0], DEBUG_STDERR);
-
-	pc = poptGetContext(NULL, argc, (const char **) argv, long_options,
-			    POPT_CONTEXT_KEEP_FIRST);
-	while ((opt = poptGetNextOpt(pc)) != -1) {
-		switch (opt) {
-		case 'v':
-			verbose = true;
-			break;
-		case 'a':
-			automatic = true;
-			break;
-		case 'T':
-			dry_run = true;
-			break;
-		}
-	}
-
-	DEBUG(1, ("using configfile = %s\n", get_dyn_CONFIGFILE()));
+	return cclean(c->opt_verbose, c->opt_testmode, c->opt_auto);
+}
 
-	if (!lp_load_initial_only(get_dyn_CONFIGFILE())) {
-		DEBUG(0, ("Can't load %s - run testparm to debug it\n",
-			  get_dyn_CONFIGFILE()));
-		goto done;
-	}
+int net_connections(struct net_context *c, int argc, const char **argv)
+{
+	int ret = -1;
 
-	if (lp_clustering()) {
-		evt_ctx = event_context_init(frame);
-		if (evt_ctx == NULL) {
-			DEBUG(0, ("tevent_context_init failed\n"));
-			goto done;
-		}
+	struct functable func[] = {
+		{
+			"cleanup",
+			net_connections_cleanup,
+			NET_TRANSPORT_LOCAL,
+			N_("Remove orphaned entries from connections.tdb"),
+			N_("net connections cleanup\n"
+			   "    Remove orphaned entries from connections.tdb")
+		},
+		{ NULL, NULL, 0, NULL, NULL }
+	};
 
-		msg_ctx = messaging_init(frame, evt_ctx);
-		if (msg_ctx == NULL) {
-			DEBUG(0, ("messaging_init failed\n"));
-			goto done;
+	if (!c->display_usage) {
+		if (!connections_init(!c->opt_testmode)) {
+			DEBUG(0, ("Failed to open connections tdb\n"));
+			return -1;
 		}
 	}
 
-	if (!lp_load_global(get_dyn_CONFIGFILE())) {
-		DEBUG(0, ("Can't load %s - run testparm to debug it\n",
-			  get_dyn_CONFIGFILE()));
-		goto done;
-	}
+	ret = net_run_function(c, argc, argv, "net connections", func);
 
-	if (!connections_init(!dry_run)) {
-		DEBUG(0, ("Failed to open connections tdb\n"));
-		goto done;
-	}
-
-	ret = cclean();
-done:
-	talloc_free(frame);
 	return ret;
 }
diff --git a/source3/utils/net_proto.h b/source3/utils/net_proto.h
index 3f99e14..a683abb 100644
--- a/source3/utils/net_proto.h
+++ b/source3/utils/net_proto.h
@@ -132,6 +132,10 @@ int net_rap(struct net_context *c, int argc, const char **argv);
 
 int net_registry(struct net_context *c, int argc, const char **argv);
 
+/* The following definitions come from utils/net_connections.c  */
+
+int net_connections(struct net_context *c, int argc, const char **argv);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list