Skip to content

Commit

Permalink
fixed some changes proposed by jreidinger
Browse files Browse the repository at this point in the history
  • Loading branch information
vpereira committed Oct 5, 2016
1 parent a5ce056 commit e7a1a07
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 38 deletions.
9 changes: 2 additions & 7 deletions src/clients/security.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,8 @@ def SecurityLevelHandler(options)
options = deep_copy(options)
current = :custom

levels = @Levels.select { |_key, level| level == Security.Settings }
current = @Levels.select{ |_key, level| level == Security.Settings }.keys.last || :custom

current = if levels.empty?
:custom
else
levels.last # mimic the old implementation
end

lvl = if options.key?("workstation")
"Level1"
Expand Down Expand Up @@ -231,7 +226,7 @@ def SecuritySetHandler(options)
if options.key?("remember") &&
Security.Settings["PASSWD_REMEMBER_HISTORY"] != options["remember"]
if options["remember"].to_i.between?(0, 400)
Security.Settings["PASSWD_REMEMBER_HISTORY"] = options["remember"].to_i
Security.Settings["PASSWD_REMEMBER_HISTORY"] = options["remember"] # as string not int
Security.modified = true
else
Report.Error(
Expand Down
21 changes: 4 additions & 17 deletions src/clients/security_auto.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def main
# Check arguments
if !Yast::WFM.Args.empty?
@func = Yast::WFM.Args[0]
if Yast::WFM.Args.length > 1 && Yast::WFM.Args[1].is_a?(Hash)
if Yast::WFM.Args[1].is_a?(Hash)
@param = WFM.Args[1]
end
end
Expand Down Expand Up @@ -88,23 +88,13 @@ def main
Ops.get_string(@param, "encryption", "des")
)
end
@ret = Security.Import(
Map.KeysToUpper(
Convert.convert(@param, from: "map", to: "map <string, any>")
)
)
@ret = Security.Import(Map.KeysToUpper(@param))
# Return required packages
when "Packages"
@ret = {}
# Return actual state
when "Export"
@ret = Map.KeysToLower(
Convert.convert(
Security.Export,
from: "map",
to: "map <string, any>"
)
)
@ret = Security.Import(Map.KeysToUpper(Security.Export))
# Read current state
when "Read"
Yast.import "Progress"
Expand All @@ -130,10 +120,7 @@ def main
Builtins.y2debug("ret=%1", @ret)
Builtins.y2milestone("Security auto finished")
Builtins.y2milestone("----------------------------------------")

# is it needed?
deep_copy(@ret)
# EOF
@ret
end
end
end
Expand Down
7 changes: 3 additions & 4 deletions src/include/security/dialogs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def DisplayHelpPopup(help_id)
if help_id == "MANDATORY_SERVICES"
missing = Security.MissingMandatoryServices

if !missing.nil? && missing != []
if missing && !missing.empty?
srvs = ""

Builtins.foreach(missing) do |l|
Expand All @@ -370,8 +370,7 @@ def DisplayHelpPopup(help_id)
end
elsif help_id == "EXTRA_SERVICES"
extra = Security.ExtraServices

if !extra.nil? && extra != []
if extra && !extra.empty?
srvs = Builtins.mergestring(extra, "<BR>")
help +=
_("<P>These extra services are enabled:<BR><B>%s</B></P>") % srvs
Expand All @@ -381,7 +380,7 @@ def DisplayHelpPopup(help_id)
end
end

if !help.nil? && help != ""
if help && !help.empty?
Popup.LongText(
Ops.get(@label_mapping, help_id, _("Description")),
RichText(help),
Expand Down
10 changes: 3 additions & 7 deletions src/include/security/routines.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def settings2widget(_ID)
# "Widget" == "IntField"
if widget == "IntField"
intval = Builtins.tointeger(value)
intval = 0 if intval.nil?
intval ||= 0
return VBox(
Left(IntField(Id(_ID), label, minval, maxval, intval)),
VSeparator()
Expand All @@ -112,7 +112,7 @@ def settings2widget(_ID)
# string|list it
Builtins.y2debug("li=%1 (%2)", li, i)
it = Ops.get(li, i)
it = "" if it.nil?
it ||= ""
Builtins.y2debug("it=%1", it)
id_t = ""
id_s = ""
Expand Down Expand Up @@ -158,11 +158,7 @@ def widget2settings(_ID)
ret = UI.QueryWidget(Id(_ID), :Value)
new = ""
if Ops.is_boolean?(ret)
new = if ret == true
"yes"
else
"no"
end
new = ret ? "yes" : "no"
elsif Ops.is_integer?(ret)
new = Builtins.sformat("%1", ret)
elsif Ops.is_string?(ret)
Expand Down
7 changes: 4 additions & 3 deletions src/modules/Security.rb
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def PollAbort
# Abort function
# @return false
def Abort
return Builtins.eval(@AbortFunction) == true if !@AbortFunction.nil?
return Builtins.eval(@AbortFunction) == true if @AbortFunction
false
end

Expand Down Expand Up @@ -733,13 +733,14 @@ def Import(settings)
# (For use by autoinstallation.)
# @return [Hash] Dumped settings (later acceptable by Import ())
def Export
@Settings if @Settings.is_a?(Hash)
deep_copy(@Settings)
end

# Create a textual summary and a list of unconfigured cards
# @return summary of the current configuration
def Summary
settings = deep_copy(@Settings)
# settings -= @do_not_test
@do_not_test.each { |k| settings.delete k }

# Determine current settings
Expand All @@ -755,7 +756,7 @@ def Summary
summary = _("Current Security Level: Custom settings")
if current != :custom
# Summary text
summary = _("Current Security Level: #{@LevelsNames[current]}")
summary = _("Current Security Level: %s") % @LevelsNames[current]
end
[summary, []]
end
Expand Down

0 comments on commit e7a1a07

Please sign in to comment.