• 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/dialogs.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/dialogs.ycp
23
# Package:        Security configuration
24
# Summary:        Dialogs definitions
25
# Authors:        Michal Svec <msvec@suse.cz>
26
#
27
# $Id$
28
module Yast
×
29
  module SecurityDialogsInclude
×
30
    def initialize_security_dialogs(include_target)
×
31
      Yast.import "UI"
×
32

33
      textdomain "security"
×
34

35
      Yast.import "Label"
×
36
      Yast.import "Popup"
×
37
      Yast.import "Message"
×
38
      Yast.import "Security"
×
39
      Yast.import "Wizard"
×
40

41
      Yast.include include_target, "security/helps.rb"
×
42
      Yast.include include_target, "security/routines.rb"
×
43

44
      @display_manager = Security.display_manager
×
45

46
      @tree_dialogs = [
×
47
        "main",
×
48
        "overview",
×
49
        "password",
×
50
        "boot",
×
51
        "login",
×
52
        "users",
×
53
        "misc",
×
54
        :wizardTree
×
55
      ]
×
56

57
      @configurable_options = [
×
58
        "PERMISSION_SECURITY",
×
59
        "MANDATORY_SERVICES",
×
60
        "EXTRA_SERVICES",
×
61
        "kernel.sysrq"
×
62
      ]
×
63

64
      @UNKNOWN_STATUS = _("Unknown")
×
65

66
      @label_mapping = {
×
67
        "kernel.sysrq"                              => _("Use magic SysRq keys"),
×
68
        "PERMISSION_SECURITY"                       => _(
×
69
          "Use secure file permissions"
×
70
        ),
×
71
        "DISPLAYMANAGER_REMOTE_ACCESS"              => _(
×
72
          "Remote access to the display manager"
×
73
        ),
×
74
        "SYSLOG_ON_NO_ERROR"                        => _(
×
75
          "Always generate syslog message for cron scripts"
×
76
        ),
×
77
        "DHCPD_RUN_CHROOTED"                        => _(
×
78
          "Run the DHCP daemon in a chroot"
×
79
        ),
×
80
        "DHCPD_RUN_AS"                              => _(
×
81
          "Run the DHCP daemon as dhcp user"
×
82
        ),
×
83
        "DISPLAYMANAGER_ROOT_LOGIN_REMOTE"          => _(
×
84
          "Remote root login in the display manager"
×
85
        ),
×
86
        "DISPLAYMANAGER_XSERVER_TCP_PORT_6000_OPEN" => _(
×
87
          "Remote access to the X server"
×
88
        ),
×
89
        "SMTPD_LISTEN_REMOTE"                       => _(
×
90
          "Remote access to the email delivery subsystem"
×
91
        ),
×
92
        "DISABLE_RESTART_ON_UPDATE"                 => _(
×
93
          "Restart services on update"
×
94
        ),
×
95
        "DISABLE_STOP_ON_REMOVAL"                   => _(
×
96
          "Stop services on removal"
×
97
        ),
×
98
        "net.ipv4.tcp_syncookies"                   => _(
×
99
          "Enable TCP syncookies"
×
100
        ),
×
101
        "net.ipv4.ip_forward"                       => _("IPv4 forwarding"),
×
102
        "net.ipv6.conf.all.forwarding"              => _("IPv6 forwarding"),
×
103
        "MANDATORY_SERVICES"                        => _(
×
104
          "Enable basic system services"
×
105
        ),
×
106
        "EXTRA_SERVICES"                            => _(
×
107
          "Disable extra services"
×
108
        )
×
109
      }
×
110

111
      # mapping for "Enable" and "Disable" links
112
      # current value -> new value
113
      @link_value_mapping = {
×
114
        "yes" => "no",
×
115
        "no" => "yes",
×
116
        "1" => "0",
×
117
        "0" => "1",
×
118
        true => false,
×
119
        false => true
×
120
      }
×
121

122
      # mapping for "Configure" links
123
      # config name -> dialog name
124
      @link_config_mapping = {
×
125
        "PERMISSION_SECURITY" => "misc",
×
126
        "kernel.sysrq"        => "misc"
×
127
      }
×
128

129
      # mapping for "Configure" links
130
      # config name -> yast client
131
      @link_client_mapping = {
×
132
        "MANDATORY_SERVICES" => "services-manager",
×
133
        "EXTRA_SERVICES"     => "services-manager"
×
134
      }
×
135

136
      @link_update_mapping = {
×
137
        "MANDATORY_SERVICES" => lambda { Security.ReadServiceSettings },
×
138
        "EXTRA_SERVICES"     => lambda { Security.ReadServiceSettings }
×
139
      }
×
140
    end
×
141

142
    def SecurityStatus(option, plaintext)
×
143
      ret = ""
×
144

145
      value = Ops.get(Security.Settings, option, "")
×
146

147
      Builtins.y2milestone("Option: %1, value: %2", option, value)
×
148

149
      # handle the special cases at first
150
      if Builtins.contains(@configurable_options, option)
×
151
        ret = _("Configure")
×
152
      elsif ["1", "yes", true].include?(value)
×
153
        ret = _("Enabled")
×
154
      elsif ["0", "no", false].include?(value)
×
155
        ret = _("Disabled")
×
156
      else
×
157
        return @UNKNOWN_STATUS
×
158
      end
×
159

160
      return ret if plaintext
×
161

162
      ret = Builtins.sformat("<A HREF=\"%1\">%2</A>", option, ret)
×
163

164
      ret
×
165
    end
×
166

167
    def OverviewText(type)
×
168
      ret = ""
×
169
      ret_table = []
×
170

171
      if type == :richtext
×
172
        # open a table
173
        ret = Builtins.sformat(
×
174
          "<TABLE><TR> <TD><BIG><B>%1</B></BIG></TD>\n" +
×
175
            "<TD ALIGN=center><BIG><B>&nbsp;&nbsp;&nbsp;&nbsp;%2&nbsp;&nbsp;&nbsp;&nbsp;</B></BIG></TD>\n" +
×
176
            "<TD ALIGN=center><BIG><B>&nbsp;&nbsp;&nbsp;&nbsp;%3&nbsp;&nbsp;&nbsp;&nbsp;</B></BIG></TD>\n" +
×
177
            "<TD></TD>\n" +
×
178
            "</TR> <TR></TR>",
×
179
          # table header
180
          _("Security Setting"),
×
181
          _("Status"),
×
182
          _("Security Status")
×
183
        )
×
184
      end
×
185

186
      security_mapping = [
×
187
        {
×
188
          "id"        => "kernel.sysrq",
×
189
          "is_secure" => Ops.get(Security.Settings, "kernel.sysrq", "0") == "0"
×
190
        },
×
191
        {
×
192
          "id"        => "PERMISSION_SECURITY",
×
193
          "is_secure" => Ops.get(Security.Settings, "PERMISSION_SECURITY", "") == "secure" ||
×
194
            Ops.get(Security.Settings, "PERMISSION_SECURITY", "") == "paranoid"
×
195
        },
×
196
        {
×
197
          "id"        => "DISPLAYMANAGER_REMOTE_ACCESS",
×
198
          "is_secure" => Ops.get(
×
199
            Security.Settings,
×
200
            "DISPLAYMANAGER_REMOTE_ACCESS",
×
201
            ""
×
202
          ) == "no"
×
203
        },
×
204
        {
×
205
          "id"        => "SYSLOG_ON_NO_ERROR",
×
206
          "is_secure" => Ops.get(Security.Settings, "SYSLOG_ON_NO_ERROR", "") == "yes"
×
207
        },
×
208
        {
×
209
          "id"        => "DHCPD_RUN_CHROOTED",
×
210
          "is_secure" => Ops.get(Security.Settings, "DHCPD_RUN_CHROOTED", "") == "yes"
×
211
        },
×
212
        {
×
213
          "id"        => "DHCPD_RUN_AS",
×
214
          "is_secure" => Ops.get(Security.Settings, "DHCPD_RUN_AS", "") == "dhcp"
×
215
        },
×
216
        {
×
217
          "id"        => "DISPLAYMANAGER_ROOT_LOGIN_REMOTE",
×
218
          "is_secure" => Ops.get(
×
219
            Security.Settings,
×
220
            "DISPLAYMANAGER_ROOT_LOGIN_REMOTE",
×
221
            ""
×
222
          ) == "no"
×
223
        },
×
224
        {
×
225
          "id"        => "DISPLAYMANAGER_XSERVER_TCP_PORT_6000_OPEN",
×
226
          "is_secure" => Ops.get(
×
227
            Security.Settings,
×
228
            "DISPLAYMANAGER_XSERVER_TCP_PORT_6000_OPEN",
×
229
            ""
×
230
          ) == "no"
×
231
        },
×
232
        {
×
233
          "id"        => "SMTPD_LISTEN_REMOTE",
×
234
          "is_secure" => Ops.get(Security.Settings, "SMTPD_LISTEN_REMOTE", "") == "no"
×
235
        },
×
236
        {
×
237
          "id"        => "DISABLE_RESTART_ON_UPDATE",
×
238
          "is_secure" => Ops.get(
×
239
            Security.Settings,
×
240
            "DISABLE_RESTART_ON_UPDATE",
×
241
            ""
×
242
          ) == "no"
×
243
        },
×
244
        {
×
245
          "id"        => "DISABLE_STOP_ON_REMOVAL",
×
246
          "is_secure" => Ops.get(
×
247
            Security.Settings,
×
248
            "DISABLE_STOP_ON_REMOVAL",
×
249
            ""
×
250
          ) == "no"
×
251
        },
×
252
        {
×
253
          "id"        => "net.ipv4.tcp_syncookies",
×
254
          "is_secure" => Security.Settings[ "net.ipv4.tcp_syncookies" ]
×
255
        },
×
256
        {
×
257
          "id"        => "net.ipv4.ip_forward",
×
258
          "is_secure" => !Security.Settings["net.ipv4.ip_forward"]
×
259
        },
×
260
        {
×
261
          "id"        => "net.ipv6.conf.all.forwarding",
×
262
          "is_secure" => !Security.Settings["net.ipv6.conf.all.forwarding"]
×
263
        },
×
264
        {
×
265
          "id"        => "MANDATORY_SERVICES",
×
266
          "is_secure" => Security.Settings["MANDATORY_SERVICES"] == "secure"
×
267
        },
×
268
        {
×
269
          "id"        => "EXTRA_SERVICES",
×
270
          "is_secure" => Security.Settings["EXTRA_SERVICES"] == "secure"
×
271
        }
×
272
      ]
×
273

274
      Builtins.foreach(security_mapping) do |setting|
×
275
        current_value = Ops.get(
×
276
          Security.Settings,
×
277
          Ops.get_string(setting, "name", ""),
×
278
          ""
×
279
        )
×
280
        id = Ops.get_string(setting, "id", "")
×
281
        if type == :table
×
282
          ret_table = Builtins.add(
×
283
            ret_table,
×
284
            Item(
×
285
              Id(id),
×
286
              Ops.get(@label_mapping, id, ""),
×
287
              SecurityStatus(id, true),
×
288
              Ops.get_boolean(setting, "is_secure", false) ? "\u2714" : "\u2718"
×
289
            )
×
290
          )
×
291
        elsif type == :richtext
×
292
          # add one line for each security setting
293
          ret = Ops.add(
×
294
            ret,
×
295
            Builtins.sformat(
×
296
              "<TR><TD>%1&nbsp;&nbsp;&nbsp;&nbsp;</TD><TD ALIGN=center>%2</TD><TD ALIGN=center>&nbsp;&nbsp;&nbsp;%3</TD><TD>%4</TD></TR>",
×
297
              Ops.get(@label_mapping, id, ""),
×
298
              SecurityStatus(id, false),
×
299
              Ops.get_boolean(setting, "is_secure", false) ?
×
300
                "<SUP><FONT COLOR=green SIZE=20>\u2714</FONT></SUP>" :
×
301
                "<FONT COLOR=red SIZE=20><SUP>\u2718</SUP></FONT>",
×
302
              Builtins.haskey(@help_mapping, id) ?
×
303
                Builtins.sformat(
×
304
                  "<A HREF=\"help_%1\">%2</A>&nbsp;&nbsp;<BR>",
×
305
                  id,
×
306
                  _("Help")
×
307
                ) :
×
308
                ""
×
309
            )
×
310
          )
×
311
        end
×
312
      end 
×
313

314
      if type == :table
×
315
        Builtins.y2debug("Overview table: %1", ret_table)
×
316
        return deep_copy(ret_table)
×
317
      elsif type == :richtext
×
318
        # close the table
319
        ret = Ops.add(ret, "</TABLE>")
×
320

321
        Builtins.y2debug("Overview text: %1", ret)
×
322
        return ret
×
323
      end
×
324

325
      Builtins.y2error("Unknown type: %1", type)
×
326

327
      nil
×
328
    end
×
329

330
    def DisplayHelpPopup(help_id)
×
331
      help = Ops.get(@help_mapping, help_id, "")
×
332

333
      # add the warning if the option is unknown
334
      if SecurityStatus(help_id, true) == @UNKNOWN_STATUS
×
335
        help = Ops.add(help, Ops.get_string(@HELPS, "unknown_status", ""))
×
336
      end
×
337

338
      # add extra help to service related options
339
      if help_id == "MANDATORY_SERVICES"
×
340
        missing = Security.MissingMandatoryServices
×
341

342
        if missing != nil && missing != []
×
343
          srvs = ""
×
344

345
          Builtins.foreach(missing) do |l|
×
346
            # this is a separator between service names
347
            # e.g.: "postfix" + " or " + "sendmail"
348
            group = Builtins.mergestring(l, _(" or "))
×
349
            srvs = Ops.add(Ops.add(srvs, group), "<BR>")
×
350
          end
×
351

352
          # richtext message: %1 = runlevel ("3" or "5"), %2 = list of services
353
          help +=
×
354
            _("<P>These basic system services are not enabled:<BR><B>%s</B></P>") % srvs
×
355
        else
×
356
          help += _("<P>All basic services are enabled.</P>")
×
357
        end
×
358
      elsif help_id == "EXTRA_SERVICES"
×
359
        extra = Security.ExtraServices
×
360

361
        if extra != nil && extra != []
×
362
          srvs = Builtins.mergestring(extra, "<BR>")
×
363
          help +=
×
364
            _("<P>These extra services are enabled:<BR><B>%s</B></P>") % srvs
×
365
          help += _("<P>Check the list of services and disable all unused services.</P>")
×
366
        else
×
367
          help += _("<P>Only basic system services are enabled.</P>")
×
368
        end
×
369
      end
×
370

371
      if help != nil && help != ""
×
372
        Popup.LongText(
×
373
          Ops.get(@label_mapping, help_id, _("Description")),
×
374
          RichText(help),
×
375
          70,
×
376
          15
×
377
        )
×
378
      end
×
379

380
      nil
×
381
    end
×
382

383
    def OverviewDialog
×
384
      # Overview dialog caption
385
      caption = _("Security Overview")
×
386
      help = Ops.get_string(@HELPS, "overview", "")
×
387
      no_richtext = !Ops.get_boolean(
×
388
        UI.GetDisplayInfo,
×
389
        "RichTextSupportsTable",
×
390
        true
×
391
      )
×
392

393
      # table header
394
      tabheader = Header(
×
395
        _("Security Setting"),
×
396
        _("Status"),
×
397
        Center(_("Security Status"))
×
398
      )
×
399
      contents = no_richtext ?
×
400
        Table(Id(:table), Opt(:immediate), tabheader, OverviewText(:table)) :
×
401
        RichText(Id(:rtext), OverviewText(:richtext))
×
402

403
      if no_richtext
×
404
        # add a button box below the table
405
        contents = VBox(
×
406
          contents,
×
407
          VSpacing(1),
×
408
          HBox(
×
409
            # push button label
410
            PushButton(Id(:change), _("Change &Status")),
×
411
            HSpacing(2),
×
412
            # push button label
413
            PushButton(Id(:descr), _("&Description"))
×
414
          ),
×
415
          VSpacing(1)
×
416
        )
×
417
      end
×
418

419
      Wizard.SetContentsButtons(
×
420
        caption,
×
421
        contents,
×
422
        help,
×
423
        Label.BackButton,
×
424
        Label.OKButton
×
425
      )
×
426

427
      Wizard.HideBackButton
×
428
      Wizard.SetAbortButton(:abort, Label.CancelButton)
×
429

430
      # select the dialog in the tree navigation
431
      Wizard.SelectTreeItem("overview")
×
432

433
      ret = nil
×
434
      while true
×
435
        ret = UI.UserInput
×
436

437
        # abort?
438
        if ret == :abort || ret == :cancel
×
439
          if ReallyAbort()
×
440
            break
×
441
          else
×
442
            next
×
443
          end
×
444
        elsif ret == :back || ret == :next ||
×
445
            Builtins.contains(@tree_dialogs, ret)
×
446
          # the current item has been selected, do not change to the same dialog
447
          if ret == "overview"
×
448
            # preselect the item if it has been unselected
449
            if Wizard.QueryTreeItem != "overview"
×
450
              Wizard.SelectTreeItem("overview")
×
451
            end
×
452

453
            next
×
454
          end
×
455

456
          break
×
457
        # user clicked a link in the richtext
458
        elsif Ops.is_string?(ret) && Builtins.haskey(Security.Settings, ret) ||
×
459
            ret == :change
×
460
          if ret == :change
×
461
            # query the table in textmode
462
            ret = Convert.to_string(UI.QueryWidget(Id(:table), :CurrentItem))
×
463
          end
×
464

465
          Builtins.y2milestone("Clicked %1 link", ret)
×
466

467
          current_value = Ops.get(Security.Settings, Convert.to_string(ret), "")
×
468
          new_value = @link_value_mapping[current_value]
×
469

470
          # set the new value and refresh the overview
471
          if Builtins.haskey(@link_value_mapping, current_value) &&
×
472
              new_value != current_value
×
473
            Builtins.y2milestone("New value for %1: %2", ret, new_value)
×
474
            Ops.set(Security.Settings, Convert.to_string(ret), new_value)
×
475
            # the config has been changed
476
            Security.SetModified
×
477

478
            if no_richtext
×
479
              UI.ChangeWidget(Id(:table), :Items, OverviewText(:table))
×
480
              UI.ChangeWidget(Id(:table), :CurrentItem, ret)
×
481
              UI.SetFocus(Id(:table))
×
482
            else
×
483
              UI.ChangeWidget(Id(:rtext), :Value, OverviewText(:richtext))
×
484
            end
×
485
          elsif Builtins.haskey(@link_config_mapping, ret)
×
486
            new_dialog = Ops.get_string(@link_config_mapping, ret, "")
×
487

488
            Builtins.y2milestone("Switching to dialog %1", new_dialog)
×
489
            return new_dialog
×
490
          elsif Builtins.haskey(@link_client_mapping, ret)
×
491
            client = Ops.get_string(@link_client_mapping, ret, "")
×
492

493
            if client != ""
×
494
              Builtins.y2milestone("Calling Yast client %1", client)
×
495
              client_ret = WFM.CallFunction(client, [])
×
496
              Builtins.y2milestone("Client returned %1", client_ret)
×
497

498
              if client_ret == :next || client_ret == :ok ||
×
499
                  client_ret == :finish || client_ret == true
×
500
                # update the current value
501
                if @link_update_mapping.has_key?(ret)
×
502
                  Popup.Feedback(_("Analyzing system"), Message.takes_a_while) do
×
503
                    @link_update_mapping[ret].call
×
504
                  end
×
505
                end
×
506

507
                # update the overview
508
                if no_richtext
×
509
                  UI.ChangeWidget(Id(:table), :Items, OverviewText(:table))
×
510
                  UI.ChangeWidget(Id(:table), :CurrentItem, ret)
×
511
                  UI.SetFocus(Id(:table))
×
512
                else
×
513
                  UI.ChangeWidget(Id(:rtext), :Value, OverviewText(:richtext))
×
514
                end
×
515
              end
×
516
            end
×
517
          else
×
518
            Builtins.y2error("Unknown action for link %1", ret)
×
519
          end
×
520
        elsif Ops.is_string?(ret) &&
×
521
            Builtins.regexpmatch(Convert.to_string(ret), "^help_") ||
×
522
            ret == :descr
×
523
          help_id = no_richtext ?
×
524
            Convert.to_string(UI.QueryWidget(Id(:table), :CurrentItem)) :
×
525
            Builtins.regexpsub(Convert.to_string(ret), "^help_(.*)", "\\1")
×
526
          Builtins.y2milestone("Clicked help link: %1", help_id)
×
527

528
          DisplayHelpPopup(help_id)
×
529

530
          # switch the focus back to the table in text/GTK UI
531
          UI.SetFocus(Id(:table)) if no_richtext
×
532
        elsif ret == :table
×
533
          # disable "Change Status" button if the action is unknown
534
          current_item = Convert.to_string(
×
535
            UI.QueryWidget(Id(:table), :CurrentItem)
×
536
          )
×
537
          status = SecurityStatus(
×
538
            current_item, # plaintext
×
539
            true
×
540
          )
×
541

542
          UI.ChangeWidget(Id(:change), :Enabled, status != @UNKNOWN_STATUS)
×
543
        else
×
544
          Builtins.y2error("Unexpected return code: %1", ret)
×
545
          next
×
546
        end
×
547
      end
×
548

549
      deep_copy(ret)
×
550
    end
×
551

552
    def vbox_boot_permissions
×
553
      display_manager_widget = Empty()
×
554
      if @display_manager && !@display_manager.shutdown_var_name.empty?
×
555
        display_manager_widget = VBox(
×
556
          VSpacing(1.0),
×
557
          settings2widget(@display_manager.shutdown_var_name)
×
558
        )
×
559
      end
×
560

561
      VBox(
×
562
        VSpacing(1),
×
563
        settings2widget("CONSOLE_SHUTDOWN"),
×
564
        display_manager_widget,
×
565
        VSpacing(1.0),
×
566
        settings2widget("HIBERNATE_SYSTEM"),
×
567
        VSpacing(1)
×
568
      )
×
569
    end
×
570

571
    # Boot dialog
572
    # @return dialog result
573
    def BootDialog
×
574
      # Boot dialog caption
575
      caption = _("Boot Settings")
×
576
      help = Ops.get_string(@HELPS, "boot", "")
×
577

578
      # Boot dialog contents
579
      contents = HVCenter(
×
580
        HVSquash(
×
581
          HBox(
×
582
            HSpacing(5),
×
583
            VBox(
×
584
              VSpacing(2),
×
585
              # Frame label
586
              Frame(
×
587
                _("Boot Permissions"),
×
588
                HBox(
×
589
                  HSpacing(3),
×
590
                  vbox_boot_permissions,
×
591
                  HSpacing(3)
×
592
                )
×
593
              ),
×
594
              VSpacing(2)
×
595
            ),
×
596
            HSpacing(5)
×
597
          )
×
598
        )
×
599
      )
×
600

601
      Wizard.SetContentsButtons(
×
602
        caption,
×
603
        contents,
×
604
        help,
×
605
        Label.BackButton,
×
606
        Label.OKButton
×
607
      )
×
608

609
      Wizard.HideBackButton
×
610
      Wizard.SetAbortButton(:abort, Label.CancelButton)
×
611

612
      # select the dialog in the tree navigation
613
      Wizard.SelectTreeItem("boot")
×
614

615
      ret = nil
×
616
      while true
×
617
        ret = UI.UserInput
×
618

619
        # abort?
620
        if ret == :abort || ret == :cancel
×
621
          if ReallyAbort()
×
622
            break
×
623
          else
×
624
            next
×
625
          end
×
626
        elsif ret == :back || ret == :next ||
×
627
            Builtins.contains(@tree_dialogs, ret)
×
628
          # the current item has been selected, do not change to the same dialog
629
          if ret == "boot"
×
630
            # preselect the item if it has been unselected
631
            Wizard.SelectTreeItem("boot") if Wizard.QueryTreeItem != "boot"
×
632

633
            next
×
634
          end
×
635

636
          break
×
637
        else
×
638
          Builtins.y2error("Unexpected return code: %1", ret)
×
639
          next
×
640
        end
×
641
      end
×
642

643
      if ret == :next || Builtins.contains(@tree_dialogs, ret)
×
644
        widget2settings("CONSOLE_SHUTDOWN")
×
645
        if @display_manager && !@display_manager.shutdown_var_name.empty?
×
646
          widget2settings(@display_manager.shutdown_var_name)
×
647
        end
×
648
        widget2settings("HIBERNATE_SYSTEM")
×
649
      end
×
650

651
      deep_copy(ret)
×
652
    end
×
653

654
    # Misc dialog
655
    # @return dialog result
656
    def MiscDialog
×
657
      # Misc dialog caption
658
      caption = _("Miscellaneous Settings")
×
659
      help = Ops.get_string(@HELPS, "misc", "")
×
660

661
      # Misc dialog contents
662
      contents = VBox(
×
663
        VSeparator(),
×
664
        settings2widget("PERMISSION_SECURITY"),
×
665
        VSpacing(1.0),
×
666
        settings2widget("RUN_UPDATEDB_AS"),
×
667
        VSpacing(1.0),
×
668
        settings2widget("kernel.sysrq"),
×
669
        VSpacing(1.8)
×
670
      )
×
671
      contents = HVCenter(
×
672
        HVSquash(
×
673
          HBox(
×
674
            HSpacing(5),
×
675
            VBox(VSpacing(2), ReplacePoint(Id(:rp_main), contents), VSpacing(2)),
×
676
            HSpacing(5)
×
677
          )
×
678
        )
×
679
      )
×
680

681
      Wizard.SetContentsButtons(
×
682
        caption,
×
683
        contents,
×
684
        help,
×
685
        Label.BackButton,
×
686
        Label.OKButton
×
687
      )
×
688

689
      Wizard.HideBackButton
×
690
      Wizard.SetAbortButton(:abort, Label.CancelButton)
×
691

692
      # select the dialog in the tree navigation
693
      Wizard.SelectTreeItem("misc")
×
694

695
      ret = nil
×
696
      while true
×
697
        ret = UI.UserInput
×
698

699
        # abort?
700
        if ret == :abort || ret == :cancel
×
701
          if ReallyAbort()
×
702
            break
×
703
          else
×
704
            next
×
705
          end
×
706
        elsif ret == :back
×
707
          break
×
708
        elsif ret == :next || Builtins.contains(@tree_dialogs, ret)
×
709
          # the current item has been selected, do not change to the same dialog
710
          if ret == "misc"
×
711
            # preselect the item if it has been unselected
712
            Wizard.SelectTreeItem("misc") if Wizard.QueryTreeItem != "misc"
×
713

714
            next
×
715
          end
×
716

717
          # check_*
718
          break
×
719
        else
×
720
          Builtins.y2error("Unexpected return code: %1", ret)
×
721
          next
×
722
        end
×
723
      end
×
724

725
      if ret == :next || Builtins.contains(@tree_dialogs, ret)
×
726
        widget2settings("PERMISSION_SECURITY")
×
727
        widget2settings("RUN_UPDATEDB_AS")
×
728
        widget2settings("kernel.sysrq")
×
729
      end
×
730

731
      deep_copy(ret)
×
732
    end
×
733

734
    # Password dialog
735
    # @return dialog result
736
    def PassDialog
×
737
      # Password dialog caption
738
      caption = _("Password Settings")
×
739
      help = Ops.get_string(@HELPS, "password", "")
×
740

741
      # Password dialog contents
742
      contents = VBox(
×
743
        # Frame label
744
        XFrame(
×
745
          0.3,
×
746
          0.15,
×
747
          _("Checks"),
×
748
          VBox(
×
749
            settings2widget("PASSWD_USE_PWQUALITY"),
×
750
            VSeparator(),
×
751
            settings2widget("PASS_MIN_LEN"),
×
752
            VSeparator(),
×
753
            settings2widget("PASSWD_REMEMBER_HISTORY"),
×
754
            VSeparator()
×
755
          )
×
756
        ),
×
757
        VSpacing(0.4),
×
758
        settings2widget("PASSWD_ENCRYPTION"),
×
759
        VSpacing(0.4),
×
760
        # Frame label
761
        Frame(
×
762
          _("Password Age"),
×
763
          HBox(
×
764
            HSpacing(0.4),
×
765
            settings2widget("PASS_MIN_DAYS"),
×
766
            HSpacing(0.4),
×
767
            settings2widget("PASS_MAX_DAYS"),
×
768
            HSpacing(0.4)
×
769
          )
×
770
        ),
×
771
        VSpacing(0.15),
×
772
        settings2widget("PASS_WARN_AGE"),
×
773
        VSpacing(0.0)
×
774
      )
×
775
      contents = HVCenter(
×
776
        HVSquash(
×
777
          HBox(
×
778
            HSpacing(5),
×
779
            VBox(VSpacing(2), ReplacePoint(Id(:rp_main), contents), VSpacing(2)),
×
780
            HSpacing(5)
×
781
          )
×
782
        )
×
783
      )
×
784

785
      Wizard.SetContentsButtons(
×
786
        caption,
×
787
        contents,
×
788
        help,
×
789
        Label.BackButton,
×
790
        Label.OKButton
×
791
      )
×
792

793
      Wizard.HideBackButton
×
794
      Wizard.SetAbortButton(:abort, Label.CancelButton)
×
795

796
      # select the dialog in the tree navigation
797
      Wizard.SelectTreeItem("password")
×
798

799
      UI.ChangeWidget(
×
800
        Id("PASS_MIN_LEN"),
×
801
        :Enabled,
×
802
        Ops.get(Security.Settings, "PASSWD_USE_PWQUALITY", "") == "yes"
×
803
      )
×
804

805
      ret = nil
×
806
      while true
×
807
        ret = UI.UserInput
×
808

809
        # abort?
810
        if ret == :abort || ret == :cancel
×
811
          if ReallyAbort()
×
812
            break
×
813
          else
×
814
            next
×
815
          end
×
816
        elsif ret == :back
×
817
          break
×
818
        elsif ret == "PASSWD_USE_PWQUALITY"
×
819
          # minlen is an option for pam_pwquality
820
          UI.ChangeWidget(
×
821
            Id("PASS_MIN_LEN"),
×
822
            :Enabled,
×
823
            UI.QueryWidget(Id(ret), :Value) == true
×
824
          )
×
825
        elsif ret == :next || Builtins.contains(@tree_dialogs, ret)
×
826
          # the current item has been selected, do not change to the same dialog
827
          if ret == "password"
×
828
            # preselect the item if it has been unselected
829
            if Wizard.QueryTreeItem != "password"
×
830
              Wizard.SelectTreeItem("password")
×
831
            end
×
832

833
            next
×
834
          end
×
835

836
          # check_*
837
          if checkMinMax("PASS_MIN_DAYS", "PASS_MAX_DAYS") != true
×
838
            # Popup text
839
            Popup.Error(
×
840
              _(
×
841
                "The minimum number of days cannot be larger\nthan the maximum."
×
842
              )
×
843
            )
×
844
            next
×
845
          end
×
846
          enc = Convert.to_string(
×
847
            UI.QueryWidget(Id("PASSWD_ENCRYPTION"), :Value)
×
848
          )
×
849
          min = Convert.to_integer(UI.QueryWidget(Id("PASS_MIN_LEN"), :Value))
×
850
          if Ops.greater_than(
×
851
              min,
×
852
              Ops.get_integer(Security.PasswordMaxLengths, enc, 8)
×
853
            )
×
854
            # Popup text, %1 is number
855
            Popup.Error(
×
856
              Builtins.sformat(
×
857
                _(
×
858
                  "The minimum password length cannot be larger than the maximum.\nThe maximum password length for the selected encryption method is %1."
×
859
                ),
×
860
                Ops.get_integer(Security.PasswordMaxLengths, enc, 8)
×
861
              )
×
862
            )
×
863
            next
×
864
          end
×
865
          break
×
866
        elsif ret != "PASSWD_ENCRYPTION"
×
867
          Builtins.y2error("Unexpected return code: %1", ret)
×
868
          next
×
869
        end
×
870
      end
×
871

872
      if ret == :next || Builtins.contains(@tree_dialogs, ret)
×
873
        widget2settings("PASS_MIN_DAYS")
×
874
        widget2settings("PASS_MAX_DAYS")
×
875
        widget2settings("PASS_MIN_LEN")
×
876
        widget2settings("PASSWD_USE_PWQUALITY")
×
877
        widget2settings("PASS_WARN_AGE")
×
878
        widget2settings("PASSWD_ENCRYPTION")
×
879
        widget2settings("PASSWD_REMEMBER_HISTORY")
×
880
      end
×
881

882
      deep_copy(ret)
×
883
    end
×
884

885
    # Login dialog
886
    # @return dialog result
887
    def LoginDialog
×
888
      # Login dialog caption
889
      caption = _("Login Settings")
×
890
      help = Ops.get_string(@HELPS, "login", "")
×
891

892
      # Login dialog contents
893
      contents = VBox(
×
894
        # Frame label
895
        XFrame(
×
896
          3.0,
×
897
          1.0,
×
898
          _("Login"),
×
899
          VBox(
×
900
            #VSeparator(),
901
            settings2widget("FAIL_DELAY"), #VSeparator()
×
902
            #VSeparator(),
903
            VSpacing(0.5),
×
904
            VSeparator(),
×
905
            settings2widget("DISPLAYMANAGER_REMOTE_ACCESS")
×
906
          )
×
907
        ) #,`VSpacing(1.7)
×
908
      )
×
909
      contents = HVCenter(
×
910
        HVSquash(
×
911
          HBox(
×
912
            HSpacing(5),
×
913
            VBox(VSpacing(2), ReplacePoint(Id(:rp_main), contents), VSpacing(2)),
×
914
            HSpacing(5)
×
915
          )
×
916
        )
×
917
      )
×
918

919
      Wizard.SetContentsButtons(
×
920
        caption,
×
921
        contents,
×
922
        help,
×
923
        Label.BackButton,
×
924
        Label.OKButton
×
925
      )
×
926

927
      Wizard.HideBackButton
×
928
      Wizard.SetAbortButton(:abort, Label.CancelButton)
×
929

930
      # select the dialog in the tree navigation
931
      Wizard.SelectTreeItem("login")
×
932

933
      ret = nil
×
934
      while true
×
935
        ret = UI.UserInput
×
936

937
        # abort?
938
        if ret == :abort || ret == :cancel
×
939
          if ReallyAbort()
×
940
            break
×
941
          else
×
942
            next
×
943
          end
×
944
        elsif ret == :back
×
945
          break
×
946
        elsif ret == :next || Builtins.contains(@tree_dialogs, ret)
×
947
          # the current item has been selected, do not change to the same dialog
948
          if ret == "login"
×
949
            # preselect the item if it has been unselected
950
            Wizard.SelectTreeItem("login") if Wizard.QueryTreeItem != "login"
×
951

952
            next
×
953
          end
×
954

955
          # check_*
956
          break
×
957
        else
×
958
          Builtins.y2error("Unexpected return code: %1", ret)
×
959
          next
×
960
        end
×
961
      end
×
962

963
      if ret == :next || Builtins.contains(@tree_dialogs, ret)
×
964
        widget2settings("FAIL_DELAY")
×
965
        widget2settings("DISPLAYMANAGER_REMOTE_ACCESS")
×
966
      end
×
967

968
      deep_copy(ret)
×
969
    end
×
970
  end
×
971
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