[SCM] Samba Shared Repository - branch master updated

Andreas Schneider asn at samba.org
Fri Jul 17 20:10:04 UTC 2015


The branch, master has been updated
       via  1f90bb6 selftest: Add test for the dfree command
       via  f1f3028 s3-smbd: Remove the global dfree_broken variable
       via  48a4d5a s3-smbd: Leave sys_disk_free() if dfree command is used
      from  323e4f8 s3:winbindd: initialize dst->primary_gid with (gid_t)-1

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


- Log -----------------------------------------------------------------
commit 1f90bb60499eabf1927ed038838ee9b3f34ad624
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Jul 14 16:30:35 2015 +0200

    selftest: Add test for the dfree command
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    
    Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
    Autobuild-Date(master): Fri Jul 17 22:09:34 CEST 2015 on sn-devel-104

commit f1f30286d5be59eae93f915048ff014593d7641c
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Jul 17 09:37:52 2015 +0200

    s3-smbd: Remove the global dfree_broken variable
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 48a4d5a4078ff2a66dd753323d6e5d76d34b9828
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Jul 17 09:35:11 2015 +0200

    s3-smbd: Leave sys_disk_free() if dfree command is used
    
    If we have a broken system which reports incorrect sizes we provide the
    'dfree command'. This command makes sure Samba gets the correct values.
    However after that we call the quota command which then reports the
    broken values. The dfree command should take care to provide the correct
    values and in case of quota's it should also calculate the quote
    correctly.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11403
    
    Pair-Programmed-With: Michael Adam <obnox at samba.org>
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

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

Summary of changes:
 selftest/target/Samba3.pm                  |  8 +++++
 source3/script/tests/test_dfree_command.sh | 51 ++++++++++++++++++++++++++++++
 source3/selftest/tests.py                  |  1 +
 source3/smbd/dfree.c                       | 30 ++++++++----------
 source3/smbd/globals.c                     |  3 --
 source3/smbd/globals.h                     |  2 --
 testprogs/blackbox/dfree.sh                |  2 ++
 7 files changed, 76 insertions(+), 21 deletions(-)
 create mode 100755 source3/script/tests/test_dfree_command.sh
 create mode 100755 testprogs/blackbox/dfree.sh


Changeset truncated at 500 lines:

diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index 03c78f2..9af8faa 100755
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -563,6 +563,7 @@ sub setup_fileserver($$)
 {
 	my ($self, $path) = @_;
 	my $prefix_abs = abs_path($path);
+	my $srcdir_abs = abs_path($self->{srcdir});
 
 	print "PROVISIONING file server ...\n";
 
@@ -579,6 +580,9 @@ sub setup_fileserver($$)
 	my $lower_case_share_dir_30000="$share_dir/lower-case-30000";
 	push(@dirs, $lower_case_share_dir_30000);
 
+	my $dfree_share_dir="$share_dir/dfree";
+	push(@dirs, $dfree_share_dir);
+
 	my $fileserver_options = "
 [lowercase]
 	path = $lower_case_share_dir
@@ -594,6 +598,10 @@ sub setup_fileserver($$)
 	default case = lower
 	preserve case = no
 	short preserve case = no
+[dfree]
+	path = $dfree_share_dir
+	comment = smb username is [%U]
+	dfree command = $srcdir_abs/testprogs/blackbox/dfree.sh
 	";
 
 	my $vars = $self->provision($path,
diff --git a/source3/script/tests/test_dfree_command.sh b/source3/script/tests/test_dfree_command.sh
new file mode 100755
index 0000000..c9c3aa6
--- /dev/null
+++ b/source3/script/tests/test_dfree_command.sh
@@ -0,0 +1,51 @@
+#!/bin/sh
+#
+# Blackbox test for 'dfree command'
+#
+
+if [ $# -lt 6 ]; then
+cat <<EOF
+Usage: test_dfree_command.sh SERVER DOMAIN USERNAME PASSWORD PREFIX SMBCLIENT
+EOF
+exit 1;
+fi
+
+SERVER=$1
+DOMAIN=$2
+USERNAME=$3
+PASSWORD=$4
+PREFIX=$5
+smbclient=$6
+shift 6
+failed=0
+
+incdir=`dirname $0`/../../../testprogs/blackbox
+. $incdir/subunit.sh
+
+test_smbclient_dfree() {
+	name="$1"
+	share="$2"
+	cmd="$3"
+	shift
+	shift
+	subunit_start_test "$name"
+	output=$($VALGRIND $smbclient //$SERVER/$share -c "$cmd" $@ 2>&1)
+	status=$?
+	if [ x$status = x0 ]; then
+		echo "$output" | grep "2000 blocks of size 1024. 20 blocks available" >/dev/null
+		status=$?
+		if [ x$status = x0 ]; then
+			subunit_pass_test "$name"
+		else
+			echo "$output" | subunit_fail_test "$name"
+		fi
+	else
+		echo "$output" | subunit_fail_test "$name"
+	fi
+	return $status
+}
+
+
+test_smbclient_dfree "Test dfree command" dfree "l" -U$USERNAME%$PASSWORD || failed=`expr $failed + 1`
+
+exit $failed
diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
index 1f6174c..1833b9f 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -176,6 +176,7 @@ for env in ["nt4_dc"]:
 
 for env in ["fileserver"]:
     plantestsuite("samba3.blackbox.preserve_case (%s)" % env, env, [os.path.join(samba3srcdir, "script/tests/test_preserve_case.sh"), '$SERVER', '$DOMAIN', '$USERNAME', '$PASSWORD', '$PREFIX', smbclient3])
+    plantestsuite("samba3.blackbox.dfree_command (%s)" % env, env, [os.path.join(samba3srcdir, "script/tests/test_dfree_command.sh"), '$SERVER', '$DOMAIN', '$USERNAME', '$PASSWORD', '$PREFIX', smbclient3])
 
     #
     # tar command tests
diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c
index bcefea5..32a3a69 100644
--- a/source3/smbd/dfree.c
+++ b/source3/smbd/dfree.c
@@ -57,6 +57,7 @@ uint64_t sys_disk_free(connection_struct *conn, const char *path,
 	uint64_t bsize_q = 0;
 	uint64_t dsize_q = 0;
 	const char *dfree_command;
+	static bool dfree_broken = false;
 
 	(*dfree) = (*dsize) = 0;
 	(*bsize) = 512;
@@ -83,7 +84,7 @@ uint64_t sys_disk_free(connection_struct *conn, const char *path,
 		DEBUG (3, ("disk_free: Running command '%s'\n", syscmd));
 
 		lines = file_lines_pload(syscmd, NULL);
-		if (lines) {
+		if (lines != NULL) {
 			char *line = lines[0];
 
 			DEBUG (3, ("Read input from dfree, \"%s\"\n", line));
@@ -107,22 +108,18 @@ uint64_t sys_disk_free(connection_struct *conn, const char *path,
 				*dsize = 2048;
 			if (!*dfree)
 				*dfree = 1024;
-		} else {
-			DEBUG (0, ("disk_free: file_lines_load() failed for "
-				   "command '%s'. Error was : %s\n",
-				   syscmd, strerror(errno) ));
-			if (sys_fsusage(path, dfree, dsize) != 0) {
-				DEBUG (0, ("disk_free: sys_fsusage() failed. Error was : %s\n",
-					strerror(errno) ));
-				return (uint64_t)-1;
-			}
-		}
-	} else {
-		if (sys_fsusage(path, dfree, dsize) != 0) {
-			DEBUG (0, ("disk_free: sys_fsusage() failed. Error was : %s\n",
-				strerror(errno) ));
-			return (uint64_t)-1;
+
+			goto dfree_done;
 		}
+		DEBUG (0, ("disk_free: file_lines_load() failed for "
+			   "command '%s'. Error was : %s\n",
+			   syscmd, strerror(errno) ));
+	}
+
+	if (sys_fsusage(path, dfree, dsize) != 0) {
+		DEBUG (0, ("disk_free: sys_fsusage() failed. Error was : %s\n",
+			strerror(errno) ));
+		return (uint64_t)-1;
 	}
 
 	if (disk_quotas(path, &bsize_q, &dfree_q, &dsize_q)) {
@@ -146,6 +143,7 @@ uint64_t sys_disk_free(connection_struct *conn, const char *path,
 		*dfree = MAX(1,*dfree);
 	}
 
+dfree_done:
 	disk_norm(bsize, dfree, dsize);
 
 	if ((*bsize) < 1024) {
diff --git a/source3/smbd/globals.c b/source3/smbd/globals.c
index 03339b7..a501234 100644
--- a/source3/smbd/globals.c
+++ b/source3/smbd/globals.c
@@ -31,9 +31,6 @@ int outstanding_aio_calls = 0;
 struct smbd_dmapi_context *dmapi_ctx = NULL;
 #endif
 
-
-bool dfree_broken = false;
-
 /* how many write cache buffers have been allocated */
 unsigned int allocated_write_caches = 0;
 
diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h
index 2ca23aa..35a3ee9 100644
--- a/source3/smbd/globals.h
+++ b/source3/smbd/globals.h
@@ -30,8 +30,6 @@ struct smbd_dmapi_context;
 extern struct smbd_dmapi_context *dmapi_ctx;
 #endif
 
-extern bool dfree_broken;
-
 /* how many write cache buffers have been allocated */
 extern unsigned int allocated_write_caches;
 
diff --git a/testprogs/blackbox/dfree.sh b/testprogs/blackbox/dfree.sh
new file mode 100755
index 0000000..2da3cbd
--- /dev/null
+++ b/testprogs/blackbox/dfree.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+echo "1000 10 2048"


-- 
Samba Shared Repository



More information about the samba-cvs mailing list