From ae07279b8daded2f2a3580ba9653f23ed37c4f38 Mon Sep 17 00:00:00 2001 From: Stefan Hundhammer Date: Tue, 6 Jun 2023 15:37:55 +0200 Subject: [PATCH 1/2] Prevent setting the volume label for mounted Btrfs or swap (bsc#1211337) --- .../actions/controllers/filesystem.rb | 8 +++++++ .../y2partitioner/widgets/fstab_options.rb | 22 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/lib/y2partitioner/actions/controllers/filesystem.rb b/src/lib/y2partitioner/actions/controllers/filesystem.rb index ea7c624a0..d91da22ef 100644 --- a/src/lib/y2partitioner/actions/controllers/filesystem.rb +++ b/src/lib/y2partitioner/actions/controllers/filesystem.rb @@ -175,6 +175,14 @@ def mount_path mount_point.path end + # Check if the filesystem is currently mounted in the system device graph. + # + # @return [Boolean] + def mounted_in_system_graph? + sys_fs = system_device(filesystem) + sys_fs&.active_mount_point? + end + # Partition id of the block device if it is a partition # # @return [Y2Storage::PartitionId, nil] nil if there is no block device or the diff --git a/src/lib/y2partitioner/widgets/fstab_options.rb b/src/lib/y2partitioner/widgets/fstab_options.rb index 85f017996..afa8a3bd1 100644 --- a/src/lib/y2partitioner/widgets/fstab_options.rb +++ b/src/lib/y2partitioner/widgets/fstab_options.rb @@ -271,6 +271,7 @@ def init self.value = filesystem.label Yast::UI.ChangeWidget(Id(widget_id), :ValidChars, valid_chars) Yast::UI.ChangeWidget(Id(widget_id), :InputMaxLength, input_max_length) + disable unless can_set_volume_label? end # Validates uniqueness of the given label. The presence of the label is also @@ -288,6 +289,27 @@ def validate # @return [Widgets::FstabOptions] attr_reader :parent_widget + # Check if the volume label can be set. + # + # @return [Boolean] + def can_set_volume_label? + return true unless @controller.mounted_in_system_graph? + + blk_dev = @controller.blk_device_name + fs_type = @controller.filesystem_type + log.info("#{blk_dev} type #{fs_type} is mounted") + # Can't change the volume label for a mounted Btrfs or swap (bsc#1211337) + !btrfs? && !swap? + end + + def btrfs? + @controller.filesystem_type.is?(:btrfs) + end + + def swap? + @controller.filesystem_type.is?(:swap) + end + # Checks whether a label is given when the filesystem is mounted by label # # @note An error popup is presented when the filesystem is mounted by label From 8d6c28af41c7158c036b079d1eabd9482fbfe08d Mon Sep 17 00:00:00 2001 From: Stefan Hundhammer Date: Wed, 7 Jun 2023 10:06:01 +0200 Subject: [PATCH 2/2] Version bump and change log --- package/yast2-storage-ng.changes | 7 +++++++ package/yast2-storage-ng.spec | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/package/yast2-storage-ng.changes b/package/yast2-storage-ng.changes index bc319bf1a..fcc33b236 100644 --- a/package/yast2-storage-ng.changes +++ b/package/yast2-storage-ng.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Wed Jun 7 08:03:52 UTC 2023 - Stefan Hundhammer + +- Prevent setting the volume label for a mounted btrfs or swap + (bsc#1211337) +- 4.4.43 + ------------------------------------------------------------------- Tue Jan 17 14:32:36 UTC 2023 - Stefan Hundhammer diff --git a/package/yast2-storage-ng.spec b/package/yast2-storage-ng.spec index 567f135e9..76cb0f298 100644 --- a/package/yast2-storage-ng.spec +++ b/package/yast2-storage-ng.spec @@ -16,7 +16,7 @@ # Name: yast2-storage-ng -Version: 4.4.42 +Version: 4.4.43 Release: 0 Summary: YaST2 - Storage Configuration License: GPL-2.0-only OR GPL-3.0-only