[Python-modules-commits] [pysmbc] 01/03: Import pysmbc_1.0.15.6.orig.tar.bz2

Dmitry Shachnev mitya57 at moszumanska.debian.org
Fri Dec 2 10:52:09 UTC 2016


This is an automated email from the git hooks/post-receive script.

mitya57 pushed a commit to branch master
in repository pysmbc.

commit b84de6b891badd8cb4ffc8fff74b90b548867307
Author: Dmitry Shachnev <mitya57 at gmail.com>
Date:   Sat Nov 26 15:47:27 2016 +0300

    Import pysmbc_1.0.15.6.orig.tar.bz2
---
 PKG-INFO       |  2 +-
 setup.py       |  2 +-
 smbc/context.c | 43 +++++++++++++++++++++++++++++++++++++------
 3 files changed, 39 insertions(+), 8 deletions(-)

diff --git a/PKG-INFO b/PKG-INFO
index ff846b9..0d0fc90 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: pysmbc
-Version: 1.0.15.5
+Version: 1.0.15.6
 Summary: Python bindings for libsmbclient
 Home-page: http://cyberelk.net/tim/software/pysmbc/
 Author: ['Tim Waugh <twaugh at redhat.com>', 'Tsukasa Hamano <hamano at osstech.co.jp>', 'Roberto Polli <rpolli at babel.it>']
diff --git a/setup.py b/setup.py
index f255270..b915405 100644
--- a/setup.py
+++ b/setup.py
@@ -64,7 +64,7 @@ def pkgconfig_I (pkg):
     return dirs
     
 setup (name="pysmbc",
-       version="1.0.15.5",
+       version="1.0.15.6",
        description="Python bindings for libsmbclient",
        long_description=__doc__,
        author=["Tim Waugh <twaugh at redhat.com>",
diff --git a/smbc/context.c b/smbc/context.c
index acf4ec5..fd2d247 100644
--- a/smbc/context.c
+++ b/smbc/context.c
@@ -520,28 +520,59 @@ Context_getxattr (Context *self, PyObject *args)
   int ret;
   char *uri = NULL;
   char *name = NULL;
-  char value[1024];
+  char *buffer = NULL;
   static smbc_getxattr_fn fn;
 
-  bzero(value, sizeof (value));
-
   // smbc_getxattr takes two string parameters
   if (!PyArg_ParseTuple (args, "ss", &uri, &name))
     {
       return NULL;
     }
 
+  /* The security descriptor string returned by this call will vary depending on the requested attribute
+   * A call with system.nt_sec_desc.* will return the longest string which would be in the following format:
+   *
+   * REVISION:<revision number>,OWNER:<sid>,GROUP:<sid>,ACL:<sid>:<type>/<flags>/<mask>
+   *
+   * There could be multiple ACL entries up to a reasonable maximum of 1820.
+   *
+   * <revision number> : 3 chars
+   * <sid> :  184 chars
+   * <type>:  1 char
+   * <flags>: 3 chars
+   * <mask>:  10 chars
+   *
+   * The maximum size of the security descriptor string returned can be
+   * derived as follows (includes space for terminating null):
+   * Sec Desc = 13 + 2 x (7 + <sid>) + 1820 * (5 + <acl>) = 375315
+   *
+   * References: https://msdn.microsoft.com/en-us/library/cc246018.aspx
+   *             https://technet.microsoft.com/en-us/library/cc961995.aspx
+   *             https://technet.microsoft.com/en-us/library/cc961986.aspx
+   */
+
+  size_t size = 375315;
+  buffer = (char *)malloc (size);
+  if(!buffer)
+    return PyErr_NoMemory ();
+
+  bzero(buffer, size);
+
   errno = 0;
   fn = smbc_getFunctionGetxattr(self->context);
-  ret = (*fn)(self->context, uri, name, value, sizeof (value));
+  ret = (*fn)(self->context, uri, name, buffer, size);
 
   if (ret < 0)
     {
       pysmbc_SetFromErrno ();
+      free(buffer);
       return NULL;
-  }
+    }
+
+  PyObject *value = PyUnicode_FromString(buffer);
+  free(buffer);
 
-  return PyUnicode_FromString (value);
+  return value;
 }
 
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/pysmbc.git



More information about the Python-modules-commits mailing list