Remove patch: "reposync: Implement --safe-write-path option"

Resolves: rhbz#2207946
This commit is contained in:
Jaroslav Rohel 2023-05-17 19:57:49 +02:00
parent 022945760b
commit 1b834e68de
2 changed files with 4 additions and 99 deletions

View File

@ -1,97 +0,0 @@
From bb8c0ad46144362e2e1e2bd9f2d2400aca9a72c0 Mon Sep 17 00:00:00 2001
From: Marek Blaha <mblaha@redhat.com>
Date: Wed, 6 Oct 2021 16:43:10 +0200
Subject: [PATCH] reposync: Implement --safe-write-path option (RhBug:1898089)
By default reposync is not allowed to write files outside of repository
download path (by default ./<repo id>). But there are some repositories
that store packages using relative parent paths (e.g.
../packages-store/f/foo.rpm).
This patch introduces new --safe-write-path option that can override
this limitation and set a root directory that is considered safe for
writing.
For example `dnf reposync --repoid=the_repo --safe-write-path=.` will
allow reposync to write files not only to `./the_repo` directory but
also to current working directory itself.
= changelog =
msg: With --safe-write-path option reposync can download repositories with relative package locations (like ../package-store/f/foo.rpm)
type: enhancement
resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1898089
---
doc/reposync.rst | 3 +++
plugins/reposync.py | 27 ++++++++++++++++++++-------
2 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/doc/reposync.rst b/doc/reposync.rst
index bbf714c..ede8901 100644
--- a/doc/reposync.rst
+++ b/doc/reposync.rst
@@ -71,6 +71,9 @@ All general DNF options are accepted. Namely, the ``--repoid`` option can be use
``-p <download-path>, --download-path=<download-path>``
Root path under which the downloaded repositories are stored, relative to the current working directory. Defaults to the current working directory. Every downloaded repository has a subdirectory named after its ID under this path.
+``--safe-write-path``
+ Specify the filesystem path prefix under which the reposync is allowed to write. If not specified it defaults to download path of the repository. Useful for repositories that use relative locations of packages out of repository directory (e.g. "../packages_store/foo.rpm"). Use with care, any file under the ``safe-write-path`` can be overwritten. Can be only used when syncing a single repository.
+
``--remote-time``
Try to set the timestamps of the downloaded files to those on the remote side.
diff --git a/plugins/reposync.py b/plugins/reposync.py
index 0ff936f..63d8e98 100644
--- a/plugins/reposync.py
+++ b/plugins/reposync.py
@@ -88,6 +88,8 @@ class RepoSyncCommand(dnf.cli.Command):
parser.add_argument('-u', '--urls', default=False, action='store_true',
help=_("Just list urls of what would be downloaded, "
"don't download"))
+ parser.add_argument('--safe-write-path', default=None,
+ help=_("Filesystem path that is considered safe for writing. Defaults to download path."))
def configure(self):
demands = self.cli.demands
@@ -108,9 +110,16 @@ class RepoSyncCommand(dnf.cli.Command):
if self.opts.source:
repos.enable_source_repos()
- if len(list(repos.iter_enabled())) > 1 and self.opts.norepopath:
- raise dnf.cli.CliError(
- _("Can't use --norepopath with multiple repositories"))
+ if self.opts.safe_write_path is not None:
+ self.opts.safe_write_path = os.path.realpath(self.opts.safe_write_path)
+
+ if len(list(repos.iter_enabled())) > 1:
+ if self.opts.norepopath:
+ raise dnf.cli.CliError(
+ _("Can't use --norepopath with multiple repositories"))
+ elif self.opts.safe_write_path is not None:
+ raise dnf.cli.CliError(
+ _("Can't use --safe-write-path with multiple repositories"))
for repo in repos.iter_enabled():
repo._repo.expire()
@@ -188,13 +197,17 @@ class RepoSyncCommand(dnf.cli.Command):
repo_target = self.repo_target(pkg.repo)
pkg_download_path = os.path.realpath(
os.path.join(repo_target, pkg.location))
- # join() ensures repo_target ends with a path separator (otherwise the
+
+ # join() ensures safe_write_path ends with a path separator (otherwise the
# check would pass if pkg_download_path was a "sibling" path component
# of repo_target that has the same prefix).
- if not pkg_download_path.startswith(os.path.join(repo_target, '')):
+ safe_write_path = os.path.join(self.opts.safe_write_path or repo_target, '')
+
+ if not pkg_download_path.startswith(safe_write_path):
raise dnf.exceptions.Error(
- _("Download target '{}' is outside of download path '{}'.").format(
- pkg_download_path, repo_target))
+ _("Download target '{0}' for location '{1}' of '{2}' package "
+ "is outside of safe write path '{3}'.").format(
+ pkg_download_path, pkg.location, pkg.name, safe_write_path))
return pkg_download_path
def delete_old_local_packages(self, repo, pkglist):
--
2.40.1

View File

@ -34,7 +34,7 @@
Name: dnf-plugins-core
Version: 4.3.0
Release: 6%{?dist}
Release: 7%{?dist}
Summary: Core Plugins for DNF
License: GPLv2+
URL: https://github.com/rpm-software-management/dnf-plugins-core
@ -47,7 +47,6 @@ Patch5: 0005-Update-translations.patch
Patch6: 0006-Fix-boot-time-derivation-for-systems-with-no-rtc.patch
Patch7: 0007-system-upgrade-Add-poweroff-option-to-reboot-subcomm.patch
Patch8: 0008-Doc-update-for-reposync-RhBug-2132383-2182004.patch
Patch9: 0009-reposync-Implement-safe-write-path-opt-RhBug-1898089.patch
BuildArch: noarch
BuildRequires: cmake
@ -795,6 +794,9 @@ ln -sf %{_mandir}/man1/%{yum_utils_subpackage_name}.1.gz %{buildroot}%{_mandir}/
%endif
%changelog
* Wed May 17 2023 Jaroslav Rohel <jrohel@redhat.com> - 4.3.0-7
- Remove patch: "reposync: Implement --safe-write-path option (RhBug:1898089,2203766)" (RhBug:2207946)
* Mon May 15 2023 Jaroslav Rohel <jrohel@redhat.com> - 4.3.0-6
- Fix boot time derivation for systems with no rtc (RhBug:2166444,2182157)
- system-upgrade: Add --poweroff option to reboot subcommand (RhBug:2157844)