Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge branch 'SLE-15-GA' into merge-sle-15
* SLE-15-GA: Use exists_in_probed? instead of the raw version Bump version and update changes file Use default_btrfs_subvolume to find out the prefix on new filesystems Several improvements Update version and changelog Update dependency Add method to use crypttab names Add class to manage crypttab files
- Loading branch information
Showing
14 changed files
with
514 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# encoding: utf-8 | ||
|
||
# Copyright (c) [2018] SUSE LLC | ||
# | ||
# All Rights Reserved. | ||
# | ||
# This program is free software; you can redistribute it and/or modify it | ||
# under the terms of version 2 of the GNU General Public License as published | ||
# by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
# more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with this program; if not, contact SUSE LLC. | ||
# | ||
# To contact SUSE LLC about this file by physical or electronic mail, you may | ||
# find current contact information at www.suse.com. | ||
|
||
require "yast" | ||
require "storage" | ||
require "y2storage/simple_etc_crypttab_entry" | ||
|
||
module Y2Storage | ||
# Class to represent a crypttab file | ||
class Crypttab | ||
include Yast::Logger | ||
|
||
CRYPTTAB_PATH = "/etc/crypttab" | ||
private_constant :CRYPTTAB_PATH | ||
|
||
# @return [Array<SimpleEtcCrypttabEntry>] | ||
attr_reader :entries | ||
|
||
# Constructor | ||
# | ||
# @param path [String] path to crypttab file | ||
def initialize(path = CRYPTTAB_PATH) | ||
@path = path | ||
@entries = read_entries | ||
end | ||
|
||
private | ||
|
||
# @return [String] crypttab file path | ||
attr_reader :path | ||
|
||
# Reads a crypttab file and returns its entries | ||
# | ||
# @return [Array<SimpleEtcCrypttabEntry>] | ||
def read_entries | ||
entries = Storage.read_simple_etc_crypttab(path) | ||
entries.map { |e| SimpleEtcCrypttabEntry.new(e) } | ||
rescue Storage::Exception | ||
log.error("Not possible to read the crypttab file: #{path}") | ||
[] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# encoding: utf-8 | ||
|
||
# Copyright (c) [2018] SUSE LLC | ||
# | ||
# All Rights Reserved. | ||
# | ||
# This program is free software; you can redistribute it and/or modify it | ||
# under the terms of version 2 of the GNU General Public License as published | ||
# by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
# more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with this program; if not, contact SUSE LLC. | ||
# | ||
# To contact SUSE LLC about this file by physical or electronic mail, you may | ||
# find current contact information at www.suse.com. | ||
|
||
require "y2storage/storage_class_wrapper" | ||
|
||
module Y2Storage | ||
# Information about one entry in crypttab | ||
# | ||
# This is a wrapper for Storage::SimpleEtcCrypttabEntry | ||
class SimpleEtcCrypttabEntry | ||
include StorageClassWrapper | ||
wrap_class Storage::SimpleEtcCrypttabEntry | ||
|
||
# @!method name | ||
# @return [String] name of the resulting encrypted block device | ||
storage_forward :name | ||
|
||
# @!method device | ||
# @return [String] path to the underlying block device or a | ||
# specification of a block device via "UUID=" | ||
storage_forward :device | ||
|
||
# @!method password | ||
# @return [String] | ||
storage_forward :password | ||
|
||
# @!method crypt_options | ||
# @return [Array<String>] | ||
storage_forward :crypt_options | ||
|
||
# Plain device for the crypttab entry | ||
# | ||
# @note It always returns the underlying block device, even when the encryption | ||
# device is indicated by its UUID. | ||
# | ||
# TODO: Right now the device only is found when it is indicated by any udev | ||
# name, see {Devicegraph#find_by_any_name), but it is not possible to find | ||
# it when the crypttab entry contains an UUID (or label). | ||
# | ||
# @param devicegraph [Devicegraph] | ||
# @return [BlkDevice, nil] nil if the device is not found | ||
def find_device(devicegraph) | ||
devicegraph.find_by_any_name(device) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
luks1 /dev/sda1 passw1 option1,option2=2 | ||
luks2 /dev/sda2 passw2 | ||
luks3 /dev/sda3 passw3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
- disk: | ||
size: 800.00 GiB | ||
name: "/dev/sda" | ||
partition_table: gpt | ||
partitions: | ||
|
||
- partition: | ||
size: 755707 MiB | ||
name: /dev/sda1 | ||
id: windows_basic_data | ||
file_system: ntfs | ||
label: windows | ||
|
||
- partition: | ||
size: 5 MiB | ||
name: "/dev/sda3" | ||
id: bios_boot | ||
|
||
- partition: | ||
size: 40 GiB | ||
name: "/dev/sda4" | ||
id: linux | ||
file_system: btrfs | ||
mount_point: "/" | ||
encryption: | ||
type: luks | ||
name: "/dev/mapper/cr_sda4" | ||
password: '12345678' | ||
|
||
- partition: | ||
size: 2 GiB | ||
name: "/dev/sda5" | ||
id: swap | ||
file_system: swap | ||
mount_point: swap | ||
encryption: | ||
type: luks | ||
name: "/dev/mapper/cr_sda5" | ||
password: '12345678' | ||
|
||
- partition: | ||
size: unlimited | ||
name: "/dev/sda2" | ||
id: windows_basic_data | ||
file_system: vfat | ||
label: recovery |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.