Hello community, here is the log from the commit of package python-xattr for openSUSE:Factory checked in at 2019-03-04 09:10:37 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-xattr (Old) and /work/SRC/openSUSE:Factory/.python-xattr.new.28833 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-xattr" Mon Mar 4 09:10:37 2019 rev:18 rq:680408 version:0.9.6 Changes: -------- --- /work/SRC/openSUSE:Factory/python-xattr/python-xattr.changes 2018-07-17 09:40:08.513787215 +0200 +++ /work/SRC/openSUSE:Factory/.python-xattr.new.28833/python-xattr.changes 2019-03-04 09:10:38.860705186 +0100 @@ -1,0 +2,13 @@ +Fri Mar 1 09:33:42 UTC 2019 - Tomáš Chvátal <[email protected]> + +- Update to 0.9.6: + * Fix release build by including *.[ch] in Manifest.in + * Extract inline C code for syntax highlighting and easier maintenance + https://github.com/xattr/xattr/pull/75 + * Fix Travis build + https://github.com/xattr/xattr/pull/74 + * Always include sys/types.h (musl compatibility) + https://github.com/xattr/xattr/pull/73 +- Enable tests + +------------------------------------------------------------------- Old: ---- xattr-0.9.3.tar.gz New: ---- xattr-0.9.6.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-xattr.spec ++++++ --- /var/tmp/diff_new_pack.BVUDS6/_old 2019-03-04 09:10:39.420705092 +0100 +++ /var/tmp/diff_new_pack.BVUDS6/_new 2019-03-04 09:10:39.420705092 +0100 @@ -1,7 +1,7 @@ # # spec file for package python-xattr # -# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -12,32 +12,31 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-xattr -Version: 0.9.3 +Version: 0.9.6 Release: 0 Summary: Python wrapper for extended filesystem attributes License: MIT Group: Development/Languages/Python -Url: http://github.com/xattr/xattr +URL: http://github.com/xattr/xattr Source: https://files.pythonhosted.org/packages/source/x/xattr/xattr-%{version}.tar.gz BuildRequires: %{python_module cffi} BuildRequires: %{python_module devel} BuildRequires: %{python_module setuptools} +BuildRequires: fdupes BuildRequires: python-rpm-macros Requires: python-cffi >= 1.11 Requires(post): update-alternatives Requires(postun): update-alternatives -BuildRoot: %{_tmppath}/%{name}-%{version}-build %ifpython2 Provides: pyxattr = %{version} Obsoletes: pyxattr < %{version} %endif - %python_subpackages %description @@ -58,8 +57,12 @@ %install %python_install +%python_expand %fdupes %{buildroot}%{$python_sitearch} %python_clone -a %{buildroot}%{_bindir}/xattr +%check +%python_exec -m unittest discover + %post %python_install_alternative xattr @@ -67,8 +70,8 @@ %python_uninstall_alternative xattr %files %{python_files} -%defattr(-,root,root) -%doc README.rst LICENSE.txt +%license LICENSE.txt +%doc README.rst %python_alternative %{_bindir}/xattr %{python_sitearch}/xattr %{python_sitearch}/xattr-*egg-info ++++++ xattr-0.9.3.tar.gz -> xattr-0.9.6.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xattr-0.9.3/CHANGES.txt new/xattr-0.9.6/CHANGES.txt --- old/xattr-0.9.3/CHANGES.txt 2018-01-29 16:47:41.000000000 +0100 +++ new/xattr-0.9.6/CHANGES.txt 2018-07-31 19:10:59.000000000 +0200 @@ -1,3 +1,19 @@ +Version 0.9.6 released 2018-07-31 + +* Fix release build by including *.[ch] in Manifest.in + https://github.com/xattr/xattr/pull/77 + https://github.com/xattr/xattr/pull/78 + https://github.com/xattr/xattr/pull/79 + +Version 0.9.4 released 2018-07-30 + +* Extract inline C code for syntax highlighting and easier maintenance + https://github.com/xattr/xattr/pull/75 +* Fix Travis build + https://github.com/xattr/xattr/pull/74 +* Always include sys/types.h (musl compatibility) + https://github.com/xattr/xattr/pull/73 + Version 0.9.3 released 2018-01-28 * Do not attempt to use surrogateescape unless it is available diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xattr-0.9.3/MANIFEST.in new/xattr-0.9.6/MANIFEST.in --- old/xattr-0.9.3/MANIFEST.in 2018-01-29 16:47:41.000000000 +0100 +++ new/xattr-0.9.6/MANIFEST.in 2018-07-31 19:10:59.000000000 +0200 @@ -1,4 +1,6 @@ include *.py +include xattr/*.c +include xattr/*.h include *.txt include MANIFEST.in include xattr/tests/*.py diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xattr-0.9.3/PKG-INFO new/xattr-0.9.6/PKG-INFO --- old/xattr-0.9.3/PKG-INFO 2018-01-29 16:48:05.000000000 +0100 +++ new/xattr-0.9.6/PKG-INFO 2018-07-31 19:13:38.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: xattr -Version: 0.9.3 +Version: 0.9.6 Summary: Python wrapper for extended filesystem attributes Home-page: http://github.com/xattr/xattr Author: Bob Ippolito diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xattr-0.9.3/setup.cfg new/xattr-0.9.6/setup.cfg --- old/xattr-0.9.3/setup.cfg 2018-01-29 16:48:05.000000000 +0100 +++ new/xattr-0.9.6/setup.cfg 2018-07-31 19:13:38.000000000 +0200 @@ -1,5 +1,4 @@ [egg_info] tag_build = tag_date = 0 -tag_svn_revision = 0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xattr-0.9.3/setup.py new/xattr-0.9.6/setup.py --- old/xattr-0.9.3/setup.py 2018-01-29 16:47:41.000000000 +0100 +++ new/xattr-0.9.6/setup.py 2018-07-31 19:10:59.000000000 +0200 @@ -5,7 +5,7 @@ from setuptools import setup -VERSION = '0.9.3' +VERSION = '0.9.6' DESCRIPTION = "Python wrapper for extended filesystem attributes" LONG_DESCRIPTION = """ Extended attributes extend the basic attributes of files and directories diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xattr-0.9.3/xattr/__init__.py new/xattr-0.9.6/xattr/__init__.py --- old/xattr-0.9.3/xattr/__init__.py 2018-01-29 16:47:41.000000000 +0100 +++ new/xattr-0.9.6/xattr/__init__.py 2018-07-31 19:10:59.000000000 +0200 @@ -7,7 +7,7 @@ that exposes these extended attributes. """ -__version__ = '0.9.3' +__version__ = '0.9.6' from .compat import integer_types from .lib import (XATTR_NOFOLLOW, XATTR_CREATE, XATTR_REPLACE, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xattr-0.9.3/xattr/lib.py new/xattr-0.9.6/xattr/lib.py --- old/xattr-0.9.3/xattr/lib.py 2018-01-29 16:47:41.000000000 +0100 +++ new/xattr-0.9.6/xattr/lib.py 2018-07-31 19:10:59.000000000 +0200 @@ -6,8 +6,8 @@ try: from ._lib import lib, ffi except ImportError: - from .lib_build import ffi, C_SRC - lib = ffi.verify(C_SRC) + from .lib_build import ffi, c_source + lib = ffi.verify(c_source) XATTR_NOFOLLOW = lib.XATTR_XATTR_NOFOLLOW XATTR_CREATE = lib.XATTR_XATTR_CREATE diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xattr-0.9.3/xattr/lib_build.c new/xattr-0.9.6/xattr/lib_build.c --- old/xattr-0.9.3/xattr/lib_build.c 1970-01-01 01:00:00.000000000 +0100 +++ new/xattr-0.9.6/xattr/lib_build.c 2018-07-31 19:10:59.000000000 +0200 @@ -0,0 +1,565 @@ +#include "Python.h" +#include <sys/types.h> +#ifdef __FreeBSD__ +#include <sys/extattr.h> +#elif defined(__SUN__) || defined(__sun__) || defined(__sun) +#include <sys/stat.h> +#include <fcntl.h> +#include <unistd.h> +#include <dirent.h> +#include <alloca.h> +#else +#include <sys/xattr.h> +#endif + +#ifdef __FreeBSD__ + +/* FreeBSD compatibility API */ +#define XATTR_XATTR_NOFOLLOW 0x0001 +#define XATTR_XATTR_CREATE 0x0002 +#define XATTR_XATTR_REPLACE 0x0004 +#define XATTR_XATTR_NOSECURITY 0x0008 + +#define XATTR_CREATE 0x1 +#define XATTR_REPLACE 0x2 + +/* Converts a freebsd format attribute list into a NULL terminated list. + * The first byte is the length of the following attribute. + */ +static void convert_bsd_list(char *namebuf, size_t size) +{ + size_t offset = 0; + while(offset < size) { + int length = (int) (unsigned char)namebuf[offset]; + memmove(namebuf+offset, namebuf+offset+1, length); + namebuf[offset+length] = '\0'; + offset += length+1; + } +} + +static ssize_t xattr_getxattr(const char *path, const char *name, + void *value, ssize_t size, u_int32_t position, + int options) +{ + if (position != 0 || + !(options == 0 || options == XATTR_XATTR_NOFOLLOW)) { + return -1; + } + + if (options & XATTR_XATTR_NOFOLLOW) { + return extattr_get_link(path, EXTATTR_NAMESPACE_USER, + name, value, size); + } + else { + return extattr_get_file(path, EXTATTR_NAMESPACE_USER, + name, value, size); + } +} + +static ssize_t xattr_setxattr(const char *path, const char *name, + void *value, ssize_t size, u_int32_t position, + int options) +{ + int rv = 0; + int nofollow; + + if (position != 0) { + return -1; + } + + nofollow = options & XATTR_XATTR_NOFOLLOW; + options &= ~XATTR_XATTR_NOFOLLOW; + + if (options == XATTR_XATTR_CREATE || + options == XATTR_XATTR_REPLACE) { + + /* meh. FreeBSD doesn't really have this in its + * API... Oh well. + */ + } + else if (options != 0) { + return -1; + } + + if (nofollow) { + rv = extattr_set_link(path, EXTATTR_NAMESPACE_USER, + name, value, size); + } + else { + rv = extattr_set_file(path, EXTATTR_NAMESPACE_USER, + name, value, size); + } + + /* freebsd returns the written length on success, not zero. */ + if (rv >= 0) { + return 0; + } + else { + return rv; + } +} + +static ssize_t xattr_removexattr(const char *path, const char *name, + int options) +{ + if (!(options == 0 || + options == XATTR_XATTR_NOFOLLOW)) { + return -1; + } + + if (options & XATTR_XATTR_NOFOLLOW) { + return extattr_delete_link(path, EXTATTR_NAMESPACE_USER, name); + } + else { + return extattr_delete_file(path, EXTATTR_NAMESPACE_USER, name); + } +} + + +static ssize_t xattr_listxattr(const char *path, char *namebuf, + size_t size, int options) +{ + ssize_t rv = 0; + if (!(options == 0 || + options == XATTR_XATTR_NOFOLLOW)) { + return -1; + } + + if (options & XATTR_XATTR_NOFOLLOW) { + rv = extattr_list_link(path, EXTATTR_NAMESPACE_USER, namebuf, size); + } + else { + rv = extattr_list_file(path, EXTATTR_NAMESPACE_USER, namebuf, size); + } + + if (rv > 0 && namebuf) { + convert_bsd_list(namebuf, rv); + } + + return rv; +} + +static ssize_t xattr_fgetxattr(int fd, const char *name, void *value, + ssize_t size, u_int32_t position, int options) +{ + if (position != 0 || + !(options == 0 || options == XATTR_XATTR_NOFOLLOW)) { + return -1; + } + + if (options & XATTR_XATTR_NOFOLLOW) { + return -1; + } + else { + return extattr_get_fd(fd, EXTATTR_NAMESPACE_USER, name, value, size); + } +} + +static ssize_t xattr_fsetxattr(int fd, const char *name, void *value, + ssize_t size, u_int32_t position, int options) +{ + int rv = 0; + int nofollow; + + if (position != 0) { + return -1; + } + + nofollow = options & XATTR_XATTR_NOFOLLOW; + options &= ~XATTR_XATTR_NOFOLLOW; + + if (options == XATTR_XATTR_CREATE || + options == XATTR_XATTR_REPLACE) { + /* freebsd noop */ + } + else if (options != 0) { + return -1; + } + + if (nofollow) { + return -1; + } + else { + rv = extattr_set_fd(fd, EXTATTR_NAMESPACE_USER, + name, value, size); + } + + /* freebsd returns the written length on success, not zero. */ + if (rv >= 0) { + return 0; + } + else { + return rv; + } +} + +static ssize_t xattr_fremovexattr(int fd, const char *name, int options) +{ + + if (!(options == 0 || + options == XATTR_XATTR_NOFOLLOW)) { + return -1; + } + + if (options & XATTR_XATTR_NOFOLLOW) { + return -1; + } + else { + return extattr_delete_fd(fd, EXTATTR_NAMESPACE_USER, name); + } +} + + +static ssize_t xattr_flistxattr(int fd, char *namebuf, size_t size, int options) +{ + ssize_t rv = 0; + + if (!(options == 0 || + options == XATTR_XATTR_NOFOLLOW)) { + return -1; + } + + if (options & XATTR_XATTR_NOFOLLOW) { + return -1; + } + else { + rv = extattr_list_fd(fd, EXTATTR_NAMESPACE_USER, namebuf, size); + } + + if (rv > 0 && namebuf) { + convert_bsd_list(namebuf, rv); + } + + return rv; +} + +#elif defined(__SUN__) || defined(__sun__) || defined(__sun) + +/* Solaris 9 and later compatibility API */ +#define XATTR_XATTR_NOFOLLOW 0x0001 +#define XATTR_XATTR_CREATE 0x0002 +#define XATTR_XATTR_REPLACE 0x0004 +#define XATTR_XATTR_NOSECURITY 0x0008 + +#define XATTR_CREATE 0x1 +#define XATTR_REPLACE 0x2 + +#ifndef u_int32_t +#define u_int32_t uint32_t +#endif + +static ssize_t xattr_fgetxattr(int fd, const char *name, void *value, + ssize_t size, u_int32_t position, int options) +{ + int xfd; + ssize_t bytes; + struct stat statbuf; + + /* XXX should check that name does not have / characters in it */ + xfd = openat(fd, name, O_RDONLY | O_XATTR); + if (xfd == -1) { + return -1; + } + if (lseek(xfd, position, SEEK_SET) == -1) { + close(xfd); + return -1; + } + if (value == NULL) { + if (fstat(xfd, &statbuf) == -1) { + close(xfd); + return -1; + } + close(xfd); + return statbuf.st_size; + } + /* XXX should keep reading until the buffer is exhausted or EOF */ + bytes = read(xfd, value, size); + close(xfd); + return bytes; +} + +static ssize_t xattr_getxattr(const char *path, const char *name, + void *value, ssize_t size, u_int32_t position, + int options) +{ + int fd; + ssize_t bytes; + + if (position != 0 || + !(options == 0 || options == XATTR_XATTR_NOFOLLOW)) { + return -1; + } + + fd = open(path, + O_RDONLY | + ((options & XATTR_XATTR_NOFOLLOW) ? O_NOFOLLOW : 0)); + if (fd == -1) { + return -1; + } + bytes = xattr_fgetxattr(fd, name, value, size, position, options); + close(fd); + return bytes; +} + +static ssize_t xattr_fsetxattr(int fd, const char *name, void *value, + ssize_t size, u_int32_t position, int options) +{ + int xfd; + ssize_t bytes = 0; + + /* XXX should check that name does not have / characters in it */ + xfd = openat(fd, name, O_XATTR | O_TRUNC | + ((options & XATTR_XATTR_CREATE) ? O_EXCL : 0) | + ((options & XATTR_XATTR_NOFOLLOW) ? O_NOFOLLOW : 0) | + ((options & XATTR_XATTR_REPLACE) ? O_RDWR : O_WRONLY|O_CREAT), + 0644); + if (xfd == -1) { + return -1; + } + while (size > 0) { + bytes = write(xfd, value, size); + if (bytes == -1) { + close(xfd); + return -1; + } + size -= bytes; + value += bytes; + } + close(xfd); + return 0; +} + +static ssize_t xattr_setxattr(const char *path, const char *name, + void *value, ssize_t size, u_int32_t position, + int options) +{ + int fd; + ssize_t bytes; + + if (position != 0) { + return -1; + } + + fd = open(path, + O_RDONLY | (options & XATTR_XATTR_NOFOLLOW) ? O_NOFOLLOW : 0); + if (fd == -1) { + return -1; + } + bytes = xattr_fsetxattr(fd, name, value, size, position, options); + close(fd); + return bytes; +} + +static ssize_t xattr_fremovexattr(int fd, const char *name, int options) +{ + int xfd, status; + /* XXX should check that name does not have / characters in it */ + if (!(options == 0 || options == XATTR_XATTR_NOFOLLOW)) { + return -1; + } + if (options & XATTR_XATTR_NOFOLLOW) { + return -1; + } + xfd = openat(fd, ".", O_XATTR, 0644); + if (xfd == -1) { + return -1; + } + status = unlinkat(xfd, name, 0); + close(xfd); + return status; +} + +static ssize_t xattr_removexattr(const char *path, const char *name, + int options) +{ + int fd; + ssize_t status; + + fd = open(path, + O_RDONLY | ((options & XATTR_XATTR_NOFOLLOW) ? O_NOFOLLOW : 0)); + if (fd == -1) { + return -1; + } + status = xattr_fremovexattr(fd, name, options); + close(fd); + return status; +} + +static ssize_t xattr_xflistxattr(int xfd, char *namebuf, size_t size, int options) +{ + int esize; + DIR *dirp; + struct dirent *entry; + ssize_t nsize = 0; + + dirp = fdopendir(xfd); + if (dirp == NULL) { + return (-1); + } + while (entry = readdir(dirp)) { + if (strcmp(entry->d_name, ".") == 0 || + strcmp(entry->d_name, "..") == 0) + continue; + esize = strlen(entry->d_name); + if (nsize + esize + 1 <= size) { + snprintf((char *)(namebuf + nsize), esize + 1, + entry->d_name); + } + nsize += esize + 1; /* +1 for \0 */ + } + closedir(dirp); + return nsize; +} +static ssize_t xattr_flistxattr(int fd, char *namebuf, size_t size, int options) +{ + int xfd; + + xfd = openat(fd, ".", O_RDONLY | O_XATTR); + return xattr_xflistxattr(xfd, namebuf, size, options); +} + +static ssize_t xattr_listxattr(const char *path, char *namebuf, + size_t size, int options) +{ + int xfd; + + xfd = attropen(path, ".", O_RDONLY); + return xattr_xflistxattr(xfd, namebuf, size, options); +} + +#elif !defined(XATTR_NOFOLLOW) +/* Linux compatibility API */ +#define XATTR_XATTR_NOFOLLOW 0x0001 +#define XATTR_XATTR_CREATE 0x0002 +#define XATTR_XATTR_REPLACE 0x0004 +#define XATTR_XATTR_NOSECURITY 0x0008 +static ssize_t xattr_getxattr(const char *path, const char *name, void *value, ssize_t size, u_int32_t position, int options) { + if (position != 0 || !(options == 0 || options == XATTR_XATTR_NOFOLLOW)) { + return -1; + } + if (options & XATTR_XATTR_NOFOLLOW) { + return lgetxattr(path, name, value, size); + } else { + return getxattr(path, name, value, size); + } +} + +static ssize_t xattr_setxattr(const char *path, const char *name, void *value, ssize_t size, u_int32_t position, int options) { + int nofollow; + if (position != 0) { + return -1; + } + nofollow = options & XATTR_XATTR_NOFOLLOW; + options &= ~XATTR_XATTR_NOFOLLOW; + if (options == XATTR_XATTR_CREATE) { + options = XATTR_CREATE; + } else if (options == XATTR_XATTR_REPLACE) { + options = XATTR_REPLACE; + } else if (options != 0) { + return -1; + } + if (nofollow) { + return lsetxattr(path, name, value, size, options); + } else { + return setxattr(path, name, value, size, options); + } +} + +static ssize_t xattr_removexattr(const char *path, const char *name, int options) { + if (!(options == 0 || options == XATTR_XATTR_NOFOLLOW)) { + return -1; + } + if (options & XATTR_XATTR_NOFOLLOW) { + return lremovexattr(path, name); + } else { + return removexattr(path, name); + } +} + + +static ssize_t xattr_listxattr(const char *path, char *namebuf, size_t size, int options) { + if (!(options == 0 || options == XATTR_XATTR_NOFOLLOW)) { + return -1; + } + if (options & XATTR_XATTR_NOFOLLOW) { + return llistxattr(path, namebuf, size); + } else { + return listxattr(path, namebuf, size); + } +} + +static ssize_t xattr_fgetxattr(int fd, const char *name, void *value, ssize_t size, u_int32_t position, int options) { + if (position != 0 || !(options == 0 || options == XATTR_XATTR_NOFOLLOW)) { + return -1; + } + if (options & XATTR_XATTR_NOFOLLOW) { + return -1; + } else { + return fgetxattr(fd, name, value, size); + } +} + +static ssize_t xattr_fsetxattr(int fd, const char *name, void *value, ssize_t size, u_int32_t position, int options) { + int nofollow; + if (position != 0) { + return -1; + } + nofollow = options & XATTR_XATTR_NOFOLLOW; + options &= ~XATTR_XATTR_NOFOLLOW; + if (options == XATTR_XATTR_CREATE) { + options = XATTR_CREATE; + } else if (options == XATTR_XATTR_REPLACE) { + options = XATTR_REPLACE; + } else if (options != 0) { + return -1; + } + if (nofollow) { + return -1; + } else { + return fsetxattr(fd, name, value, size, options); + } +} + +static ssize_t xattr_fremovexattr(int fd, const char *name, int options) { + if (!(options == 0 || options == XATTR_XATTR_NOFOLLOW)) { + return -1; + } + if (options & XATTR_XATTR_NOFOLLOW) { + return -1; + } else { + return fremovexattr(fd, name); + } +} + + +static ssize_t xattr_flistxattr(int fd, char *namebuf, size_t size, int options) { + if (!(options == 0 || options == XATTR_XATTR_NOFOLLOW)) { + return -1; + } + if (options & XATTR_XATTR_NOFOLLOW) { + return -1; + } else { + return flistxattr(fd, namebuf, size); + } +} + +#else /* Mac OS X assumed */ +#define xattr_getxattr getxattr +#define xattr_fgetxattr fgetxattr +#define xattr_removexattr removexattr +#define xattr_fremovexattr fremovexattr +#define xattr_setxattr setxattr +#define xattr_fsetxattr fsetxattr +#define xattr_listxattr listxattr +#define xattr_flistxattr flistxattr + +/* define these for use in python (see below) */ +#define XATTR_XATTR_NOFOLLOW XATTR_NOFOLLOW +#define XATTR_XATTR_CREATE XATTR_CREATE +#define XATTR_XATTR_REPLACE XATTR_REPLACE +#define XATTR_XATTR_NOSECURITY XATTR_NOSECURITY +#endif + +#ifndef XATTR_MAXNAMELEN +#define XATTR_MAXNAMELEN 127 +#endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xattr-0.9.3/xattr/lib_build.h new/xattr-0.9.6/xattr/lib_build.h --- old/xattr-0.9.3/xattr/lib_build.h 1970-01-01 01:00:00.000000000 +0100 +++ new/xattr-0.9.6/xattr/lib_build.h 2018-07-31 19:10:59.000000000 +0200 @@ -0,0 +1,17 @@ +#define XATTR_XATTR_NOFOLLOW ... +#define XATTR_XATTR_CREATE ... +#define XATTR_XATTR_REPLACE ... +#define XATTR_XATTR_NOSECURITY ... +#define XATTR_MAXNAMELEN ... + +ssize_t xattr_getxattr(const char *, const char *, void *, ssize_t, uint32_t, int); +ssize_t xattr_fgetxattr(int, const char *, void *, ssize_t, uint32_t, int); + +ssize_t xattr_setxattr(const char *, const char *, void *, ssize_t, uint32_t, int); +ssize_t xattr_fsetxattr(int, const char *, void *, ssize_t, uint32_t, int); + +ssize_t xattr_removexattr(const char *, const char *, int); +ssize_t xattr_fremovexattr(int, const char *, int); + +ssize_t xattr_listxattr(const char *, char *, size_t, int); +ssize_t xattr_flistxattr(int, char *, size_t, int); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xattr-0.9.3/xattr/lib_build.py new/xattr-0.9.6/xattr/lib_build.py --- old/xattr-0.9.3/xattr/lib_build.py 2018-01-29 16:47:41.000000000 +0100 +++ new/xattr-0.9.6/xattr/lib_build.py 2018-07-31 19:10:59.000000000 +0200 @@ -1,600 +1,17 @@ -import os import sys +import os +from cffi import FFI -import cffi - -ffi = cffi.FFI() -ffi.cdef(""" -#define XATTR_XATTR_NOFOLLOW ... -#define XATTR_XATTR_CREATE ... -#define XATTR_XATTR_REPLACE ... -#define XATTR_XATTR_NOSECURITY ... -#define XATTR_MAXNAMELEN ... - -ssize_t xattr_getxattr(const char *, const char *, void *, ssize_t, uint32_t, int); -ssize_t xattr_fgetxattr(int, const char *, void *, ssize_t, uint32_t, int); - -ssize_t xattr_setxattr(const char *, const char *, void *, ssize_t, uint32_t, int); -ssize_t xattr_fsetxattr(int, const char *, void *, ssize_t, uint32_t, int); - -ssize_t xattr_removexattr(const char *, const char *, int); -ssize_t xattr_fremovexattr(int, const char *, int); - -ssize_t xattr_listxattr(const char *, char *, size_t, int); -ssize_t xattr_flistxattr(int, char *, size_t, int); - -""") - -C_SRC = """ -#include "Python.h" -#ifdef __FreeBSD__ -#include <sys/extattr.h> -#elif defined(__SUN__) || defined(__sun__) || defined(__sun) -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <unistd.h> -#include <dirent.h> -#include <alloca.h> -#else -#include <sys/xattr.h> -#endif - -#ifdef __FreeBSD__ - -/* FreeBSD compatibility API */ -#define XATTR_XATTR_NOFOLLOW 0x0001 -#define XATTR_XATTR_CREATE 0x0002 -#define XATTR_XATTR_REPLACE 0x0004 -#define XATTR_XATTR_NOSECURITY 0x0008 - -#define XATTR_CREATE 0x1 -#define XATTR_REPLACE 0x2 - -/* Converts a freebsd format attribute list into a NULL terminated list. - * The first byte is the length of the following attribute. - */ -static void convert_bsd_list(char *namebuf, size_t size) -{ - size_t offset = 0; - while(offset < size) { - int length = (int) (unsigned char)namebuf[offset]; - memmove(namebuf+offset, namebuf+offset+1, length); - namebuf[offset+length] = '\\0'; - offset += length+1; - } -} - -static ssize_t xattr_getxattr(const char *path, const char *name, - void *value, ssize_t size, u_int32_t position, - int options) -{ - if (position != 0 || - !(options == 0 || options == XATTR_XATTR_NOFOLLOW)) { - return -1; - } - - if (options & XATTR_XATTR_NOFOLLOW) { - return extattr_get_link(path, EXTATTR_NAMESPACE_USER, - name, value, size); - } - else { - return extattr_get_file(path, EXTATTR_NAMESPACE_USER, - name, value, size); - } -} - -static ssize_t xattr_setxattr(const char *path, const char *name, - void *value, ssize_t size, u_int32_t position, - int options) -{ - int rv = 0; - int nofollow; - - if (position != 0) { - return -1; - } - - nofollow = options & XATTR_XATTR_NOFOLLOW; - options &= ~XATTR_XATTR_NOFOLLOW; - - if (options == XATTR_XATTR_CREATE || - options == XATTR_XATTR_REPLACE) { - - /* meh. FreeBSD doesn't really have this in its - * API... Oh well. - */ - } - else if (options != 0) { - return -1; - } - - if (nofollow) { - rv = extattr_set_link(path, EXTATTR_NAMESPACE_USER, - name, value, size); - } - else { - rv = extattr_set_file(path, EXTATTR_NAMESPACE_USER, - name, value, size); - } - - /* freebsd returns the written length on success, not zero. */ - if (rv >= 0) { - return 0; - } - else { - return rv; - } -} - -static ssize_t xattr_removexattr(const char *path, const char *name, - int options) -{ - if (!(options == 0 || - options == XATTR_XATTR_NOFOLLOW)) { - return -1; - } - - if (options & XATTR_XATTR_NOFOLLOW) { - return extattr_delete_link(path, EXTATTR_NAMESPACE_USER, name); - } - else { - return extattr_delete_file(path, EXTATTR_NAMESPACE_USER, name); - } -} - - -static ssize_t xattr_listxattr(const char *path, char *namebuf, - size_t size, int options) -{ - ssize_t rv = 0; - if (!(options == 0 || - options == XATTR_XATTR_NOFOLLOW)) { - return -1; - } - - if (options & XATTR_XATTR_NOFOLLOW) { - rv = extattr_list_link(path, EXTATTR_NAMESPACE_USER, namebuf, size); - } - else { - rv = extattr_list_file(path, EXTATTR_NAMESPACE_USER, namebuf, size); - } - - if (rv > 0 && namebuf) { - convert_bsd_list(namebuf, rv); - } - - return rv; -} - -static ssize_t xattr_fgetxattr(int fd, const char *name, void *value, - ssize_t size, u_int32_t position, int options) -{ - if (position != 0 || - !(options == 0 || options == XATTR_XATTR_NOFOLLOW)) { - return -1; - } - - if (options & XATTR_XATTR_NOFOLLOW) { - return -1; - } - else { - return extattr_get_fd(fd, EXTATTR_NAMESPACE_USER, name, value, size); - } -} - -static ssize_t xattr_fsetxattr(int fd, const char *name, void *value, - ssize_t size, u_int32_t position, int options) -{ - int rv = 0; - int nofollow; - - if (position != 0) { - return -1; - } - - nofollow = options & XATTR_XATTR_NOFOLLOW; - options &= ~XATTR_XATTR_NOFOLLOW; - - if (options == XATTR_XATTR_CREATE || - options == XATTR_XATTR_REPLACE) { - /* freebsd noop */ - } - else if (options != 0) { - return -1; - } - - if (nofollow) { - return -1; - } - else { - rv = extattr_set_fd(fd, EXTATTR_NAMESPACE_USER, - name, value, size); - } - - /* freebsd returns the written length on success, not zero. */ - if (rv >= 0) { - return 0; - } - else { - return rv; - } -} - -static ssize_t xattr_fremovexattr(int fd, const char *name, int options) -{ - - if (!(options == 0 || - options == XATTR_XATTR_NOFOLLOW)) { - return -1; - } - - if (options & XATTR_XATTR_NOFOLLOW) { - return -1; - } - else { - return extattr_delete_fd(fd, EXTATTR_NAMESPACE_USER, name); - } -} - - -static ssize_t xattr_flistxattr(int fd, char *namebuf, size_t size, int options) -{ - ssize_t rv = 0; - - if (!(options == 0 || - options == XATTR_XATTR_NOFOLLOW)) { - return -1; - } - - if (options & XATTR_XATTR_NOFOLLOW) { - return -1; - } - else { - rv = extattr_list_fd(fd, EXTATTR_NAMESPACE_USER, namebuf, size); - } - - if (rv > 0 && namebuf) { - convert_bsd_list(namebuf, rv); - } - - return rv; -} - -#elif defined(__SUN__) || defined(__sun__) || defined(__sun) - -/* Solaris 9 and later compatibility API */ -#define XATTR_XATTR_NOFOLLOW 0x0001 -#define XATTR_XATTR_CREATE 0x0002 -#define XATTR_XATTR_REPLACE 0x0004 -#define XATTR_XATTR_NOSECURITY 0x0008 - -#define XATTR_CREATE 0x1 -#define XATTR_REPLACE 0x2 - -#ifndef u_int32_t -#define u_int32_t uint32_t -#endif - -static ssize_t xattr_fgetxattr(int fd, const char *name, void *value, - ssize_t size, u_int32_t position, int options) -{ - int xfd; - ssize_t bytes; - struct stat statbuf; - - /* XXX should check that name does not have / characters in it */ - xfd = openat(fd, name, O_RDONLY | O_XATTR); - if (xfd == -1) { - return -1; - } - if (lseek(xfd, position, SEEK_SET) == -1) { - close(xfd); - return -1; - } - if (value == NULL) { - if (fstat(xfd, &statbuf) == -1) { - close(xfd); - return -1; - } - close(xfd); - return statbuf.st_size; - } - /* XXX should keep reading until the buffer is exhausted or EOF */ - bytes = read(xfd, value, size); - close(xfd); - return bytes; -} - -static ssize_t xattr_getxattr(const char *path, const char *name, - void *value, ssize_t size, u_int32_t position, - int options) -{ - int fd; - ssize_t bytes; - - if (position != 0 || - !(options == 0 || options == XATTR_XATTR_NOFOLLOW)) { - return -1; - } - - fd = open(path, - O_RDONLY | - ((options & XATTR_XATTR_NOFOLLOW) ? O_NOFOLLOW : 0)); - if (fd == -1) { - return -1; - } - bytes = xattr_fgetxattr(fd, name, value, size, position, options); - close(fd); - return bytes; -} - -static ssize_t xattr_fsetxattr(int fd, const char *name, void *value, - ssize_t size, u_int32_t position, int options) -{ - int xfd; - ssize_t bytes = 0; - - /* XXX should check that name does not have / characters in it */ - xfd = openat(fd, name, O_XATTR | O_TRUNC | - ((options & XATTR_XATTR_CREATE) ? O_EXCL : 0) | - ((options & XATTR_XATTR_NOFOLLOW) ? O_NOFOLLOW : 0) | - ((options & XATTR_XATTR_REPLACE) ? O_RDWR : O_WRONLY|O_CREAT), - 0644); - if (xfd == -1) { - return -1; - } - while (size > 0) { - bytes = write(xfd, value, size); - if (bytes == -1) { - close(xfd); - return -1; - } - size -= bytes; - value += bytes; - } - close(xfd); - return 0; -} - -static ssize_t xattr_setxattr(const char *path, const char *name, - void *value, ssize_t size, u_int32_t position, - int options) -{ - int fd; - ssize_t bytes; - - if (position != 0) { - return -1; - } - - fd = open(path, - O_RDONLY | (options & XATTR_XATTR_NOFOLLOW) ? O_NOFOLLOW : 0); - if (fd == -1) { - return -1; - } - bytes = xattr_fsetxattr(fd, name, value, size, position, options); - close(fd); - return bytes; -} - -static ssize_t xattr_fremovexattr(int fd, const char *name, int options) -{ - int xfd, status; - /* XXX should check that name does not have / characters in it */ - if (!(options == 0 || options == XATTR_XATTR_NOFOLLOW)) { - return -1; - } - if (options & XATTR_XATTR_NOFOLLOW) { - return -1; - } - xfd = openat(fd, ".", O_XATTR, 0644); - if (xfd == -1) { - return -1; - } - status = unlinkat(xfd, name, 0); - close(xfd); - return status; -} - -static ssize_t xattr_removexattr(const char *path, const char *name, - int options) -{ - int fd; - ssize_t status; - - fd = open(path, - O_RDONLY | ((options & XATTR_XATTR_NOFOLLOW) ? O_NOFOLLOW : 0)); - if (fd == -1) { - return -1; - } - status = xattr_fremovexattr(fd, name, options); - close(fd); - return status; -} - -static ssize_t xattr_xflistxattr(int xfd, char *namebuf, size_t size, int options) -{ - int esize; - DIR *dirp; - struct dirent *entry; - ssize_t nsize = 0; - - dirp = fdopendir(xfd); - if (dirp == NULL) { - return (-1); - } - while (entry = readdir(dirp)) { - if (strcmp(entry->d_name, ".") == 0 || - strcmp(entry->d_name, "..") == 0) - continue; - esize = strlen(entry->d_name); - if (nsize + esize + 1 <= size) { - snprintf((char *)(namebuf + nsize), esize + 1, - entry->d_name); - } - nsize += esize + 1; /* +1 for \\0 */ - } - closedir(dirp); - return nsize; -} -static ssize_t xattr_flistxattr(int fd, char *namebuf, size_t size, int options) -{ - int xfd; - - xfd = openat(fd, ".", O_RDONLY | O_XATTR); - return xattr_xflistxattr(xfd, namebuf, size, options); -} - -static ssize_t xattr_listxattr(const char *path, char *namebuf, - size_t size, int options) -{ - int xfd; - - xfd = attropen(path, ".", O_RDONLY); - return xattr_xflistxattr(xfd, namebuf, size, options); -} - -#elif !defined(XATTR_NOFOLLOW) -/* Linux compatibility API */ -#define XATTR_XATTR_NOFOLLOW 0x0001 -#define XATTR_XATTR_CREATE 0x0002 -#define XATTR_XATTR_REPLACE 0x0004 -#define XATTR_XATTR_NOSECURITY 0x0008 -static ssize_t xattr_getxattr(const char *path, const char *name, void *value, ssize_t size, u_int32_t position, int options) { - if (position != 0 || !(options == 0 || options == XATTR_XATTR_NOFOLLOW)) { - return -1; - } - if (options & XATTR_XATTR_NOFOLLOW) { - return lgetxattr(path, name, value, size); - } else { - return getxattr(path, name, value, size); - } -} - -static ssize_t xattr_setxattr(const char *path, const char *name, void *value, ssize_t size, u_int32_t position, int options) { - int nofollow; - if (position != 0) { - return -1; - } - nofollow = options & XATTR_XATTR_NOFOLLOW; - options &= ~XATTR_XATTR_NOFOLLOW; - if (options == XATTR_XATTR_CREATE) { - options = XATTR_CREATE; - } else if (options == XATTR_XATTR_REPLACE) { - options = XATTR_REPLACE; - } else if (options != 0) { - return -1; - } - if (nofollow) { - return lsetxattr(path, name, value, size, options); - } else { - return setxattr(path, name, value, size, options); - } -} - -static ssize_t xattr_removexattr(const char *path, const char *name, int options) { - if (!(options == 0 || options == XATTR_XATTR_NOFOLLOW)) { - return -1; - } - if (options & XATTR_XATTR_NOFOLLOW) { - return lremovexattr(path, name); - } else { - return removexattr(path, name); - } -} - - -static ssize_t xattr_listxattr(const char *path, char *namebuf, size_t size, int options) { - if (!(options == 0 || options == XATTR_XATTR_NOFOLLOW)) { - return -1; - } - if (options & XATTR_XATTR_NOFOLLOW) { - return llistxattr(path, namebuf, size); - } else { - return listxattr(path, namebuf, size); - } -} - -static ssize_t xattr_fgetxattr(int fd, const char *name, void *value, ssize_t size, u_int32_t position, int options) { - if (position != 0 || !(options == 0 || options == XATTR_XATTR_NOFOLLOW)) { - return -1; - } - if (options & XATTR_XATTR_NOFOLLOW) { - return -1; - } else { - return fgetxattr(fd, name, value, size); - } -} - -static ssize_t xattr_fsetxattr(int fd, const char *name, void *value, ssize_t size, u_int32_t position, int options) { - int nofollow; - if (position != 0) { - return -1; - } - nofollow = options & XATTR_XATTR_NOFOLLOW; - options &= ~XATTR_XATTR_NOFOLLOW; - if (options == XATTR_XATTR_CREATE) { - options = XATTR_CREATE; - } else if (options == XATTR_XATTR_REPLACE) { - options = XATTR_REPLACE; - } else if (options != 0) { - return -1; - } - if (nofollow) { - return -1; - } else { - return fsetxattr(fd, name, value, size, options); - } -} - -static ssize_t xattr_fremovexattr(int fd, const char *name, int options) { - if (!(options == 0 || options == XATTR_XATTR_NOFOLLOW)) { - return -1; - } - if (options & XATTR_XATTR_NOFOLLOW) { - return -1; - } else { - return fremovexattr(fd, name); - } -} - - -static ssize_t xattr_flistxattr(int fd, char *namebuf, size_t size, int options) { - if (!(options == 0 || options == XATTR_XATTR_NOFOLLOW)) { - return -1; - } - if (options & XATTR_XATTR_NOFOLLOW) { - return -1; - } else { - return flistxattr(fd, namebuf, size); - } -} - -#else /* Mac OS X assumed */ -#define xattr_getxattr getxattr -#define xattr_fgetxattr fgetxattr -#define xattr_removexattr removexattr -#define xattr_fremovexattr fremovexattr -#define xattr_setxattr setxattr -#define xattr_fsetxattr fsetxattr -#define xattr_listxattr listxattr -#define xattr_flistxattr flistxattr - -/* define these for use in python (see below) */ -#define XATTR_XATTR_NOFOLLOW XATTR_NOFOLLOW -#define XATTR_XATTR_CREATE XATTR_CREATE -#define XATTR_XATTR_REPLACE XATTR_REPLACE -#define XATTR_XATTR_NOSECURITY XATTR_NOSECURITY -#endif - -#ifndef XATTR_MAXNAMELEN -#define XATTR_MAXNAMELEN 127 -#endif -""" +PATH = os.path.dirname(__file__) -ffi.set_source('_lib', C_SRC) +with open(os.path.join(PATH, 'lib_build.h')) as hf: + c_header = hf.read() +with open(os.path.join(PATH, 'lib_build.c')) as cf: + c_source = cf.read() + +ffi = FFI() +ffi.cdef(c_header) +ffi.set_source('_lib', c_source) if __name__ == '__main__': ffi.compile() - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xattr-0.9.3/xattr/tests/test_xattr.py new/xattr-0.9.6/xattr/tests/test_xattr.py --- old/xattr-0.9.3/xattr/tests/test_xattr.py 2018-01-29 16:47:41.000000000 +0100 +++ new/xattr-0.9.6/xattr/tests/test_xattr.py 2018-07-31 19:10:59.000000000 +0200 @@ -13,7 +13,22 @@ # manual override here. TESTDIR = None - def test_attr(self): + def test_attr_fs_encoding_unicode(self): + # Not using setlocale(LC_ALL, ..) to set locale because + # sys.getfilesystemencoding() implementation falls back + # to user's preferred locale by calling setlocale(LC_ALL, ''). + xattr.compat.fs_encoding = 'UTF-8' + self._test_attr() + + def test_attr_fs_encoding_ascii(self): + xattr.compat.fs_encoding = 'US-ASCII' + if sys.version_info[0] < 3: + with self.assertRaises(UnicodeEncodeError): + self._test_attr() + else: + self._test_attr() + + def _test_attr(self): x = xattr.xattr(self.tempfile) # Solaris 11 and forward contain system attributes (file flags) in diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xattr-0.9.3/xattr.egg-info/PKG-INFO new/xattr-0.9.6/xattr.egg-info/PKG-INFO --- old/xattr-0.9.3/xattr.egg-info/PKG-INFO 2018-01-29 16:48:05.000000000 +0100 +++ new/xattr-0.9.6/xattr.egg-info/PKG-INFO 2018-07-31 19:13:38.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: xattr -Version: 0.9.3 +Version: 0.9.6 Summary: Python wrapper for extended filesystem attributes Home-page: http://github.com/xattr/xattr Author: Bob Ippolito diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xattr-0.9.3/xattr.egg-info/SOURCES.txt new/xattr-0.9.6/xattr.egg-info/SOURCES.txt --- old/xattr-0.9.3/xattr.egg-info/SOURCES.txt 2018-01-29 16:48:05.000000000 +0100 +++ new/xattr-0.9.6/xattr.egg-info/SOURCES.txt 2018-07-31 19:13:38.000000000 +0200 @@ -9,6 +9,8 @@ xattr/__init__.py xattr/compat.py xattr/lib.py +xattr/lib_build.c +xattr/lib_build.h xattr/lib_build.py xattr/pyxattr_compat.py xattr/tool.py
