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

yast / yast-bootloader / 8831324946

25 Apr 2024 10:56AM UTC coverage: 87.126% (+0.1%) from 86.999%
8831324946

push

github

schubi2
fixed testcase

3228 of 3705 relevant lines covered (87.13%)

12.78 hits per line

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

89.23
/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)]
8✔
39
      end
40
    end
41

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

52
      names[name] or raise "Unknown supported bootloader '#{name}'"
8✔
53
    end
54

55
    # rubocop:disable Metrics/MethodLength
56
    # It will be reduced again if systemd-boot is not anymore in beta phase.
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 new_bl == "systemd-boot"
1✔
77
        # popup - Continue/Cancel
78
        popup_msg = _(
×
79
          "\n" \
80
          "Systemd-boot support is currently work in progress and\n" \
81
          "may not work as expected. Use at your own risk.\n" \
82
          "\n" \
83
          "Currently we do not provide official maintenance or support.\n" \
84
          "Proceed?\n"
85
        )
86

87
        return :redraw if !Yast::Popup.ContinueCancel(popup_msg)
×
88
      end
89

90
      if !Yast::Stage.initial && (old_bl == "systemd-boot")
1✔
91
        Yast::Popup.Warning(_(
×
92
        "Switching from systemd-boot to another bootloader\n" \
93
        "is currently not supported.\n"
94
      ))
95
        return :redraw
×
96
      end
97

98
      BootloaderFactory.current_name = new_bl
1✔
99
      BootloaderFactory.current.propose
1✔
100

101
      :redraw
1✔
102
    end
103

104
    # rubocop:enable Metrics/MethodLength
105
    def help
1✔
106
      _(
1✔
107
        "<p><b>Boot Loader</b>\n" \
108
        "specifies which boot loader to install. Can be also set to <tt>None</tt> " \
109
        "which means that the boot loader configuration is not managed by YaST and also " \
110
        "the kernel post install script does not update the boot loader configuration."
111
      )
112
    end
113
  end
114

115
  # Represents decision if smt is enabled
116
  class CpuMitigationsWidget < CWM::ComboBox
1✔
117
    def initialize
1✔
118
      textdomain "bootloader"
12✔
119

120
      super
12✔
121
    end
122

123
    def label
1✔
124
      _("CPU Mitigations")
2✔
125
    end
126

127
    def items
1✔
128
      ::Bootloader::CpuMitigations::ALL.map do |m|
2✔
129
        [m.value.to_s, m.to_human_string]
8✔
130
      end
131
    end
132

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

158
    def init; end
1✔
159

160
    def store; end
1✔
161
  end
162

163
  # represents kernel command line
164
  class KernelAppendWidget < CWM::InputField
1✔
165
    def initialize
1✔
166
      textdomain "bootloader"
6✔
167

168
      super
6✔
169
    end
170

171
    def label
1✔
172
      _("O&ptional Kernel Command Line Parameter")
1✔
173
    end
174

175
    def help
1✔
176
      _(
1✔
177
        "<p><b>Optional Kernel Command Line Parameter</b> lets you define " \
178
        "additional parameters to pass to the kernel.</p>"
179
      )
180
    end
181

182
    def init; end
1✔
183

184
    def store; end
1✔
185
  end
186
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

© 2026 Coveralls, Inc