mirror of
https://github.com/samba-team/samba.git
synced 2025-07-31 20:22:15 +03:00
py: Fix initialisation of subtypes, fix segfaults.
This commit is contained in:
@ -43,7 +43,7 @@ else:
|
||||
|
||||
import ldb
|
||||
import credentials
|
||||
import misc
|
||||
import glue
|
||||
|
||||
class Ldb(ldb.Ldb):
|
||||
"""Simple Samba-specific LDB subclass that takes care
|
||||
@ -80,7 +80,7 @@ class Ldb(ldb.Ldb):
|
||||
if session_info is not None:
|
||||
self.set_session_info(session_info)
|
||||
|
||||
assert misc.ldb_register_samba_handlers(self) == 0
|
||||
glue.ldb_register_samba_handlers(self)
|
||||
|
||||
if lp is not None:
|
||||
self.set_loadparm(lp)
|
||||
@ -92,10 +92,14 @@ class Ldb(ldb.Ldb):
|
||||
if url is not None:
|
||||
self.connect(url)
|
||||
|
||||
def set_credentials(self, credentials):
|
||||
glue.ldb_set_credentials(self, credentials)
|
||||
|
||||
set_credentials = misc.ldb_set_credentials
|
||||
set_session_info = misc.ldb_set_session_info
|
||||
set_loadparm = misc.ldb_set_loadparm
|
||||
def set_session_info(self, session_info):
|
||||
glue.ldb_set_session_info(self, session_info)
|
||||
|
||||
def set_loadparm(self, lp_ctx):
|
||||
glue.ldb_set_loadparm(self, lp_ctx)
|
||||
|
||||
def searchone(self, attribute, basedn=None, expression=None,
|
||||
scope=ldb.SCOPE_BASE):
|
||||
@ -235,4 +239,4 @@ def valid_netbios_name(name):
|
||||
return False
|
||||
return True
|
||||
|
||||
version = misc.version
|
||||
version = glue.version
|
||||
|
@ -23,7 +23,7 @@
|
||||
__docformat__ = "restructuredText"
|
||||
|
||||
import samba
|
||||
import misc
|
||||
import glue
|
||||
import ldb
|
||||
|
||||
class IDmapDB(samba.Ldb):
|
||||
@ -50,7 +50,7 @@ class IDmapDB(samba.Ldb):
|
||||
self.connect(lp.get("idmap database"))
|
||||
|
||||
def connect(self, url):
|
||||
super(IDmapDB, self).connect(misc.private_path(self.lp, url))
|
||||
super(IDmapDB, self).connect(self.lp.private_path(url))
|
||||
|
||||
def setup_name_mapping(self, sid, type, unixid):
|
||||
"""Setup a mapping between a sam name and a unix name.
|
||||
|
@ -29,7 +29,7 @@ import os
|
||||
import pwd
|
||||
import grp
|
||||
import time
|
||||
import uuid, misc
|
||||
import uuid, glue
|
||||
import socket
|
||||
import param
|
||||
import registry
|
||||
@ -926,13 +926,13 @@ def provision(setup_dir, message, session_info,
|
||||
if policyguid is None:
|
||||
policyguid = str(uuid.uuid4())
|
||||
if adminpass is None:
|
||||
adminpass = misc.random_password(12)
|
||||
adminpass = glue.generate_random_str(12)
|
||||
if krbtgtpass is None:
|
||||
krbtgtpass = misc.random_password(12)
|
||||
krbtgtpass = glue.generate_random_str(12)
|
||||
if machinepass is None:
|
||||
machinepass = misc.random_password(12)
|
||||
machinepass = glue.generate_random_str(12)
|
||||
if dnspass is None:
|
||||
dnspass = misc.random_password(12)
|
||||
dnspass = glue.generate_random_str(12)
|
||||
root_uid = findnss_uid([root or "root"])
|
||||
nobody_uid = findnss_uid([nobody or "nobody"])
|
||||
users_gid = findnss_gid([users or "users"])
|
||||
@ -1172,7 +1172,7 @@ def provision_backend(setup_dir=None, message=None,
|
||||
root = findnss(pwd.getpwnam, ["root"])[0]
|
||||
|
||||
if adminpass is None:
|
||||
adminpass = misc.random_password(12)
|
||||
adminpass = glue.generate_random_str(12)
|
||||
|
||||
if targetdir is not None:
|
||||
if (not os.path.exists(os.path.join(targetdir, "etc"))):
|
||||
|
@ -23,7 +23,7 @@
|
||||
"""Convenience functions for using the SAM."""
|
||||
|
||||
import samba
|
||||
import misc
|
||||
import glue
|
||||
import ldb
|
||||
from samba.idmap import IDmapDB
|
||||
import pwd
|
||||
@ -43,14 +43,14 @@ class SamDB(samba.Ldb):
|
||||
self.lp = lp
|
||||
super(SamDB, self).__init__(session_info=session_info, credentials=credentials,
|
||||
modules_dir=modules_dir, lp=lp)
|
||||
assert misc.dsdb_set_global_schema(self) == 0
|
||||
glue.dsdb_set_global_schema(self)
|
||||
if url:
|
||||
self.connect(url)
|
||||
else:
|
||||
self.connect(lp.get("sam database"))
|
||||
|
||||
def connect(self, url):
|
||||
super(SamDB, self).connect(misc.private_path(self.lp, url))
|
||||
super(SamDB, self).connect(self.lp.private_path(url))
|
||||
|
||||
def add_foreign(self, domaindn, sid, desc):
|
||||
"""Add a foreign security principle."""
|
||||
@ -182,17 +182,17 @@ userPassword: %s
|
||||
|
||||
:param sid: The new domain sid to use.
|
||||
"""
|
||||
misc.samdb_set_domain_sid(self, sid)
|
||||
glue.samdb_set_domain_sid(self, sid)
|
||||
|
||||
def attach_schema_from_ldif(self, pf, df):
|
||||
misc.dsdb_attach_schema_from_ldif_file(self, pf, df)
|
||||
glue.dsdb_attach_schema_from_ldif_file(self, pf, df)
|
||||
|
||||
def set_invocation_id(self, invocation_id):
|
||||
"""Set the invocation id for this SamDB handle.
|
||||
|
||||
:param invocation_id: GUID of the invocation id.
|
||||
"""
|
||||
misc.dsdb_set_ntds_invocation_id(self, invocation_id)
|
||||
glue.dsdb_set_ntds_invocation_id(self, invocation_id)
|
||||
|
||||
def setexpiry(self, user, expiry_seconds, noexpiry):
|
||||
"""Set the password expiry for a user
|
||||
@ -212,7 +212,7 @@ userPassword: %s
|
||||
accountExpires = 0
|
||||
else:
|
||||
userAccountControl = userAccountControl & ~0x10000
|
||||
accountExpires = misc.unix2nttime(expiry_seconds + int(time.time()))
|
||||
accountExpires = glue.unix2nttime(expiry_seconds + int(time.time()))
|
||||
|
||||
mod = """
|
||||
dn: %s
|
||||
|
Reference in New Issue
Block a user