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

yast / yast-security / 10885841068

16 Sep 2024 02:23PM UTC coverage: 39.551%. Remained the same
10885841068

push

github

lslezak
Bump version to 4.7.0

1374 of 3474 relevant lines covered (39.55%)

5.82 hits per line

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

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

33
      textdomain "security"
×
34

35
      Yast.import "Label"
×
36
      Yast.import "Security"
×
37
      Yast.import "Wizard"
×
38

39
      Yast.include include_target, "security/helps.rb"
×
40
      Yast.include include_target, "security/levels.rb"
×
41
      Yast.include include_target, "security/routines.rb"
×
42
      Yast.include include_target, "security/dialogs.rb"
×
43
    end
×
44

45
    # Write settings dialog
46
    # @return `next if success, else `abort
47
    def WriteDialog
×
48
      Wizard.RestoreHelp(Ops.get_string(@HELPS, "write", ""))
×
49
      Security.AbortFunction = lambda { Security.PollAbort }
×
50
      ret = Security.Write
×
51
      ret ? :next : :abort
×
52
    end
×
53

54
    # Main dialog
55
    # @return dialog result
56
    def MainDialog
×
57
      # Main dialog caption
58
      caption = _("Local Security Configuration")
×
59
      help = Ops.get_string(@HELPS, "main", "")
×
60

61
      settings = deep_copy(Security.Settings)
×
62
      Builtins.foreach(Security.do_not_test) do |key|
×
63
        settings = Builtins.remove(settings, key)
×
64
      end
×
65

66
      # Determine current settings
67
      current = :custom
×
68
      Builtins.maplist(@Levels) do |key, level|
×
69
        Builtins.y2debug("%1=%2", key, level)
×
70
        current = key if level == settings
×
71
      end
×
72
      Builtins.y2debug("%1=%2", current, Security.Settings)
×
73

74
      # Create RB group from the list of settings
75
      _RB = VBox()
×
76
      _RB = Builtins.add(_RB, VSpacing(0.5))
×
77
      Builtins.mapmap(@LevelsLabels) do |key, name|
×
78
        _RB = Builtins.add(
×
79
          _RB,
×
80
          Left(RadioButton(Id(key), Opt(:notify), name, key == current))
×
81
        )
×
82
        _RB = Builtins.add(_RB, VSpacing(0.03))
×
83
        { 0 => 0 }
×
84
      end
×
85
      _RB = Builtins.add(_RB, VSpacing(0.6))
×
86
      # RadioButton label
87
      _RB = Builtins.add(
×
88
        _RB,
×
89
        Left(
×
90
          RadioButton(
×
91
            Id(:custom),
×
92
            Opt(:notify),
×
93
            _("&Custom Settings"),
×
94
            current == :custom
×
95
          )
×
96
        )
×
97
      )
×
98
      _RB = Builtins.add(_RB, VSpacing(0.5))
×
99
      Builtins.y2debug("RB=%1", _RB)
×
100

101
      # Main dialog contents
102
      contents = HVCenter(
×
103
        VBox(
×
104
          HVSquash(
×
105
            # Frame caption
106
            Frame(
×
107
              _("Security Settings"),
×
108
              HBox(HSpacing(0.8), RadioButtonGroup(Id(:rb), _RB), HSpacing(0.8))
×
109
            )
×
110
          ),
×
111
          VSpacing(0.6)
×
112
        )
×
113
      )
×
114

115
      contents = HVCenter(
×
116
        HVSquash(
×
117
          HBox(
×
118
            HSpacing(5),
×
119
            VBox(VSpacing(2), ReplacePoint(Id(:rp_main), contents), VSpacing(2)),
×
120
            HSpacing(5)
×
121
          )
×
122
        )
×
123
      )
×
124
      Wizard.SetContentsButtons(
×
125
        caption,
×
126
        contents,
×
127
        help,
×
128
        Label.BackButton,
×
129
        Label.OKButton
×
130
      )
×
131

132
      Wizard.HideBackButton
×
133
      Wizard.SetAbortButton(:abort, Label.CancelButton)
×
134

135
      ret = nil
×
136
      while true
×
137
        cur = UI.QueryWidget(Id(:rb), :CurrentButton)
×
138
        ret = UI.UserInput
×
139

140
        # abort?
141
        if ret == :abort || ret == :cancel
×
142
          if ReallyAbort()
×
143
            break
×
144
          else
×
145
            next
×
146
          end
×
147
        elsif ret == :back
×
148
          break
×
149
        elsif ret == :next
×
150
          # check_*
151
          break
×
152
        elsif ret == :custom
×
153
          next
×
154
        elsif Ops.is_string?(ret) || ret == :wizardTree
×
155
          if Builtins.contains(@tree_dialogs, ret)
×
156
            # the current item has been selected, do not change to the same dialog
157
            if ret == "main"
×
158
              # preselect the item if it has been unselected
159
              Wizard.SelectTreeItem("main") if Wizard.QueryTreeItem != "main"
×
160

161
              next
×
162
            end
×
163

164
            # switch to another dialog
165
            break
×
166
          end
×
167
          if !Builtins.haskey(@Levels, Convert.to_string(ret))
×
168
            Builtins.y2error("Unexpected return code (key missing): %1", ret)
×
169
            next
×
170
          end
×
171
          next
×
172
        else
×
173
          Builtins.y2error("Unexpected return code: %1", ret)
×
174
          next
×
175
        end
×
176
      end
×
177

178
      if ret == :next || Builtins.contains(@tree_dialogs, ret)
×
179
        cur = UI.QueryWidget(Id(:rb), :CurrentButton)
×
180

181
        Builtins.y2debug("current=%1", current)
×
182
        Builtins.y2debug("cur=%1", cur)
×
183

184
        if cur != :custom
×
185
          if current != cur
×
186
            Builtins.y2debug("Level modified (%1)", cur)
×
187
            Security.Settings = Ops.get(@Levels, Convert.to_string(cur), {})
×
188
            Security.modified = true
×
189
          end
×
190
          ret = :finish if ret == :next
×
191
        end
×
192
      end
×
193

194
      deep_copy(ret)
×
195
    end
×
196
  end
×
197
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