Skip to content

Commit

Permalink
rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
schubi2 committed Apr 10, 2024
1 parent 161df11 commit 1010a0f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 16 deletions.
25 changes: 18 additions & 7 deletions src/lib/y2storage/dialogs/guided_setup/select_scheme.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ def initialize(*params)
super
end


# Handler for :encryption_method ComboBox.
# @param focus [Boolean] whether password field should be focused
def encryption_method_handler(focus: true)
widget_update(:encryption_pbkdf, (using_encryption? && using_luks2_encryption?), attr: :Enabled)
widget_update(:encryption_pbkdf, (using_encryption? && using_luks2_encryption?),
attr: :Enabled)
return unless focus && using_encryption? && using_luks2_encryption?

Yast::UI.SetFocus(Id(:encryption_pbkdf))
Expand Down Expand Up @@ -149,7 +149,9 @@ def enable_disk_encryption
Id(:encryption_method),
Opt(:notify, :hstretch),
_("Encryption method"),
Y2Storage::EncryptionMethod.available.reject(&:only_for_swap?).map { |m| Item(Id(m.to_sym), m.to_human_string,false) }
Y2Storage::EncryptionMethod.available.reject(&:only_for_swap?).map do |m|
Item(Id(m.to_sym), m.to_human_string, false)
end
)
)
),
Expand All @@ -160,7 +162,9 @@ def enable_disk_encryption
Id(:encryption_pbkdf),
Opt(:hstretch),
_("Password-Based Key Derivation &Function (PBKDF)"),
Y2Storage::PbkdFunction.all.map { |m| Item(Id(m.value), m.name, (m.value == "pbkdf2" ? true : false)) }
Y2Storage::PbkdFunction.all.map do |m|
Item(Id(m.value), m.name, (m.value == "pbkdf2"))
end
)
)
)
Expand All @@ -173,7 +177,10 @@ def initialize_widgets
widget_update(:encryption, settings.use_encryption)
encryption_handler(focus: false)
widget_update(:encryption_method, settings.encryption_method.id) if settings.encryption_method
widget_update(:encryption_pbkdf, Id(settings.encryption_pbkdf.value)) if settings.encryption_pbkdf
if settings.encryption_pbkdf
widget_update(:encryption_pbkdf,
Id(settings.encryption_pbkdf.value))
end
encryption_method_handler(focus: false)
return unless settings.use_encryption

Expand All @@ -185,8 +192,12 @@ def update_settings!
settings.use_lvm = widget_value(:lvm)
settings.separate_vgs = widget_value(:separate_vgs) if settings.separate_vgs_relevant?
settings.encryption_password = using_encryption? ? widget_value(:password) : nil
settings.encryption_method = using_encryption? ? Y2Storage::EncryptionMethod.find(widget_value(:encryption_method)) : nil
settings.encryption_pbkdf = (using_encryption? && using_luks2_encryption?) ? Y2Storage::PbkdFunction.find(widget_value(:encryption_pbkdf)) : nil
settings.encryption_method = if using_encryption?
Y2Storage::EncryptionMethod.find(widget_value(:encryption_method))
end
settings.encryption_pbkdf = if using_encryption? && using_luks2_encryption?
Y2Storage::PbkdFunction.find(widget_value(:encryption_pbkdf))
end
end

def help_text
Expand Down
11 changes: 6 additions & 5 deletions src/lib/y2storage/dialogs/proposal.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# coding: utf-8
# Copyright (c) [2016-2022] SUSE LLC
#
# All Rights Reserved.
Expand Down Expand Up @@ -148,13 +147,15 @@ def actions_html

def encryption_error
ret = ""
if (!@proposal.nil? &&
if !@proposal.nil? &&
!@proposal.settings.nil? &&
!@proposal.settings.encryption_method.nil? &&
@proposal.settings.encryption_password.nil?)
ret = Yast::HTML.Para (_("Missing encryption password - Proposal has been done without encryption.")) +
@proposal.settings.encryption_password.nil?
ret = Yast::HTML.Para(
_("Missing encryption password - Proposal has been done without encryption.")
) +
Yast::HTML.Newline +
_("Please use \"Guided Setup\" in order to set the password or in order to disable encryption.")
_("Please use \"Guided Setup\" in order to set the password or to disable encryption.")
ret = Yast::HTML.Colorize(ret, "red")
end
ret
Expand Down
2 changes: 1 addition & 1 deletion src/lib/y2storage/encryption_processes/secure_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def repository_path(base_dir = "/")
#
# @return [String]
def repo_dir
ENV["ZKEY_REPOSITORY"] || DEFAULT_REPO_DIR
ENV.fetch("ZKEY_REPOSITORY", nil) || DEFAULT_REPO_DIR
end

# Arguments to be used with the "zkey generate" command
Expand Down
3 changes: 1 addition & 2 deletions src/lib/y2storage/proposal_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,7 @@ def load_encryption
self.encryption_password = passwd

# If an encryption password and no method have been set, we are using LUKS2 as default
self.encryption_method = EncryptionMethod::LUKS2 if self.encryption_method.nil?

self.encryption_method = EncryptionMethod::LUKS2 if encryption_method.nil?
end

def validated_delete_mode(mode)
Expand Down
2 changes: 1 addition & 1 deletion src/lib/y2storage/storage_env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def read(variable)
key = ENV.keys.sort.find { |k| k.match(/\A#{variable}\z/i) }
return nil unless key

value = ENV[key]
value = ENV.fetch(key, nil)
log.debug "Found ENV variable key: #{key.inspect} value: #{value.inspect}"
value
end
Expand Down

0 comments on commit 1010a0f

Please sign in to comment.