Skip to content

Commit

Permalink
httpinstance: clean up /etc/httpd/alias on uninstall
Browse files Browse the repository at this point in the history
Restore cert8.db, key3.db, pwdfile.txt and secmod.db in /etc/httpd/alias
from backup on uninstall.

Files modified by IPA are kept with .ipasave suffix.

https://pagure.io/freeipa/issue/4639

Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
  • Loading branch information
Jan Cholasta authored and Martin Babinsky committed Mar 22, 2017
1 parent bbd18cf commit e263cb4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ipapython/certdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,19 @@ def create_db(self, user=None, group=None, mode=None, backup=False):
new_mode = filemode
os.chmod(path, new_mode)

def restore(self):
for filename in NSS_FILES:
path = os.path.join(self.secdir, filename)
backup_path = path + '.orig'
save_path = path + '.ipasave'
try:
if os.path.exists(path):
os.rename(path, save_path)
if os.path.exists(backup_path):
os.rename(backup_path, path)
except OSError as e:
root_logger.debug(e)

def list_certs(self):
"""Return nicknames and cert flags for all certs in the database
Expand Down
3 changes: 3 additions & 0 deletions ipaserver/install/certs.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ def create_certdbs(self):
backup=True)
self.set_perms(self.passwd_fname, write=True)

def restore(self):
self.nssdb.restore()

def list_certs(self):
"""
Return a tuple of tuples containing (nickname, trust)
Expand Down
3 changes: 3 additions & 0 deletions ipaserver/install/httpinstance.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,9 @@ def uninstall(self):
ca_iface.Set('org.fedorahosted.certmonger.ca',
'external-helper', helper)

db = certs.CertDB(self.realm, paths.HTTPD_ALIAS_DIR)
db.restore()

for f in [paths.HTTPD_IPA_CONF, paths.HTTPD_SSL_CONF, paths.HTTPD_NSS_CONF]:
try:
self.fstore.restore_file(f)
Expand Down

0 comments on commit e263cb4

Please sign in to comment.