From 0883df36c1c4c2e769ee736b342e657fba14664d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Iv=C3=A1n=20L=C3=B3pez=20Gonz=C3=A1lez?= Date: Tue, 10 Dec 2019 15:29:13 +0000 Subject: [PATCH 1/3] Generate encryption name according to mount point --- src/lib/y2storage/encryption.rb | 64 +++++++----- src/lib/y2storage/mount_point.rb | 3 + test/y2storage/blk_device_test.rb | 14 ++- test/y2storage/encryption_test.rb | 157 +++++++++++++++--------------- 4 files changed, 134 insertions(+), 104 deletions(-) diff --git a/src/lib/y2storage/encryption.rb b/src/lib/y2storage/encryption.rb index bb1bbdafd0..422e70a8d3 100644 --- a/src/lib/y2storage/encryption.rb +++ b/src/lib/y2storage/encryption.rb @@ -149,6 +149,26 @@ def dm_table_name=(name) super end + # Generates an unused device mapper name for the encryption device + # + # This name is used for devices with auto dm names, see {.update_dm_names}. + # + # @return [String] + def auto_dm_table_name + name = + if !blk_device.dm_table_name.empty? + blk_device.dm_table_name + elsif !mount_point.nil? + mount_point_to_dm_name + elsif blk_device.udev_ids.any? + blk_device.udev_ids.first + else + blk_device.basename + end + + self.class.ensure_unused_dm_name(devicegraph, "cr_#{name}") + end + # Whether {#dm_table_name} was automatically set by YaST. # # @note This relies on the userdata mechanism, see {#userdata_value}. @@ -384,6 +404,18 @@ def propagate_mount_option(option, mount_points) end end + # Generates a base dm name from the mount point path + # + # @return [String, nil] nil if the encryption has no mount point. + def mount_point_to_dm_name + return nil if mount_point.nil? + + return "root" if mount_point.root? + + # Removes trailing slashes and replaces internal slashes by underscore + mount_point.path.gsub(/^\/|\/$/, "").gsub("/", "_") + end + class << self # Updates the DeviceMapper name for all encryption devices in the device # that have a name automatically set by YaST. @@ -409,23 +441,21 @@ def update_dm_names(devicegraph) # ...reassign them according to the current names of the block devices encryptions.each do |enc| - dm_name = dm_name_for(enc.blk_device) - enc.assign_dm_table_name(dm_name) + enc.assign_dm_table_name(enc.auto_dm_table_name) end end - # Auto-generated DeviceMapper name to use for the encrypted version of the - # given device. + # Ensures that the given dm name is not used yet by adding a suffix if needed + # + # @param devicegraph [Devicegraph] + # @param dm_name [String] # - # @param device [BlkDevice] block device to be encrypted # @return [String] - def dm_name_for(device) - basename = dm_basename_for(device) + def ensure_unused_dm_name(devicegraph, dm_name) suffix = "" - devicegraph = device.devicegraph loop do - candidate = "#{basename}#{suffix}" + candidate = "#{dm_name}#{suffix}" return candidate unless dm_name_in_use?(devicegraph, candidate) suffix = next_dm_name_suffix(suffix) @@ -444,21 +474,7 @@ def dm_name_in_use?(devicegraph, name) devicegraph.blk_devices.any? { |i| i.dm_table_name == name } end - # Initial part of {.dm_name_for} - # - # @param device [BlkDevice] - # @return [String] - def dm_basename_for(device) - device_name = - if device.dm_table_name.empty? - device.udev_ids.first || device.basename - else - device.dm_table_name - end - "cr_#{device_name}" - end - - # @see #dm_name_for + # @see #ensure_unused_dm_name # # @param previous [String] previous value of the suffix # @return [String] diff --git a/src/lib/y2storage/mount_point.rb b/src/lib/y2storage/mount_point.rb index 74c5cf9ee1..4e42158bd3 100644 --- a/src/lib/y2storage/mount_point.rb +++ b/src/lib/y2storage/mount_point.rb @@ -19,6 +19,7 @@ require "y2storage/storage_class_wrapper" require "y2storage/device" +require "y2storage/encryption" require "y2storage/encryption_type" require "y2storage/filesystems/mount_by_type" require "pathname" @@ -81,6 +82,8 @@ def path=(path) else 0 end + + Y2Storage::Encryption.update_dm_names(devicegraph) end # @!method mount_by diff --git a/test/y2storage/blk_device_test.rb b/test/y2storage/blk_device_test.rb index 8e7534b21d..1ea566cb72 100755 --- a/test/y2storage/blk_device_test.rb +++ b/test/y2storage/blk_device_test.rb @@ -1138,9 +1138,12 @@ end RSpec.shared_examples "auto-generated encryption name" do - it "creates an encryption device with an auto-generated name and #auto_dm_name?" do - expect(Y2Storage::Encryption).to receive(:dm_name_for).with(device).and_return "cr_auto" + before do + allow_any_instance_of(Y2Storage::Encryption) + .to receive(:auto_dm_table_name).and_return("cr_auto") + end + it "creates an encryption device with an auto-generated name and #auto_dm_name?" do expect(enc).to be_a Y2Storage::Encryption expect(enc.blk_device).to eq device expect(enc.dm_table_name).to eq "cr_auto" @@ -1272,12 +1275,15 @@ def create_encrypted_partition(disk, slot_index) before do # Ensure the first option for the name is already taken - enc_name = Y2Storage::Encryption.dm_name_for(sda2) - sda3.encryption.dm_table_name = enc_name + sda2.encrypt + sda3.encryption.dm_table_name = sda2.dm_table_name + + sda2.remove_encryption end it "does not generate redundant DeviceMapper names" do sda2.encrypt + expect_no_dm_duplicates end end diff --git a/test/y2storage/encryption_test.rb b/test/y2storage/encryption_test.rb index ef71222bdc..10ac2df163 100755 --- a/test/y2storage/encryption_test.rb +++ b/test/y2storage/encryption_test.rb @@ -27,114 +27,119 @@ fake_scenario(scenario) end + let(:blk_device) { devicegraph.find_by_name(device_name) } + let(:devicegraph) { Y2Storage::StorageManager.instance.staging } - describe ".dm_name_for" do - context "when generating a name for a partition" do - let(:blk_device) { devicegraph.find_by_name("/dev/sda2") } + describe "#auto_dm_table_name" do + subject { blk_device.create_encryption("cr_test") } - context "if some udev id is known for the partition" do - # Use the XML format, which includes support for ids - let(:scenario) { "encrypted_partition.xml" } + let(:scenario) { "mixed_disks" } - it "generates a name based on the partition udev id" do - result = described_class.dm_name_for(blk_device) - expect(result).to match(/^cr_ata-VBOX_HARDDISK_VB777f5d67-56603f01-part2/) - end - end + let(:device_name) { "/dev/sda2" } - context "if no udev id is recognized for the partition" do - let(:scenario) { "trivial_lvm_and_other_partitions" } + before do + allow(subject).to receive(:blk_device).and_return(blk_device) - it "generates a name based on the partition name" do - result = described_class.dm_name_for(blk_device) - expect(result).to match(/^cr_sda2/) - end - end - end + allow(subject).to receive(:mount_point).and_return(mount_point) - context "when generating a name for a logical volume" do - let(:scenario) { "trivial_lvm_and_other_partitions" } - let(:blk_device) { devicegraph.find_by_name("/dev/vg0/lv1") } + allow(blk_device).to receive(:dm_table_name).and_return(dm_table_name) - it "generates a name based on the volume DeviceMapper name" do - result = described_class.dm_name_for(blk_device) - expect(result).to match(/^cr_vg0-lv1/) - end + allow(blk_device).to receive(:udev_ids).and_return(udev_ids) end - context "when generating a name for a whole disk" do - let(:blk_device) { devicegraph.find_by_name("/dev/sda") } + let(:mount_point) { nil } + + let(:dm_table_name) { "" } - context "if some udev id is known for the disk" do - # Use the XML format, which includes support for ids - let(:scenario) { "encrypted_partition.xml" } + let(:udev_ids) { [] } - it "generates a name based on the disk udev id" do - result = described_class.dm_name_for(blk_device) - expect(result).to match(/^cr_ata-VBOX_HARDDISK_VB777f5d67-56603f01/) + shared_examples "repeated dm name" do |dm_name| + context "and an encryption device with the same name already exists" do + before do + sda1 = devicegraph.find_by_name("/dev/sda1") + + sda1.create_encryption(dm_name) end - end - context "if no udev id is recognized for the disk" do - let(:scenario) { "trivial_lvm_and_other_partitions" } + it "adds a number-based suffix" do + expect(subject.auto_dm_table_name).to eq(dm_name + "_2") + end + + context "and an encryption name with the suffix also exists" do + before do + sdb1 = devicegraph.find_by_name("/dev/sdb1") + + sdb1.create_encryption(dm_name + "_2") + end - it "generates a name based on the disk name" do - result = described_class.dm_name_for(blk_device) - expect(result).to match(/^cr_sda/) + it "increases the number in the suffix as much as needed" do + expect(subject.auto_dm_table_name).to eq(dm_name + "_3") + end end end end - context "when the generated name is already taken" do - let(:blk_device) { devicegraph.find_by_name("/dev/sda2") } + context "when the underlying device has a device mapper name (e.g., an LVM LV)" do + let(:dm_table_name) { "system-root" } - context "if some udev id is known for the partition" do - # Use the XML format, which includes support for ids - let(:scenario) { "encrypted_partition.xml" } + it "generates an encryption name based on the device mapper name" do + expect(subject.auto_dm_table_name).to eq("cr_system-root") + end - it "generates a name based on the partition udev id" do - result = described_class.dm_name_for(blk_device) - expect(result).to match(/^cr_ata-VBOX_HARDDISK_VB777f5d67-56603f01-part2/) + include_examples "repeated dm name", "cr_system-root" + end + + context "when the underlying device has not a device mapper name" do + let(:dm_table_name) { "" } + + context "and the encryption device is mounted" do + let(:mount_point) do + Y2Storage::MountPoint.new(Storage::MountPoint.create(devicegraph.to_storage_value, path)) end - end - context "if no udev id is recognized for the partition" do - let(:scenario) { "trivial_lvm_and_other_partitions" } + context "and it is mounted as root" do + let(:path) { "/" } + + it "generates an encryption name like 'cr_root'" do + expect(subject.auto_dm_table_name).to eq("cr_root") + end - it "generates a name based on the partition name" do - result = described_class.dm_name_for(blk_device) - expect(result).to match(/^cr_sda2/) + include_examples "repeated dm name", "cr_root" end - end - end - context "when the candidate name is already taken" do - let(:scenario) { "trivial_lvm_and_other_partitions" } - let(:sda2) { devicegraph.find_by_name("/dev/sda2") } - let(:sda3) { devicegraph.find_by_name("/dev/sda3") } - let(:lv1) { devicegraph.find_by_name("/dev/vg0/lv1") } + context "and it is not mounted as root" do + let(:path) { "/home/foo" } - before do - # Ensure the first option for the name is already taken - enc_name = Y2Storage::Encryption.dm_name_for(sda2) - sda3.encryption.dm_table_name = enc_name - end + it "generates an encryption name based on the mount point" do + expect(subject.auto_dm_table_name).to eq("cr_home_foo") + end - it "adds a number-based suffix" do - result = described_class.dm_name_for(sda2) - expect(result).to match(/^cr_sda2_2/) + include_examples "repeated dm name", "cr_home_foo" + end end - context "and the version with suffix is also taken" do - before do - # Ensure the second option is taken as well - lv1.dm_table_name = Y2Storage::Encryption.dm_name_for(sda2) + context "and the encryption device is not mounted" do + let(:mount_point) { nil } + + context "and some udev ids are recognized for the underlying device" do + let(:udev_ids) { ["disk-1122-part2"] } + + it "generates an encryption name based on the udev id" do + expect(subject.auto_dm_table_name).to eq("cr_disk-1122-part2") + end + + include_examples "repeated dm name", "cr_disk-1122-part2" end - it "increases the number in the suffix as much as needed" do - result = described_class.dm_name_for(sda2) - expect(result).to match(/^cr_sda2_3/) + context "and no udev ids are recognized for the underlying device" do + let(:udev_ids) { [] } + + it "generates an encryption name based on the underlying device name" do + expect(subject.auto_dm_table_name).to eq("cr_sda2") + end + + include_examples "repeated dm name", "cr_sda2" end end end From bfa9831b509597a7244f1cd48f0a02e29735cec4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Iv=C3=A1n=20L=C3=B3pez=20Gonz=C3=A1lez?= Date: Tue, 10 Dec 2019 15:30:27 +0000 Subject: [PATCH 2/3] Adapt unit tests --- .../output/empty_hard_disk_gpt_50GiB-enc-sep-home.yml | 6 +++--- .../output/empty_hard_disk_gpt_50GiB-enc.yml | 4 ++-- .../output/multi-linux-pc-enc-sep-home.yml | 6 +++--- test/data/devicegraphs/output/multi-linux-pc-enc.yml | 4 ++-- .../output/multi-linux-pc-gpt-enc-sep-home.yml | 6 +++--- .../devicegraphs/output/multi-linux-pc-gpt-enc.yml | 4 ++-- .../output/windows-linux-multiboot-pc-enc-sep-home.yml | 6 +++--- .../output/windows-linux-multiboot-pc-enc.yml | 4 ++-- .../windows-linux-multiboot-pc-gpt-enc-sep-home.yml | 6 +++--- .../output/windows-linux-multiboot-pc-gpt-enc.yml | 4 ++-- .../devicegraphs/output/windows-pc-enc-sep-home.yml | 6 +++--- test/data/devicegraphs/output/windows-pc-enc.yml | 4 ++-- .../output/windows-pc-gpt-enc-sep-home.yml | 6 +++--- test/data/devicegraphs/output/windows-pc-gpt-enc.yml | 4 ++-- test/y2storage/fake_device_factory_test.rb | 10 +++++----- 15 files changed, 40 insertions(+), 40 deletions(-) diff --git a/test/data/devicegraphs/output/empty_hard_disk_gpt_50GiB-enc-sep-home.yml b/test/data/devicegraphs/output/empty_hard_disk_gpt_50GiB-enc-sep-home.yml index dd35a555b6..ae3fe950d0 100644 --- a/test/data/devicegraphs/output/empty_hard_disk_gpt_50GiB-enc-sep-home.yml +++ b/test/data/devicegraphs/output/empty_hard_disk_gpt_50GiB-enc-sep-home.yml @@ -16,7 +16,7 @@ mount_point: "/" encryption: type: luks - name: "/dev/mapper/cr_sda2" + name: "/dev/mapper/cr_root" password: '12345678' - partition: size: 2 GiB @@ -26,7 +26,7 @@ mount_point: swap encryption: type: luks - name: "/dev/mapper/cr_sda3" + name: "/dev/mapper/cr_swap" password: '12345678' - partition: size: unlimited @@ -35,7 +35,7 @@ mount_point: "/home" encryption: type: luks - name: "/dev/mapper/cr_sda4" + name: "/dev/mapper/cr_home" password: '12345678' - free: size: 16.5 KiB diff --git a/test/data/devicegraphs/output/empty_hard_disk_gpt_50GiB-enc.yml b/test/data/devicegraphs/output/empty_hard_disk_gpt_50GiB-enc.yml index 1a2cb2f1e0..3408d31da3 100644 --- a/test/data/devicegraphs/output/empty_hard_disk_gpt_50GiB-enc.yml +++ b/test/data/devicegraphs/output/empty_hard_disk_gpt_50GiB-enc.yml @@ -16,7 +16,7 @@ mount_point: "/" encryption: type: luks - name: "/dev/mapper/cr_sda2" + name: "/dev/mapper/cr_root" password: '12345678' - partition: size: 2 GiB @@ -26,5 +26,5 @@ mount_point: swap encryption: type: luks - name: "/dev/mapper/cr_sda3" + name: "/dev/mapper/cr_swap" password: '12345678' diff --git a/test/data/devicegraphs/output/multi-linux-pc-enc-sep-home.yml b/test/data/devicegraphs/output/multi-linux-pc-enc-sep-home.yml index b5ec87d780..7ea0046264 100644 --- a/test/data/devicegraphs/output/multi-linux-pc-enc-sep-home.yml +++ b/test/data/devicegraphs/output/multi-linux-pc-enc-sep-home.yml @@ -51,7 +51,7 @@ mount_point: "/" encryption: type: luks - name: "/dev/mapper/cr_sda6" + name: "/dev/mapper/cr_root" password: '12345678' - partition: @@ -63,7 +63,7 @@ mount_point: swap encryption: type: luks - name: "/dev/mapper/cr_sda7" + name: "/dev/mapper/cr_swap" password: '12345678' - partition: @@ -75,5 +75,5 @@ mount_point: "/home" encryption: type: luks - name: "/dev/mapper/cr_sda8" + name: "/dev/mapper/cr_home" password: '12345678' diff --git a/test/data/devicegraphs/output/multi-linux-pc-enc.yml b/test/data/devicegraphs/output/multi-linux-pc-enc.yml index 4fcf1b001e..9e94495d58 100644 --- a/test/data/devicegraphs/output/multi-linux-pc-enc.yml +++ b/test/data/devicegraphs/output/multi-linux-pc-enc.yml @@ -47,7 +47,7 @@ mount_point: "/" encryption: type: luks - name: "/dev/mapper/cr_sda6" + name: "/dev/mapper/cr_root" password: '12345678' - partition: size: 2 GiB @@ -58,5 +58,5 @@ mount_point: swap encryption: type: luks - name: "/dev/mapper/cr_sda7" + name: "/dev/mapper/cr_swap" password: '12345678' diff --git a/test/data/devicegraphs/output/multi-linux-pc-gpt-enc-sep-home.yml b/test/data/devicegraphs/output/multi-linux-pc-gpt-enc-sep-home.yml index b86448c7fe..7bfda6360a 100644 --- a/test/data/devicegraphs/output/multi-linux-pc-gpt-enc-sep-home.yml +++ b/test/data/devicegraphs/output/multi-linux-pc-gpt-enc-sep-home.yml @@ -43,7 +43,7 @@ mount_point: "/" encryption: type: luks - name: "/dev/mapper/cr_sda6" + name: "/dev/mapper/cr_root" password: '12345678' - partition: @@ -54,7 +54,7 @@ mount_point: swap encryption: type: luks - name: "/dev/mapper/cr_sda7" + name: "/dev/mapper/cr_swap" password: '12345678' - partition: @@ -65,7 +65,7 @@ mount_point: "/home" encryption: type: luks - name: "/dev/mapper/cr_sda8" + name: "/dev/mapper/cr_home" password: '12345678' # The last 16.5 KiB of a GPT disk are not usable diff --git a/test/data/devicegraphs/output/multi-linux-pc-gpt-enc.yml b/test/data/devicegraphs/output/multi-linux-pc-gpt-enc.yml index b38c03e599..2a45c86c58 100644 --- a/test/data/devicegraphs/output/multi-linux-pc-gpt-enc.yml +++ b/test/data/devicegraphs/output/multi-linux-pc-gpt-enc.yml @@ -43,7 +43,7 @@ mount_point: "/" encryption: type: luks - name: "/dev/mapper/cr_sda6" + name: "/dev/mapper/cr_root" password: '12345678' - partition: @@ -54,7 +54,7 @@ mount_point: swap encryption: type: luks - name: "/dev/mapper/cr_sda7" + name: "/dev/mapper/cr_swap" password: '12345678' - free: diff --git a/test/data/devicegraphs/output/windows-linux-multiboot-pc-enc-sep-home.yml b/test/data/devicegraphs/output/windows-linux-multiboot-pc-enc-sep-home.yml index 5f6637b865..b436aa86ef 100644 --- a/test/data/devicegraphs/output/windows-linux-multiboot-pc-enc-sep-home.yml +++ b/test/data/devicegraphs/output/windows-linux-multiboot-pc-enc-sep-home.yml @@ -27,7 +27,7 @@ mount_point: "/" encryption: type: luks - name: "/dev/mapper/cr_sda3" + name: "/dev/mapper/cr_root" password: '12345678' - partition: size: unlimited @@ -43,7 +43,7 @@ mount_point: swap encryption: type: luks - name: "/dev/mapper/cr_sda5" + name: "/dev/mapper/cr_swap" password: '12345678' - partition: size: 210941 MiB (206.00 GiB) @@ -54,5 +54,5 @@ mount_point: "/home" encryption: type: luks - name: "/dev/mapper/cr_sda6" + name: "/dev/mapper/cr_home" password: '12345678' diff --git a/test/data/devicegraphs/output/windows-linux-multiboot-pc-enc.yml b/test/data/devicegraphs/output/windows-linux-multiboot-pc-enc.yml index be8fe8ed01..e3ea5651d6 100644 --- a/test/data/devicegraphs/output/windows-linux-multiboot-pc-enc.yml +++ b/test/data/devicegraphs/output/windows-linux-multiboot-pc-enc.yml @@ -27,7 +27,7 @@ mount_point: "/" encryption: type: luks - name: "/dev/mapper/cr_sda3" + name: "/dev/mapper/cr_root" password: '12345678' - partition: size: 2 GiB @@ -38,5 +38,5 @@ mount_point: swap encryption: type: luks - name: "/dev/mapper/cr_sda4" + name: "/dev/mapper/cr_swap" password: '12345678' diff --git a/test/data/devicegraphs/output/windows-linux-multiboot-pc-gpt-enc-sep-home.yml b/test/data/devicegraphs/output/windows-linux-multiboot-pc-gpt-enc-sep-home.yml index 7daa88244c..062ee2ec09 100644 --- a/test/data/devicegraphs/output/windows-linux-multiboot-pc-gpt-enc-sep-home.yml +++ b/test/data/devicegraphs/output/windows-linux-multiboot-pc-gpt-enc-sep-home.yml @@ -30,7 +30,7 @@ mount_point: "/" encryption: type: luks - name: "/dev/mapper/cr_sda4" + name: "/dev/mapper/cr_root" password: '12345678' - partition: size: 2 GiB @@ -41,7 +41,7 @@ mount_point: swap encryption: type: luks - name: "/dev/mapper/cr_sda5" + name: "/dev/mapper/cr_swap" password: '12345678' - partition: size: unlimited @@ -51,7 +51,7 @@ mount_point: "/home" encryption: type: luks - name: "/dev/mapper/cr_sda6" + name: "/dev/mapper/cr_home" password: '12345678' - free: size: 16.5 KiB diff --git a/test/data/devicegraphs/output/windows-linux-multiboot-pc-gpt-enc.yml b/test/data/devicegraphs/output/windows-linux-multiboot-pc-gpt-enc.yml index f123269758..3143dbfb6d 100644 --- a/test/data/devicegraphs/output/windows-linux-multiboot-pc-gpt-enc.yml +++ b/test/data/devicegraphs/output/windows-linux-multiboot-pc-gpt-enc.yml @@ -29,7 +29,7 @@ mount_point: "/" encryption: type: luks - name: "/dev/mapper/cr_sda4" + name: "/dev/mapper/cr_root" password: '12345678' - partition: size: 2 GiB @@ -40,5 +40,5 @@ mount_point: swap encryption: type: luks - name: "/dev/mapper/cr_sda5" + name: "/dev/mapper/cr_swap" password: '12345678' diff --git a/test/data/devicegraphs/output/windows-pc-enc-sep-home.yml b/test/data/devicegraphs/output/windows-pc-enc-sep-home.yml index a0dee83cb1..2d697004f4 100644 --- a/test/data/devicegraphs/output/windows-pc-enc-sep-home.yml +++ b/test/data/devicegraphs/output/windows-pc-enc-sep-home.yml @@ -21,7 +21,7 @@ mount_point: "/" encryption: type: luks - name: "/dev/mapper/cr_sda3" + name: "/dev/mapper/cr_root" password: '12345678' - partition: @@ -39,7 +39,7 @@ mount_point: swap encryption: type: luks - name: "/dev/mapper/cr_sda5" + name: "/dev/mapper/cr_swap" password: '12345678' - partition: @@ -51,7 +51,7 @@ mount_point: "/home" encryption: type: luks - name: "/dev/mapper/cr_sda6" + name: "/dev/mapper/cr_home" password: '12345678' - partition: diff --git a/test/data/devicegraphs/output/windows-pc-enc.yml b/test/data/devicegraphs/output/windows-pc-enc.yml index 9fe68dd903..f9855f2b14 100644 --- a/test/data/devicegraphs/output/windows-pc-enc.yml +++ b/test/data/devicegraphs/output/windows-pc-enc.yml @@ -21,7 +21,7 @@ mount_point: "/" encryption: type: luks - name: "/dev/mapper/cr_sda3" + name: "/dev/mapper/cr_root" password: '12345678' - partition: @@ -32,7 +32,7 @@ mount_point: swap encryption: type: luks - name: "/dev/mapper/cr_sda4" + name: "/dev/mapper/cr_swap" password: '12345678' - partition: diff --git a/test/data/devicegraphs/output/windows-pc-gpt-enc-sep-home.yml b/test/data/devicegraphs/output/windows-pc-gpt-enc-sep-home.yml index d0744d011b..2245714dd4 100644 --- a/test/data/devicegraphs/output/windows-pc-gpt-enc-sep-home.yml +++ b/test/data/devicegraphs/output/windows-pc-gpt-enc-sep-home.yml @@ -25,7 +25,7 @@ mount_point: "/" encryption: type: luks - name: "/dev/mapper/cr_sda4" + name: "/dev/mapper/cr_root" password: '12345678' - partition: @@ -36,7 +36,7 @@ mount_point: swap encryption: type: luks - name: "/dev/mapper/cr_sda5" + name: "/dev/mapper/cr_swap" password: '12345678' - partition: @@ -47,7 +47,7 @@ mount_point: "/home" encryption: type: luks - name: "/dev/mapper/cr_sda6" + name: "/dev/mapper/cr_home" password: '12345678' - partition: diff --git a/test/data/devicegraphs/output/windows-pc-gpt-enc.yml b/test/data/devicegraphs/output/windows-pc-gpt-enc.yml index 71930f1a6e..e0269c522d 100644 --- a/test/data/devicegraphs/output/windows-pc-gpt-enc.yml +++ b/test/data/devicegraphs/output/windows-pc-gpt-enc.yml @@ -25,7 +25,7 @@ mount_point: "/" encryption: type: luks - name: "/dev/mapper/cr_sda4" + name: "/dev/mapper/cr_root" password: '12345678' - partition: @@ -36,7 +36,7 @@ mount_point: swap encryption: type: luks - name: "/dev/mapper/cr_sda5" + name: "/dev/mapper/cr_swap" password: '12345678' - partition: diff --git a/test/y2storage/fake_device_factory_test.rb b/test/y2storage/fake_device_factory_test.rb index 4a600d28ab..144cdad91e 100755 --- a/test/y2storage/fake_device_factory_test.rb +++ b/test/y2storage/fake_device_factory_test.rb @@ -426,7 +426,7 @@ disk = Storage.to_disk(Storage::BlkDevice.find_by_name(staging, "/dev/sdb")) expect(disk.has_encryption).to be true - expect(disk.encryption.name).to eq "/dev/mapper/cr_sdb" + expect(disk.encryption.name).to eq "/dev/mapper/cr_data" end end @@ -441,7 +441,7 @@ label: "backup" encryption: type: "luks" - name: "/dev/mapper/cr_data" + name: "/dev/mapper/cr_custom_name" ) end @@ -451,7 +451,7 @@ disk = Storage.to_disk(Storage::BlkDevice.find_by_name(staging, "/dev/sdb")) expect(disk.has_encryption).to be true - expect(disk.encryption.name).to eq "/dev/mapper/cr_data" + expect(disk.encryption.name).to eq "/dev/mapper/cr_custom_name" end end @@ -466,7 +466,7 @@ label: "backup" encryption: type: "luks" - name: "cr_data" + name: "cr_dm_name" ) end @@ -476,7 +476,7 @@ disk = Storage.to_disk(Storage::BlkDevice.find_by_name(staging, "/dev/sdb")) expect(disk.has_encryption).to be true - expect(disk.encryption.name).to eq "/dev/mapper/cr_data" + expect(disk.encryption.name).to eq "/dev/mapper/cr_dm_name" end end From 96ab5ad878015be9758b938e6c308ef1f6ea58a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Iv=C3=A1n=20L=C3=B3pez=20Gonz=C3=A1lez?= Date: Tue, 10 Dec 2019 15:34:18 +0000 Subject: [PATCH 3/3] Update version and changelog --- 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 3189bc4e77..15c83ec391 100644 --- a/package/yast2-storage-ng.changes +++ b/package/yast2-storage-ng.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Tue Dec 10 15:32:05 UTC 2019 - José Iván López González + +- Generate encryption names according to the mount point of the + encryption device (bsc#1125774). +- 4.2.61 + ------------------------------------------------------------------- Wed Dec 4 12:17:37 UTC 2019 - José Iván López González diff --git a/package/yast2-storage-ng.spec b/package/yast2-storage-ng.spec index 2d993dcd0e..64e47d1ac6 100644 --- a/package/yast2-storage-ng.spec +++ b/package/yast2-storage-ng.spec @@ -16,7 +16,7 @@ # Name: yast2-storage-ng -Version: 4.2.60 +Version: 4.2.61 Release: 0 Summary: YaST2 - Storage Configuration License: GPL-2.0-only OR GPL-3.0-only