s.provision : package documentation

Part of samba

Functions for setting up a Samba configuration.
Module backend Functions for setting up a Samba configuration (LDB and LDAP backends).
Module common Functions for setting up a Samba configuration.
Module descriptor Functions for setting up a Samba configuration (security descriptors).
Module sambadns DNS-related provisioning

From the __init__.py module:

Class InvalidNetbiosName A specified name was not a valid NetBIOS name.
Class MissingShareError Undocumented
Class ProvisionNames Undocumented
Class ProvisionPaths Undocumented
Class ProvisionResult Result of a provision.
Class ProvisioningError A generic provision error.
Function check_install Check whether the current install seems ok.
Function create_default_gpo Create the default GPO for a domain
Function create_gpo_struct Undocumented
Function create_krb5_conf Write out a file containing zone statements suitable for inclusion in a named.conf file (including GSS-TSIG configuration).
Function create_phpldapadmin_config Create a PHP LDAP admin configuration file.
Function determine_netbios_name Determine a netbios name from a hostname.
Function fill_samdb Undocumented
Function find_provision_key_parameters Get key provision parameters (realm, domain, ...) from a given provision
Function findnss Find a user or group from a list of possibilities.
Function get_last_provision_usn Get USNs ranges modified by a provision or an upgradeprovision
Function get_max_usn This function return the biggest USN present in the provision
Function getpolicypath Return the physical path of policy given its guid.
Function guess_names Guess configuration settings to use.
Function interface_ips_v4 return only IPv4 IPs
Function interface_ips_v6 return only IPv6 IPs
Function make_smbconf Create a new smb.conf file based on a couple of basic settings.
Function provision Provision samba4
Function provision_become_dc Undocumented
Function provision_fill Undocumented
Function provision_paths_from_lp Set the default paths for provisioning.
Function sanitize_server_role Sanitize a server role name.
Function secretsdb_self_join Add domain join-specific bits to a secrets database.
Function set_dir_acl Undocumented
Function set_gpos_acl Set ACL on the sysvol/<dnsname>/Policies folder and the policy folders beneath.
Function set_provision_usn No summary
Function setsysvolacl Set the ACL for the sysvol share and the subfolders
Function setup_idmapdb Setup the idmap database.
Function setup_name_mappings setup reasonable name mappings for sam names to unix names.
Function setup_privileges Setup the privileges database.
Function setup_registry Setup the registry.
Function setup_samdb Setup a complete SAM Database.
Function setup_samdb_partitions Setup the partitions for the SAM database.
Function setup_samdb_rootdse Setup the SamDB rootdse.
Function setup_secretsdb Setup the secrets database.
Function setup_self_join Join a host to its own domain.
Function update_provision_usn Update the field provisionUSN in sam.ldb
def find_provision_key_parameters(samdb, secretsdb, idmapdb, paths, smbconf, lp):
Get key provision parameters (realm, domain, ...) from a given provision
ParameterssamdbAn LDB object connected to the sam.ldb file
secretsdbAn LDB object connected to the secrets.ldb file
idmapdbAn LDB object connected to the idmap.ldb file
pathsA list of path to provision object
smbconfPath to the smb.conf file
lpA LoadParm object
ReturnsA list of key provision parameters
def update_provision_usn(samdb, low, high, id, replace=False):
Update the field provisionUSN in sam.ldb

This field is used to track range of USN modified by provision and upgradeprovision. This value is used afterward by next provision to figure out if the field have been modified since last provision.

ParameterssamdbAn LDB object connect to sam.ldb
lowThe lowest USN modified by this upgrade
highThe highest USN modified by this upgrade
idThe invocation id of the samba's dc
replaceA boolean indicating if the range should replace any existing one or appended (default)
def set_provision_usn(samdb, low, high, id):
Set the field provisionUSN in sam.ldb This field is used to track range of USN modified by provision and upgradeprovision. This value is used afterward by next provision to figure out if the field have been modified since last provision.
ParameterssamdbAn LDB object connect to sam.ldb
lowThe lowest USN modified by this upgrade
highThe highest USN modified by this upgrade
idThe invocationId of the provision
def get_max_usn(samdb, basedn):
This function return the biggest USN present in the provision
ParameterssamdbA LDB object pointing to the sam.ldb
basednA string containing the base DN of the provision (ie. DC=foo, DC=bar)
ReturnsThe biggest USN in the provision
def get_last_provision_usn(sam):
Get USNs ranges modified by a provision or an upgradeprovision
ParameterssamAn LDB object pointing to the sam.ldb
Returnsa dictionnary which keys are invocation id and values are an array of integer representing the different ranges
def check_install(lp, session_info, credentials):
Check whether the current install seems ok.
ParameterslpLoadparm context
session_infoSession information
credentialsCredentials
def findnss(nssfn, names):
Find a user or group from a list of possibilities.
ParametersnssfnNSS Function to try (should raise KeyError if not found)
namesNames to check.
ReturnsValue return by first names list.
def provision_paths_from_lp(lp, dnsdomain):
Set the default paths for provisioning.
ParameterslpLoadparm context.
dnsdomainDNS Domain name
def determine_netbios_name(hostname):
Determine a netbios name from a hostname.
def guess_names(lp=None, hostname=None, domain=None, dnsdomain=None, serverrole=None, rootdn=None, domaindn=None, configdn=None, schemadn=None, serverdn=None, sitename=None):
Guess configuration settings to use.
def make_smbconf(smbconf, hostname, domain, realm, targetdir, serverrole=None, sid_generator=None, eadb=False, lp=None, server_services=None):
Create a new smb.conf file based on a couple of basic settings.
def setup_name_mappings(idmap, sid, root_uid, nobody_uid, users_gid, wheel_gid):
setup reasonable name mappings for sam names to unix names.
ParameterssamdbSamDB object.
idmapIDmap db object.
sidThe domain sid.
domaindnThe domain DN.
root_uiduid of the UNIX root user.
nobody_uiduid of the UNIX nobody user.
users_gidgid of the UNIX users group.
wheel_gidgid of the UNIX wheel group.
def setup_samdb_partitions(samdb_path, logger, lp, session_info, provision_backend, names, schema, serverrole, erase=False):
Setup the partitions for the SAM database.

Alternatively, provision() may call this, and then populate the database.

NotesThis will wipe the Sam Database!
This function always removes the local SAM LDB file. The erase parameter controls whether to erase the existing data, which may not be stored locally but in LDAP.
def secretsdb_self_join(secretsdb, domain, netbiosname, machinepass, domainsid=None, realm=None, dnsdomain=None, keytab_path=None, key_version_number=1, secure_channel_type=SEC_CHAN_WKSTA):
Add domain join-specific bits to a secrets database.
ParameterssecretsdbLdb Handle to the secrets database
machinepassMachine password
def setup_secretsdb(paths, session_info, backend_credentials, lp):
Setup the secrets database.
ParameterspathPath to the secrets database.
session_infoSession info.
credentialsCredentials
lpLoadparm context
ReturnsLDB handle for the created secrets database
Note
This function does not handle exceptions and transaction on purpose,
it's up to the caller to do this job.
def setup_privileges(path, session_info, lp):
Setup the privileges database.
ParameterspathPath to the privileges database.
session_infoSession info.
credentialsCredentials
lpLoadparm context
ReturnsLDB handle for the created secrets database
def setup_registry(path, session_info, lp):
Setup the registry.
ParameterspathPath to the registry database
session_infoSession information
credentialsCredentials
lpLoadparm context
def setup_idmapdb(path, session_info, lp):
Setup the idmap database.
Parameterspathpath to the idmap database
session_infoSession information
credentialsCredentials
lpLoadparm context
def setup_samdb_rootdse(samdb, names):
Setup the SamDB rootdse.
ParameterssamdbSam Database handle
def setup_self_join(samdb, admin_session_info, names, fill, machinepass, dnspass, domainsid, next_rid, invocationid, policyguid, policyguid_dc, domainControllerFunctionality, ntdsguid=None, dc_rid=None):
Join a host to its own domain.
def getpolicypath(sysvolpath, dnsdomain, guid):
Return the physical path of policy given its guid.
ParameterssysvolpathPath to the sysvol folder
dnsdomainDNS name of the AD domain
guidThe GUID of the policy
ReturnsA string with the complete path to the policy folder
def create_gpo_struct(policy_path):
Undocumented
def create_default_gpo(sysvolpath, dnsdomain, policyguid, policyguid_dc):
Create the default GPO for a domain
ParameterssysvolpathPhysical path for the sysvol folder
dnsdomainDNS domain name of the AD domain
policyguidGUID of the default domain policy
policyguid_dcGUID of the default domain controler policy
def setup_samdb(path, session_info, provision_backend, lp, names, logger, fill, serverrole, schema, am_rodc=False):
Setup a complete SAM Database.
NoteThis will wipe the main SAM database file!
def fill_samdb(samdb, lp, names, logger, domainsid, domainguid, policyguid, policyguid_dc, fill, adminpass, krbtgtpass, machinepass, invocationid, dnspass, ntdsguid, serverrole, am_rodc=False, dom_for_fun_level=None, schema=None, next_rid=None, dc_rid=None):
Undocumented
def set_dir_acl(path, acl, lp, domsid):
Undocumented
def set_gpos_acl(sysvol, dnsdomain, domainsid, domaindn, samdb, lp):
Set ACL on the sysvol/<dnsname>/Policies folder and the policy folders beneath.
ParameterssysvolPhysical path for the sysvol folder
dnsdomainThe DNS name of the domain
domainsidThe SID of the domain
domaindnThe DN of the domain (ie. DC=...)
samdbAn LDB object on the SAM db
lpan LP object
def setsysvolacl(samdb, netlogon, sysvol, gid, domainsid, dnsdomain, domaindn, lp):
Set the ACL for the sysvol share and the subfolders
ParameterssamdbAn LDB object on the SAM db
netlogonPhysical path for the netlogon folder
sysvolPhysical path for the sysvol folder
gidThe GID of the "Domain adminstrators" group
domainsidThe SID of the domain
dnsdomainThe DNS name of the domain
domaindnThe DN of the domain (ie. DC=...)
def interface_ips_v4(lp):
return only IPv4 IPs
def interface_ips_v6(lp, linklocal=False):
return only IPv6 IPs
def provision_fill(samdb, secrets_ldb, logger, names, paths, domainsid, schema=None, targetdir=None, samdb_fill=FILL_FULL, hostip=None, hostip6=None, next_rid=1000, dc_rid=None, adminpass=None, krbtgtpass=None, domainguid=None, policyguid=None, policyguid_dc=None, invocationid=None, machinepass=None, ntdsguid=None, dns_backend=None, dnspass=None, serverrole=None, dom_for_fun_level=None, am_rodc=False, lp=None):
Undocumented
def sanitize_server_role(role):
Sanitize a server role name.
ParametersroleServer role
ReturnsSanitized server role (one of "member server", "domain controller", "standalone")
RaisesValueErrorIf the role can not be interpreted
def provision(logger, session_info, credentials, smbconf=None, targetdir=None, samdb_fill=FILL_FULL, realm=None, rootdn=None, domaindn=None, schemadn=None, configdn=None, serverdn=None, domain=None, hostname=None, hostip=None, hostip6=None, domainsid=None, next_rid=1000, dc_rid=None, adminpass=None, ldapadminpass=None, krbtgtpass=None, domainguid=None, policyguid=None, policyguid_dc=None, dns_backend=None, dnspass=None, invocationid=None, machinepass=None, ntdsguid=None, root=None, nobody=None, users=None, wheel=None, backup=None, aci=None, serverrole=None, dom_for_fun_level=None, backend_type=None, sitename=None, ol_mmr_urls=None, ol_olc=None, slapd_path=None, useeadb=False, am_rodc=False, lp=None):
Provision samba4
Notecaution, this wipes all existing data!
def provision_become_dc(smbconf=None, targetdir=None, realm=None, rootdn=None, domaindn=None, schemadn=None, configdn=None, serverdn=None, domain=None, hostname=None, domainsid=None, adminpass=None, krbtgtpass=None, domainguid=None, policyguid=None, policyguid_dc=None, invocationid=None, machinepass=None, dnspass=None, dns_backend=None, root=None, nobody=None, users=None, wheel=None, backup=None, serverrole=None, ldap_backend=None, ldap_backend_type=None, sitename=None, debuglevel=1):
Undocumented
def create_phpldapadmin_config(path, ldapi_uri):
Create a PHP LDAP admin configuration file.
ParameterspathPath to write the configuration to.
def create_krb5_conf(path, dnsdomain, hostname, realm):
Write out a file containing zone statements suitable for inclusion in a named.conf file (including GSS-TSIG configuration).
ParameterspathPath of the new named.conf file.
dnsdomainDNS Domain name
hostnameLocal hostname
realmRealm name
API Documentation for Samba, generated by pydoctor at 2012-03-06 23:17:58.