[SCM] Samba Shared Repository - branch master updated

Tim Beale timbeale at samba.org
Tue Jan 8 02:14:02 UTC 2019


The branch, master has been updated
       via  24cfa0baf51 netcmd: Small refactor to SMB connection in domain backup
       via  888c6080c5f netcmd: Refactor duplicated SMB connect in GPO commands
       via  5a6fcdd8fee tests: Avoid hardcoding domain in GPO tests
       via  af1fe6fdd95 python/ntacls: Convert ntacls to use s3 flags
       via  3ba32aa55fa s3:pylibsmb: Add flags used by .list() to SMB Py bindings
       via  27e2b5c6c0c s3:pylibsmb: Rename 'credentials' param to match s4
       via  bd66d46a399 tests: Rename libsmb_samba_internal test to libsmb
       via  8662ff67201 s3:pylibsmb: Rename libsmb_samba_internal Py bindings to libsmb
      from  01079b50a94 tests: Run SMB Py bindings tests against testenv with SMBv1-disabled

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 24cfa0baf515cf81f21c3f7547b66fd7a44a8ea1
Author: Tim Beale <timbeale at catalyst.net.nz>
Date:   Thu Dec 13 16:50:00 2018 +1300

    netcmd: Small refactor to SMB connection in domain backup
    
    Rework the code so we only do this in one place.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676
    
    Signed-off-by: Tim Beale <timbeale at catalyst.net.nz>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    
    Autobuild-User(master): Tim Beale <timbeale at samba.org>
    Autobuild-Date(master): Tue Jan  8 03:13:48 CET 2019 on sn-devel-144

commit 888c6080c5fed1a85374090f7389fc4cb9d36782
Author: Tim Beale <timbeale at catalyst.net.nz>
Date:   Fri Dec 14 10:47:45 2018 +1300

    netcmd: Refactor duplicated SMB connect in GPO commands
    
    Do the SMB connection in a single helper function.
    
    Note: this highlights that perhaps we want all SMB connections to be
    signed, but we can fix that up separately.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676
    
    Signed-off-by: Tim Beale <timbeale at catalyst.net.nz>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit 5a6fcdd8feea3505407b5130174ff3547a88915d
Author: Tim Beale <timbeale at catalyst.net.nz>
Date:   Fri Dec 14 09:50:02 2018 +1300

    tests: Avoid hardcoding domain in GPO tests
    
    The realm varies by testenv. Currently the GPO tests will only run on
    the ad_dc testenv.
    
    A slightly better solution is to use the REALM environmental variable,
    so that the test can run on any testenv.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676
    
    Signed-off-by: Tim Beale <timbeale at catalyst.net.nz>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit af1fe6fdd95153dd74415a4d20b3c3cd428bd16d
Author: Tim Beale <timbeale at catalyst.net.nz>
Date:   Fri Dec 14 10:34:48 2018 +1300

    python/ntacls: Convert ntacls to use s3 flags
    
    This helper code is just using the flags defined by the Python bindings.
    Convert it over to use s3 bindings instead of s4.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676
    
    Signed-off-by: Tim Beale <timbeale at catalyst.net.nz>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit 3ba32aa55fa6bcd89a2ae9ed73e748ea8ca30b26
Author: Tim Beale <timbeale at catalyst.net.nz>
Date:   Fri Dec 14 10:30:38 2018 +1300

    s3:pylibsmb: Add flags used by .list() to SMB Py bindings
    
    These flags are exposed by the s4 code. Python code that calls .list()
    checks the returned attribs/mode for the directory listing, e.g. to work
    out whether something is a sub-directory:
    
      if item['attrib'] & libsmb.FILE_ATTRIBUTE_DIRECTORY...
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676
    
    Signed-off-by: Tim Beale <timbeale at catalyst.net.nz>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit 27e2b5c6c0c8daada0763fd2c90b3b17c0a68cd6
Author: Tim Beale <timbeale at catalyst.net.nz>
Date:   Thu Dec 13 12:40:49 2018 +1300

    s3:pylibsmb: Rename 'credentials' param to match s4
    
    s4 just calls it 'creds'. Renaming it will make it easier to convert
    existing SMB connections over to use the new bindings.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676
    
    Signed-off-by: Tim Beale <timbeale at catalyst.net.nz>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Gary Lockyer <gary at catalyst.net.nz>

commit bd66d46a399ac3e78ab49ebede867f160c67e774
Author: Tim Beale <timbeale at catalyst.net.nz>
Date:   Thu Dec 13 12:37:33 2018 +1300

    tests: Rename libsmb_samba_internal test to libsmb
    
    So that it better matches the updated Python bindings name.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676
    
    Signed-off-by: Tim Beale <timbeale at catalyst.net.nz>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit 8662ff6720189fae9b7f7ef8afad8c2ed41bd350
Author: Tim Beale <timbeale at catalyst.net.nz>
Date:   Thu Dec 13 12:32:17 2018 +1300

    s3:pylibsmb: Rename libsmb_samba_internal Py bindings to libsmb
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676
    
    Signed-off-by: Tim Beale <timbeale at catalyst.net.nz>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

-----------------------------------------------------------------------

Summary of changes:
 python/samba/netcmd/domain_backup.py               |  9 +++--
 python/samba/netcmd/gpo.py                         | 42 ++++++++++------------
 python/samba/ntacls.py                             | 12 +++----
 python/samba/tests/dcerpc/raw_testcase.py          |  6 ++--
 python/samba/tests/gpo.py                          | 25 +++++++------
 .../tests/{libsmb_samba_internal.py => libsmb.py}  | 10 +++---
 python/samba/tests/smb.py                          |  6 ++--
 source3/libsmb/pylibsmb.c                          | 30 +++++++++++++---
 source3/wscript_build                              |  2 +-
 source4/selftest/tests.py                          |  2 +-
 10 files changed, 83 insertions(+), 61 deletions(-)
 rename python/samba/tests/{libsmb_samba_internal.py => libsmb.py} (88%)


Changeset truncated at 500 lines:

diff --git a/python/samba/netcmd/domain_backup.py b/python/samba/netcmd/domain_backup.py
index c7602a8be26..58d5a4c3510 100644
--- a/python/samba/netcmd/domain_backup.py
+++ b/python/samba/netcmd/domain_backup.py
@@ -101,6 +101,11 @@ def get_sid_for_restore(samdb):
     return str(sid) + '-' + str(rid)
 
 
+def smb_sysvol_conn(server, lp, creds):
+    """Returns an SMB connection to the sysvol share on the DC"""
+    return smb.SMB(server, "sysvol", lp=lp, creds=creds, sign=True)
+
+
 def get_timestamp():
     return datetime.datetime.now().isoformat().replace(':', '-')
 
@@ -251,7 +256,7 @@ class cmd_domain_backup_online(samba.netcmd.Command):
 
         # Grab the remote DC's sysvol files and bundle them into a tar file
         sysvol_tar = os.path.join(tmpdir, 'sysvol.tar.gz')
-        smb_conn = smb.SMB(server, "sysvol", lp=lp, creds=creds, sign=True)
+        smb_conn = smb_sysvol_conn(server, lp, creds)
         backup_online(smb_conn, sysvol_tar, remote_sam.get_domain_sid())
 
         # remove the default sysvol files created by the clone (we want to
@@ -836,7 +841,7 @@ class cmd_domain_backup_rename(samba.netcmd.Command):
         # use the old realm) backed here, as well as default files generated
         # for the new realm as part of the clone/join.
         sysvol_tar = os.path.join(tmpdir, 'sysvol.tar.gz')
-        smb_conn = smb.SMB(server, "sysvol", lp=lp, creds=creds, sign=True)
+        smb_conn = smb_sysvol_conn(server, lp, creds)
         backup_online(smb_conn, sysvol_tar, remote_sam.get_domain_sid())
 
         # connect to the local DB (making sure we use the new/renamed config)
diff --git a/python/samba/netcmd/gpo.py b/python/samba/netcmd/gpo.py
index f1f1e985e61..b65fb7c042c 100644
--- a/python/samba/netcmd/gpo.py
+++ b/python/samba/netcmd/gpo.py
@@ -360,6 +360,14 @@ def create_directory_hier(conn, remotedir):
         if not conn.chkpath(path):
             conn.mkdir(path)
 
+def smb_connection(dc_hostname, service, lp, creds, sign=False):
+    # SMB connect to DC
+    try:
+        conn = smb.SMB(dc_hostname, service, lp=lp, creds=creds, sign=sign)
+    except Exception:
+        raise CommandError("Error connecting to '%s' using SMB" % dc_hostname)
+    return conn
+
 
 class GPOCommand(Command):
     def construct_tmpdir(self, tmpdir, gpo):
@@ -964,14 +972,8 @@ class cmd_fetch(GPOCommand):
             raise CommandError("Invalid GPO path (%s)" % unc)
 
         # SMB connect to DC
-        try:
-            conn = smb.SMB(dc_hostname,
-                           service,
-                           lp=self.lp,
-                           creds=self.creds,
-                           sign=True)
-        except Exception:
-            raise CommandError("Error connecting to '%s' using SMB" % dc_hostname)
+        conn = smb_connection(dc_hostname, service, lp=self.lp,
+                              creds=self.creds, sign=True)
 
         # Copy GPT
         tmpdir, gpodir = self.construct_tmpdir(tmpdir, gpo)
@@ -1033,10 +1035,8 @@ class cmd_backup(GPOCommand):
             raise CommandError("Invalid GPO path (%s)" % unc)
 
         # SMB connect to DC
-        try:
-            conn = smb.SMB(dc_hostname, service, lp=self.lp, creds=self.creds)
-        except Exception:
-            raise CommandError("Error connecting to '%s' using SMB" % dc_hostname)
+        conn = smb_connection(dc_hostname, service, lp=self.lp,
+                              creds=self.creds)
 
         # Copy GPT
         tmpdir, gpodir = self.construct_tmpdir(tmpdir, gpo)
@@ -1192,10 +1192,8 @@ class cmd_create(GPOCommand):
         # Connect to DC over SMB
         [dom_name, service, sharepath] = parse_unc(unc_path)
         self.sharepath = sharepath
-        try:
-            conn = smb.SMB(dc_hostname, service, lp=self.lp, creds=self.creds)
-        except Exception as e:
-            raise CommandError("Error connecting to '%s' using SMB" % dc_hostname, e)
+        conn = smb_connection(dc_hostname, service, lp=self.lp,
+                              creds=self.creds)
 
         self.conn = conn
 
@@ -1449,10 +1447,8 @@ class cmd_del(GPOCommand):
 
         # Connect to DC over SMB
         [dom_name, service, sharepath] = parse_unc(unc_path)
-        try:
-            conn = smb.SMB(dc_hostname, service, lp=self.lp, creds=self.creds)
-        except Exception as e:
-            raise CommandError("Error connecting to '%s' using SMB" % dc_hostname, e)
+        conn = smb_connection(dc_hostname, service, lp=self.lp,
+                              creds=self.creds)
 
         self.samdb.transaction_start()
         try:
@@ -1527,10 +1523,8 @@ class cmd_aclcheck(GPOCommand):
                 raise CommandError("Invalid GPO path (%s)" % unc)
 
             # SMB connect to DC
-            try:
-                conn = smb.SMB(dc_hostname, service, lp=self.lp, creds=self.creds)
-            except Exception:
-                raise CommandError("Error connecting to '%s' using SMB" % dc_hostname)
+            conn = smb_connection(dc_hostname, service, lp=self.lp,
+                                  creds=self.creds)
 
             fs_sd = conn.get_acl(sharepath, security.SECINFO_OWNER | security.SECINFO_GROUP | security.SECINFO_DACL, security.SEC_FLAG_MAXIMUM_ALLOWED)
 
diff --git a/python/samba/ntacls.py b/python/samba/ntacls.py
index 6ac5a3871a8..1ab5fd36e15 100644
--- a/python/samba/ntacls.py
+++ b/python/samba/ntacls.py
@@ -32,13 +32,13 @@ from samba.samba3 import param as s3param
 from samba.dcerpc import security, xattr, idmap
 from samba.ndr import ndr_pack, ndr_unpack
 from samba.samba3 import smbd
-from samba import smb
+from samba.samba3 import libsmb
 
 # don't include volumes
-SMB_FILE_ATTRIBUTE_FLAGS = smb.FILE_ATTRIBUTE_SYSTEM | \
-                           smb.FILE_ATTRIBUTE_DIRECTORY | \
-                           smb.FILE_ATTRIBUTE_ARCHIVE | \
-                           smb.FILE_ATTRIBUTE_HIDDEN
+SMB_FILE_ATTRIBUTE_FLAGS = libsmb.FILE_ATTRIBUTE_SYSTEM | \
+                           libsmb.FILE_ATTRIBUTE_DIRECTORY | \
+                           libsmb.FILE_ATTRIBUTE_ARCHIVE | \
+                           libsmb.FILE_ATTRIBUTE_HIDDEN
 
 
 SECURITY_SECINFO_FLAGS = security.SECINFO_OWNER | \
@@ -348,7 +348,7 @@ class SMBHelper:
 
         attrib is from list method.
         """
-        return bool(attrib & smb.FILE_ATTRIBUTE_DIRECTORY)
+        return bool(attrib & libsmb.FILE_ATTRIBUTE_DIRECTORY)
 
     def join(self, root, name):
         """
diff --git a/python/samba/tests/dcerpc/raw_testcase.py b/python/samba/tests/dcerpc/raw_testcase.py
index 3a50ceb5330..4f3f9992549 100644
--- a/python/samba/tests/dcerpc/raw_testcase.py
+++ b/python/samba/tests/dcerpc/raw_testcase.py
@@ -35,15 +35,15 @@ from samba.ntstatus import (
 )
 from samba import NTSTATUSError
 from samba.samba3 import param as s3param
-from samba.samba3 import libsmb_samba_internal
+from samba.samba3 import libsmb
 
 class smb_pipe_socket(object):
 
     def __init__(self, target_hostname, pipename, creds, impersonation_level, lp):
         lp3 = s3param.get_context()
         lp3.load(lp.configfile)
-        self.smbconn = libsmb_samba_internal.Conn(target_hostname, 'IPC$', lp3,
-                                                  credentials=creds, sign=True)
+        self.smbconn = libsmb.Conn(target_hostname, 'IPC$', lp3,
+                                   creds=creds, sign=True)
         self.smbfid = self.smbconn.create(pipename,
                                           DesiredAccess=0x12019f,
                                           ShareAccess=0x7,
diff --git a/python/samba/tests/gpo.py b/python/samba/tests/gpo.py
index 70dc28c4c23..bf92aea77b6 100644
--- a/python/samba/tests/gpo.py
+++ b/python/samba/tests/gpo.py
@@ -29,8 +29,13 @@ import logging
 from samba.credentials import Credentials
 from samba.compat import get_bytes
 
-poldir = r'\\addom.samba.example.com\sysvol\addom.samba.example.com\Policies'
-dspath = 'CN=Policies,CN=System,DC=addom,DC=samba,DC=example,DC=com'
+realm = os.environ.get('REALM')
+policies = realm + '/POLICIES'
+realm = realm.lower()
+poldir = r'\\{0}\sysvol\{0}\Policies'.format(realm)
+# the first part of the base DN varies by testenv. Work it out from the realm
+base_dn = 'DC={0},DC=samba,DC=example,DC=com'.format(realm.split('.')[0])
+dspath = 'CN=Policies,CN=System,' + base_dn
 gpt_data = '[General]\nVersion=%d'
 
 def days2rel_nttime(val):
@@ -79,6 +84,7 @@ class GPOTests(tests.TestCase):
     def setUp(self):
         super(GPOTests, self).setUp()
         self.server = os.environ["SERVER"]
+        self.dc_account = self.server.upper() + '$'
         self.lp = LoadParm()
         self.lp.load_default()
         self.creds = self.insta_creds(template=self.get_credentials())
@@ -112,7 +118,6 @@ class GPOTests(tests.TestCase):
     def test_gpt_version(self):
         global gpt_data
         local_path = self.lp.cache_path('gpo_cache')
-        policies = 'ADDOM.SAMBA.EXAMPLE.COM/POLICIES'
         guid = '{31B2F340-016D-11D2-945F-00C04FB984F9}'
         gpo_path = os.path.join(local_path, policies, guid)
         old_vers = gpo.gpo_get_sysvol_gpt_version(gpo_path)[1]
@@ -138,7 +143,7 @@ class GPOTests(tests.TestCase):
                         'GPO cache %s was not created' % cache)
 
         guid = '{31B2F340-016D-11D2-945F-00C04FB984F9}'
-        gpt_ini = os.path.join(cache, 'ADDOM.SAMBA.EXAMPLE.COM/POLICIES',
+        gpt_ini = os.path.join(cache, policies,
                                guid, 'GPT.INI')
         self.assertTrue(os.path.exists(gpt_ini),
                         'GPT.INI was not cached for %s' % guid)
@@ -152,9 +157,9 @@ class GPOTests(tests.TestCase):
         self.assertEqual(check_safe_path('\\\\etc/\\passwd'), 'etc/passwd')
 
         # there should be no backslashes used to delineate paths
-        before = 'sysvol/addom.samba.example.com\\Policies/' \
+        before = 'sysvol/' + realm + '\\Policies/' \
             '{31B2F340-016D-11D2-945F-00C04FB984F9}\\GPT.INI'
-        after = 'addom.samba.example.com/Policies/' \
+        after = realm + '/Policies/' \
             '{31B2F340-016D-11D2-945F-00C04FB984F9}/GPT.INI'
         result = check_safe_path(before)
         self.assertEquals(result, after, 'check_safe_path() didn\'t'
@@ -201,7 +206,7 @@ class GPOTests(tests.TestCase):
         local_path = self.lp.get('path', 'sysvol')
         guids = ['{31B2F340-016D-11D2-945F-00C04FB984F9}',
                  '{6AC1786C-016F-11D2-945F-00C04FB984F9}']
-        gpofile = '%s/addom.samba.example.com/Policies/%s/MACHINE/Microsoft/' \
+        gpofile = '%s/' + realm + '/Policies/%s/MACHINE/Microsoft/' \
                   'Windows NT/SecEdit/GptTmpl.inf'
         stage = '[System Access]\nMinimumPasswordAge = 998\n'
         cache_dir = self.lp.get('cache directory')
@@ -214,7 +219,7 @@ class GPOTests(tests.TestCase):
         ret = gpupdate_force(self.lp)
         self.assertEquals(ret, 0, 'gpupdate force failed')
 
-        gp_db = store.get_gplog('ADDC$')
+        gp_db = store.get_gplog(self.dc_account)
 
         applied_guids = gp_db.get_applied_guids()
         self.assertEquals(len(applied_guids), 2, 'The guids were not found')
@@ -240,7 +245,7 @@ class GPOTests(tests.TestCase):
 
         ads = gpo.ADS_STRUCT(self.server, self.lp, self.creds)
         if ads.connect():
-            gpos = ads.get_gpo_list('ADDC$')
+            gpos = ads.get_gpo_list(self.dc_account)
         del_gpos = get_deleted_gpos_list(gp_db, gpos[:-1])
         self.assertEqual(len(del_gpos), 1, 'Returned delete gpos is incorrect')
         self.assertEqual(guids[-1], del_gpos[0][0],
@@ -261,7 +266,7 @@ class GPOTests(tests.TestCase):
         local_path = self.lp.cache_path('gpo_cache')
         guids = ['{31B2F340-016D-11D2-945F-00C04FB984F9}',
                  '{6AC1786C-016F-11D2-945F-00C04FB984F9}']
-        gpofile = '%s/ADDOM.SAMBA.EXAMPLE.COM/POLICIES/%s/MACHINE/MICROSOFT/' \
+        gpofile = '%s/' + policies + '/%s/MACHINE/MICROSOFT/' \
                   'WINDOWS NT/SECEDIT/GPTTMPL.INF'
         logger = logging.getLogger('gpo_tests')
         cache_dir = self.lp.get('cache directory')
diff --git a/python/samba/tests/libsmb_samba_internal.py b/python/samba/tests/libsmb.py
similarity index 88%
rename from python/samba/tests/libsmb_samba_internal.py
rename to python/samba/tests/libsmb.py
index ebfed948315..5a37b09978b 100644
--- a/python/samba/tests/libsmb_samba_internal.py
+++ b/python/samba/tests/libsmb.py
@@ -15,9 +15,9 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
-"""Tests for samba.samba3.libsmb_samba_internal."""
+"""Tests for samba.samba3.libsmb."""
 
-from samba.samba3 import libsmb_samba_internal
+from samba.samba3 import libsmb
 from samba.dcerpc import security
 from samba.samba3 import param as s3param
 from samba import credentials
@@ -59,9 +59,9 @@ class LibsmbTestCase(samba.tests.TestCase):
         creds.set_username(os.getenv("USERNAME"))
         creds.set_password(os.getenv("PASSWORD"))
 
-        c = libsmb_samba_internal.Conn(os.getenv("SERVER_IP"), "tmp",
-                                       lp, creds, multi_threaded=True,
-                                       force_smb1=True)
+        c = libsmb.Conn(os.getenv("SERVER_IP"), "tmp",
+                        lp, creds, multi_threaded=True,
+                        force_smb1=True)
 
         mythreads = []
 
diff --git a/python/samba/tests/smb.py b/python/samba/tests/smb.py
index 9700953d57a..fcb0b7fd7b8 100644
--- a/python/samba/tests/smb.py
+++ b/python/samba/tests/smb.py
@@ -19,11 +19,10 @@ import samba
 import os
 import random
 import sys
-from samba import smb
 from samba import NTSTATUSError
 from samba.ntstatus import (NT_STATUS_OBJECT_NAME_NOT_FOUND,
                             NT_STATUS_OBJECT_PATH_NOT_FOUND)
-from samba.samba3 import libsmb_samba_internal
+from samba.samba3 import libsmb
 from samba.samba3 import param as s3param
 
 PY3 = sys.version_info[0] == 3
@@ -47,8 +46,7 @@ class SMBTests(samba.tests.TestCase):
         # create an SMB connection to the server
         lp = s3param.get_context()
         lp.load(os.getenv("SMB_CONF_PATH"))
-        self.smb_conn = libsmb_samba_internal.Conn(self.server, "sysvol",
-                                                   lp, creds)
+        self.smb_conn = libsmb.Conn(self.server, "sysvol", lp, creds)
 
         self.smb_conn.mkdir(test_dir)
 
diff --git a/source3/libsmb/pylibsmb.c b/source3/libsmb/pylibsmb.c
index 452c30e9490..4322c2b0712 100644
--- a/source3/libsmb/pylibsmb.c
+++ b/source3/libsmb/pylibsmb.c
@@ -440,7 +440,7 @@ static int py_cli_state_init(struct py_cli_state *self, PyObject *args,
 	int flags = 0;
 
 	static const char *kwlist[] = {
-		"host", "share", "lp", "credentials",
+		"host", "share", "lp", "creds",
 		"multi_threaded", "sign", "force_smb1",
 		NULL
 	};
@@ -1526,7 +1526,7 @@ static PyMethodDef py_cli_state_methods[] = {
 
 static PyTypeObject py_cli_state_type = {
 	PyVarObject_HEAD_INIT(NULL, 0)
-	.tp_name = "libsmb_samba_internal.Conn",
+	.tp_name = "libsmb.Conn",
 	.tp_basicsize = sizeof(struct py_cli_state),
 	.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
 	.tp_doc = "libsmb connection",
@@ -1540,17 +1540,17 @@ static PyMethodDef py_libsmb_methods[] = {
 	{ NULL },
 };
 
-void initlibsmb_samba_internal(void);
+void initlibsmb(void);
 
 static struct PyModuleDef moduledef = {
     PyModuleDef_HEAD_INIT,
-    .m_name = "libsmb_samba_internal",
+    .m_name = "libsmb",
     .m_doc = "libsmb wrapper",
     .m_size = -1,
     .m_methods = py_libsmb_methods,
 };
 
-MODULE_INIT_FUNC(libsmb_samba_internal)
+MODULE_INIT_FUNC(libsmb)
 {
 	PyObject *m = NULL;
 
@@ -1565,5 +1565,25 @@ MODULE_INIT_FUNC(libsmb_samba_internal)
 	}
 	Py_INCREF(&py_cli_state_type);
 	PyModule_AddObject(m, "Conn", (PyObject *)&py_cli_state_type);
+
+#define ADD_FLAGS(val)	PyModule_AddObject(m, #val, PyInt_FromLong(val))
+
+	ADD_FLAGS(FILE_ATTRIBUTE_READONLY);
+	ADD_FLAGS(FILE_ATTRIBUTE_HIDDEN);
+	ADD_FLAGS(FILE_ATTRIBUTE_SYSTEM);
+	ADD_FLAGS(FILE_ATTRIBUTE_VOLUME);
+	ADD_FLAGS(FILE_ATTRIBUTE_DIRECTORY);
+	ADD_FLAGS(FILE_ATTRIBUTE_ARCHIVE);
+	ADD_FLAGS(FILE_ATTRIBUTE_DEVICE);
+	ADD_FLAGS(FILE_ATTRIBUTE_NORMAL);
+	ADD_FLAGS(FILE_ATTRIBUTE_TEMPORARY);
+	ADD_FLAGS(FILE_ATTRIBUTE_SPARSE);
+	ADD_FLAGS(FILE_ATTRIBUTE_REPARSE_POINT);
+	ADD_FLAGS(FILE_ATTRIBUTE_COMPRESSED);
+	ADD_FLAGS(FILE_ATTRIBUTE_OFFLINE);
+	ADD_FLAGS(FILE_ATTRIBUTE_NONINDEXED);
+	ADD_FLAGS(FILE_ATTRIBUTE_ENCRYPTED);
+	ADD_FLAGS(FILE_ATTRIBUTE_ALL_MASK);
+
 	return m;
 }
diff --git a/source3/wscript_build b/source3/wscript_build
index a8ea8e581df..9d188a8d36a 100644
--- a/source3/wscript_build
+++ b/source3/wscript_build
@@ -1323,7 +1323,7 @@ for env in bld.gen_python_environments():
     bld.SAMBA3_PYTHON('pylibsmb',
                   source='libsmb/pylibsmb.c',
                   deps='smbclient samba-credentials %s' % pycredentials,
-                  realname='samba/samba3/libsmb_samba_internal.so'
+                  realname='samba/samba3/libsmb.so'
                   )
 
 bld.SAMBA3_BINARY('spotlight2sparql',
diff --git a/source4/selftest/tests.py b/source4/selftest/tests.py
index dd3b0ae6fe3..32887066161 100755
--- a/source4/selftest/tests.py
+++ b/source4/selftest/tests.py
@@ -421,7 +421,7 @@ for t in smbtorture4_testsuites("dlz_bind9."):
     # The dlz_bind9 tests needs to look at the DNS database
     plansmbtorture4testsuite(t, "chgdcpass:local", ["ncalrpc:$SERVER", '-U$USERNAME%$PASSWORD'])
 
-planpythontestsuite("nt4_dc", "samba.tests.libsmb_samba_internal", py3_compatible=True)
+planpythontestsuite("nt4_dc", "samba.tests.libsmb", py3_compatible=True)
 
 # Blackbox Tests:
 # tests that interact directly with the command-line tools rather than using


-- 
Samba Shared Repository



More information about the samba-cvs mailing list