mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-28 01:41:14 -06:00
ipa-adtrust-install does not re-add member in adtrust agents group
When a CIFS service exists and adtrust agents group does not have it as a member attribute (for whatever reason), re-running ipa-adtrust-install does not fix the inconsistency. Make the installer more robust by being able to fix the inconsistency. https://fedorahosted.org/freeipa/ticket/4464 Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
This commit is contained in:
parent
34de95545d
commit
7caed6ecfb
@ -497,28 +497,31 @@ class ADTRUSTInstance(service.Service):
|
|||||||
def __setup_principal(self):
|
def __setup_principal(self):
|
||||||
try:
|
try:
|
||||||
api.Command.service_add(unicode(self.cifs_principal))
|
api.Command.service_add(unicode(self.cifs_principal))
|
||||||
# Add the principal to the 'adtrust agents' group
|
except errors.DuplicateEntry:
|
||||||
# as 389-ds only operates with GroupOfNames, we have to use
|
|
||||||
# the principal's proper dn as defined in self.cifs_agent
|
|
||||||
try:
|
|
||||||
current = self.admin_conn.get_entry(self.smb_dn)
|
|
||||||
members = current.get('member', [])
|
|
||||||
if not(self.cifs_agent in members):
|
|
||||||
current["member"] = members + [self.cifs_agent]
|
|
||||||
self.admin_conn.update_entry(current)
|
|
||||||
except errors.NotFound:
|
|
||||||
entry = self.admin_conn.make_entry(
|
|
||||||
self.smb_dn,
|
|
||||||
objectclass=["top", "GroupOfNames"],
|
|
||||||
cn=[self.smb_dn['cn']],
|
|
||||||
member=[self.cifs_agent],
|
|
||||||
)
|
|
||||||
self.admin_conn.add_entry(entry)
|
|
||||||
except Exception:
|
|
||||||
# CIFS principal already exists, it is not the first time
|
# CIFS principal already exists, it is not the first time
|
||||||
# adtrustinstance is managed
|
# adtrustinstance is managed
|
||||||
# That's fine, we we'll re-extract the key again.
|
# That's fine, we we'll re-extract the key again.
|
||||||
pass
|
pass
|
||||||
|
except Exception, e:
|
||||||
|
self.print_msg("Cannot add CIFS service: %s" % e)
|
||||||
|
|
||||||
|
# Add the principal to the 'adtrust agents' group
|
||||||
|
# as 389-ds only operates with GroupOfNames, we have to use
|
||||||
|
# the principal's proper dn as defined in self.cifs_agent
|
||||||
|
try:
|
||||||
|
current = self.admin_conn.get_entry(self.smb_dn)
|
||||||
|
members = current.get('member', [])
|
||||||
|
if not(self.cifs_agent in members):
|
||||||
|
current["member"] = members + [self.cifs_agent]
|
||||||
|
self.admin_conn.update_entry(current)
|
||||||
|
except errors.NotFound:
|
||||||
|
entry = self.admin_conn.make_entry(
|
||||||
|
self.smb_dn,
|
||||||
|
objectclass=["top", "GroupOfNames"],
|
||||||
|
cn=[self.smb_dn['cn']],
|
||||||
|
member=[self.cifs_agent],
|
||||||
|
)
|
||||||
|
self.admin_conn.add_entry(entry)
|
||||||
|
|
||||||
self.clean_samba_keytab()
|
self.clean_samba_keytab()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user