[SCM] Samba Shared Repository - branch master updated

Andreas Schneider asn at samba.org
Fri Nov 9 20:08:03 UTC 2018


The branch, master has been updated
       via  b161b3a8915 mdb_util: Better error message if lmdb-utils not installed
       via  55fa7bc01df selftest: Fix backup testenv creation on certain host machines
       via  96d47c21d50 selftest: Add README note: always use --configfile in testenv creation
       via  f8f2c5620c0 s4-kdc: restore MIT KDC backend
      from  f21bc3addaa selftest: Test hide new files timeout

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


- Log -----------------------------------------------------------------
commit b161b3a89154a9529404f5ee31d8679ddd1c48b0
Author: Tim Beale <timbeale at catalyst.net.nz>
Date:   Fri Nov 9 12:17:40 2018 +1300

    mdb_util: Better error message if lmdb-utils not installed
    
    mdb_copy() was dutifully checking the PATH for the mdb_copy executable,
    then, if it didn't find it, blindly proceeding anyway and trying to run
    a non-existent executable. This resulted in a cryptic error:
    
      ERROR(<type 'exceptions.OSError'>): uncaught exception - [Errno 2] No
        such file or directory
    
    Add in an extra check that we actually find the executable and raise a
    better human-readable exception if we don't.
    
    Signed-off-by: Tim Beale <timbeale at catalyst.net.nz>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Alexander Bokovoy <ab at samba.org>
    
    Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
    Autobuild-Date(master): Fri Nov  9 21:07:47 CET 2018 on sn-devel-144

commit 55fa7bc01df1e167af8795bba37f12be6c2e5056
Author: Tim Beale <timbeale at catalyst.net.nz>
Date:   Fri Nov 9 11:49:12 2018 +1300

    selftest: Fix backup testenv creation on certain host machines
    
    When we created the backup-file for the restoredc/renamedc/labdc
    testenvs we weren't explicitly a --configfile on the samba-tool command.
    This meant the command tried to use the smb.conf form the default
    install location, i.e. /usr/local/samba/etc/smb.conf. On the gitlab CI
    runner, there's no samba installed, so it ends up using the default
    settings, which is fine. However, if the host machine had an invalid
    smb.conf installed there, creating the testenv would fail with an error
    like:
    
    ERROR(runtime): uncaught exception - Unable to load default file
    File "bin/python/samba/netcmd/__init__.py", line 184, in _run
    return self.run(*args, **kwargs)
    File "bin/python/samba/netcmd/domain_backup.py", line 222, in run
    lp = sambaopts.get_loadparm()
      File "bin/python/samba/getopt.py", line 94, in get_loadparm
        self._lp.load_default()
    
    We can avoid this by always explictly specifying the backupfromdc's
    smb.conf when creating the backup file.
    
    Likewise, labdc/customdc also need the config specified when the admin
    password is reset.
    
    Signed-off-by: Tim Beale <timbeale at catalyst.net.nz>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Alexander Bokovoy <ab at samba.org>

commit 96d47c21d503e08b00659d8b35f46e8409dc0172
Author: Tim Beale <timbeale at catalyst.net.nz>
Date:   Fri Nov 9 11:44:18 2018 +1300

    selftest: Add README note: always use --configfile in testenv creation
    
    We always need to specify "env->{CONFIGURATION}" when running a samba-tool
    command to setup a testenv. Add a note to the README as this wasn't at
    all clear.
    
    Signed-off-by: Tim Beale <timbeale at catalyst.net.nz>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Alexander Bokovoy <ab at samba.org>

commit f8f2c5620c0a45f4ffc3a09ed1f72b4e7afa8763
Author: Philipp Gesang <philipp.gesang at intra2net.com>
Date:   Mon Nov 5 15:54:35 2018 +0100

    s4-kdc: restore MIT KDC backend
    
    Fix fallout from the KDC prefork patchset (99aea42520fc..).
    
    GCC warns when Samba is being built with --with-system-mitkrb5.
    Fix this by adapting the signature of mitkdc_task_init() to match
    task_init which has been extended to return a status code.
    
    Status codes try to mimick those of kdc-heimdal.c:kdc_task_init()
    as closely as possible.
    
    Signed-off-by: Philipp Gesang <philipp.gesang at intra2net.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Alexander Bokovoy <ab at samba.org>

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

Summary of changes:
 python/samba/mdb_util.py      |  7 +++++++
 selftest/target/README        | 10 ++++++++++
 selftest/target/Samba3.pm     |  3 +++
 selftest/target/Samba4.pm     |  8 +++++++-
 source4/kdc/kdc-service-mit.c | 35 +++++++++++++++++++----------------
 source4/kdc/kdc-service-mit.h |  2 +-
 6 files changed, 47 insertions(+), 18 deletions(-)


Changeset truncated at 500 lines:

diff --git a/python/samba/mdb_util.py b/python/samba/mdb_util.py
index 4dbff48b05a..1be16d5bb3d 100644
--- a/python/samba/mdb_util.py
+++ b/python/samba/mdb_util.py
@@ -19,6 +19,7 @@
 import samba
 import subprocess
 import os
+from samba.netcmd import CommandError
 
 
 def mdb_copy(file1, file2):
@@ -26,11 +27,17 @@ def mdb_copy(file1, file2):
     """
     # Find the location of the mdb_copy tool
     dirs = os.getenv('PATH').split(os.pathsep)
+    found = False
     for d in dirs:
         toolpath = os.path.join(d, "mdb_copy")
         if os.path.exists(toolpath):
+            found = True
             break
 
+    if not found:
+        raise CommandError("mdb_copy not found. "
+                           "You may need to install the lmdb-utils package")
+
     mdb_copy_cmd = [toolpath, "-n", file1, "%s.copy.mdb" % file1]
     status = subprocess.check_call(mdb_copy_cmd, close_fds=True, shell=False)
 
diff --git a/selftest/target/README b/selftest/target/README
index 28a8d00cb97..237cd6cd963 100644
--- a/selftest/target/README
+++ b/selftest/target/README
@@ -16,6 +16,16 @@ interference.
 
 Some of the different testenvs are described in more detail below.
 
+Important notes if adding a new testenv
+---------------------------------------
+- When adding a new testenv, in the Perl code it is recommended to always
+explicitly specify the --configfile option in the samba-tool command, i.e. add
+"env->{CONFIGURATION}" to the samba-tool command. Otherwise, the samba-tool
+can try to load smb.conf from the default install location (i.e.
+/usr/local/samba/etc/smb.conf). Loading a host-specific smb.conf that's outside
+of the testenv is obviously not ideal and something we want to avoid in a
+reliable test framework.
+
 'local' disambiguation
 ----------------------
 You may notice some variation in the target testenv that test suites are run
diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index 569b5d69517..363840e4521 100755
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -3,6 +3,9 @@
 # Copyright (C) 2005-2007 Jelmer Vernooij <jelmer at samba.org>
 # Published under the GNU GPL, v3 or later.
 
+# NOTE: Refer to the README for more details about the various testenvs,
+# and tips about adding new testenvs.
+
 package Samba3;
 
 use strict;
diff --git a/selftest/target/Samba4.pm b/selftest/target/Samba4.pm
index 1f142336293..5de0a706f35 100755
--- a/selftest/target/Samba4.pm
+++ b/selftest/target/Samba4.pm
@@ -3,6 +3,9 @@
 # Copyright (C) 2005-2007 Jelmer Vernooij <jelmer at samba.org>
 # Published under the GNU GPL, v3 or later.
 
+# NOTE: Refer to the README for more details about the various testenvs,
+# and tips about adding new testenvs.
+
 package Samba4;
 
 use strict;
@@ -2667,6 +2670,7 @@ sub get_backup_server_args
 	my $server = $dcvars->{DC_SERVER_IP};
 	my $server_args = "--server=$server ";
 	$server_args .= "-U$dcvars->{DC_USERNAME}\%$dcvars->{DC_PASSWORD}";
+	$server_args .= " $dcvars->{CONFIGURATION}";
 
 	return $server_args;
 }
@@ -2977,10 +2981,11 @@ sub setup_labdc
 	my $samba_tool = Samba::bindir_path($self, "samba-tool");
 	my $cmd = "$samba_tool user setpassword $env->{USERNAME} ";
 	$cmd .= "--newpassword=$env->{PASSWORD} -H $restore_dir/private/sam.ldb";
+	$cmd .= " $env->{CONFIGURATION}";
 
 	unless(system($cmd) == 0) {
 		warn("Failed to reset admin's password: \n$cmd");
-		return -1;
+		return undef;
 	}
 
 	# start samba for the restored DC
@@ -3070,6 +3075,7 @@ sub setup_customdc
 	my $samba_tool = Samba::bindir_path($self, "samba-tool");
 	my $cmd = "$samba_tool user setpassword $env->{USERNAME} ";
 	$cmd .= "--newpassword=$password -H $restore_dir/private/sam.ldb";
+	$cmd .= " $env->{CONFIGURATION}";
 
 	unless(system($cmd) == 0) {
 		warn("Failed to reset admin's password: \n$cmd");
diff --git a/source4/kdc/kdc-service-mit.c b/source4/kdc/kdc-service-mit.c
index 8ae1c219dc7..dd6902f083d 100644
--- a/source4/kdc/kdc-service-mit.c
+++ b/source4/kdc/kdc-service-mit.c
@@ -134,7 +134,7 @@ out:
 /*
  * Startup a copy of the krb5kdc as a child daemon
  */
-void mitkdc_task_init(struct task_server *task)
+NTSTATUS mitkdc_task_init(struct task_server *task)
 {
 	struct tevent_req *subreq;
 	const char * const *kdc_cmd;
@@ -155,13 +155,13 @@ void mitkdc_task_init(struct task_server *task)
 				      "The KDC is not required in standalone "
 				      "server configuration, terminate!",
 				      false);
-		return;
+		return NT_STATUS_INVALID_DOMAIN_ROLE;
 	case ROLE_DOMAIN_MEMBER:
 		task_server_terminate(task,
 				      "The KDC is not required in member "
 				      "server configuration",
 				      false);
-		return;
+		return NT_STATUS_INVALID_DOMAIN_ROLE;
 	case ROLE_ACTIVE_DIRECTORY_DC:
 		/* Yes, we want to start the KDC */
 		break;
@@ -173,7 +173,7 @@ void mitkdc_task_init(struct task_server *task)
 		task_server_terminate(task,
 				      "KDC: no network interfaces configured",
 				      false);
-		return;
+		return NT_STATUS_UNSUCCESSFUL;
 	}
 
 	kdc_config = talloc_asprintf(task,
@@ -183,7 +183,7 @@ void mitkdc_task_init(struct task_server *task)
 		task_server_terminate(task,
 				      "KDC: no memory",
 				      false);
-		return;
+		return NT_STATUS_NO_MEMORY;
 	}
 	setenv("KRB5_KDC_PROFILE", kdc_config, 0);
 	TALLOC_FREE(kdc_config);
@@ -208,7 +208,7 @@ void mitkdc_task_init(struct task_server *task)
 		task_server_terminate(task,
 				      "Failed to startup mitkdc task",
 				      true);
-		return;
+		return NT_STATUS_INTERNAL_ERROR;
 	}
 
 	tevent_req_set_callback(subreq, mitkdc_server_done, task);
@@ -227,7 +227,7 @@ void mitkdc_task_init(struct task_server *task)
 	kdc = talloc_zero(task, struct kdc_server);
 	if (kdc == NULL) {
 		task_server_terminate(task, "KDC: Out of memory", true);
-		return;
+		return NT_STATUS_NO_MEMORY;
 	}
 	talloc_set_destructor(kdc, kdc_server_destroy);
 
@@ -236,7 +236,7 @@ void mitkdc_task_init(struct task_server *task)
 	kdc->base_ctx = talloc_zero(kdc, struct samba_kdc_base_context);
 	if (kdc->base_ctx == NULL) {
 		task_server_terminate(task, "KDC: Out of memory", true);
-		return;
+		return NT_STATUS_NO_MEMORY;
 	}
 
 	kdc->base_ctx->ev_ctx = task->event_ctx;
@@ -249,9 +249,9 @@ void mitkdc_task_init(struct task_server *task)
 				     &kdc->smb_krb5_context);
 	if (code != 0) {
 		task_server_terminate(task,
-				      "KDC: Unable to initialized krb5 context",
+				      "KDC: Unable to initialize krb5 context",
 				      true);
-		return;
+		return NT_STATUS_INTERNAL_ERROR;
 	}
 
 	code = kadm5_init_krb5_context(&kdc->smb_krb5_context->krb5_context);
@@ -259,7 +259,7 @@ void mitkdc_task_init(struct task_server *task)
 		task_server_terminate(task,
 				      "KDC: Unable to init kadm5 krb5_context",
 				      true);
-		return;
+		return NT_STATUS_INTERNAL_ERROR;
 	}
 
 	ZERO_STRUCT(config);
@@ -279,7 +279,7 @@ void mitkdc_task_init(struct task_server *task)
 		task_server_terminate(task,
 				      "KDC: Initialize kadm5",
 				      true);
-		return;
+		return NT_STATUS_INTERNAL_ERROR;
 	}
 	kdc->private_data = server_handle;
 
@@ -288,7 +288,7 @@ void mitkdc_task_init(struct task_server *task)
 		task_server_terminate(task,
 				      "KDC: Unable to KDB",
 				      true);
-		return;
+		return NT_STATUS_INTERNAL_ERROR;
 	}
 
 	kdc->keytab_name = talloc_asprintf(kdc, "KDB:");
@@ -296,7 +296,7 @@ void mitkdc_task_init(struct task_server *task)
 		task_server_terminate(task,
 				      "KDC: Out of memory",
 				      true);
-		return;
+		return NT_STATUS_NO_MEMORY;
 	}
 
 	kdc->samdb = samdb_connect(kdc,
@@ -307,9 +307,9 @@ void mitkdc_task_init(struct task_server *task)
 				   0);
 	if (kdc->samdb == NULL) {
 		task_server_terminate(task,
-				      "KDC: Unable to connect to sambdb",
+				      "KDC: Unable to connect to samdb",
 				      true);
-		return;
+		return NT_STATUS_CONNECTION_INVALID;
 	}
 
 	status = startup_kpasswd_server(kdc,
@@ -320,9 +320,12 @@ void mitkdc_task_init(struct task_server *task)
 		task_server_terminate(task,
 				      "KDC: Unable to start kpasswd server",
 				      true);
+		return status;
 	}
 
 	DEBUG(5,("Started kpasswd service for kdc_server\n"));
+
+	return NT_STATUS_OK;
 }
 
 /*
diff --git a/source4/kdc/kdc-service-mit.h b/source4/kdc/kdc-service-mit.h
index 6f38fe7ed97..79439331e16 100644
--- a/source4/kdc/kdc-service-mit.h
+++ b/source4/kdc/kdc-service-mit.h
@@ -22,6 +22,6 @@
 #ifndef _KDC_SERVICE_MIT_H
 #define _KDC_SERVICE_MIT_H
 
-void mitkdc_task_init(struct task_server *task);
+NTSTATUS mitkdc_task_init(struct task_server *task);
 
 #endif /* _KDC_SERVICE_MIT_H */


-- 
Samba Shared Repository



More information about the samba-cvs mailing list