Accepting request 677186 from home:lee_duncan:branches:devel:languages:python
- Added 3 patches subbmitted and accepted upstream, to deal with possibly-write-only sysfs attributes (bsc#1123933), adding: * 0001-Handle-write-only-attributes.patch * 0002-Handle-write-only-parameters-like-attributes.patch * 0003-Add-readable-param-to-Group-list_-methods.patch OBS-URL: https://build.opensuse.org/request/show/677186 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-rtslib-fb?expand=0&rev=43
This commit is contained in:
parent
a41e969040
commit
6f28e9a230
124
0001-Handle-write-only-attributes.patch
Normal file
124
0001-Handle-write-only-attributes.patch
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
From 03c8c15983a21bc2b158c58140a2871bb1ed857b Mon Sep 17 00:00:00 2001
|
||||||
|
From: Lee Duncan <lduncan@suse.com>
|
||||||
|
Date: Wed, 6 Feb 2019 12:29:41 -0800
|
||||||
|
Subject: [PATCH 1/3] Handle write-only attributes.
|
||||||
|
Patch-mainline: In developer's queue
|
||||||
|
|
||||||
|
A recent kernel change (see commit 6baca7601bdee2e5) makes
|
||||||
|
the pi_prot_format protection information attribute write-only,
|
||||||
|
since it always returned 0 when being read. This commit is being
|
||||||
|
reverted, but it still brought up the prospect of write-only
|
||||||
|
attributes.
|
||||||
|
|
||||||
|
Currently, when doing a dump(), rtslib iterates through all
|
||||||
|
readable attributes to decide which ones to save as part of
|
||||||
|
our current state, but saving write-only attributes
|
||||||
|
makes no sense, since we cannot read them to capture their
|
||||||
|
value. Towards this end, enhande the _list_files() internal
|
||||||
|
method to allow filtering on whether the file is writable
|
||||||
|
as well as whether or not it is readable. Then modify
|
||||||
|
list_attributes() to allow this new parameter and modify
|
||||||
|
dump() to request only R/W attributes.
|
||||||
|
---
|
||||||
|
rtslib/node.py | 53 ++++++++++++++++++++++++++++++++++-------------------
|
||||||
|
1 file changed, 34 insertions(+), 19 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/rtslib/node.py b/rtslib/node.py
|
||||||
|
index 1d77cd1b81ba..1ab7d9b8c58b 100644
|
||||||
|
--- a/rtslib/node.py
|
||||||
|
+++ b/rtslib/node.py
|
||||||
|
@@ -81,31 +81,42 @@ class CFSNode(object):
|
||||||
|
raise RTSLibNotInCFS("This %s does not exist in configFS"
|
||||||
|
% self.__class__.__name__)
|
||||||
|
|
||||||
|
- def _list_files(self, path, writable=None):
|
||||||
|
+ def _list_files(self, path, writable=None, readable=None):
|
||||||
|
'''
|
||||||
|
List files under a path depending on their owner's write permissions.
|
||||||
|
@param path: The path under which the files are expected to be. If the
|
||||||
|
path itself is not a directory, an empty list will be returned.
|
||||||
|
@type path: str
|
||||||
|
- @param writable: If None (default), returns all parameters, if True,
|
||||||
|
- returns read-write parameters, if False, returns just the read-only
|
||||||
|
- parameters.
|
||||||
|
+ @param writable: If None (default), return all files despite their
|
||||||
|
+ writability. If True, return only writable files. If False, return
|
||||||
|
+ only non-writable files.
|
||||||
|
@type writable: bool or None
|
||||||
|
- @return: List of file names filtered according to their write perms.
|
||||||
|
+ @param readable: If None (default), return all files despite their
|
||||||
|
+ readability. If True, return only readable files. If False, return
|
||||||
|
+ only non-readable files.
|
||||||
|
+ @type readable: bool or None
|
||||||
|
+ @return: List of file names filtered according to their
|
||||||
|
+ read/write perms.
|
||||||
|
'''
|
||||||
|
if not os.path.isdir(path):
|
||||||
|
return []
|
||||||
|
|
||||||
|
- if writable is None:
|
||||||
|
+ if writable is None and readable is None:
|
||||||
|
names = os.listdir(path)
|
||||||
|
- elif writable:
|
||||||
|
- names = [name for name in os.listdir(path)
|
||||||
|
- if (os.stat("%s/%s" % (path, name))[stat.ST_MODE] \
|
||||||
|
- & stat.S_IWUSR)]
|
||||||
|
else:
|
||||||
|
- names = [os.path.basename(name) for name in os.listdir(path)
|
||||||
|
- if not (os.stat("%s/%s" % (path, name))[stat.ST_MODE] \
|
||||||
|
- & stat.S_IWUSR)]
|
||||||
|
+ names = []
|
||||||
|
+ for name in os.listdir(path):
|
||||||
|
+ sres = os.stat("%s/%s" % (path, name))
|
||||||
|
+ if writable is not None:
|
||||||
|
+ if writable != ((sres[stat.ST_MODE] & stat.S_IWUSR) == \
|
||||||
|
+ stat.S_IWUSR):
|
||||||
|
+ continue
|
||||||
|
+ if readable is not None:
|
||||||
|
+ if readable != ((sres[stat.ST_MODE] & stat.S_IRUSR) == \
|
||||||
|
+ stat.S_IRUSR):
|
||||||
|
+ continue
|
||||||
|
+ names.append(name)
|
||||||
|
+
|
||||||
|
names.sort()
|
||||||
|
return names
|
||||||
|
|
||||||
|
@@ -123,17 +134,21 @@ class CFSNode(object):
|
||||||
|
path = "%s/param" % self.path
|
||||||
|
return self._list_files(path, writable)
|
||||||
|
|
||||||
|
- def list_attributes(self, writable=None):
|
||||||
|
+ def list_attributes(self, writable=None, readable=None):
|
||||||
|
'''
|
||||||
|
- @param writable: If None (default), returns all attributes, if True,
|
||||||
|
- returns read-write attributes, if False, returns just the read-only
|
||||||
|
- attributes.
|
||||||
|
+ @param writable: If None (default), return all files despite their
|
||||||
|
+ writability. If True, return only writable files. If False, return
|
||||||
|
+ only non-writable files.
|
||||||
|
@type writable: bool or None
|
||||||
|
+ @param readable: If None (default), return all files despite their
|
||||||
|
+ readability. If True, return only readable files. If False, return
|
||||||
|
+ only non-readable files.
|
||||||
|
+ @type readable: bool or None
|
||||||
|
@return: A list of existing attribute names as strings.
|
||||||
|
'''
|
||||||
|
self._check_self()
|
||||||
|
path = "%s/attrib" % self.path
|
||||||
|
- return self._list_files(path, writable)
|
||||||
|
+ return self._list_files(path, writable, readable)
|
||||||
|
|
||||||
|
def set_attribute(self, attribute, value):
|
||||||
|
'''
|
||||||
|
@@ -220,7 +235,7 @@ class CFSNode(object):
|
||||||
|
d = {}
|
||||||
|
attrs = {}
|
||||||
|
params = {}
|
||||||
|
- for item in self.list_attributes(writable=True):
|
||||||
|
+ for item in self.list_attributes(writable=True, readable=True):
|
||||||
|
try:
|
||||||
|
attrs[item] = int(self.get_attribute(item))
|
||||||
|
except ValueError:
|
||||||
|
--
|
||||||
|
2.16.4
|
||||||
|
|
58
0002-Handle-write-only-parameters-like-attributes.patch
Normal file
58
0002-Handle-write-only-parameters-like-attributes.patch
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
From ee005008acfec749d3a9731a82fd08c6774cff49 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Lee Duncan <lduncan@suse.com>
|
||||||
|
Date: Sat, 9 Feb 2019 09:36:33 -0800
|
||||||
|
Subject: [PATCH 2/3] Handle write-only parameters like attributes
|
||||||
|
Patch-mainline: In developer's queue
|
||||||
|
|
||||||
|
Commit 03c8c15983a21bc2 added handling of write-only
|
||||||
|
attributes, but we could also see write-only parameters,
|
||||||
|
since they are also from sysfs. To be safe, ensure
|
||||||
|
the parameter list returned is writable in addition
|
||||||
|
to being readable.
|
||||||
|
---
|
||||||
|
rtslib/node.py | 16 ++++++++++------
|
||||||
|
1 file changed, 10 insertions(+), 6 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/rtslib/node.py b/rtslib/node.py
|
||||||
|
index 1ab7d9b8c58b..415f45d675f9 100644
|
||||||
|
--- a/rtslib/node.py
|
||||||
|
+++ b/rtslib/node.py
|
||||||
|
@@ -122,17 +122,21 @@ class CFSNode(object):
|
||||||
|
|
||||||
|
# CFSNode public stuff
|
||||||
|
|
||||||
|
- def list_parameters(self, writable=None):
|
||||||
|
+ def list_parameters(self, writable=None, readable=None):
|
||||||
|
'''
|
||||||
|
- @param writable: If None (default), returns all parameters, if True,
|
||||||
|
- returns read-write parameters, if False, returns just the read-only
|
||||||
|
- parameters.
|
||||||
|
+ @param writable: If None (default), return all parameters despite
|
||||||
|
+ their writability. If True, return only writable parameters. If
|
||||||
|
+ False, return only non-writable parameters.
|
||||||
|
@type writable: bool or None
|
||||||
|
+ @param readable: If None (default), return all parameters despite
|
||||||
|
+ their readability. If True, return only readable parameters. If
|
||||||
|
+ False, return only non-readable parameters.
|
||||||
|
+ @type readable: bool or None
|
||||||
|
@return: The list of existing RFC-3720 parameter names.
|
||||||
|
'''
|
||||||
|
self._check_self()
|
||||||
|
path = "%s/param" % self.path
|
||||||
|
- return self._list_files(path, writable)
|
||||||
|
+ return self._list_files(path, writable, readable)
|
||||||
|
|
||||||
|
def list_attributes(self, writable=None, readable=None):
|
||||||
|
'''
|
||||||
|
@@ -242,7 +246,7 @@ class CFSNode(object):
|
||||||
|
attrs[item] = self.get_attribute(item)
|
||||||
|
if attrs:
|
||||||
|
d['attributes'] = attrs
|
||||||
|
- for item in self.list_parameters(writable=True):
|
||||||
|
+ for item in self.list_parameters(writable=True, readable=True):
|
||||||
|
params[item] = self.get_parameter(item)
|
||||||
|
if params:
|
||||||
|
d['parameters'] = params
|
||||||
|
--
|
||||||
|
2.16.4
|
||||||
|
|
41
0003-Add-readable-param-to-Group-list_-methods.patch
Normal file
41
0003-Add-readable-param-to-Group-list_-methods.patch
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
From 6f17cf775ca9be1aa2cf51a7efbcf4ea67e8175c Mon Sep 17 00:00:00 2001
|
||||||
|
From: Lee Duncan <lduncan@suse.com>
|
||||||
|
Date: Tue, 12 Feb 2019 10:09:58 -0800
|
||||||
|
Subject: [PATCH 3/3] Add 'readable' param to Group list_*() methods
|
||||||
|
Patch-mainline: In developer's queue
|
||||||
|
|
||||||
|
Extend use of the new 'readable' optional param
|
||||||
|
for the Node class into the Group class, so they
|
||||||
|
also return writable *and* readable entries.
|
||||||
|
|
||||||
|
Did NOT update the calls to list_attributes() and
|
||||||
|
list_parameters() in NodeACLGroup class, since
|
||||||
|
we don't need ACLs to be readable to write them
|
||||||
|
out.
|
||||||
|
---
|
||||||
|
rtslib/target.py | 8 ++++----
|
||||||
|
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/rtslib/target.py b/rtslib/target.py
|
||||||
|
index 814a98339a2a..92d54786501c 100644
|
||||||
|
--- a/rtslib/target.py
|
||||||
|
+++ b/rtslib/target.py
|
||||||
|
@@ -1302,11 +1302,11 @@ class Group(object):
|
||||||
|
for mem in self._mem_func(self):
|
||||||
|
setattr(mem, prop, value)
|
||||||
|
|
||||||
|
- def list_attributes(self, writable=None):
|
||||||
|
- return self._get_first_member().list_attributes(writable)
|
||||||
|
+ def list_attributes(self, writable=None, readable=None):
|
||||||
|
+ return self._get_first_member().list_attributes(writable, readable)
|
||||||
|
|
||||||
|
- def list_parameters(self, writable=None):
|
||||||
|
- return self._get_first_member().list_parameters(writable)
|
||||||
|
+ def list_parameters(self, writable=None, readable=None):
|
||||||
|
+ return self._get_first_member().list_parameters(writable, readable)
|
||||||
|
|
||||||
|
def set_attribute(self, attribute, value):
|
||||||
|
for obj in self._mem_func(self):
|
||||||
|
--
|
||||||
|
2.16.4
|
||||||
|
|
@ -1,3 +1,12 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Mon Feb 18 17:56:57 UTC 2019 - lduncan@suse.com
|
||||||
|
|
||||||
|
- Added 3 patches subbmitted and accepted upstream, to deal with
|
||||||
|
possibly-write-only sysfs attributes (bsc#1123933), adding:
|
||||||
|
* 0001-Handle-write-only-attributes.patch
|
||||||
|
* 0002-Handle-write-only-parameters-like-attributes.patch
|
||||||
|
* 0003-Add-readable-param-to-Group-list_-methods.patch
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Fri Dec 7 09:29:54 UTC 2018 - ddiss@suse.com
|
Fri Dec 7 09:29:54 UTC 2018 - ddiss@suse.com
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# spec file for package python-rtslib-fb
|
# spec file for package python-rtslib-fb
|
||||||
#
|
#
|
||||||
# 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
|
# 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
|
||||||
@ -12,7 +12,7 @@
|
|||||||
# license that conforms to the Open Source Definition (Version 1.9)
|
# license that conforms to the Open Source Definition (Version 1.9)
|
||||||
# published by the Open Source Initiative.
|
# published by the Open Source Initiative.
|
||||||
|
|
||||||
# Please submit bugfixes or comments via https://bugs.opensuse.org/
|
# Please submit bugfixes or comments via http://bugs.opensuse.org/
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
@ -24,9 +24,12 @@ Release: 0%{?dist}
|
|||||||
Summary: API for Linux kernel SCSI target (aka LIO)
|
Summary: API for Linux kernel SCSI target (aka LIO)
|
||||||
License: Apache-2.0
|
License: Apache-2.0
|
||||||
Group: Development/Languages/Python
|
Group: Development/Languages/Python
|
||||||
Url: http://github.com/open-iscsi/rtslib-fb.git
|
Url: https://github.com/open-iscsi/rtslib-fb.git
|
||||||
Source: %{name}-%{version}.tar.xz
|
Source: %{name}-%{version}.tar.xz
|
||||||
Patch1: rbd-support.patch
|
Patch1: rbd-support.patch
|
||||||
|
Patch2: 0001-Handle-write-only-attributes.patch
|
||||||
|
Patch3: 0002-Handle-write-only-parameters-like-attributes.patch
|
||||||
|
Patch4: 0003-Add-readable-param-to-Group-list_-methods.patch
|
||||||
BuildRequires: %{python_module pyudev}
|
BuildRequires: %{python_module pyudev}
|
||||||
BuildRequires: %{python_module setuptools}
|
BuildRequires: %{python_module setuptools}
|
||||||
BuildRequires: %{python_module six}
|
BuildRequires: %{python_module six}
|
||||||
@ -56,6 +59,9 @@ the Apache 2.0 license. Contributions are welcome
|
|||||||
# RBD support is dependent on LIO changes present in the SLE/Leap kernel
|
# RBD support is dependent on LIO changes present in the SLE/Leap kernel
|
||||||
%patch1 -p1
|
%patch1 -p1
|
||||||
%endif
|
%endif
|
||||||
|
%patch2 -p1
|
||||||
|
%patch3 -p1
|
||||||
|
%patch4 -p1
|
||||||
|
|
||||||
%build
|
%build
|
||||||
%python_build
|
%python_build
|
||||||
|
Loading…
Reference in New Issue
Block a user