[SCM] Samba Shared Repository - branch master updated

Michael Adam obnox at samba.org
Wed Dec 11 11:56:04 MST 2013


The branch, master has been updated
       via  27baff0 shadow_copy2: add a comment explaining why we don't talloc_zero_array().
       via  71318d7 shadow_copy2: revert expensive and unnecessary zero-initialization
       via  5aade72 lib:util: fix a comment typo
       via  ae6a13e s3: use directory_create_or_exist_strict() to create corepath
       via  dfff019 selftest: pass -l logdir to daemon processes.
       via  2846a7d selftest: use MALLOC_CHECK_=3 to give a diagnostic on failure
       via  c140fe0 selftest: set valgrind options
       via  db9188f selftest: setup {NMBD,WINBINDD,SMBD}_VALGRIND
       via  a32366e selftest/Samba3: export ENVNAME
      from  c16afdd docs: Fix typos in vfs_shadow_copy2.8.xml.

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


- Log -----------------------------------------------------------------
commit 27baff0ec96cded0446ecd7739e9d31aaeb90868
Author: Michael Adam <obnox at samba.org>
Date:   Wed Dec 11 09:41:38 2013 +0100

    shadow_copy2: add a comment explaining why we don't talloc_zero_array().
    
    Since I stumbled over this slighly sublte point, I thought it is
    worthwile to point it our in a comment.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    
    Autobuild-User(master): Michael Adam <obnox at samba.org>
    Autobuild-Date(master): Wed Dec 11 19:55:20 CET 2013 on sn-devel-104

commit 71318d7d685f8e1e112076f84ef2d788acb83547
Author: Michael Adam <obnox at samba.org>
Date:   Wed Dec 11 09:34:47 2013 +0100

    shadow_copy2: revert expensive and unnecessary zero-initialization
    
    I was being overly cautious. This is initialization is not
    necessary, since further down in the for-loop, the memory
    always gets fully initialized because the insert string is
    inserted at various slash positions.
    
    So this talloc_zero_array can be skipped: this an expensive
    thing to do in virtually every VFS call.
    
    This essentially reverts commit 249e9b4a34d8959bd94735c1921ecfc24d6a2705.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 5aade722cc56ae0d9388dbc4d061c99ebde05214
Author: Michael Adam <obnox at samba.org>
Date:   Wed Dec 11 17:47:36 2013 +0100

    lib:util: fix a comment typo
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit ae6a13eecb8cf368c49ec069a395865fba6765f1
Author: Gregor Beck <gbeck at sernet.de>
Date:   Mon Apr 22 13:33:00 2013 +0200

    s3: use directory_create_or_exist_strict() to create corepath
    
    This simplifies the code and even works in testenv where the chown call
    fails.
    
    Signed-off-by: Gregor Beck <gbeck at sernet.de>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit dfff01910be57d0f693f3539dac010859ecb01c9
Author: Gregor Beck <gbeck at sernet.de>
Date:   Mon Apr 22 12:35:01 2013 +0200

    selftest: pass -l logdir to daemon processes.
    
    The daemons try to set up the corefile path within logdir before the config
    file was read.
    
    Signed-off-by: Gregor Beck <gbeck at sernet.de>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 2846a7d0accf87542b42b08077b7848871261b79
Author: Gregor Beck <gbeck at sernet.de>
Date:   Wed Mar 20 10:58:22 2013 +0100

    selftest: use MALLOC_CHECK_=3 to give a diagnostic on failure
    
    With MALLOC_CHECK_ set to 2 in case of a failure abort() is called
    silently which hopefully creates a core dump.
    MALLOC_CHECK_=3 additionally gives an error message on stderr in case.
    
    Signed-off-by: Gregor Beck <gbeck at sernet.de>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit c140fe0e146f9d6d6fc563d6ad181ae2513e9a91
Author: Gregor Beck <gbeck at sernet.de>
Date:   Wed Mar 20 10:36:37 2013 +0100

    selftest: set valgrind options
    
    In particular '--db-attach' interferes badly with the io redirection of the
    test environment and is superseded by the vgdb feature of valgrind.
    
    Signed-off-by: Gregor Beck <gbeck at sernet.de>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit db9188fbffb538b840d7e17fa3d1fc6dd215b3da
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Mar 19 15:44:02 2013 +0100

    selftest: setup {NMBD,WINBINDD,SMBD}_VALGRIND
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit a32366e973c35ef08b890d30b0ac742820a92274
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Mar 19 15:43:12 2013 +0100

    selftest/Samba3: export ENVNAME
    
    This is used by selftest/in_screen.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

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

Summary of changes:
 lib/util/util.c                    |    2 +-
 selftest/selftest.pl               |    2 +-
 selftest/selftest.py               |    2 +-
 selftest/target/Samba3.pm          |   20 ++++++++++++++++----
 selftest/valgrind_run              |    6 +++++-
 selftest/wscript                   |    3 +++
 source3/lib/dumpcore.c             |   33 +++++++++++++++++----------------
 source3/modules/vfs_shadow_copy2.c |   11 ++++++++++-
 8 files changed, 54 insertions(+), 25 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/util/util.c b/lib/util/util.c
index 3e9047c..2080884 100644
--- a/lib/util/util.c
+++ b/lib/util/util.c
@@ -234,7 +234,7 @@ _PUBLIC_ bool directory_create_or_exist(const char *dname,
  * @brief Try to create a specified directory if it doesn't exist.
  *
  * The function creates a directory with the given uid and permissions if it
- * doesn't exixt. If it exists it makes sure the uid and permissions are
+ * doesn't exist. If it exists it makes sure the uid and permissions are
  * correct and it will fail if they are different.
  *
  * @param[in]  dname  The directory to create.
diff --git a/selftest/selftest.pl b/selftest/selftest.pl
index b60b762..c74eff1 100755
--- a/selftest/selftest.pl
+++ b/selftest/selftest.pl
@@ -256,7 +256,7 @@ my @tests = @ARGV;
 # quick hack to disable rpc validation when using valgrind - its way too slow
 unless (defined($ENV{VALGRIND})) {
 	$ENV{VALIDATE} = "validate";
-	$ENV{MALLOC_CHECK_} = 2;
+	$ENV{MALLOC_CHECK_} = 3;
 }
 
 # make all our python scripts unbuffered
diff --git a/selftest/selftest.py b/selftest/selftest.py
index 2da1ef8..8a1999a 100755
--- a/selftest/selftest.py
+++ b/selftest/selftest.py
@@ -153,7 +153,7 @@ tests = args
 # quick hack to disable rpc validation when using valgrind - it is way too slow
 if not os.environ.get("VALGRIND"):
     os.environ["VALIDATE"] = "validate"
-    os.environ["MALLOC_CHECK_"] = "2"
+    os.environ["MALLOC_CHECK_"] = "3"
 
 # make all our python scripts unbuffered
 os.environ["PYTHONUNBUFFERED"] = "1"
diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index e4a2417..573b8e1 100755
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -166,7 +166,9 @@ sub check_env($$)
 sub setup_env($$$)
 {
 	my ($self, $envname, $path) = @_;
-	
+
+	$ENV{ENVNAME} = $envname;
+
 	if (defined($self->{vars}->{$envname})) {
 	        return $self->{vars}->{$envname};
 	}
@@ -643,6 +645,8 @@ sub check_or_start($$$$$) {
 
 		$ENV{UID_WRAPPER} = "1";
 
+		$ENV{ENVNAME} = "$ENV{ENVNAME}.nmbd";
+
 		if ($nmbd ne "yes") {
 			$SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
 				my $signame = shift;
@@ -668,7 +672,8 @@ sub check_or_start($$$$$) {
 		close($env_vars->{STDIN_PIPE});
 		open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
 
-		exec(@preargs, Samba::bindir_path($self, "nmbd"), "-F", "--no-process-group", "--log-stdout", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start nmbd: $!");
+		exec(@preargs, Samba::bindir_path($self, "nmbd"), "-F", "--no-process-group", "--log-stdout", "-s", $env_vars->{SERVERCONFFILE},
+		     "-l", $env_vars->{LOGDIR}, @optargs) or die("Unable to start nmbd: $!");
 	}
 	$env_vars->{NMBD_TL_PID} = $pid;
 	write_pid($env_vars, "nmbd", $pid);
@@ -693,6 +698,8 @@ sub check_or_start($$$$$) {
 
 		$ENV{UID_WRAPPER} = "1";
 
+		$ENV{ENVNAME} = "$ENV{ENVNAME}.winbindd";
+
 		if ($winbindd ne "yes") {
 			$SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
 				my $signame = shift;
@@ -720,7 +727,8 @@ sub check_or_start($$$$$) {
 		close($env_vars->{STDIN_PIPE});
 		open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
 
-		exec(@preargs, Samba::bindir_path($self, "winbindd"), "-F", "--no-process-group", "--stdout", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start winbindd: $!");
+		exec(@preargs, Samba::bindir_path($self, "winbindd"), "-F", "--no-process-group", "--stdout", "-s", $env_vars->{SERVERCONFFILE},
+		     "-l", $env_vars->{LOGDIR}, @optargs) or die("Unable to start winbindd: $!");
 	}
 	$env_vars->{WINBINDD_TL_PID} = $pid;
 	write_pid($env_vars, "winbindd", $pid);
@@ -745,6 +753,8 @@ sub check_or_start($$$$$) {
 
 		$ENV{UID_WRAPPER} = "1";
 
+		$ENV{ENVNAME} = "$ENV{ENVNAME}.smbd";
+
 		if ($smbd ne "yes") {
 			$SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
 				my $signame = shift;
@@ -768,7 +778,8 @@ sub check_or_start($$$$$) {
 		close($env_vars->{STDIN_PIPE});
 		open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
 
-		exec(@preargs, Samba::bindir_path($self, "smbd"), "-F", "--no-process-group", "--log-stdout", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start smbd: $!");
+		exec(@preargs, Samba::bindir_path($self, "smbd"), "-F", "--no-process-group", "--log-stdout", "-s", $env_vars->{SERVERCONFFILE},
+		     "-l", $env_vars->{LOGDIR},  @optargs) or die("Unable to start smbd: $!");
 	}
 	$env_vars->{SMBD_TL_PID} = $pid;
 	write_pid($env_vars, "smbd", $pid);
@@ -1229,6 +1240,7 @@ domadmins:X:$gid_domadmins:
 	$ret{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
 	$ret{NSS_WRAPPER_WINBIND_SO_PATH} = Samba::nss_wrapper_winbind_so_path($self);
 	$ret{LOCAL_PATH} = "$shrdir";
+        $ret{LOGDIR} = $logdir;
 
 	return \%ret;
 }
diff --git a/selftest/valgrind_run b/selftest/valgrind_run
index 5171d17..f06fa86 100755
--- a/selftest/valgrind_run
+++ b/selftest/valgrind_run
@@ -4,6 +4,10 @@ ENV="$1"
 
 shift 1
 
-CMD="$ENV valgrind -q --db-attach=yes --num-callers=30 $@"
+CMD="$ENV valgrind --num-callers=30
+--trace-children=yes --log-file=valgrind.%p.log
+${VALGRIND_OPT- --time-stamp=yes --track-fds=yes --read-var-info=yes --track-origins=yes --leak-check=yes}
+$@"
+
 echo $CMD
 eval $CMD
diff --git a/selftest/wscript b/selftest/wscript
index 0c2fec8..3c5457f 100644
--- a/selftest/wscript
+++ b/selftest/wscript
@@ -168,6 +168,9 @@ def cmd_testonly(opt):
 
     if server_wrapper != '':
         os.environ['SAMBA_VALGRIND'] = EXPAND_VARIABLES(opt, server_wrapper)
+        os.environ['NMBD_VALGRIND'] = EXPAND_VARIABLES(opt, server_wrapper)
+        os.environ['WINBINDD_VALGRIND'] = EXPAND_VARIABLES(opt, server_wrapper)
+        os.environ['SMBD_VALGRIND'] = EXPAND_VARIABLES(opt, server_wrapper)
 
     # this is needed for systems without rpath, or with rpath disabled
     ADD_LD_LIBRARY_PATH('bin/shared')
diff --git a/source3/lib/dumpcore.c b/source3/lib/dumpcore.c
index 90acc16..f284ea4 100644
--- a/source3/lib/dumpcore.c
+++ b/source3/lib/dumpcore.c
@@ -43,34 +43,35 @@ static char *corepath;
  */
 static char *get_default_corepath(const char *logbase, const char *progname)
 {
+	const mode_t mode = 0700;
+	const uid_t uid = getuid();
 	char *tmp_corepath;
 
 	/* Setup core dir in logbase. */
 	tmp_corepath = talloc_asprintf(NULL, "%s/cores", logbase);
-	if (!tmp_corepath)
+	if (!tmp_corepath) {
+		DEBUG(0, ("Out of memory\n"));
 		return NULL;
+	}
 
-	if ((mkdir(tmp_corepath, 0700) == -1) && errno != EEXIST)
-		goto err_out;
-
-	if (chmod(tmp_corepath, 0700) == -1)
+	if (!directory_create_or_exist_strict(tmp_corepath, uid, mode)) {
+		DEBUG(0, ("Failed to create %s for user %d with mode 0%o\n",
+			  tmp_corepath, (int)uid, (int)mode));
 		goto err_out;
-
-	talloc_free(tmp_corepath);
+	}
 
 	/* Setup progname-specific core subdir */
-	tmp_corepath = talloc_asprintf(NULL, "%s/cores/%s", logbase, progname);
-	if (!tmp_corepath)
-		return NULL;
-
-	if (mkdir(tmp_corepath, 0700) == -1 && errno != EEXIST)
-		goto err_out;
-
-	if (chown(tmp_corepath, getuid(), getgid()) == -1)
+	tmp_corepath = talloc_asprintf_append(tmp_corepath, "/%s", progname);
+	if (!tmp_corepath) {
+		DEBUG(0, ("Out of memory\n"));
 		goto err_out;
+	}
 
-	if (chmod(tmp_corepath, 0700) == -1)
+	if (!directory_create_or_exist(tmp_corepath, uid, mode)) {
+		DEBUG(0, ("Failed to create %s for user %d with mode 0%o\n",
+			  tmp_corepath, (int)uid, (int)mode));
 		goto err_out;
+	}
 
 	return tmp_corepath;
 
diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c
index 8243f63..fca05cf 100644
--- a/source3/modules/vfs_shadow_copy2.c
+++ b/source3/modules/vfs_shadow_copy2.c
@@ -482,7 +482,16 @@ static char *shadow_copy2_convert(TALLOC_CTX *mem_ctx,
 	}
 	insertlen = talloc_get_size(insert)-1;
 
-	converted = talloc_zero_array(mem_ctx, char, pathlen + insertlen + 1);
+	/*
+	 * Note: We deliberatly don't expensively initialize the
+	 * array with talloc_zero here: Putting zero into
+	 * converted[pathlen+insertlen] below is sufficient, because
+	 * in the following for loop, the insert string is inserted
+	 * at various slash places. So the memory up to position
+	 * pathlen+insertlen will always be initialized when the
+	 * converted string is used.
+	 */
+	converted = talloc_array(mem_ctx, char, pathlen + insertlen + 1);
 	if (converted == NULL) {
 		goto fail;
 	}


-- 
Samba Shared Repository


More information about the samba-cvs mailing list