summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/scripting/python/samba/getopt.py4
-rw-r--r--source4/scripting/python/samba/hostconfig.py33
-rw-r--r--source4/scripting/python/samba/provision.py8
-rw-r--r--source4/scripting/python/samba/samba3.py14
-rw-r--r--source4/scripting/python/samba/samr.py8
-rw-r--r--source4/scripting/python/samba/tests/dcerpc/bare.py1
-rw-r--r--source4/scripting/python/samba/tests/dcerpc/registry.py1
-rw-r--r--source4/scripting/python/samba/tests/dcerpc/rpcecho.py2
-rw-r--r--source4/scripting/python/samba/tests/provision.py2
-rw-r--r--source4/scripting/python/samba/tests/samba3.py1
-rw-r--r--source4/scripting/python/subunit/__init__.py2
-rwxr-xr-xsource4/setup/newuser5
12 files changed, 66 insertions, 15 deletions
diff --git a/source4/scripting/python/samba/getopt.py b/source4/scripting/python/samba/getopt.py
index 9ecb66e21c..c12245f6c5 100644
--- a/source4/scripting/python/samba/getopt.py
+++ b/source4/scripting/python/samba/getopt.py
@@ -21,6 +21,7 @@
import optparse
from credentials import Credentials, AUTO_USE_KERBEROS, DONT_USE_KERBEROS, MUST_USE_KERBEROS
+from hostconfig import Hostconfig
__docformat__ = "restructuredText"
@@ -52,6 +53,9 @@ class SambaOptions(optparse.OptionGroup):
lp.load_default()
return lp
+ def get_hostconfig(self):
+ return Hostconfig(self.get_loadparm())
+
class VersionOptions(optparse.OptionGroup):
"""Command line option for printing Samba version."""
diff --git a/source4/scripting/python/samba/hostconfig.py b/source4/scripting/python/samba/hostconfig.py
new file mode 100644
index 0000000000..313e3420b0
--- /dev/null
+++ b/source4/scripting/python/samba/hostconfig.py
@@ -0,0 +1,33 @@
+#!/usr/bin/python
+
+# Unix SMB/CIFS implementation.
+# Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+from samdb import SamDB
+
+class Hostconfig(object):
+ """Aggregate object that contains all information about the configuration
+ of a Samba host."""
+
+ def __init__(self, lp):
+ self.lp = lp
+
+ def get_samdb(self, session_info, credentials):
+ return SamDB(url=self.lp.get("sam database"),
+ session_info=session_info, credentials=credentials,
+ lp=self.lp)
+
diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py
index 6dd9f3b8bd..4f7fbfc6e6 100644
--- a/source4/scripting/python/samba/provision.py
+++ b/source4/scripting/python/samba/provision.py
@@ -53,7 +53,7 @@ class InvalidNetbiosName(Exception):
super(InvalidNetbiosName, self).__init__("The name '%r' is not a valid NetBIOS name" % name)
-class ProvisionPaths:
+class ProvisionPaths(object):
def __init__(self):
self.shareconf = None
self.hklm = None
@@ -77,7 +77,8 @@ class ProvisionPaths:
self.fedoradsinf = None
self.fedoradspartitions = None
-class ProvisionNames:
+
+class ProvisionNames(object):
def __init__(self):
self.rootdn = None
self.domaindn = None
@@ -92,7 +93,8 @@ class ProvisionNames:
self.sitename = None
self.smbconf = None
-class ProvisionResult:
+
+class ProvisionResult(object):
def __init__(self):
self.paths = None
self.domaindn = None
diff --git a/source4/scripting/python/samba/samba3.py b/source4/scripting/python/samba/samba3.py
index c1340b7760..0e0c29dac8 100644
--- a/source4/scripting/python/samba/samba3.py
+++ b/source4/scripting/python/samba/samba3.py
@@ -308,7 +308,7 @@ class ShareInfoDatabase(TdbDatabase):
return secdesc
-class Shares:
+class Shares(object):
"""Container for share objects."""
def __init__(self, lp, shareinfo):
self.lp = lp
@@ -371,7 +371,7 @@ def decode_acb(text):
return ret
-class SAMUser:
+class SAMUser(object):
"""Samba 3 SAM User.
:note: Unknown or unset fields are set to None.
@@ -421,7 +421,8 @@ class SAMUser:
return False
return self.__dict__ == other.__dict__
-class SmbpasswdFile:
+
+class SmbpasswdFile(object):
"""Samba 3 smbpasswd file reader."""
def __init__(self, file):
self.users = {}
@@ -482,7 +483,7 @@ TDBSAM_FORMAT_STRING_V2 = "dddddddBBBBBBBBBBBBddBBBwwdBwwd"
TDBSAM_USER_PREFIX = "USER_"
-class LdapSam:
+class LdapSam(object):
"""Samba 3 LDAP passdb backend reader."""
def __init__(self, url):
self.ldap_url = ldap_url
@@ -605,7 +606,7 @@ def shellsplit(text):
return ret
-class WinsDatabase:
+class WinsDatabase(object):
"""Samba 3 WINS database reader."""
def __init__(self, file):
self.entries = {}
@@ -643,7 +644,8 @@ class WinsDatabase:
def close(self): # for consistency
pass
-class Samba3:
+
+class Samba3(object):
"""Samba 3 configuration and state data reader."""
def __init__(self, libdir, smbconfpath):
"""Open the configuration and data for a Samba 3 installation.
diff --git a/source4/scripting/python/samba/samr.py b/source4/scripting/python/samba/samr.py
index 314f78b8ad..62a7c6eb3d 100644
--- a/source4/scripting/python/samba/samr.py
+++ b/source4/scripting/python/samba/samr.py
@@ -97,7 +97,8 @@ def call_fn(fn, pipe, args):
return result;
-class SamrHandle:
+
+class SamrHandle(object):
def __init__(self, pipe, handle):
@@ -137,6 +138,7 @@ class SamrHandle:
call_fn(dcerpc.dcerpc_samr_SetSecurity, self.pipe, r)
+
class ConnectHandle(SamrHandle):
def EnumDomains(self):
@@ -212,6 +214,7 @@ class ConnectHandle(SamrHandle):
call_fn(dcerpc.dcerpc_samr_SetBootKeyInformation, self.pipe, r)
+
class DomainHandle(SamrHandle):
def QueryDomainInfo(self, level = 2):
@@ -517,6 +520,7 @@ class DomainHandle(SamrHandle):
call_fn(dcerpc.dcerpc_samr_TestPrivateFunctionsDomain, self.pipe, r)
+
class UserHandle(SamrHandle):
def DeleteUser(self):
@@ -576,6 +580,7 @@ class UserHandle(SamrHandle):
call_fn(dcerpc.dcerpc_samr_TestPrivateFunctionsUser, self.pipe, r)
+
class GroupHandle(SamrHandle):
def QueryGroupInfo(self, level):
@@ -608,6 +613,7 @@ class GroupHandle(SamrHandle):
dcerpc.uint32_array_getitem(r.data_out.rids.unknown, x))
for x in range(r.data_out.rids.count)]
+
class AliasHandle(SamrHandle):
def DeleteDomAlias(self):
diff --git a/source4/scripting/python/samba/tests/dcerpc/bare.py b/source4/scripting/python/samba/tests/dcerpc/bare.py
index fae699a249..cd939b8098 100644
--- a/source4/scripting/python/samba/tests/dcerpc/bare.py
+++ b/source4/scripting/python/samba/tests/dcerpc/bare.py
@@ -22,6 +22,7 @@ from samba.dcerpc import ClientConnection
from unittest import TestCase
from samba.tests import cmdline_loadparm
+
class BareTestCase(TestCase):
def test_bare(self):
# Connect to the echo pipe
diff --git a/source4/scripting/python/samba/tests/dcerpc/registry.py b/source4/scripting/python/samba/tests/dcerpc/registry.py
index 81133ff641..526b2340cc 100644
--- a/source4/scripting/python/samba/tests/dcerpc/registry.py
+++ b/source4/scripting/python/samba/tests/dcerpc/registry.py
@@ -21,6 +21,7 @@ from samba.dcerpc import winreg
import unittest
from samba.tests import RpcInterfaceTestCase
+
class WinregTests(RpcInterfaceTestCase):
def setUp(self):
self.conn = winreg.winreg("ncalrpc:", self.get_loadparm(),
diff --git a/source4/scripting/python/samba/tests/dcerpc/rpcecho.py b/source4/scripting/python/samba/tests/dcerpc/rpcecho.py
index 96bb3923a6..12638e2397 100644
--- a/source4/scripting/python/samba/tests/dcerpc/rpcecho.py
+++ b/source4/scripting/python/samba/tests/dcerpc/rpcecho.py
@@ -22,6 +22,7 @@ from samba.ndr import ndr_pack, ndr_unpack
import unittest
from samba.tests import RpcInterfaceTestCase
+
class RpcEchoTests(RpcInterfaceTestCase):
def setUp(self):
self.conn = echo.rpcecho("ncalrpc:", self.get_loadparm())
@@ -56,6 +57,7 @@ class RpcEchoTests(RpcInterfaceTestCase):
def test_server_name(self):
self.assertEquals(None, self.conn.server_name)
+
class NdrEchoTests(unittest.TestCase):
def test_info1_push(self):
x = echo.info1()
diff --git a/source4/scripting/python/samba/tests/provision.py b/source4/scripting/python/samba/tests/provision.py
index 76c10145f0..352357f694 100644
--- a/source4/scripting/python/samba/tests/provision.py
+++ b/source4/scripting/python/samba/tests/provision.py
@@ -87,7 +87,7 @@ class FindNssTests(unittest.TestCase):
self.assertEquals("ha", findnss(x, ["bloe", "bla"]))
-class Disabled:
+class Disabled(object):
def test_setup_templatesdb(self):
raise NotImplementedError(self.test_setup_templatesdb)
diff --git a/source4/scripting/python/samba/tests/samba3.py b/source4/scripting/python/samba/tests/samba3.py
index 175aa90497..1755cbdcf0 100644
--- a/source4/scripting/python/samba/tests/samba3.py
+++ b/source4/scripting/python/samba/tests/samba3.py
@@ -153,6 +153,7 @@ class WinsDatabaseTestCase(unittest.TestCase):
def tearDown(self):
self.winsdb.close()
+
class SmbpasswdTestCase(unittest.TestCase):
def setUp(self):
self.samdb = SmbpasswdFile(os.path.join(DATADIR, "smbpasswd"))
diff --git a/source4/scripting/python/subunit/__init__.py b/source4/scripting/python/subunit/__init__.py
index ac3d0c3a40..406cd8765b 100644
--- a/source4/scripting/python/subunit/__init__.py
+++ b/source4/scripting/python/subunit/__init__.py
@@ -376,7 +376,7 @@ def run_isolated(klass, self, result):
return result
-class SubunitTestRunner:
+class SubunitTestRunner(object):
def __init__(self, stream=sys.stdout):
self.stream = stream
diff --git a/source4/setup/newuser b/source4/setup/newuser
index e6ab4eda2b..5b677af142 100755
--- a/source4/setup/newuser
+++ b/source4/setup/newuser
@@ -15,7 +15,6 @@ import samba.getopt as options
import optparse
from getpass import getpass
from samba.auth import system_session
-from samba.samdb import SamDB
parser = optparse.OptionParser("newuser [options] <username> [<password>]")
sambaopts = options.SambaOptions(parser)
@@ -44,6 +43,6 @@ if opts.unixname is None:
lp = sambaopts.get_loadparm()
creds = credopts.get_credentials(lp)
-samdb = SamDB(url=lp.get("sam database"), session_info=system_session(),
- credentials=creds, lp=lp)
+samdb = sambaopts.get_hostconfig().get_samdb(session_info=system_session(),
+ credentials=creds)
samdb.newuser(username, opts.unixname, password)