The branch, master has been updated
       via  80685fd823f s4:libcli: Remove (now unused) pysmb.c bindings
       via  8c097b4a317 s3:pylibsmb: Initialize pointers to NULL in new API code
      from  d93f901ed7d Fix tests when building with selftest but without 
developer

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


- Log -----------------------------------------------------------------
commit 80685fd823f3bdb47876e5ec5985420df506ce4e
Author: Tim Beale <[email protected]>
Date:   Tue Jan 22 11:18:50 2019 +1300

    s4:libcli: Remove (now unused) pysmb.c bindings
    
    The s4 SMB client bindings don't support SMBv2, so we've made the
    decision to use the s3 SMB client bindings/library code instead.
    Everything in the Samba codebase now uses the s3 bindings, and we'll
    add a warning message to Samba v4.10 that the s4 bindings are
    deprecated. This patch removes the unused s4 bindings completely for
    the next (i.e. v4.11) release.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676
    
    Signed-off-by: Tim Beale <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>
    
    Autobuild-User(master): Jeremy Allison <[email protected]>
    Autobuild-Date(master): Sat Jan 26 04:05:25 CET 2019 on sn-devel-144

commit 8c097b4a3177c8c5786ed599fe7c39ce8421fb2c
Author: Tim Beale <[email protected]>
Date:   Thu Jan 17 10:52:24 2019 +1300

    s3:pylibsmb: Initialize pointers to NULL in new API code
    
    Fix a few uninitialized pointers that managed to sneak through review.
    
    Signed-off-by: Tim Beale <[email protected]>
    Reviewed-by: Douglas Bagnall <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

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

Summary of changes:
 source3/libsmb/pylibsmb.c    |   8 +-
 source4/libcli/pysmb.c       | 747 -------------------------------------------
 source4/libcli/wscript_build |  10 -
 3 files changed, 4 insertions(+), 761 deletions(-)
 delete mode 100644 source4/libcli/pysmb.c


Changeset truncated at 500 lines:

diff --git a/source3/libsmb/pylibsmb.c b/source3/libsmb/pylibsmb.c
index b4903a9b8c5..629ff0a4fd3 100644
--- a/source3/libsmb/pylibsmb.c
+++ b/source3/libsmb/pylibsmb.c
@@ -1223,7 +1223,7 @@ static PyObject *py_cli_list(struct py_cli_state *self,
        char *user_mask = NULL;
        unsigned int attribute = LIST_ATTRIBUTE_MASK;
        NTSTATUS status;
-       PyObject *result;
+       PyObject *result = NULL;
        const char *kwlist[] = { "directory", "mask", "attribs", NULL };
 
        if (!ParseTupleAndKeywords(args, kwds, "z|sH:list", kwlist,
@@ -1313,7 +1313,7 @@ static NTSTATUS remove_dir(struct py_cli_state *self, 
const char *dirname)
 static PyObject *py_smb_rmdir(struct py_cli_state *self, PyObject *args)
 {
        NTSTATUS status;
-       const char *dirname;
+       const char *dirname = NULL;
 
        if (!PyArg_ParseTuple(args, "s:rmdir", &dirname)) {
                return NULL;
@@ -1331,7 +1331,7 @@ static PyObject *py_smb_rmdir(struct py_cli_state *self, 
PyObject *args)
 static PyObject *py_smb_mkdir(struct py_cli_state *self, PyObject *args)
 {
        NTSTATUS status;
-       const char *dirname;
+       const char *dirname = NULL;
 
        if (!PyArg_ParseTuple(args, "s:mkdir", &dirname)) {
                return NULL;
@@ -1379,7 +1379,7 @@ static bool check_dir_path(struct py_cli_state *self, 
const char *path)
 
 static PyObject *py_smb_chkpath(struct py_cli_state *self, PyObject *args)
 {
-       const char *path;
+       const char *path = NULL;
        bool dir_exists;
 
        if (!PyArg_ParseTuple(args, "s:chkpath", &path)) {
diff --git a/source4/libcli/pysmb.c b/source4/libcli/pysmb.c
deleted file mode 100644
index 5a028169661..00000000000
--- a/source4/libcli/pysmb.c
+++ /dev/null
@@ -1,747 +0,0 @@
-/*
-   Unix SMB/CIFS implementation.
-
-   Copyright (C) Amitay Isaacs 2011
-
-   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/>.
-*/
-
-#include <Python.h>
-#include "python/py3compat.h"
-#include <tevent.h>
-#include <pytalloc.h>
-#include "includes.h"
-#include "param/param.h"
-#include "param/pyparam.h"
-#include "system/dir.h"
-#include "system/filesys.h"
-#include "lib/events/events.h"
-#include "auth/credentials/credentials.h"
-#include "auth/credentials/pycredentials.h"
-#include "auth/gensec/gensec.h"
-#include "libcli/libcli.h"
-#include "libcli/raw/libcliraw.h"
-#include "libcli/raw/raw_proto.h"
-#include "libcli/resolve/resolve.h"
-#include "libcli/util/pyerrors.h"
-#include "libcli/smb_composite/smb_composite.h"
-#include "libcli/security/security_descriptor.h"
-#include "librpc/rpc/pyrpc_util.h"
-
-static PyTypeObject PySMB;
-
-void initsmb(void);
-
-struct smb_private_data {
-       struct loadparm_context *lp_ctx;
-       struct cli_credentials *creds;
-       struct tevent_context *ev_ctx;
-       struct smbcli_tree *tree;
-};
-
-static void dos_format(char *s)
-{
-       string_replace(s, '/', '\\');
-}
-
-
-/*
- * Connect to SMB share using smb_full_connection
- */
-static NTSTATUS do_smb_connect(TALLOC_CTX *mem_ctx, struct smb_private_data 
*spdata,
-                              const char *hostname, const char *service,
-                              struct smbcli_options *options,
-                              struct smbcli_session_options *session_options,
-                              struct smbcli_tree **tree)
-{
-       struct smbcli_state *smb_state;
-       NTSTATUS status;
-
-       *tree = NULL;
-
-       gensec_init();
-
-       smb_state = smbcli_state_init(mem_ctx);
-
-       status = smbcli_full_connection(mem_ctx, &smb_state, hostname, 
-                                       lpcfg_smb_ports(spdata->lp_ctx),
-                                       service, 
-                                       NULL,
-                                       lpcfg_socket_options(spdata->lp_ctx),
-                                       spdata->creds,
-                                       lpcfg_resolve_context(spdata->lp_ctx),
-                                       spdata->ev_ctx,
-                                       options,
-                                       session_options,
-                                       lpcfg_gensec_settings(mem_ctx, 
spdata->lp_ctx));
-
-       if (NT_STATUS_IS_OK(status)) {
-               *tree = smb_state->tree;
-       }
-
-       return status;
-}
-
-
-/*
- * Read SMB file and return the contents of the file as python string
- */
-static PyObject * py_smb_loadfile(PyObject *self, PyObject *args)
-{
-       struct smb_composite_loadfile io;
-       const char *filename;
-       NTSTATUS status;
-       struct smb_private_data *spdata;
-
-       if (!PyArg_ParseTuple(args, "s:loadfile", &filename)) {
-               return NULL;
-       }
-
-       ZERO_STRUCT(io);
-
-       io.in.fname = filename;
-
-       spdata = pytalloc_get_ptr(self);
-       status = smb_composite_loadfile(spdata->tree, 
pytalloc_get_mem_ctx(self), &io);
-       PyErr_NTSTATUS_IS_ERR_RAISE(status);
-
-       return Py_BuildValue(PYARG_BYTES_LEN, io.out.data, io.out.size);
-}
-
-/*
- * Create a SMB file with given string as the contents
- */
-static PyObject * py_smb_savefile(PyObject *self, PyObject *args)
-{
-       struct smb_composite_savefile io;
-       const char *filename;
-       char *data = NULL;
-       Py_ssize_t size = 0;
-       NTSTATUS status;
-       struct smb_private_data *spdata;
-
-       if (!PyArg_ParseTuple(args, "s"PYARG_BYTES_LEN":savefile", &filename, 
&data, &size )) {
-               return NULL;
-       }
-
-       io.in.fname = filename;
-       io.in.data = (unsigned char *)data;
-       io.in.size = size;
-
-       spdata = pytalloc_get_ptr(self);
-       status = smb_composite_savefile(spdata->tree, &io);
-       PyErr_NTSTATUS_IS_ERR_RAISE(status);
-
-       Py_RETURN_NONE;
-}
-
-/*
- * Callback function to accumulate directory contents in a python list
- */
-static void py_smb_list_callback(struct clilist_file_info *f, const char 
*mask, void *state)
-{
-       PyObject *py_dirlist;
-       PyObject *dict;
-
-       if(!ISDOT(f->name) && !ISDOTDOT(f->name)) {
-               py_dirlist = (PyObject *)state;
-
-               dict = PyDict_New();
-               if(dict) {
-                       PyDict_SetItemString(dict, "name", 
PyStr_FromString(f->name));
-                       
-                       /* Windows does not always return short_name */
-                       if (f->short_name) {
-                               PyDict_SetItemString(dict, "short_name", 
PyStr_FromString(f->short_name));
-                       } else {
-                               PyDict_SetItemString(dict, "short_name", 
Py_None);
-                       }
-
-                       PyDict_SetItemString(dict, "size", 
PyLong_FromUnsignedLongLong(f->size));
-                       PyDict_SetItemString(dict, "attrib", 
PyInt_FromLong(f->attrib));
-                       PyDict_SetItemString(dict, "mtime", 
PyInt_FromLong(f->mtime));
-
-                       PyList_Append(py_dirlist, dict);
-               }
-       }
-}
-
-/*
- * List the directory contents for specified directory (Ignore '.' and '..' 
dirs)
- */
-static PyObject *py_smb_list(PyObject *self, PyObject *args, PyObject *kwargs)
-{
-       struct smb_private_data *spdata;
-       PyObject *py_dirlist;
-       const char *kwnames[] = { "directory", "mask", "attribs", NULL };
-       char *base_dir;
-       char *user_mask = NULL;
-       char *mask;
-       uint16_t attribute = FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_DIRECTORY
-                               | FILE_ATTRIBUTE_ARCHIVE;
-
-       if (!PyArg_ParseTupleAndKeywords(args, kwargs, "z|sH:list",
-                                       discard_const_p(char *, kwnames),
-                                       &base_dir, &user_mask, &attribute)) {
-               return NULL;
-       }
-
-       if (user_mask == NULL) {
-               mask = talloc_asprintf(pytalloc_get_mem_ctx(self), "%s\\*", 
base_dir);
-       } else {
-               mask = talloc_asprintf(pytalloc_get_mem_ctx(self), "%s\\%s", 
base_dir, user_mask);
-       }
-       dos_format(mask);
-
-       spdata = pytalloc_get_ptr(self);
-
-       if((py_dirlist = PyList_New(0)) == NULL) {
-               PyErr_NoMemory();
-               return NULL;
-       }
-
-       smbcli_list(spdata->tree, mask, attribute, py_smb_list_callback, (void 
*)py_dirlist);
-
-       talloc_free(mask);
-
-       return py_dirlist;
-}
-
-/*
- * Create a directory
- */
-static PyObject *py_smb_mkdir(PyObject *self, PyObject *args)
-{
-       NTSTATUS status;
-       const char *dirname;
-       struct smb_private_data *spdata;
-
-       if (!PyArg_ParseTuple(args, "s:mkdir", &dirname)) {
-               return NULL;
-       }
-
-       spdata = pytalloc_get_ptr(self);
-       status = smbcli_mkdir(spdata->tree, dirname);
-       PyErr_NTSTATUS_IS_ERR_RAISE(status);
-
-       Py_RETURN_NONE;
-}
-
-/*
- * Remove a directory
- */
-static PyObject *py_smb_rmdir(PyObject *self, PyObject *args)
-{
-       NTSTATUS status;
-       const char *dirname;
-       struct smb_private_data *spdata;
-
-       if (!PyArg_ParseTuple(args, "s:rmdir", &dirname)) {
-               return NULL;
-       }
-
-       spdata = pytalloc_get_ptr(self);
-       status = smbcli_rmdir(spdata->tree, dirname);
-       PyErr_NTSTATUS_IS_ERR_RAISE(status);
-
-       Py_RETURN_NONE;
-}
-
-
-/*
- * Remove a file
- */
-static PyObject *py_smb_unlink(PyObject *self, PyObject *args)
-{
-       NTSTATUS status;
-       const char *filename;
-       struct smb_private_data *spdata;
-
-       if (!PyArg_ParseTuple(args, "s:unlink", &filename)) {
-               return NULL;
-       }
-
-       spdata = pytalloc_get_ptr(self);
-       status = smbcli_unlink(spdata->tree, filename);
-       PyErr_NTSTATUS_IS_ERR_RAISE(status);
-
-       Py_RETURN_NONE;
-}
-
-/*
- * Remove a directory and all its contents
- */
-static PyObject *py_smb_deltree(PyObject *self, PyObject *args)
-{
-       int status;
-       const char *dirname;
-       struct smb_private_data *spdata;
-
-       if (!PyArg_ParseTuple(args, "s:deltree", &dirname)) {
-               return NULL;
-       }
-
-       spdata = pytalloc_get_ptr(self);
-       status = smbcli_deltree(spdata->tree, dirname);
-       if (status <= 0) {
-               return NULL;
-       }
-
-       Py_RETURN_NONE;
-}
-
-/*
- * Check existence of a path
- */
-static PyObject *py_smb_chkpath(PyObject *self, PyObject *args)
-{
-       NTSTATUS status;
-       const char *path;
-       struct smb_private_data *spdata;
-
-       if (!PyArg_ParseTuple(args, "s:chkpath", &path)) {
-               return NULL;
-       }
-
-       spdata = pytalloc_get_ptr(self);
-       status = smbcli_chkpath(spdata->tree, path);
-
-       if (NT_STATUS_IS_OK(status)) {
-               Py_RETURN_TRUE;
-       }
-
-       Py_RETURN_FALSE;
-}
-
-/*
- * Read ACL on a given file/directory as a security descriptor object
- */
-static PyObject *py_smb_getacl(PyObject *self, PyObject *args, PyObject 
*kwargs)
-{
-       NTSTATUS status;
-       union smb_open io;
-       union smb_fileinfo fio;
-       struct smb_private_data *spdata;
-       const char *filename;
-       uint32_t sinfo = 0;
-       int access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
-       int fnum;
-
-       if (!PyArg_ParseTuple(args, "s|Ii:get_acl", &filename, &sinfo, 
&access_mask)) {
-               return NULL;
-       }
-
-       ZERO_STRUCT(io);
-
-       spdata = pytalloc_get_ptr(self);
-
-       io.generic.level = RAW_OPEN_NTCREATEX;
-       io.ntcreatex.in.root_fid.fnum = 0;
-       io.ntcreatex.in.flags = 0;
-       io.ntcreatex.in.access_mask = access_mask;
-       io.ntcreatex.in.create_options = 0;
-       io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
-       io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | 
-                                       NTCREATEX_SHARE_ACCESS_WRITE;
-       io.ntcreatex.in.alloc_size = 0;
-       io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
-       io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
-       io.ntcreatex.in.security_flags = 0;
-       io.ntcreatex.in.fname = filename;
-       
-       status = smb_raw_open(spdata->tree, pytalloc_get_mem_ctx(self), &io);
-       PyErr_NTSTATUS_IS_ERR_RAISE(status);
-
-       fnum = io.ntcreatex.out.file.fnum;
-
-       ZERO_STRUCT(fio);
-
-       fio.query_secdesc.level = RAW_FILEINFO_SEC_DESC;
-       fio.query_secdesc.in.file.fnum = fnum;
-       if (sinfo)
-               fio.query_secdesc.in.secinfo_flags = sinfo;
-       else
-               fio.query_secdesc.in.secinfo_flags = SECINFO_OWNER |
-                                               SECINFO_GROUP |
-                                               SECINFO_DACL |
-                                               SECINFO_PROTECTED_DACL |
-                                               SECINFO_UNPROTECTED_DACL |
-                                               SECINFO_SACL |
-                                               SECINFO_PROTECTED_SACL |
-                                               SECINFO_UNPROTECTED_SACL;
-
-       status = smb_raw_query_secdesc(spdata->tree, 
pytalloc_get_mem_ctx(self), &fio);
-       smbcli_close(spdata->tree, fnum);
-
-       PyErr_NTSTATUS_IS_ERR_RAISE(status);
-
-       return py_return_ndr_struct("samba.dcerpc.security", "descriptor",
-                               pytalloc_get_mem_ctx(self), 
fio.query_secdesc.out.sd);
-}
-
-/*
- * Set ACL on file/directory using given security descriptor object
- */
-static PyObject *py_smb_setacl(PyObject *self, PyObject *args, PyObject 
*kwargs)
-{
-       NTSTATUS status;
-       union smb_open io;
-       union smb_setfileinfo fio;
-       struct smb_private_data *spdata;
-       const char *filename;
-       PyObject *py_sd;
-       struct security_descriptor *sd;
-       uint32_t sinfo = 0;
-       int fnum;
-
-       if (!PyArg_ParseTuple(args, "sO|I:get_acl", &filename, &py_sd, &sinfo)) 
{
-               return NULL;
-       }
-
-       spdata = pytalloc_get_ptr(self);
-
-       sd = pytalloc_get_type(py_sd, struct security_descriptor);
-       if (!sd) {
-               PyErr_Format(PyExc_TypeError, 
-                       "Expected dcerpc.security.descriptor as argument, got 
%s", 
-                       talloc_get_name(pytalloc_get_ptr(py_sd)));
-               return NULL;
-       }
-
-       ZERO_STRUCT(io);
-
-       spdata = pytalloc_get_ptr(self);
-
-       io.generic.level = RAW_OPEN_NTCREATEX;
-       io.ntcreatex.in.root_fid.fnum = 0;
-       io.ntcreatex.in.flags = 0;
-       io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
-       io.ntcreatex.in.create_options = 0;
-       io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
-       io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | 
-                                       NTCREATEX_SHARE_ACCESS_WRITE;
-       io.ntcreatex.in.alloc_size = 0;
-       io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
-       io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
-       io.ntcreatex.in.security_flags = 0;
-       io.ntcreatex.in.fname = filename;
-       
-       status = smb_raw_open(spdata->tree, pytalloc_get_mem_ctx(self), &io);
-       PyErr_NTSTATUS_IS_ERR_RAISE(status);
-
-       fnum = io.ntcreatex.out.file.fnum;
-
-       ZERO_STRUCT(fio);
-
-       fio.set_secdesc.level = RAW_SFILEINFO_SEC_DESC;
-       fio.set_secdesc.in.file.fnum = fnum;
-       if (sinfo)
-               fio.set_secdesc.in.secinfo_flags = sinfo;
-       else
-               fio.set_secdesc.in.secinfo_flags = SECINFO_OWNER |
-                                               SECINFO_GROUP |
-                                               SECINFO_DACL |


-- 
Samba Shared Repository

Reply via email to