Module: check_mk
Branch: master
Commit: e1f63b6c9bd5151e674f175f12f0bea40e87c9ff
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e1f63b6c9bd515…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Sep 30 10:58:46 2016 +0200
3914 FIX Roles: Aliases are now unique during cloning
---
.bugs/2494 | 7 +++++--
.werks/3914 | 9 +++++++++
ChangeLog | 3 +++
web/htdocs/wato.py | 21 +++++++++++++++++++--
4 files changed, 36 insertions(+), 4 deletions(-)
diff --git a/.bugs/2494 b/.bugs/2494
index 01bf7fe..95ffe4c 100644
--- a/.bugs/2494
+++ b/.bugs/2494
@@ -1,9 +1,12 @@
Title: Cloning of roles creates roles with an existing non-unique alias
Component: wato
-State: open
+Class: bug
+State: done
Date: 2016-05-19 14:53:37
Targetversion: 1.2.8
-Class: bug
This prevents you from saving the properties. And creates in invalid state.
Rather create an artificial Alias like "Clone of role Administrator" or the
like.
+
+2016-09-30 01:50:51: changed state open -> done
+Fied
diff --git a/.werks/3914 b/.werks/3914
new file mode 100644
index 0000000..2058626
--- /dev/null
+++ b/.werks/3914
@@ -0,0 +1,9 @@
+Title: Roles: Aliases are now unique during cloning
+Level: 1
+Component: wato
+Compatible: compat
+Version: 1.4.0i2
+Date: 1475225899
+Class: fix
+
+
diff --git a/ChangeLog b/ChangeLog
index 4ce978d..003d92a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,9 @@
Checks & Agents:
* 3894 FIX: mkeventd_status: Fixed bug in case Event Console is not running
+ WATO:
+ * 3914 FIX: Roles: Aliases are now unique during cloning
+
1.4.0i1:
Core & Setup:
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 614aaab..62a2371 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -10711,6 +10711,10 @@ def mode_roles(phase):
if phase == "action":
if html.var("_delete"):
delid = html.var("_delete")
+
+ if delid not in roles:
+ raise MKUserError(None, _("This role does not exist."))
+
if html.transaction_valid() and roles[delid].get('builtin'):
raise MKUserError(None, _("You cannot delete the builtin
roles!"))
@@ -10727,15 +10731,28 @@ def mode_roles(phase):
elif html.var("_clone"):
if html.check_transaction():
cloneid = html.var("_clone")
- cloned_role = roles[cloneid]
+
+ try:
+ cloned_role = roles[cloneid]
+ except KeyError:
+ raise MKUserError(None, _("This role does not exist."))
+
newid = cloneid
while newid in roles:
newid += "x"
+
new_role = {}
new_role.update(cloned_role)
+
+ new_alias = new_role["alias"]
+ while not is_alias_used("roles", newid, new_alias)[0]:
+ new_alias += _(" (copy)")
+ new_role["alias"] = new_alias
+
if cloned_role.get("builtin"):
- new_role["builtin"] = False
+ new_role["builtin"] = False
new_role["basedon"] = cloneid
+
roles[newid] = new_role
save_roles(roles)
update_login_sites_replication_status()