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

yast / yast-security / 7348705966

28 Dec 2023 02:50PM UTC coverage: 39.237% (-0.3%) from 39.568%
7348705966

Pull #157

github

web-flow
Merge 7db7fc531 into a9a6f29de
Pull Request #157: Update rubocop

68 of 442 new or added lines in 17 files covered. (15.38%)

40 existing lines in 4 files now uncovered.

1378 of 3512 relevant lines covered (39.24%)

5.86 hits per line

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

0.0
/src/include/security/widgets.rb
1
# ------------------------------------------------------------------------------
2
# Copyright (c) 2006-2012 Novell, Inc. All Rights Reserved.
3
#
4
#
5
# This program is free software; you can redistribute it and/or modify it under
6
# the terms of version 2 of the GNU General Public License as published by the
7
# Free Software Foundation.
8
#
9
# This program is distributed in the hope that it will be useful, but WITHOUT
10
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License along with
14
# this program; if not, contact Novell, Inc.
15
#
16
# To contact Novell about this file by physical or electronic mail, you may find
17
# current contact information at www.novell.com.
18
# ------------------------------------------------------------------------------
19

20
#  * File:        include/security/widgets.ycp
21
#  * Module:        Security configuration
22
#  * Summary:        Security widgets definitions
23
#  * Authors:        Michal Svec <msvec@suse.cz>
24
#  *
25
#  * $Id$
26
#  *
27
#  * This file contains the definitions of all widgets used by the
28
#  * security module. They are all in one map (function) called
29
#  * WIDGETS.
30
#
31
# <pre>
32
#
33
# The WIDGETS format:
34
# -------------------
35
#
36
# map WIDGETS = $[
37
#     "Item unique ID" : $[
38
#         "Widget" : "ComboBox",
39
#         "Label" : "Item Label",
40
#         "Options" : [ "option1", "option2", ... ],
41
#         "Value" : "option2"
42
#     ],
43
#   ...
44
# ];
45
#
46
# The "Value" is the current value of this option and one from "Options".
47
#
48
# Particular "Options" can be either <string> or [ <string>, <string> ]. In the
49
# latter case, the first string is used as ID and the second is displayed. For
50
# example: [ "option1", ["option2",_("Option2 translation")], ... ].
51
#
52
# Possible "Widget" values so far: "ComboBox, CheckBox, TextEntry".
53
#
54
# Implementation:
55
# ---------------
56
#
57
# map2widget("ID")
58
# - look up the "ID" in the "WIDGETS" map
59
# - create the widget
60
#
61
# widget2value("ID")
62
# - query UI for the widget with `id(ID)
63
# - return its current value
64
#
65
# updatewidget("ID")
66
# - look up the "ID" and change its "Value" to the "val"
67
# - updates the WIDGETS map
68
# - called after start and after each subdialog [OK]
69
# - must check if the value is in "Options"! (TODO)
70
#
71
# processinput()
72
# - return true (OK) or false (abort, back, nil, help!, ...)
73
#
74
# </pre>
75
#
76
#  *
77

78
# @return [Hash] all widgets
79
module Yast
×
80
  module SecurityWidgetsInclude
×
81
    include Yast::I18n
×
82
    extend Yast::I18n
×
83

84
    BOOT_OPTION_LABELS = {
×
85
      "ignore" => N_("Ignore"),
×
86
      "reboot" => N_("Reboot"),
×
87
      "halt"   => N_("Halt")
×
NEW
88
    }.freeze
×
89

90
    SHUTDOWN_LABELS = {
×
91
      "root" => N_("Only root"),
×
92
      "all"  => N_("All Users"),
×
93
      "none" => N_("Nobody")
×
NEW
94
    }.freeze
×
95

NEW
96
    def initialize_security_widgets(_include_target)
×
97
      textdomain "security"
×
98

99
      @display_manager = Security.display_manager
×
100

101
      # All widgets are here
102
      @WIDGETS =
×
103
        #     "" : $[
104
        #         "Widget" : "",
105
        #         /* Widget label * /
106
        #         "Label" : _(""),
107
        #         /* Widget values * /
108
        #         "Options" : [["",_("")]],
109
        #         "Value" : ""
110
        #     ],
111
        {
×
112
          "CONSOLE_SHUTDOWN"             => {
×
113
            "Widget"  => "ComboBox",
×
114
            # ComboBox label
115
            "Label"   => _(
×
116
              "&Interpretation of Ctrl + Alt + Del"
×
117
            ),
×
118
            "Options" => console_shutdown_options,
×
119
            "Value"   => ::Security::CtrlAltDelConfig.default
×
120
          },
×
121
          "DISPLAYMANAGER_REMOTE_ACCESS" => {
×
122
            "Widget" => "CheckBox",
×
123
            # CheckBox label
124
            "Label"  => _("Allow Remote &Graphical Login"),
×
125
            "Value"  => "no"
×
126
          },
×
127
          "kernel.sysrq"                 => {
×
128
            "Widget"   => "ComboBox",
×
129
            # CheckBox label
130
            "Label"    => _("&Magic SysRq Keys"),
×
131
            "Options"  => [
×
132
              # ComboBox value
133
              ["0", _("Disable")],
×
134
              # ComboBox value
135
              ["1", _("Enable All Functions")]
×
136
            ],
×
137
            "Editable" => "yes"
×
138
          },
×
139
          "FAIL_DELAY"                   => {
×
140
            "Widget" => "IntField",
×
141
            # IntField label
142
            "Label"  => _(
×
143
              "&Delay after Incorrect Login Attempt"
×
144
            ),
×
145
            "Value"  => "3"
×
146
          },
×
147
          "GID_MAX"                      => {
×
148
            "Widget" => "IntField",
×
149
            # IntField label
150
            "Label"  => _("Maxim&um"),
×
151
            "Value"  => "60000"
×
152
          },
×
153
          "GID_MIN"                      => {
×
154
            "Widget" => "IntField",
×
155
            # IntField label
156
            "Label"  => _("M&inimum"),
×
157
            "Value"  => "101"
×
158
          },
×
159
          "HIBERNATE_SYSTEM"             => {
×
160
            "Widget"  => "ComboBox",
×
161
            # ComboBox label
162
            "Label"   => _("System Hybernation"),
×
163
            "Options" => [
×
164
              # ComboBox value
165
              ["active_console", _("User on the active console")],
×
166
              # ComboBox value
167
              ["anyone", _("Anyone can hibernate")],
×
168
              # ComboBox value
169
              ["auth_admin", _("Authentication always required")]
×
170
            ],
×
171
            "Value"   => "active_console"
×
172
          },
×
173
          "PASSWD_ENCRYPTION"            => {
×
174
            "Widget"  => "ComboBox",
×
175
            # ComboBox label
176
            "Label"   => _("P&assword Encryption Method"),
×
177
            # ComboBox values
178
            "Options" => [
×
179
              ["des", "DES"],
×
180
              ["md5", "MD5"],
×
181
              ["sha256", "SHA-256"],
×
182
              ["sha512", "SHA-512"]
×
183
            ],
×
184
            "Value"   => "des",
×
185
            "Notify"  => "yes"
×
186
          },
×
187
          "PASSWD_USE_PWQUALITY"         => {
×
188
            "Widget" => "CheckBox",
×
189
            # CheckBox label
190
            "Label"  => _("&Check New Passwords"),
×
191
            "Notify" => "yes",
×
192
            "Value"  => "yes"
×
193
          },
×
194
          "PASS_MAX_DAYS"                => {
×
195
            "Widget" => "IntField",
×
196
            # IntField label
197
            "Label"  => _("Maxim&um"),
×
198
            "Value"  => "99999"
×
199
          },
×
200
          "PASSWD_REMEMBER_HISTORY"      => {
×
201
            "Widget"   => "IntField",
×
202
            # IntField label
203
            "Label"    => _("Numb&er of Passwords to Remember"),
×
204
            "MinValue" => 0,
×
205
            "MaxValue" => 400
×
206
          },
×
207
          "PASS_MIN_DAYS"                => {
×
208
            "Widget" => "IntField",
×
209
            # IntField label
210
            "Label"  => _("M&inimum"),
×
211
            "Value"  => "0"
×
212
          },
×
213
          "PASS_MIN_LEN"                 => {
×
214
            "Widget" => "IntField",
×
215
            # IntField label
216
            "Label"  => _(
×
217
              "&Minimum Acceptable Password Length"
×
218
            ),
×
219
            "Value"  => "5"
×
220
          },
×
221
          "PASS_WARN_AGE"                => {
×
222
            "Widget" => "IntField",
×
223
            # IntField label
224
            "Label"  => _(
×
225
              "&Days before Password Expires Warning"
×
226
            ),
×
227
            "Value"  => "7"
×
228
          },
×
229
          "PERMISSION_SECURITY"          => {
×
230
            "Widget"  => "ComboBox",
×
231
            # ComboBox label
232
            "Label"   => _("&File Permissions"),
×
233
            "Options" => [
×
234
              # ComboBox value
235
              ["easy", _("Easy")],
×
236
              # ComboBox value
237
              ["secure", _("Secure")],
×
238
              # ComboBox value
239
              ["paranoid", _("Paranoid")]
×
240
            ],
×
241
            "Value"   => "secure"
×
242
          },
×
243
          "RUN_UPDATEDB_AS"              => {
×
244
            "Widget"  => "ComboBox",
×
245
            # ComboBox label
246
            "Label"   => _("&User Launching updatedb"),
×
247
            "Options" => ["nobody", "root"],
×
248
            "Value"   => "nobody"
×
249
          },
×
250
          "UID_MAX"                      => {
×
251
            "Widget" => "IntField",
×
252
            # IntField label
253
            "Label"  => _("Ma&ximum"),
×
254
            "Value"  => "60000"
×
255
          },
×
256
          "UID_MIN"                      => {
×
257
            "Widget" => "IntField",
×
258
            # IntField label
259
            "Label"  => _("&Minimum"),
×
260
            "Value"  => "100"
×
261
          }
×
262
        }
×
263

NEW
264
      return unless @display_manager
×
NEW
265
      return if @display_manager.shutdown_var_name.empty?
×
266

267
      @WIDGETS.merge!(
×
268
        @display_manager.shutdown_var_name => shutdown_login_manager_widget
×
NEW
269
      )
×
270
    end
×
271

272
    def shutdown_login_manager_widget
×
273
      {
×
274
        "Widget"  => "ComboBox",
×
275
        # ComboBox label
276
        # TRANSLATORS: %s will be the configured display manager usually: GDM or KDM,
277
        # but could be XDM,WDM,ENTRANCE,CONSOLE
278
        "Label"   => _(
×
279
          "&Shutdown Behaviour of %s Login Manager:"
×
280
        ) % @display_manager.name,
×
281
        "Options" => shutdown_options,
×
282
        "Value"   => @display_manager.shutdown_default_value
×
283
      }
×
284
    end
×
285

286
    def console_shutdown_options
×
287
      ::Security::CtrlAltDelConfig.options.map do |opt|
×
288
        [opt, _(BOOT_OPTION_LABELS[opt.downcase])]
×
289
      end
×
290
    end
×
291

292
    def shutdown_options
×
293
      @display_manager.shutdown_options.map do |opt|
×
294
        [opt, _(SHUTDOWN_LABELS[opt.downcase])]
×
295
      end
×
296
    end
×
297
  end
×
298
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