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

yast / yast-security / 7348696296

28 Dec 2023 02:47PM UTC coverage: 39.237% (-0.4%) from 39.615%
7348696296

push

github

jreidinger
rubocop: enable Layout/LineLength - manual fixes

3 of 111 new or added lines in 3 files covered. (2.7%)

418 existing lines in 13 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/complex.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/complex.ycp
21
# Package:        Security configuration
22
# Summary:        Complex dialogs definitions
23
# Authors:        Michal Svec <msvec@suse.cz>
24
#
25
# $Id$
UNCOV
26
module Yast
×
UNCOV
27
  module SecurityComplexInclude
×
28
    def initialize_security_complex(include_target)
×
29
      Yast.import "UI"
×
30

31
      textdomain "security"
×
32

33
      Yast.import "Label"
×
UNCOV
34
      Yast.import "Security"
×
35
      Yast.import "Wizard"
×
36

37
      Yast.include include_target, "security/helps.rb"
×
UNCOV
38
      Yast.include include_target, "security/levels.rb"
×
39
      Yast.include include_target, "security/routines.rb"
×
40
      Yast.include include_target, "security/dialogs.rb"
×
41
    end
×
42

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

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

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

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

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

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

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

130
      Wizard.HideBackButton
×
UNCOV
131
      Wizard.SetAbortButton(:abort, Label.CancelButton)
×
132

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

138
        # abort?
UNCOV
139
        if [:abort, :cancel].include?(ret)
×
UNCOV
140
          ReallyAbort() ? break : next
×
141
        elsif [:back, :next].include?(ret)
×
142
          break
×
143
        elsif ret == :custom
×
144
          next
×
145
        elsif Ops.is_string?(ret) || ret == :wizardTree
×
146
          if Builtins.contains(@tree_dialogs, ret)
×
147
            # the current item has been selected, do not change to the same dialog
148
            if ret == "main"
×
149
              # preselect the item if it has been unselected
150
              Wizard.SelectTreeItem("main") if Wizard.QueryTreeItem != "main"
×
151

152
              next
×
UNCOV
153
            end
×
154

155
            # switch to another dialog
156
            break
×
UNCOV
157
          end
×
158
          if !Builtins.haskey(@Levels, Convert.to_string(ret))
×
159
            Builtins.y2error("Unexpected return code (key missing): %1", ret)
×
UNCOV
160
            next
×
UNCOV
161
          end
×
162
          next
×
163
        else
×
164
          Builtins.y2error("Unexpected return code: %1", ret)
×
165
          next
×
166
        end
×
167
      end
×
168

169
      if ret == :next || Builtins.contains(@tree_dialogs, ret)
×
170
        cur = UI.QueryWidget(Id(:rb), :CurrentButton)
×
171

172
        Builtins.y2debug("current=%1", current)
×
173
        Builtins.y2debug("cur=%1", cur)
×
174

175
        if cur != :custom
×
176
          if current != cur
×
UNCOV
177
            Builtins.y2debug("Level modified (%1)", cur)
×
178
            Security.Settings = Ops.get(@Levels, Convert.to_string(cur), {})
×
179
            Security.modified = true
×
UNCOV
180
          end
×
181
          ret = :finish if ret == :next
×
182
        end
×
183
      end
×
184

185
      deep_copy(ret)
×
186
    end
×
187
  end
×
188
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