summaryrefslogtreecommitdiff
path: root/source4/scripting
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-04-06 00:40:01 +0200
committerJelmer Vernooij <jelmer@samba.org>2008-04-06 00:40:01 +0200
commit7c7880695b02df4cbe0faab959846c63d0cc0536 (patch)
treee3720b8bf812399675a9083d4027eaf00b12a489 /source4/scripting
parent3e97aa73c22ea036afb586b16a1d130ee46e5697 (diff)
downloadsamba-7c7880695b02df4cbe0faab959846c63d0cc0536.tar.gz
samba-7c7880695b02df4cbe0faab959846c63d0cc0536.tar.bz2
samba-7c7880695b02df4cbe0faab959846c63d0cc0536.zip
More PEP8 compliancy.
(This used to be commit d16b30d005933c9cc73f9196a3b77829d23687a0)
Diffstat (limited to 'source4/scripting')
-rw-r--r--source4/scripting/python/samba/provision.py25
1 files changed, 16 insertions, 9 deletions
diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py
index f81cedc729..4d5a9cb1f1 100644
--- a/source4/scripting/python/samba/provision.py
+++ b/source4/scripting/python/samba/provision.py
@@ -125,6 +125,10 @@ def findnss(nssfn, names):
raise KeyError("Unable to find user/group %r" % names)
+findnss_uid = lambda names: findnss(pwd.getpwnam, names)[2]
+findnss_gid = lambda names: findnss(grp.getgrnam, names)[2]
+
+
def open_ldb(session_info, credentials, lp, dbname):
"""Open a LDB, thrashing it if it is corrupt.
@@ -293,7 +297,7 @@ def guess_names(lp=None, hostname=None, domain=None, dnsdomain=None,
dnsdomain = dnsdomain.lower()
- if (serverrole == "domain controller"):
+ if serverrole == "domain controller":
if domain is None:
domain = lp.get("workgroup")
if domaindn is None:
@@ -385,6 +389,7 @@ def make_smbconf(smbconf, setup_path, hostname, domain, realm, serverrole,
"LOCKDIR_LINE": lockdir_line
})
+
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.
@@ -902,13 +907,13 @@ def provision(setup_dir, message, session_info,
machinepass = misc.random_password(12)
if dnspass is None:
dnspass = misc.random_password(12)
- 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]
+ root_uid = findnss_uid([root or "root"])
+ nobody_uid = findnss_uid([nobody or "nobody"])
+ users_gid = findnss_gid([users or "users"])
if wheel is None:
- wheel_gid = findnss(grp.getgrnam, ["wheel", "adm"])[2]
+ wheel_gid = findnss_gid(["wheel", "adm"])
else:
- wheel_gid = findnss(grp.getgrnam, [wheel])[2]
+ wheel_gid = findnss_gid([wheel])
if aci is None:
aci = "# no aci for local ldb"
@@ -925,8 +930,9 @@ def provision(setup_dir, message, session_info,
lp.load(smbconf)
names = guess_names(lp=lp, hostname=hostname, domain=domain,
- dnsdomain=realm, serverrole=serverrole, sitename=sitename,
- rootdn=rootdn, domaindn=domaindn, configdn=configdn, schemadn=schemadn)
+ dnsdomain=realm, serverrole=serverrole,
+ sitename=sitename, rootdn=rootdn, domaindn=domaindn,
+ configdn=configdn, schemadn=schemadn)
paths = provision_paths_from_lp(lp, names.dnsdomain)
@@ -936,7 +942,8 @@ def provision(setup_dir, message, session_info,
if hostip6 is None:
try:
hostip6 = socket.getaddrinfo(names.hostname, None, socket.AF_INET6, socket.AI_CANONNAME, socket.IPPROTO_IP)[0][-1][0]
- except socket.gaierror: pass
+ except socket.gaierror:
+ pass
if serverrole is None:
serverrole = lp.get("server role")