Skip to content

Commit 27dabb2

Browse files
committed
cleanup
1 parent 867668c commit 27dabb2

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

src/lib/bootloader/bls.rb

+23-16
Original file line numberDiff line numberDiff line change
@@ -110,22 +110,7 @@ def self.default_menu
110110
def self.enable_tpm2
111111
return unless Y2Storage::StorageManager.instance.encryption_use_tpm2
112112

113-
begin
114-
pwd = Y2Storage::StorageManager.instance.encryption_tpm2_password
115-
Yast::Execute.on_target!("keyctl", "padd", "user", "cryptenroll", "@u",
116-
stdout: :capture,
117-
stdin: pwd)
118-
rescue Cheetah::ExecutionFailed => e
119-
Yast::Report.Error(
120-
format(_(
121-
"Cannot pass the password via the keyring:\n" \
122-
"Command `%{command}`.\n" \
123-
"Error output: %{stderr}"
124-
), command: e.commands.inspect, stderr: e.stderr)
125-
)
126-
return
127-
end
128-
113+
export_password
129114
generate_machine_id
130115

131116
begin
@@ -159,5 +144,27 @@ def generate_machine_id
159144
)
160145
end
161146
end
147+
148+
def export_password
149+
pwd = Y2Storage::StorageManager.instance.encryption_tpm2_password
150+
if pwd.empty?
151+
Yast::Report.Error(_("Cannot pass empty password via the keyring."))
152+
return
153+
end
154+
155+
begin
156+
Yast::Execute.on_target!("keyctl", "padd", "user", "cryptenroll", "@u",
157+
stdout: :capture,
158+
stdin: pwd)
159+
rescue Cheetah::ExecutionFailed => e
160+
Yast::Report.Error(
161+
format(_(
162+
"Cannot pass the password via the keyring:\n" \
163+
"Command `%{command}`.\n" \
164+
"Error output: %{stderr}"
165+
), command: e.commands.inspect, stderr: e.stderr)
166+
)
167+
end
168+
end
162169
end
163170
end

0 commit comments

Comments
 (0)