From 5a654b190d967949574926600f0db434a3a8d14c Mon Sep 17 00:00:00 2001 From: wangcichen Date: Sun, 21 May 2023 04:49:20 +0800 Subject: [PATCH] Inhibit if any CIFS entries found in /etc/fstab --- ...-any-CIFS-entries-found-in-etc-fstab.patch | 110 ++++++++++++++++++ leapp-repository.spec | 6 +- 2 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 0046-Inhibit-if-any-CIFS-entries-found-in-etc-fstab.patch diff --git a/0046-Inhibit-if-any-CIFS-entries-found-in-etc-fstab.patch b/0046-Inhibit-if-any-CIFS-entries-found-in-etc-fstab.patch new file mode 100644 index 0000000..36f2b95 --- /dev/null +++ b/0046-Inhibit-if-any-CIFS-entries-found-in-etc-fstab.patch @@ -0,0 +1,110 @@ +From b84aa775c7b3d4e3ce7b0bc893fb350333e88dd5 Mon Sep 17 00:00:00 2001 +From: wangcichen +Date: Sun, 21 May 2023 04:31:16 +0800 +Subject: [PATCH] Inhibit if any CIFS entries found in /etc/fstab + +Signed-off-by: wangcichen +--- + .../el7toel8/actors/checkcifs/actor.py | 21 ++++++++++++ + .../actors/checkcifs/libraries/checkcifs.py | 19 +++++++++++ + .../actors/checkcifs/tests/test_checkcifs.py | 34 +++++++++++++++++++ + 3 files changed, 74 insertions(+) + create mode 100644 repos/system_upgrade/el7toel8/actors/checkcifs/actor.py + create mode 100644 repos/system_upgrade/el7toel8/actors/checkcifs/libraries/checkcifs.py + create mode 100644 repos/system_upgrade/el7toel8/actors/checkcifs/tests/test_checkcifs.py + +diff --git a/repos/system_upgrade/el7toel8/actors/checkcifs/actor.py b/repos/system_upgrade/el7toel8/actors/checkcifs/actor.py +new file mode 100644 +index 0000000..f124b85 +--- /dev/null ++++ b/repos/system_upgrade/el7toel8/actors/checkcifs/actor.py +@@ -0,0 +1,21 @@ ++from leapp.actors import Actor ++from leapp.libraries.actor.checkcifs import checkcifs ++from leapp.models import StorageInfo ++from leapp.reporting import Report ++from leapp.tags import ChecksPhaseTag, IPUWorkflowTag ++ ++ ++class CheckCIFS(Actor): ++ """ ++ Check if CIFS filesystem is in use. If yes, inhibit the upgrade process. ++ ++ Actor looks for CIFS in /ets/fstab. ++ If there is a CIFS entry, the upgrade is inhibited. ++ """ ++ name = "check_cifs" ++ consumes = (StorageInfo,) ++ produces = (Report,) ++ tags = (ChecksPhaseTag, IPUWorkflowTag,) ++ ++ def process(self): ++ checkcifs(self.consume(StorageInfo)) +diff --git a/repos/system_upgrade/el7toel8/actors/checkcifs/libraries/checkcifs.py b/repos/system_upgrade/el7toel8/actors/checkcifs/libraries/checkcifs.py +new file mode 100644 +index 0000000..5569c1d +--- /dev/null ++++ b/repos/system_upgrade/el7toel8/actors/checkcifs/libraries/checkcifs.py +@@ -0,0 +1,19 @@ ++from leapp import reporting ++from leapp.reporting import create_report ++ ++ ++def checkcifs(storage_info): ++ for storage in storage_info: ++ if any(entry.fs_vfstype == "cifs" for entry in storage.fstab): ++ create_report([ ++ reporting.Title("Use of CIFS detected. Upgrade can't proceed"), ++ reporting.Summary("CIFS is currently not supported by the inplace upgrade."), ++ reporting.Severity(reporting.Severity.HIGH), ++ reporting.Tags([ ++ reporting.Tags.FILESYSTEM, ++ reporting.Tags.NETWORK ++ ]), ++ reporting.Remediation(hint='Comment out CIFS entries to proceed with the upgrade.'), ++ reporting.Flags([reporting.Flags.INHIBITOR]), ++ reporting.RelatedResource('file', '/etc/fstab') ++ ]) +diff --git a/repos/system_upgrade/el7toel8/actors/checkcifs/tests/test_checkcifs.py b/repos/system_upgrade/el7toel8/actors/checkcifs/tests/test_checkcifs.py +new file mode 100644 +index 0000000..ebed4ad +--- /dev/null ++++ b/repos/system_upgrade/el7toel8/actors/checkcifs/tests/test_checkcifs.py +@@ -0,0 +1,34 @@ ++from leapp.snactor.fixture import current_actor_context ++from leapp.models import StorageInfo, FstabEntry ++from leapp.reporting import Report ++ ++ ++def test_actor_with_fstab_entry(current_actor_context): ++ with_fstab_entry = [FstabEntry(fs_spec="//10.20.30.42/share1", fs_file="/mnt/win_share1", ++ fs_vfstype="cifs", ++ fs_mntops="credentials=/etc/win-credentials,file_mode=0755,dir_mode=0755", ++ fs_freq="0", fs_passno="0"), ++ FstabEntry(fs_spec="//10.20.30.42/share2", fs_file="/mnt/win_share2", ++ fs_vfstype="cifs", ++ fs_mntops="credentials=/etc/win-credentials,file_mode=0755,dir_mode=0755", ++ fs_freq="0", fs_passno="0"), ++ FstabEntry(fs_spec="/dev/mapper/fedora-home", fs_file="/home", ++ fs_vfstype="ext4", ++ fs_mntops="defaults,x-systemd.device-timeout=0", ++ fs_freq="1", fs_passno="2")] ++ current_actor_context.feed(StorageInfo(fstab=with_fstab_entry)) ++ current_actor_context.run() ++ report_fields = current_actor_context.consume(Report)[0].report ++ assert 'inhibitor' in report_fields['flags'] ++ assert report_fields['severity'] == 'high' ++ assert report_fields['title'] == "Use of CIFS detected. Upgrade can't proceed" ++ ++ ++def test_actor_no_cifs(current_actor_context): ++ with_fstab_entry = [FstabEntry(fs_spec="/dev/mapper/fedora-home", fs_file="/home", ++ fs_vfstype="ext4", ++ fs_mntops="defaults,x-systemd.device-timeout=0", ++ fs_freq="1", fs_passno="2")] ++ current_actor_context.feed(StorageInfo(fstab=with_fstab_entry)) ++ current_actor_context.run() ++ assert not current_actor_context.consume(Report) +-- +2.22.0 + diff --git a/leapp-repository.spec b/leapp-repository.spec index 2786e44..65e399b 100644 --- a/leapp-repository.spec +++ b/leapp-repository.spec @@ -11,7 +11,7 @@ }\ py2_byte_compile "%1" "%2"} -%define anolis_release 24 +%define anolis_release 25 Name: leapp-repository Version: 0.13.0 @@ -71,6 +71,7 @@ Patch42: 0042-Report-inhibitor-message-to-SMC.patch Patch43: 0043-Fix-the-memory-unit-error.patch Patch44: 0044-Setup-3rd-repo-available-if-some-pkg-installed-from-.patch Patch45: 0045-Fix-bug-with-existing-symlink-in-handleyumconfig.patch +Patch46: 0046-Inhibit-if-any-CIFS-entries-found-in-etc-fstab.patch BuildArch: noarch BuildRequires: python-devel @@ -198,6 +199,9 @@ done; # no files here %changelog +* Mon May 22 2023 Cichen Wang - 0.13.0-2.25 +- Add CIFS entries check + * Thu May 18 2023 Cichen Wang - 0.13.0-2.24 - Fix bug with existing symlink in handleyumconfig -- Gitee