summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2011-07-27 10:25:48 -0400
committerRob Crittenden <rcritten@redhat.com>2011-07-27 00:02:28 -0400
commit62445b8673288212ab3cdc1f5b6d1d81457831ac (patch)
tree3113c0c3c0af7e5dcf61ce733b3b79bd6d497e16 /ipalib
parenta2641254fecae7097cb64da32647199f0155b631 (diff)
downloadfreeipa-62445b8673288212ab3cdc1f5b6d1d81457831ac.zip
freeipa-62445b8673288212ab3cdc1f5b6d1d81457831ac.tar.gz
freeipa-62445b8673288212ab3cdc1f5b6d1d81457831ac.tar.xz
Don't leave dangling map if adding an indirect map fails
When using the add_indirect helper we create a new map and then add a key for it all in one step. If adding the key fails for any reason be sure to remove the map we added. https://fedorahosted.org/freeipa/ticket/1520
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/plugins/automount.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/ipalib/plugins/automount.py b/ipalib/plugins/automount.py
index 1879c56..d05e0cf 100644
--- a/ipalib/plugins/automount.py
+++ b/ipalib/plugins/automount.py
@@ -791,11 +791,16 @@ class automountmap_add_indirect(LDAPCreate):
def execute(self, *keys, **options):
result = self.api.Command['automountmap_add'](*keys, **options)
- options['automountinformation'] = keys[1]
- self.api.Command['automountkey_add'](
- keys[0], options['parentmap'],
- automountkey=options['key'], **options
- )
+ try:
+ options['automountinformation'] = keys[1]
+ self.api.Command['automountkey_add'](
+ keys[0], options['parentmap'],
+ automountkey=options['key'], **options
+ )
+ except Exception, e:
+ # The key exists, drop the map
+ self.api.Command['automountmap_del'](*keys, **options)
+ raise e
return result
api.register(automountmap_add_indirect)