From 4b5fcea7cae97b73f8232588f5b5d195c8164b22338275feaadc66d763db1abc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= Date: Mon, 24 Feb 2020 15:45:40 +0000 Subject: [PATCH] Accepting request 778812 from home:frispete:python - apply a manually merged version of 09c5bd80cf811a0e7b81ceddfb525d576885e097.patch, in order to fix build with 32 bit archs https://github.com/iustin/pylibacl/issues/13 OBS-URL: https://build.opensuse.org/request/show/778812 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-pylibacl?expand=0&rev=15 --- ...bd80cf811a0e7b81ceddfb525d576885e097.patch | 115 ++++++++++++++++++ python-pylibacl.changes | 7 ++ python-pylibacl.spec | 3 + 3 files changed, 125 insertions(+) create mode 100644 09c5bd80cf811a0e7b81ceddfb525d576885e097.patch diff --git a/09c5bd80cf811a0e7b81ceddfb525d576885e097.patch b/09c5bd80cf811a0e7b81ceddfb525d576885e097.patch new file mode 100644 index 0000000..fd88af2 --- /dev/null +++ b/09c5bd80cf811a0e7b81ceddfb525d576885e097.patch @@ -0,0 +1,115 @@ +From 09c5bd80cf811a0e7b81ceddfb525d576885e097 Mon Sep 17 00:00:00 2001 +From: Iustin Pop +Date: Wed, 4 Dec 2019 00:35:33 +0100 +Subject: [PATCH] Change entry qualifier set/get behaviour + +This was intended to address #13, but investigation found out more +breakage than just that. It's hard to make overflow/underflow tests +without assuming the signedness of the uid_t/gid_t types, so +assume/require that they're unsigned (it is true with glibc, MacOS and +FreeBSD) and use this to improve the behaviour: + +- Fix setting very large qualifiers, both in the sense of correctly + reporting overflow when too large, and not longer falsely reporting + overflow for larger than signed max but smaller than unsigned max; +- Fix returning very large (larger than signed max value) qualifiers; + +Fixes #13. +--- + NEWS | 6 ++++++ + acl.c | 17 +++++++++++------ + tests/test_acls.py | 11 +++++------ + 3 files changed, 22 insertions(+), 12 deletions(-) + +Index: b/acl.c +=================================================================== +--- a/acl.c ++++ b/acl.c +@@ -889,7 +889,7 @@ static PyObject* Entry_get_tag_type(PyOb + */ + static int Entry_set_qualifier(PyObject* obj, PyObject* value, void* arg) { + Entry_Object *self = (Entry_Object*) obj; +- long uidgid; ++ unsigned long uidgid; + uid_t uid; + gid_t gid; + void *p; +@@ -906,7 +906,10 @@ static int Entry_set_qualifier(PyObject* + "qualifier must be integer"); + return -1; + } +- if((uidgid = PyInt_AsLong(value)) == -1) { ++ /* This is the negative value check, and larger than long ++ check. If uid_t/gid_t are long-sized, this is enough to check ++ for both over and underflow. */ ++ if((uidgid = PyLong_AsUnsignedLong(value)) == (unsigned long) -1) { + if(PyErr_Occurred() != NULL) { + return -1; + } +@@ -920,9 +923,11 @@ static int Entry_set_qualifier(PyObject* + } + uid = uidgid; + gid = uidgid; ++ /* This is an extra overflow check, in case uid_t/gid_t are ++ int-sized (and int size smaller than long size). */ + switch(tag) { + case ACL_USER: +- if((long)uid != uidgid) { ++ if((unsigned long)uid != uidgid) { + PyErr_SetString(PyExc_OverflowError, "cannot assign given qualifier"); + return -1; + } else { +@@ -930,7 +935,7 @@ static int Entry_set_qualifier(PyObject* + } + break; + case ACL_GROUP: +- if((long)gid != uidgid) { ++ if((unsigned long)gid != uidgid) { + PyErr_SetString(PyExc_OverflowError, "cannot assign given qualifier"); + return -1; + } else { +@@ -953,7 +958,7 @@ static int Entry_set_qualifier(PyObject* + /* Returns the qualifier of the entry */ + static PyObject* Entry_get_qualifier(PyObject *obj, void* arg) { + Entry_Object *self = (Entry_Object*) obj; +- long value; ++ unsigned long value; + tag_qual tq; + + if (self->entry == NULL) { +@@ -973,7 +978,7 @@ static PyObject* Entry_get_qualifier(PyO + " group tag"); + return NULL; + } +- return PyInt_FromLong(value); ++ return PyLong_FromUnsignedLong(value); + } + + /* Returns the parent ACL of the entry */ +Index: b/test/test_acls.py +=================================================================== +--- a/test/test_acls.py ++++ b/test/test_acls.py +@@ -579,10 +579,7 @@ class ModificationTests(aclTest, unittes + qualifier = 1 + e.tag_type = tag + while True: +- if tag == posix1e.ACL_USER: +- regex = re.compile("user with uid %d" % qualifier) +- else: +- regex = re.compile("group with gid %d" % qualifier) ++ regex = re.compile("(user|group) with (u|g)id %d" % qualifier) + try: + e.qualifier = qualifier + except OverflowError: +@@ -597,7 +594,9 @@ class ModificationTests(aclTest, unittes + """Tests qualifier overflow handling""" + acl = posix1e.ACL() + e = acl.append() +- qualifier = sys.maxsize * 2 ++ # the uid_t/gid_t are unsigned, so they can hold slightly more ++ # than sys.maxsize*2 (on Linux). ++ qualifier = (sys.maxsize + 1) * 2 + for tag in [posix1e.ACL_USER, posix1e.ACL_GROUP]: + e.tag_type = tag + with self.assertRaises(OverflowError): diff --git a/python-pylibacl.changes b/python-pylibacl.changes index 97d2695..3034018 100644 --- a/python-pylibacl.changes +++ b/python-pylibacl.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Mon Feb 24 15:28:16 UTC 2020 - Hans-Peter Jansen + +- apply a manually merged version of + 09c5bd80cf811a0e7b81ceddfb525d576885e097.patch, in order to fix + build with 32 bit archs https://github.com/iustin/pylibacl/issues/13 + ------------------------------------------------------------------- Thu Jan 9 14:06:28 UTC 2020 - Tomáš Chvátal diff --git a/python-pylibacl.spec b/python-pylibacl.spec index ada3ba8..ca486ee 100644 --- a/python-pylibacl.spec +++ b/python-pylibacl.spec @@ -2,6 +2,7 @@ # spec file for package python-pylibacl # # Copyright (c) 2020 SUSE LLC +# Copyright (c) 2013-2020 LISA GmbH, Bingen, Germany # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -24,6 +25,7 @@ Summary: POSIX1e ACLs for python License: LGPL-2.1-or-later URL: https://pylibacl.k1024.org/ Source: https://files.pythonhosted.org/packages/source/p/pylibacl/pylibacl-%{version}.tar.gz +Patch: 09c5bd80cf811a0e7b81ceddfb525d576885e097.patch BuildRequires: %{python_module devel} BuildRequires: %{python_module pytest} BuildRequires: %{python_module setuptools} @@ -40,6 +42,7 @@ of the systems's acl C library - see acl(5). %prep %setup -q -n pylibacl-%{version} +%autopatch -p1 %build %python_build