forked from pool/python-pylibacl
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
This commit is contained in:
committed by
Git OBS Bridge
parent
9ea33d8ff3
commit
4b5fcea7ca
115
09c5bd80cf811a0e7b81ceddfb525d576885e097.patch
Normal file
115
09c5bd80cf811a0e7b81ceddfb525d576885e097.patch
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
From 09c5bd80cf811a0e7b81ceddfb525d576885e097 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Iustin Pop <iustin@k1024.org>
|
||||||
|
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):
|
@@ -1,3 +1,10 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Mon Feb 24 15:28:16 UTC 2020 - Hans-Peter Jansen <hpj@urpla.net>
|
||||||
|
|
||||||
|
- 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 <tchvatal@suse.com>
|
Thu Jan 9 14:06:28 UTC 2020 - Tomáš Chvátal <tchvatal@suse.com>
|
||||||
|
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
# spec file for package python-pylibacl
|
# spec file for package python-pylibacl
|
||||||
#
|
#
|
||||||
# Copyright (c) 2020 SUSE LLC
|
# Copyright (c) 2020 SUSE LLC
|
||||||
|
# Copyright (c) 2013-2020 LISA GmbH, Bingen, Germany
|
||||||
#
|
#
|
||||||
# All modifications and additions to the file contributed by third parties
|
# All modifications and additions to the file contributed by third parties
|
||||||
# remain the property of their copyright owners, unless otherwise agreed
|
# 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
|
License: LGPL-2.1-or-later
|
||||||
URL: https://pylibacl.k1024.org/
|
URL: https://pylibacl.k1024.org/
|
||||||
Source: https://files.pythonhosted.org/packages/source/p/pylibacl/pylibacl-%{version}.tar.gz
|
Source: https://files.pythonhosted.org/packages/source/p/pylibacl/pylibacl-%{version}.tar.gz
|
||||||
|
Patch: 09c5bd80cf811a0e7b81ceddfb525d576885e097.patch
|
||||||
BuildRequires: %{python_module devel}
|
BuildRequires: %{python_module devel}
|
||||||
BuildRequires: %{python_module pytest}
|
BuildRequires: %{python_module pytest}
|
||||||
BuildRequires: %{python_module setuptools}
|
BuildRequires: %{python_module setuptools}
|
||||||
@@ -40,6 +42,7 @@ of the systems's acl C library - see acl(5).
|
|||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q -n pylibacl-%{version}
|
%setup -q -n pylibacl-%{version}
|
||||||
|
%autopatch -p1
|
||||||
|
|
||||||
%build
|
%build
|
||||||
%python_build
|
%python_build
|
||||||
|
Reference in New Issue
Block a user