summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/scripting/python/samba/getopt.py2
-rw-r--r--source4/scripting/python/samba/netcmd/domain.py24
-rwxr-xr-xsource4/setup/tests/blackbox_s3upgrade.sh29
3 files changed, 38 insertions, 17 deletions
diff --git a/source4/scripting/python/samba/getopt.py b/source4/scripting/python/samba/getopt.py
index 0ab1e9e46f..01e9f87e76 100644
--- a/source4/scripting/python/samba/getopt.py
+++ b/source4/scripting/python/samba/getopt.py
@@ -53,6 +53,7 @@ class SambaOptions(optparse.OptionGroup):
callback=self._set_realm)
self._configfile = None
self._lp = LoadParm()
+ self.realm = None
def get_loadparm_path(self):
"""Return path to the smb.conf file specified on the command line."""
@@ -66,6 +67,7 @@ class SambaOptions(optparse.OptionGroup):
def _set_realm(self, option, opt_str, arg, parser):
self._lp.set('realm', arg)
+ self.realm = arg
def _set_option(self, option, opt_str, arg, parser):
if arg.find('=') == -1:
diff --git a/source4/scripting/python/samba/netcmd/domain.py b/source4/scripting/python/samba/netcmd/domain.py
index 4211b06802..b8f1e92e19 100644
--- a/source4/scripting/python/samba/netcmd/domain.py
+++ b/source4/scripting/python/samba/netcmd/domain.py
@@ -54,8 +54,8 @@ from samba.dsdb import (
DS_DOMAIN_FUNCTION_2008_R2,
)
-def get_testparm_var(testparm, varname):
- cmd = "%s -s -l --parameter-name='%s' 2>/dev/null" % (testparm, varname)
+def get_testparm_var(testparm, smbconf, varname):
+ cmd = "%s -s -l --parameter-name='%s' %s 2>/dev/null" % (testparm, varname, smbconf)
output = os.popen(cmd, 'r').readline()
return output.strip()
@@ -532,7 +532,7 @@ class cmd_domain_passwordsettings(Command):
class cmd_domain_samba3upgrade(Command):
"""Upgrade from Samba3 database to Samba4 AD database"""
- synopsis = "%prog domain samba3upgrade [options] <samba3_smb_conf> <targetdir>"
+ synopsis = "%prog domain samba3upgrade [options] <samba3_smb_conf>"
long_description = """Specify either samba3 database directory (with --libdir) or
samba3 testparm utility (with --testparm)."""
@@ -547,12 +547,14 @@ samba3 testparm utility (with --testparm)."""
help="Path to samba3 database directory"),
Option("--testparm", type="string", metavar="PATH",
help="Path to samba3 testparm utility"),
+ Option("--targetdir", type="string", metavar="DIR",
+ help="Path prefix where the new Samba 4.0 AD domain should be initialised"),
Option("--quiet", help="Be quiet"),
Option("--use-xattrs", type="choice", choices=["yes","no","auto"], metavar="[yes|no|auto]",
help="Define if we should use the native fs capabilities or a tdb file for storing attributes likes ntacl, auto tries to make an inteligent guess based on the user rights and system capabilities", default="auto"),
]
- takes_args = ["smbconf", "targetdir"]
+ takes_args = ["smbconf"]
def run(self, smbconf=None, targetdir=None, libdir=None, testparm=None,
quiet=None, use_xattrs=None, sambaopts=None, versionopts=None):
@@ -560,9 +562,6 @@ samba3 testparm utility (with --testparm)."""
if not os.path.exists(smbconf):
raise CommandError("File %s does not exist" % smbconf)
- if not os.path.isdir(targetdir):
- raise CommandError("Directory %s does not exist" % targetdir)
-
if testparm and not os.path.exists(testparm):
raise CommandError("Testparm utility %s does not exist" % testparm)
@@ -584,12 +583,11 @@ samba3 testparm utility (with --testparm)."""
logger.setLevel(logging.INFO)
lp = sambaopts.get_loadparm()
- realm = lp.get("realm")
s3conf = s3param.get_context()
- if realm:
- s3conf.set("realm", realm)
+ if sambaopts.realm:
+ s3conf.set("realm", sambaopts.realm)
eadb = True
if use_xattrs == "yes":
@@ -613,9 +611,9 @@ samba3 testparm utility (with --testparm)."""
paths["private dir"] = libdir
paths["lock directory"] = libdir
else:
- paths["state directory"] = get_testparm_var(testparm, "state directory")
- paths["private dir"] = get_testparm_var(testparm, "private dir")
- paths["lock directory"] = get_testparm_var(testparm, "lock directory")
+ paths["state directory"] = get_testparm_var(testparm, smbconf, "state directory")
+ paths["private dir"] = get_testparm_var(testparm, smbconf, "private dir")
+ paths["lock directory"] = get_testparm_var(testparm, smbconf, "lock directory")
for p in paths:
s3conf.set(p, paths[p])
diff --git a/source4/setup/tests/blackbox_s3upgrade.sh b/source4/setup/tests/blackbox_s3upgrade.sh
index 44da3234bf..a4c4b79669 100755
--- a/source4/setup/tests/blackbox_s3upgrade.sh
+++ b/source4/setup/tests/blackbox_s3upgrade.sh
@@ -12,12 +12,12 @@ shift 1
samba4bindir="$BINDIR"
samba_tool="$samba4bindir/samba-tool$EXEEXT"
+testparm="$samba4bindir/testparm$EXEEXT"
. `dirname $0`/../../../testprogs/blackbox/subunit.sh
rm -rf $PREFIX/samba3-upgrade
-mkdir -p $PREFIX/samba3-upgrade/s4_1
-mkdir -p $PREFIX/samba3-upgrade/s4_2
+mkdir -p $PREFIX/samba3-upgrade
cp -a $SRCDIR/testdata/samba3 $PREFIX/samba3-upgrade
# Test 1 (s3 member)
@@ -38,7 +38,7 @@ cat - > $PREFIX/samba3-upgrade/samba3/smb1.conf <<EOF
debug level = 0
EOF
-testit "samba3-upgrade-member" $samba_tool domain samba3upgrade $PREFIX/samba3-upgrade/samba3/smb1.conf $PREFIX/samba3-upgrade/s4_1 --libdir=$PREFIX/samba3-upgrade/samba3
+testit "samba3-upgrade-member" $samba_tool domain samba3upgrade $PREFIX/samba3-upgrade/samba3/smb1.conf --targetdir=$PREFIX/samba3-upgrade/s4_1 --libdir=$PREFIX/samba3-upgrade/samba3
# Test 2 (s3 dc)
cat - > $PREFIX/samba3-upgrade/samba3/smb2.conf <<EOF
@@ -59,7 +59,28 @@ cat - > $PREFIX/samba3-upgrade/samba3/smb2.conf <<EOF
domain logons = yes
EOF
-testit "samba3-upgrade-dc" $samba_tool domain samba3upgrade $PREFIX/samba3-upgrade/samba3/smb2.conf $PREFIX/samba3-upgrade/s4_2 --libdir=$PREFIX/samba3-upgrade/samba3
+testit "samba3-upgrade-dc" $samba_tool domain samba3upgrade $PREFIX/samba3-upgrade/samba3/smb2.conf --targetdir=$PREFIX/samba3-upgrade/s4_2 --libdir=$PREFIX/samba3-upgrade/samba3
+
+# Test 3 (s3 dc using testparm hook)
+cat - > $PREFIX/samba3-upgrade/samba3/smb3.conf <<EOF
+[global]
+ workgroup = SAMBA
+ netbiosname = S3UPGRADE
+ security = user
+ realm = s3.samba.example.com
+ passdb backend = tdbsam:$PREFIX/samba3-upgrade/samba3/passdb.tdb
+ private dir = $PREFIX/samba3-upgrade/samba3
+ lock directory = $PREFIX/samba3-upgrade/samba3
+ state directory = $PREFIX/samba3-upgrade/samba3
+ cache directory = $PREFIX/samba3-upgrade/samba3
+ pid directory = $PREFIX/samba3-upgrade/samba3
+ usershare path = $PREFIX/samba3-upgrade/samba3
+ ncalrpc dir = $PREFIX/samba3-upgrade/samba3
+ debug level = 0
+ domain logons = yes
+EOF
+
+testit "samba3-upgrade-testparm" $samba_tool domain samba3upgrade $PREFIX/samba3-upgrade/samba3/smb2.conf --targetdir=$PREFIX/samba3-upgrade/s4_3 --testparm=$testparm
rm -rf $PREFIX/samba3-upgrade