From e3fdf4a1e2b631116d043ce34851274c996013df Mon Sep 17 00:00:00 2001 From: Iustin Pop Date: Sat, 30 Jun 2007 22:18:48 +0000 Subject: [PATCH] Fix a bug when listing xattrs of symlinks Bug report and fix by cscott@cscott.net. --- Makefile | 2 +- setup.py | 4 +--- xattr.c | 20 +++++++++++--------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 25693db..68fccd4 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ doc: xattr.txt xattr.html log: rm -f ChangeLog - svn log | ~/bin/gnuify-changelog.pl > ChangeLog + svn log -r HEAD:1 | ~/bin/gnuify-changelog.pl > ChangeLog build/lib.linux-i686-2.3/xattr.so: xattr.c ./setup.py build diff --git a/setup.py b/setup.py index 21dabec..9e468b4 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ from distutils.core import setup, Extension long_desc = """This is a C extension module for Python which implements extended attributes manipulation. It is a wrapper on top of the attr C library - see attr(5).""" -version = "0.2.1" +version = "0.2.2" setup(name="pyxattr", version=version, @@ -17,6 +17,4 @@ setup(name="pyxattr", url="http://pyxattr.sourceforge.net", license="GPL", ext_modules=[Extension("xattr", ["xattr.c"], libraries=["attr"])], - data_files=[("/usr/share/doc/pyxattr-%s" % version, - ["README", "NEWS", "xattr.html", "xattr.txt"])] ) diff --git a/xattr.c b/xattr.c index 14969b9..8fd55a5 100644 --- a/xattr.c +++ b/xattr.c @@ -41,7 +41,7 @@ pygetxattr(PyObject *self, PyObject *args) char *buf; int nalloc, nret; PyObject *res; - + /* Parse the arguments */ if (!PyArg_ParseTuple(args, "Os|i", &myarg, &attrname, &dolink)) return NULL; @@ -49,7 +49,7 @@ pygetxattr(PyObject *self, PyObject *args) return NULL; /* Find out the needed size of the buffer */ - nalloc = ishandle ? + nalloc = ishandle ? fgetxattr(filedes, attrname, NULL, 0) : dolink ? lgetxattr(file, attrname, NULL, 0) : @@ -65,7 +65,7 @@ pygetxattr(PyObject *self, PyObject *args) } /* Now retrieve the attribute value */ - nret = ishandle ? + nret = ishandle ? fgetxattr(filedes, attrname, buf, nalloc) : dolink ? lgetxattr(file, attrname, buf, nalloc) : @@ -123,7 +123,7 @@ pysetxattr(PyObject *self, PyObject *args) char *buf; int bufsize, nret; int flags = 0; - + /* Parse the arguments */ if (!PyArg_ParseTuple(args, "Oss#|bi", &myarg, &attrname, &buf, &bufsize, &flags, &dolink)) return NULL; @@ -170,7 +170,7 @@ pyremovexattr(PyObject *self, PyObject *args) int ishandle, filedes, dolink=0; char *attrname; int nret; - + /* Parse the arguments */ if (!PyArg_ParseTuple(args, "Os|i", &myarg, &attrname, &dolink)) return NULL; @@ -219,7 +219,7 @@ pylistxattr(PyObject *self, PyObject *args) PyObject *mytuple; int nattrs; char *s; - + /* Parse the arguments */ if (!PyArg_ParseTuple(args, "O|i", &myarg, &dolink)) return NULL; @@ -229,6 +229,8 @@ pylistxattr(PyObject *self, PyObject *args) /* Find out the needed size of the buffer */ nalloc = ishandle ? flistxattr(filedes, NULL, 0) : + dolink ? + llistxattr(file, NULL, 0) : listxattr(file, NULL, 0); if(nalloc == -1) { @@ -242,8 +244,8 @@ pylistxattr(PyObject *self, PyObject *args) } /* Now retrieve the list of attributes */ - nret = ishandle ? - flistxattr(filedes, buf, nalloc) : + nret = ishandle ? + flistxattr(filedes, buf, nalloc) : dolink ? llistxattr(file, buf, nalloc) : listxattr(file, buf, nalloc); @@ -308,7 +310,7 @@ void initxattr(void) { PyObject *m = Py_InitModule3("xattr", xattr_methods, __xattr_doc__); - + PyModule_AddIntConstant(m, "XATTR_CREATE", XATTR_CREATE); PyModule_AddIntConstant(m, "XATTR_REPLACE", XATTR_REPLACE); -- 2.39.5