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

yast / yast-security / 4251698580

pending completion
4251698580

push

github

Unknown Committer
Unknown Commit Message

1 of 1 new or added line in 1 file covered. (100.0%)

1375 of 3475 relevant lines covered (39.57%)

5.82 hits per line

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

0.0
/src/include/security/widgets.rb
1
# encoding: utf-8
2

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

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

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

86
    BOOT_OPTION_LABELS = {
×
87
      "ignore" => N_("Ignore"),
×
88
      "reboot" => N_("Reboot"),
×
89
      "halt"   => N_("Halt")
×
90
    }
×
91

92
    SHUTDOWN_LABELS = {
×
93
      "root" => N_("Only root"),
×
94
      "all"  => N_("All Users"),
×
95
      "none" => N_("Nobody")
×
96
    }
×
97

98
    def initialize_security_widgets(include_target)
×
99
      textdomain "security"
×
100

101
      @display_manager = Security.display_manager
×
102

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

266
      @WIDGETS.merge!(
×
267
        @display_manager.shutdown_var_name => shutdown_login_manager_widget
×
268
      ) if @display_manager && !@display_manager.shutdown_var_name.empty?
×
269
    end
×
270

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

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

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