s3:pylibsmb: Make lp a mandatory param for the SMB connection
authorTim Beale <timbeale@catalyst.net.nz>
Tue, 11 Dec 2018 21:25:35 +0000 (10:25 +1300)
committerTim Beale <timbeale@samba.org>
Mon, 7 Jan 2019 00:23:07 +0000 (01:23 +0100)
Currently establishing the SMB connection relies on having initialized
the global source3 loadparm.

This patch makes the lp param mandatory, so that you always have to pass
the parameter in when establishing the SMB connection.

It also makes the source3 API more consistent with the current source4
API, which will make it easier to replace the source4 version later.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/tests/dcerpc/raw_testcase.py
python/samba/tests/libsmb_samba_internal.py
source3/libsmb/pylibsmb.c

index ca1b546a399f9da0070da166f0839614e9e281aa..3a50ceb53304b0dfc5c494df245b798efa1dd331 100644 (file)
@@ -42,7 +42,7 @@ 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$',
+        self.smbconn = libsmb_samba_internal.Conn(target_hostname, 'IPC$', lp3,
                                                   credentials=creds, sign=True)
         self.smbfid = self.smbconn.create(pipename,
                                           DesiredAccess=0x12019f,
index 8918d848ea856ee6a7abcb36acaf4e87907c1778..ebfed94831542f1adaf3c63c9dc8edc66b0104ef 100644 (file)
@@ -60,7 +60,7 @@ class LibsmbTestCase(samba.tests.TestCase):
         creds.set_password(os.getenv("PASSWORD"))
 
         c = libsmb_samba_internal.Conn(os.getenv("SERVER_IP"), "tmp",
-                                       creds, multi_threaded=True,
+                                       lp, creds, multi_threaded=True,
                                        force_smb1=True)
 
         mythreads = []
index 041d408e86e64f50e870a69e48a5883f63d9003b..c1be26b1e5b12cd99ea1f027de84daee1705cc2f 100644 (file)
@@ -423,6 +423,7 @@ static int py_cli_state_init(struct py_cli_state *self, PyObject *args,
        char *host, *share;
        PyObject *creds = NULL;
        struct cli_credentials *cli_creds;
+       PyObject *py_lp = Py_None;
        PyObject *py_multi_threaded = Py_False;
        bool multi_threaded = false;
        PyObject *py_sign = Py_False;
@@ -435,7 +436,7 @@ static int py_cli_state_init(struct py_cli_state *self, PyObject *args,
        int flags = 0;
 
        static const char *kwlist[] = {
-               "host", "share", "credentials",
+               "host", "share", "lp", "credentials",
                "multi_threaded", "sign", "force_smb1",
                NULL
        };
@@ -447,8 +448,8 @@ static int py_cli_state_init(struct py_cli_state *self, PyObject *args,
        }
 
        ret = ParseTupleAndKeywords(
-               args, kwds, "ss|O!OOO", kwlist,
-               &host, &share,
+               args, kwds, "ssO|O!OOO", kwlist,
+               &host, &share, &py_lp,
                py_type_Credentials, &creds,
                &py_multi_threaded,
                &py_sign,