• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

yast / yast-bootloader / 12048550996

27 Nov 2024 10:37AM UTC coverage: 87.484% (+0.1%) from 87.378%
12048550996

Pull #708

github

schubi2
cleanup
Pull Request #708: Supporting Grub2-BLS

210 of 240 new or added lines in 13 files covered. (87.5%)

88 existing lines in 7 files now uncovered.

3362 of 3843 relevant lines covered (87.48%)

13.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

86.42
/src/lib/bootloader/generic_widgets.rb
1
# frozen_string_literal: true
2

3
require "yast"
1✔
4

5
require "bootloader/bootloader_factory"
1✔
6
require "bootloader/cpu_mitigations"
1✔
7

8
require "cwm/widget"
1✔
9

10
Yast.import "UI"
1✔
11
Yast.import "Popup"
1✔
12

13
module Bootloader
1✔
14
  # Widget to switch between all supported bootloaders
15
  class LoaderTypeWidget < CWM::ComboBox
1✔
16
    def initialize
1✔
17
      textdomain "bootloader"
8✔
18

19
      super
8✔
20
    end
21

22
    def label
1✔
23
      textdomain "bootloader"
1✔
24

25
      _("&Boot Loader")
1✔
26
    end
27

28
    def init
1✔
29
      self.value = BootloaderFactory.current.name
×
30
    end
31

32
    def opt
1✔
33
      [:notify]
2✔
34
    end
35

36
    def items
1✔
37
      BootloaderFactory.supported_names.map do |name|
2✔
38
        [name, localized_names(name)]
10✔
39
      end
40
    end
41

42
    def localized_names(name)
1✔
43
      names = {
44
        "grub2"        => _("GRUB2"),
10✔
45
        "grub2-efi"    => _("GRUB2 for EFI"),
46
        # Translators: Using Boot Loader Specification (BLS) snippets.
47
        "grub2-bls"    => _("GRUB2 with BLS"),
48
        "systemd-boot" => _("Systemd Boot"),
49
        # Translators: option in combo box when bootloader is not managed by yast2
50
        "none"         => _("Not Managed"),
51
        "default"      => _("Default")
52
      }
53

54
      names[name] or raise "Unknown supported bootloader '#{name}'"
10✔
55
    end
56

57
    def handle
1✔
58
      old_bl = BootloaderFactory.current.name
1✔
59
      new_bl = value
1✔
60

61
      return nil if old_bl == new_bl
1✔
62

63
      if new_bl == "none"
1✔
64
        # popup - Continue/Cancel
65
        popup_msg = _(
×
66
          "\n" \
67
          "If you do not install any boot loader, the system\n" \
68
          "might not start.\n" \
69
          "\n" \
70
          "Proceed?\n"
71
        )
72

73
        return :redraw if !Yast::Popup.ContinueCancel(popup_msg)
×
74
      end
75

76
      if !Yast::Stage.initial && ["systemd-boot", "grub2-bls"].include?(old_bl)
1✔
NEW
77
        Yast::Popup.Warning(format(_(
×
78
        "Switching from %s to another bootloader\n" \
79
        "is currently not supported.\n"
80
      ), old_bl))
NEW
81
        return :redraw
×
82
      end
83

84
      if !Yast::Stage.initial && ["systemd-boot", "grub2-bls"].include?(new_bl)
1✔
NEW
85
        Yast::Popup.Warning(format(_(
×
86
        "Switching to bootloader %s \n" \
87
        "is currently not supported.\n"
88
      ), new_bl))
89
        return :redraw
×
90
      end
91

92
      BootloaderFactory.current_name = new_bl
1✔
93
      BootloaderFactory.current.propose
1✔
94

95
      :redraw
1✔
96
    end
97

98
    def help
1✔
99
      _(
1✔
100
        "<p><b>Boot Loader</b>\n" \
101
        "specifies which boot loader to install. Can be also set to <tt>None</tt> " \
102
        "which means that the boot loader configuration is not managed by YaST and also " \
103
        "the kernel post install script does not update the boot loader configuration."
104
      )
105
    end
106
  end
107

108
  # Represents decision if smt is enabled
109
  class CpuMitigationsWidget < CWM::ComboBox
1✔
110
    def initialize
1✔
111
      textdomain "bootloader"
22✔
112

113
      super
22✔
114
    end
115

116
    def label
1✔
117
      _("CPU Mitigations")
4✔
118
    end
119

120
    def items
1✔
121
      ::Bootloader::CpuMitigations::ALL.map do |m|
4✔
122
        [m.value.to_s, m.to_human_string]
16✔
123
      end
124
    end
125

126
    def help
1✔
127
      _(
4✔
128
        "<p><b>CPU Mitigations</b><br>\n" \
129
        "The option selects which default settings should be used for CPU \n" \
130
        "side channels mitigations. A highlevel description is on our Technical Information \n" \
131
        "Document TID 7023836. Following options are available:<ul>\n" \
132
        "<li><b>Auto</b>: This option enables all the mitigations needed for your CPU model. \n" \
133
        "This setting can impact performance to some degree, depending on CPU model and \n" \
134
        "workload. It provides all security mitigations, but it does not protect against \n" \
135
        "cross-CPU thread attacks.</li>\n" \
136
        "<li><b>Auto + No SMT</b>: This option enables all the above mitigations in \n" \
137
        "\"Auto\", and also disables Simultaneous Multithreading to avoid \n" \
138
        "side channel attacks across multiple CPU threads. This setting can \n" \
139
        "further impact performance, depending on your \n" \
140
        "workload. This setting provides the full set of available security mitigations.</li>\n" \
141
        "<li><b>Off</b>: All CPU Mitigations are disabled. This setting has no performance \n" \
142
        "impact, but side channel attacks against your CPU are possible, depending on CPU \n" \
143
        "model.</li>\n" \
144
        "<li><b>Manual</b>: This setting does not specify a mitigation level and leaves \n" \
145
        "this to be the kernel default. The administrator can add other mitigations options \n" \
146
        "in the <i>kernel command line</i> widget.\n" \
147
        "All CPU mitigation specific options can be set manually.</li></ul></p>"
148
      )
149
    end
150

151
    def init
1✔
152
      if Bootloader::BootloaderFactory.current.respond_to?(:cpu_mitigations)
2✔
153
        self.value = Bootloader::BootloaderFactory.current.cpu_mitigations.value.to_s
×
154
      else
155
        disable
2✔
156
      end
157
    end
158

159
    def store
1✔
160
      return unless enabled?
2✔
161

162
      Bootloader::BootloaderFactory.current.cpu_mitigations =
×
163
        ::Bootloader::CpuMitigations.new(value.to_sym)
164
    end
165
  end
166

167
  # represents kernel command line
168
  class KernelAppendWidget < CWM::InputField
1✔
169
    def initialize
1✔
170
      textdomain "bootloader"
10✔
171

172
      super
10✔
173
    end
174

175
    def label
1✔
176
      _("O&ptional Kernel Command Line Parameter")
2✔
177
    end
178

179
    def help
1✔
180
      _(
2✔
181
        "<p><b>Optional Kernel Command Line Parameter</b> lets you define " \
182
        "additional parameters to pass to the kernel.</p>"
183
      )
184
    end
185

186
    def init
1✔
187
      current_bl = ::Bootloader::BootloaderFactory.current
2✔
188
      case current_bl
2✔
189
      when ::Bootloader::SystemdBoot
190
        self.value = current_bl.kernel_params.serialize.gsub(/mitigations=\S+/, "")
1✔
191
      when ::Bootloader::Grub2Base
192
        self.value = current_bl.grub_default.kernel_params.serialize.gsub(/mitigations=\S+/, "")
1✔
193
      else
194
        disable
×
195
      end
196
    end
197

198
    def store
1✔
199
      return unless enabled?
2✔
200

201
      current_bl = ::Bootloader::BootloaderFactory.current
2✔
202
      case current_bl
2✔
203
      when ::Bootloader::SystemdBoot
204
        current_bl.kernel_params.replace(value)
1✔
205
      when ::Bootloader::Grub2Base
206
        current_bl.grub_default.kernel_params.replace(value)
1✔
207
      else
208
        log.error("Bootloader type #{current_bl} not found.")
×
209
      end
210
    end
211
  end
212
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc