Skip to content

Commit

Permalink
Merge pull request #16 from belphegor-belbel/master
Browse files Browse the repository at this point in the history
Fix 'Toggle Mode' bug for non-English locale
  • Loading branch information
jreidinger committed Jul 24, 2017
2 parents 1fff9ed + 73e0a76 commit 61e2a3c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 27 deletions.
5 changes: 5 additions & 0 deletions package/yast2-apparmor.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
-------------------------------------------------------------------
Mon Jul 24 01:26:27 UTC 2017 - belphegor@belbel.or.jp

- fix 'Toggle Mode' bug for non-English locale (bsc#1043546)

-------------------------------------------------------------------
Fri Jun 30 12:44:14 UTC 2017 - jreidinger@suse.com

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-apparmor.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2-apparmor
Version: 3.2.1
Version: 3.3.0
Release: 0
Summary: YaST2 - Plugins for AppArmor Profile Management
Url: https://github.com/yast/yast-apparmor
Expand Down
55 changes: 29 additions & 26 deletions src/include/apparmor/config_complain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def updateComplain(id, profile, mode, showAll)
nil
end

def getRecordList(showAll)
def updateRecordList(showAll)
_Settings = {}
Ops.set(_Settings, "list", "1")

Expand All @@ -99,7 +99,7 @@ def getRecordList(showAll)
Ops.set(_Settings, "showall", "0")
end

recList = []
@recList = []
key = 1

# restarts ag_complain agent if necessary
Expand All @@ -112,25 +112,18 @@ def getRecordList(showAll)
)
end

translation_mapping = {
# translators: string is value in table for mode of apparmor
"enforce" => _("enforce"),
"complain" => _("complain"),
}

Builtins.foreach(db) do |record|
recList = Builtins.add(
recList,
Item(Id(key), Ops.get(record, "name"), translation_mapping[record["mode"]])
@recList = Builtins.add(
@recList,
Item(Id(key), Ops.get(record, "name"), record["mode"])
)
key = Ops.add(key, 1)
end

deep_copy(recList)
nil
end

def getProfModeForm(recList, showAll)
recList = deep_copy(recList)
def getProfModeForm(showAll)
allBtn = PushButton(Id(:showAll), _("Show All Profiles"))
allText = _("Configure Mode for Active Profiles")

Expand All @@ -139,6 +132,17 @@ def getProfModeForm(recList, showAll)
allText = _("Configure Mode for All Profiles")
end

translation_mapping = {
# translators: string is value in table for mode of apparmor
"enforce" => _("enforce"),
"complain" => _("complain"),
}

recListTranslated = (@recList || []).map do |record|
Item(record.params[0], record.params[1],
translation_mapping[record.params[2]] || record.params[2])
end

modeForm = Frame(
Id(:changeMode),
allText,
Expand All @@ -151,7 +155,7 @@ def getProfModeForm(recList, showAll)
Id(:table),
Opt(:notify),
Header(_("Profile Name"), _("Mode")),
recList
recListTranslated
)
),
VSpacing(0.5),
Expand All @@ -168,16 +172,16 @@ def getProfModeForm(recList, showAll)
end

def updateModeConfigForm(showAll)
recList = getRecordList(showAll)
newModeForm = getProfModeForm(recList, showAll)
updateRecordList(showAll)
newModeForm = getProfModeForm(showAll)

deep_copy(newModeForm)
end

# Profile Mode Configuration -- Sets Complain and Enforce Behavior
def profileModeConfigForm
recList = getRecordList(@showAll)
modeForm = getProfModeForm(recList, @showAll)
updateRecordList(@showAll)
modeForm = getProfModeForm(@showAll)
Wizard.CreateDialog
Wizard.SetContentsButtons(
_("Profile Mode Configuration"),
Expand Down Expand Up @@ -256,13 +260,12 @@ def profileModeConfigForm
1,
""
)
mode = Ops.get_string(
Convert.to_term(
UI.QueryWidget(Id(:table), term(:Item, itemselected))
),
2,
""
)
mode = ""
Builtins.foreach(@recList) do |record|
if record.params[1] == profile
mode = record.params[2]
end
end

updateComplain(id, profile, mode, @showAll)
modified = true
Expand Down

0 comments on commit 61e2a3c

Please sign in to comment.