Compare commits
10 Commits
905b7ddfab
...
6cd613b998
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6cd613b998 | ||
|
|
2bf79c2eb2 | ||
|
|
5f4bb04080 | ||
|
|
c74353520b | ||
|
|
13b7e4f370 | ||
|
|
aea09c5eee | ||
|
|
d2efbea2e4 | ||
|
|
6f176d8e6a | ||
|
|
b64083eeda | ||
|
|
a1522eded5 |
BIN
.python-rtslib.spec.swp
Normal file
BIN
.python-rtslib.spec.swp
Normal file
Binary file not shown.
@ -1,53 +0,0 @@
|
|||||||
From b23d061ee0fa7924d2cdce6194c313b9ee06c468 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
|
||||||
Date: Thu, 28 May 2020 20:42:16 +0530
|
|
||||||
Subject: [PATCH] saveconfig: copy temp configfile with permissions
|
|
||||||
MIME-Version: 1.0
|
|
||||||
Content-Type: text/plain; charset=UTF-8
|
|
||||||
Content-Transfer-Encoding: 8bit
|
|
||||||
|
|
||||||
shutil.copyfile() will not copy permissions, so all the perms that we
|
|
||||||
set on tempfile will go for a toss, and will be reset to default
|
|
||||||
|
|
||||||
┌──────────────────┬────────┬───────────┬───────┬────────────────┐
|
|
||||||
│ Function │ Copies │ Copies │Can use│ Destination │
|
|
||||||
│ │metadata│permissions│buffer │may be directory│
|
|
||||||
├──────────────────┼────────┼───────────┼───────┼────────────────┤
|
|
||||||
│shutil.copy │ No │ Yes │ No │ Yes │
|
|
||||||
│shutil.copyfile │ No │ No │ No │ No │
|
|
||||||
│shutil.copy2 │ Yes │ Yes │ No │ Yes │
|
|
||||||
│shutil.copyfileobj│ No │ No │ Yes │ No │
|
|
||||||
└──────────────────┴────────┴───────────┴───────┴────────────────┘
|
|
||||||
|
|
||||||
Without this fix:
|
|
||||||
----------------
|
|
||||||
$ ls /etc/target/saveconfig.json -l
|
|
||||||
-rw-r--r-- 1 root root 5078 May 28 20:01 /etc/target/saveconfig.json
|
|
||||||
|
|
||||||
With this fix:
|
|
||||||
--------------
|
|
||||||
$ ls /etc/target/saveconfig.json -l
|
|
||||||
-rw------- 1 root root 5078 May 28 20:15 /etc/target/saveconfig.json
|
|
||||||
|
|
||||||
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
|
||||||
---
|
|
||||||
rtslib/root.py | 3 ++-
|
|
||||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/rtslib/root.py b/rtslib/root.py
|
|
||||||
index a101edd..7364154 100644
|
|
||||||
--- a/rtslib/root.py
|
|
||||||
+++ b/rtslib/root.py
|
|
||||||
@@ -486,7 +486,8 @@ class RTSRoot(CFSNode):
|
|
||||||
os.fsync(f.fileno())
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
- shutil.copyfile(tmp_file, save_file)
|
|
||||||
+ # copy along with permissions
|
|
||||||
+ shutil.copy(tmp_file, save_file)
|
|
||||||
os.remove(tmp_file)
|
|
||||||
|
|
||||||
def restore_from_file(self, restore_file=None, clear_existing=True,
|
|
||||||
--
|
|
||||||
1.8.3.1
|
|
||||||
|
|
||||||
@ -1,46 +0,0 @@
|
|||||||
From dffcf83bead64e959505d64ad587768647caab3a Mon Sep 17 00:00:00 2001
|
|
||||||
From: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
|
||||||
Date: Thu, 28 May 2020 19:53:04 +0530
|
|
||||||
Subject: [PATCH] saveconfig: open the temp configfile with modes set
|
|
||||||
|
|
||||||
Fixes: #161
|
|
||||||
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
|
||||||
---
|
|
||||||
rtslib/root.py | 21 +++++++++++++++++++--
|
|
||||||
1 file changed, 19 insertions(+), 2 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/rtslib/root.py b/rtslib/root.py
|
|
||||||
index afe1a53..a101edd 100644
|
|
||||||
--- a/rtslib/root.py
|
|
||||||
+++ b/rtslib/root.py
|
|
||||||
@@ -461,8 +461,25 @@ class RTSRoot(CFSNode):
|
|
||||||
|
|
||||||
tmp_file = save_file + ".temp"
|
|
||||||
|
|
||||||
- with open(tmp_file, "w+") as f:
|
|
||||||
- os.fchmod(f.fileno(), stat.S_IRUSR | stat.S_IWUSR)
|
|
||||||
+ mode = stat.S_IRUSR | stat.S_IWUSR # 0o600
|
|
||||||
+ umask = 0o777 ^ mode # Prevents always downgrading umask to 0
|
|
||||||
+
|
|
||||||
+ # For security, remove file with potentially elevated mode
|
|
||||||
+ try:
|
|
||||||
+ os.remove(tmp_file)
|
|
||||||
+ except OSError:
|
|
||||||
+ pass
|
|
||||||
+
|
|
||||||
+ umask_original = os.umask(umask)
|
|
||||||
+ # Even though the old file is first deleted, a race condition is still
|
|
||||||
+ # possible. Including os.O_EXCL with os.O_CREAT in the flags will
|
|
||||||
+ # prevent the file from being created if it exists due to a race
|
|
||||||
+ try:
|
|
||||||
+ fdesc = os.open(tmp_file, os.O_WRONLY | os.O_CREAT | os.O_EXCL, mode)
|
|
||||||
+ finally:
|
|
||||||
+ os.umask(umask_original)
|
|
||||||
+
|
|
||||||
+ with os.fdopen(fdesc, 'w+') as f:
|
|
||||||
f.write(json.dumps(saveconf, sort_keys=True, indent=2))
|
|
||||||
f.write("\n")
|
|
||||||
f.flush()
|
|
||||||
--
|
|
||||||
1.8.3.1
|
|
||||||
|
|
||||||
@ -1,26 +0,0 @@
|
|||||||
From 964520037320534512713e58bf70be6c428097dc Mon Sep 17 00:00:00 2001
|
|
||||||
From: Jaroslav <niekto@niekde.sk>
|
|
||||||
Date: Tue, 7 Jul 2020 11:21:45 +0200
|
|
||||||
Subject: [PATCH 1/4] Fix EPERM errors with scsi_generic devices
|
|
||||||
|
|
||||||
Resolves https://github.com/open-iscsi/targetcli-fb/issues/158
|
|
||||||
---
|
|
||||||
rtslib/utils.py | 2 +-
|
|
||||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/rtslib/utils.py b/rtslib/utils.py
|
|
||||||
index eff2205..4bcadea 100644
|
|
||||||
--- a/rtslib/utils.py
|
|
||||||
+++ b/rtslib/utils.py
|
|
||||||
@@ -114,7 +114,7 @@ def is_dev_in_use(path):
|
|
||||||
'''
|
|
||||||
path = os.path.realpath(str(path))
|
|
||||||
try:
|
|
||||||
- file_fd = os.open(path, os.O_EXCL|os.O_NDELAY)
|
|
||||||
+ file_fd = os.open(path, os.O_EXCL|os.O_NDELAY|os.O_RDWR)
|
|
||||||
except OSError:
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
--
|
|
||||||
1.8.3.1
|
|
||||||
|
|
||||||
@ -1,18 +1,15 @@
|
|||||||
%bcond_with python3
|
%bcond_without python3
|
||||||
|
|
||||||
%global oname rtslib-fb
|
%global oname rtslib-fb
|
||||||
|
|
||||||
Name: python-rtslib
|
Name: python-rtslib
|
||||||
Version: 2.1.70
|
Version: 2.1.76
|
||||||
Release: 7
|
Release: 2
|
||||||
Summary: Python object API for Linux kernel LIO SCSI target
|
Summary: Python object API for Linux kernel LIO SCSI target
|
||||||
|
|
||||||
License: ASL 2.0
|
License: ASL 2.0
|
||||||
URL: https://github.com/open-iscsi/%{oname}
|
URL: https://github.com/open-iscsi/%{oname}
|
||||||
Source0: %{url}/archive/v%{version}/%{oname}-%{version}.tar.gz
|
Source0: %{url}/archive/v%{version}/%{oname}-%{version}.tar.gz
|
||||||
Patch1: 0001-saveconfig-copy-temp-configfile-with-permissions.patch
|
|
||||||
Patch2: 0002-saveconfig-open-the-temp-configfile-with-modes-set.patch
|
|
||||||
Patch3: 0003-Fix-EPERM-errors-with-scsi_generic-devices.patch
|
|
||||||
|
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
BuildRequires: systemd-units
|
BuildRequires: systemd-units
|
||||||
@ -34,6 +31,7 @@ Summary: Python3 object API for Linux kernel LIO SCSI target
|
|||||||
BuildRequires: python3-devel, python3-setuptools
|
BuildRequires: python3-devel, python3-setuptools
|
||||||
Requires: python3-kmod, python3-six, python3-pyudev
|
Requires: python3-kmod, python3-six, python3-pyudev
|
||||||
%{?python_provide:%python_provide python3-rtslib}
|
%{?python_provide:%python_provide python3-rtslib}
|
||||||
|
provides: python3-%{oname}
|
||||||
|
|
||||||
%description -n python3-rtslib
|
%description -n python3-rtslib
|
||||||
python3-rtslib is a python object API for generic Linux SCSI kernel
|
python3-rtslib is a python object API for generic Linux SCSI kernel
|
||||||
@ -84,9 +82,11 @@ mkdir -p %{buildroot}%{_unitdir}
|
|||||||
mkdir -p %{buildroot}%{_sysconfdir}/target/backup
|
mkdir -p %{buildroot}%{_sysconfdir}/target/backup
|
||||||
mkdir -p %{buildroot}%{_localstatedir}/target/pr
|
mkdir -p %{buildroot}%{_localstatedir}/target/pr
|
||||||
mkdir -p %{buildroot}%{_localstatedir}/target/alua
|
mkdir -p %{buildroot}%{_localstatedir}/target/alua
|
||||||
|
mkdir -p %{buildroot}%{_bindir}
|
||||||
install -m 644 systemd/target.service %{buildroot}%{_unitdir}/target.service
|
install -m 644 systemd/target.service %{buildroot}%{_unitdir}/target.service
|
||||||
install -m 644 doc/targetctl.8.gz %{buildroot}%{_mandir}/man8/
|
install -m 644 doc/targetctl.8.gz %{buildroot}%{_mandir}/man8/
|
||||||
install -m 644 doc/saveconfig.json.5.gz %{buildroot}%{_mandir}/man5/
|
install -m 644 doc/saveconfig.json.5.gz %{buildroot}%{_mandir}/man5/
|
||||||
|
install -m 755 scripts/targetctl %{buildroot}%{_bindir}/
|
||||||
|
|
||||||
%post -n target-restore
|
%post -n target-restore
|
||||||
%systemd_post target.service
|
%systemd_post target.service
|
||||||
@ -121,6 +121,21 @@ install -m 644 doc/saveconfig.json.5.gz %{buildroot}%{_mandir}/man5/
|
|||||||
%{_mandir}/man5/saveconfig.json.5.gz
|
%{_mandir}/man5/saveconfig.json.5.gz
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Apr 16 2024 Pengda Dou <doupengda@loongson.cn> - 2.1.76-2
|
||||||
|
- Fix missing targetctl file error
|
||||||
|
|
||||||
|
* Wed Jan 10 2024 Dongxing Wang <dongxing.wang_a@thundersoft.com> - 2.1.76-1
|
||||||
|
- Update package to version 2.1.76
|
||||||
|
|
||||||
|
* Fri Oct 28 2022 Wenchao Hao <haowenchao@huawei.com> - 2.1.75-1
|
||||||
|
- update to rtslib-fb-2.1.75
|
||||||
|
|
||||||
|
* Thu Aug 11 2022 huangtianhua <huangtianhua@huawei.com> - 2.1.74-2
|
||||||
|
- Provides python3-rtslib-fb
|
||||||
|
|
||||||
|
* Tue Nov 16 2021 Wenchao Hao <haowenchao@huawei.com> - 2.1.74-1
|
||||||
|
- update to rtslib-fb-2.1.74
|
||||||
|
|
||||||
* Mon Nov 2 2020 Zhiqiang Liu <lzhq28@mail.ustc.edu.cn> - 2.1.70-7
|
* Mon Nov 2 2020 Zhiqiang Liu <lzhq28@mail.ustc.edu.cn> - 2.1.70-7
|
||||||
- backport upstream patch to solve one problem
|
- backport upstream patch to solve one problem
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
BIN
rtslib-fb-2.1.76.tar.gz
Normal file
BIN
rtslib-fb-2.1.76.tar.gz
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user