mirror of
https://github.com/samba-team/samba.git
synced 2025-07-29 15:42:04 +03:00
@ -103,7 +103,7 @@ def check_install(lp, session_info, credentials):
|
||||
:param credentials: Credentials
|
||||
"""
|
||||
if lp.get("realm") == "":
|
||||
raise Error("Realm empty")
|
||||
raise Exception("Realm empty")
|
||||
ldb = Ldb(lp.get("sam database"), session_info=session_info,
|
||||
credentials=credentials, lp=lp)
|
||||
if len(ldb.search("(cn=Administrator)")) != 1:
|
||||
@ -288,8 +288,8 @@ def guess_names(lp=None, hostname=None, domain=None, dnsdomain=None,
|
||||
realm = dnsdomain.upper()
|
||||
|
||||
if lp.get("realm").upper() != realm:
|
||||
raise Exception("realm '%s' in %s must match chosen realm '%s'" %
|
||||
(lp.get("realm"), smbconf, realm))
|
||||
raise Exception("realm '%s' must match chosen realm '%s'" %
|
||||
(lp.get("realm"), realm))
|
||||
|
||||
dnsdomain = dnsdomain.lower()
|
||||
|
||||
@ -299,7 +299,7 @@ def guess_names(lp=None, hostname=None, domain=None, dnsdomain=None,
|
||||
if domaindn is None:
|
||||
domaindn = "DC=" + dnsdomain.replace(".", ",DC=")
|
||||
if lp.get("workgroup").upper() != domain.upper():
|
||||
raise Error("workgroup '%s' in smb.conf must match chosen domain '%s'",
|
||||
raise Exception("workgroup '%s' in smb.conf must match chosen domain '%s'",
|
||||
lp.get("workgroup"), domain)
|
||||
else:
|
||||
domain = netbiosname
|
||||
@ -338,19 +338,8 @@ def guess_names(lp=None, hostname=None, domain=None, dnsdomain=None,
|
||||
return names
|
||||
|
||||
|
||||
def load_or_make_smbconf(smbconf, setup_path, hostname, domain, realm,
|
||||
serverrole, targetdir):
|
||||
if targetdir is not None:
|
||||
if not os.path.exists(targetdir):
|
||||
os.mkdir(targetdir)
|
||||
if not os.path.exists(os.path.join(targetdir, "etc")):
|
||||
os.mkdir(os.path.join(targetdir, "etc"))
|
||||
|
||||
smbconf = os.path.join(targetdir, "etc", "smb.conf")
|
||||
|
||||
# only install a new smb.conf if there isn't one there already
|
||||
|
||||
if not os.path.exists(smbconf):
|
||||
def make_smbconf(smbconf, setup_path, hostname, domain, realm, serverrole,
|
||||
targetdir):
|
||||
if hostname is None:
|
||||
hostname = socket.gethostname().split(".")[0].lower()
|
||||
|
||||
@ -396,11 +385,6 @@ def load_or_make_smbconf(smbconf, setup_path, hostname, domain, realm,
|
||||
"LOCKDIR_LINE": lockdir_line
|
||||
})
|
||||
|
||||
lp = param.LoadParm()
|
||||
lp.load(smbconf)
|
||||
|
||||
return lp
|
||||
|
||||
def setup_name_mappings(samdb, idmap, sid, domaindn, root_uid, nobody_uid,
|
||||
users_gid, wheel_gid):
|
||||
"""setup reasonable name mappings for sam names to unix names.
|
||||
@ -886,14 +870,15 @@ FILL_NT4SYNC = "NT4SYNC"
|
||||
FILL_DRS = "DRS"
|
||||
|
||||
def provision(setup_dir, message, session_info,
|
||||
credentials, smbconf=None, targetdir=None, samdb_fill=FILL_FULL, realm=None,
|
||||
rootdn=None, domaindn=None, schemadn=None, configdn=None,
|
||||
domain=None, hostname=None, hostip=None, hostip6=None,
|
||||
domainsid=None, adminpass=None, krbtgtpass=None, domainguid=None,
|
||||
policyguid=None, invocationid=None, machinepass=None,
|
||||
dnspass=None, root=None, nobody=None, nogroup=None, users=None,
|
||||
wheel=None, backup=None, aci=None, serverrole=None,
|
||||
ldap_backend=None, ldap_backend_type=None, sitename=None):
|
||||
credentials, smbconf=None, targetdir=None, samdb_fill=FILL_FULL,
|
||||
realm=None, rootdn=None, domaindn=None, schemadn=None,
|
||||
configdn=None, domain=None, hostname=None, hostip=None,
|
||||
hostip6=None, domainsid=None, adminpass=None, krbtgtpass=None,
|
||||
domainguid=None, policyguid=None, invocationid=None,
|
||||
machinepass=None, dnspass=None, root=None, nobody=None,
|
||||
nogroup=None, users=None, wheel=None, backup=None, aci=None,
|
||||
serverrole=None, ldap_backend=None, ldap_backend_type=None,
|
||||
sitename=None):
|
||||
"""Provision samba4
|
||||
|
||||
:note: caution, this wipes all existing data!
|
||||
@ -917,18 +902,9 @@ def provision(setup_dir, message, session_info,
|
||||
machinepass = misc.random_password(12)
|
||||
if dnspass is None:
|
||||
dnspass = misc.random_password(12)
|
||||
if root is None:
|
||||
root_uid = findnss(pwd.getpwnam, ["root"])[2]
|
||||
else:
|
||||
root_uid = findnss(pwd.getpwnam, [root])[2]
|
||||
if nobody is None:
|
||||
nobody_uid = findnss(pwd.getpwnam, ["nobody"])[2]
|
||||
else:
|
||||
nobody_uid = findnss(pwd.getpwnam, [nobody])[2]
|
||||
if users is None:
|
||||
users_gid = findnss(grp.getgrnam, ["users"])[2]
|
||||
else:
|
||||
users_gid = findnss(grp.getgrnam, [users])[2]
|
||||
root_uid = findnss(pwd.getpwnam, [root or "root"])[2]
|
||||
nobody_uid = findnss(pwd.getpwnam, [nobody or "nobody"])[2]
|
||||
users_gid = findnss(grp.getgrnam, [users or "users"])[2]
|
||||
if wheel is None:
|
||||
wheel_gid = findnss(grp.getgrnam, ["wheel", "adm"])[2]
|
||||
else:
|
||||
@ -936,7 +912,17 @@ def provision(setup_dir, message, session_info,
|
||||
if aci is None:
|
||||
aci = "# no aci for local ldb"
|
||||
|
||||
lp = load_or_make_smbconf(smbconf, setup_path, hostname, domain, realm, serverrole, targetdir)
|
||||
if smbconf is None:
|
||||
os.makedirs(os.path.join(targetdir, "etc"))
|
||||
smbconf = os.path.join(targetdir, "etc", "smb.conf")
|
||||
|
||||
# only install a new smb.conf if there isn't one there already
|
||||
if not os.path.exists(smbconf):
|
||||
make_smbconf(smbconf, setup_path, hostname, domain, realm, serverrole,
|
||||
targetdir)
|
||||
|
||||
lp = param.LoadParm()
|
||||
lp.load(smbconf)
|
||||
|
||||
names = guess_names(lp=lp, hostname=hostname, domain=domain,
|
||||
dnsdomain=realm, serverrole=serverrole, sitename=sitename,
|
||||
@ -1115,11 +1101,22 @@ def provision_backend(setup_dir=None, message=None,
|
||||
if root is None:
|
||||
root = findnss(pwd.getpwnam, ["root"])[0]
|
||||
|
||||
lp = load_or_make_smbconf(smbconf, setup_path, hostname, domain, realm, serverrole, targetdir)
|
||||
if smbconf is None:
|
||||
os.makedirs(os.path.join(targetdir, "etc"))
|
||||
smbconf = os.path.join(targetdir, "etc", "smb.conf")
|
||||
|
||||
# only install a new smb.conf if there isn't one there already
|
||||
if not os.path.exists(smbconf):
|
||||
make_smbconf(smbconf, setup_path, hostname, domain, realm,
|
||||
serverrole, targetdir)
|
||||
|
||||
lp = param.LoadParm()
|
||||
lp.load(smbconf)
|
||||
|
||||
names = guess_names(lp=lp, hostname=hostname, domain=domain,
|
||||
dnsdomain=realm, serverrole=serverrole,
|
||||
rootdn=rootdn, domaindn=domaindn, configdn=configdn, schemadn=schemadn)
|
||||
rootdn=rootdn, domaindn=domaindn, configdn=configdn,
|
||||
schemadn=schemadn)
|
||||
|
||||
paths = provision_paths_from_lp(lp, names.dnsdomain)
|
||||
|
||||
|
Reference in New Issue
Block a user