diff options
author | Rob Crittenden <rcritten@redhat.com> | 2012-02-22 16:40:29 -0500 |
---|---|---|
committer | Martin Kosek <mkosek@redhat.com> | 2012-02-27 14:48:26 +0100 |
commit | de9a22b3f3725156a74c55bfadd1f978e98f453c (patch) | |
tree | ac3e7e38e630ef5d912cdb5cfc4035ce2b5533dd /ipapython | |
parent | 5c7cd8ee2f513c49ddb3738811cbe75d9a01c806 (diff) | |
download | freeipa-de9a22b3f3725156a74c55bfadd1f978e98f453c.tar.gz freeipa-de9a22b3f3725156a74c55bfadd1f978e98f453c.tar.xz freeipa-de9a22b3f3725156a74c55bfadd1f978e98f453c.zip |
Remove unused kpasswd.keytab and ldappwd files if they exist.
These were used by ipa_kpasswd and krb5-server-ldap respectivily.
https://fedorahosted.org/freeipa/ticket/2397
Diffstat (limited to 'ipapython')
-rw-r--r-- | ipapython/sysrestore.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/ipapython/sysrestore.py b/ipapython/sysrestore.py index 8177a1bf..82817aca 100644 --- a/ipapython/sysrestore.py +++ b/ipapython/sysrestore.py @@ -226,6 +226,49 @@ class FileStore: return len(self.files) > 0 + def untrack_file(self, path): + """Remove file at path @path from list of backed up files. + + Does not remove any files from the filesystem. + + Returns #True if the file was untracked, #False if there + was no backup file to restore + """ + + root_logger.debug("Untracking system configuration file '%s'", path) + + if not os.path.isabs(path): + raise ValueError("Absolute path required") + + mode = None + uid = None + gid = None + filename = None + + for (key, value) in self.files.items(): + (mode,uid,gid,filepath) = string.split(value, ',', 3) + if (filepath == path): + filename = key + break + + if not filename: + raise ValueError("No such file name in the index") + + backup_path = os.path.join(self._path, filename) + if not os.path.exists(backup_path): + root_logger.debug(" -> Not restoring - '%s' doesn't exist", backup_path) + return False + + try: + os.unlink(backup_path) + except Exception, e: + root_logger.error('Error removing %s: %s' % (backup_path, str(e))) + + del self.files[filename] + self.save() + + return True + class StateFile: """A metadata file for recording system state which can be backed up and later restored. The format is something |