def undo(self, change_record=None): # Check to see if packages or installed x11_installed = sb_utils.os.software.is_installed(pkgname='SUNWxwplt') gdm_pkg_installed = sb_utils.os.software.is_installed( pkgname='SUNWgnome-display-mgr-root') # Neither package is installed, so just quit if x11_installed == False and gdm_pkg_installed == False: msg = 'module is not applicable for this system' self.logger.notice(self.module_name, 'Undo: ' + msg) return 1 # GDM installed but I was not given a change record to restore file if not change_record and gdm_pkg_installed == True: msg = "Unable to perform undo operation without change record." self.logger.error(self.module_name, 'Undo Error: ' + msg) raise tcs_utils.ActionError('%s %s' % (self.module_name, msg)) try: tcs_utils.apply_patch(change_record) except tcs_utils.ActionError, err: msg = "Unable to undo previous changes (%s)." % err self.logger.error(self.module_name, 'Undo Error: ' + msg) raise tcs_utils.ActionError('%s %s' % (self.module_name, msg))
def undo(self, change_record=None): """Undo the previous action.""" if not change_record: msg = "Skipping Undo: No change record in state file." self.logger.notice(self.module_name, 'Skipping undo: ' + msg) return False, msg, {} try: tcs_utils.apply_patch(change_record) except tcs_utils.ActionError, err: msg = "Unable to undo previous changes (%s)." % err self.logger.error(self.module_name, 'Undo Error: ' + msg) raise tcs_utils.ActionError('%s %s' % (self.module_name, msg))
def undo(self, action_record=None): """Undo previous change application.""" if not action_record: msg = "Unable to perform undo operation without change record." self.logger.error(self.module_name, 'Undo Error: ' + msg) raise tcs_utils.ActionError('%s %s' % (self.module_name, msg)) try: tcs_utils.apply_patch(action_record) except tcs_utils.ActionError, err: msg = "Unable to undo previous changes (%s)." % err self.logger.error(self.module_name, 'Undo Error: ' + msg) raise tcs_utils.ActionError('%s %s' % (self.module_name, msg))
def undoCfg(self, change_record=None): """Undo the previous action.""" # note - oldstyle changes records were patches, so try to split out any patches *first*. Anything after that we need to process as a stringified dictionary patches, changeString = tcs_utils.split_patches(change_record) if patches: # Ok, found at least one patch, pass the whole change record through to the legacy patch apply stuff, it will quietly drop anything at the end try: tcs_utils.apply_patch(change_record) except tcs_utils.ActionError, err: msg = "Unable to undo previous changes (%s)." % err self.logger.error(self.module_name+'.undoCfg', 'Undo Error: ' + msg) raise tcs_utils.ActionError('%s %s' % (self.module_name+'.undoCfg', msg))
def undo(self, change_record=None): """Undo the previous action.""" if not change_record: msg = "Unable to perform undo operation without change record." self.logger.error(self.module_name, 'Undo Error: ' + msg) raise tcs_utils.ActionError('%s %s' % (self.module_name, msg)) # Restore file to what it was before the apply try: tcs_utils.apply_patch(change_record) except tcs_utils.ActionError, err: msg = "Unable to undo previous changes (%s)." % err self.logger.error(self.module_name, 'Undo Error: ' + msg) raise tcs_utils.ActionError('%s %s' % (self.module_name, msg))
def undo(self, change_record=None): """Undo the previous action. Note that this is only a legacy to allow removall of a password that OS Lockdown set in versions 4.0.7 and earlier. SB4.0.8+ will not set grub passwords""" if not change_record: msg = "Unable to perform undo operation without change record." self.logger.error(self.module_name, 'Undo Error: ' + msg) raise tcs_utils.ActionError('%s %s' % (self.module_name, msg)) # Restore file to what it was before the apply try: tcs_utils.apply_patch(change_record) except tcs_utils.ActionError, err: msg = "Unable to undo previous changes (%s)." % err self.logger.error(self.module_name, 'Undo Error: ' + msg) raise tcs_utils.ActionError('%s %s' % (self.module_name, msg))
def undo(self, change_record=None): """Undo the previous action.""" if not change_record or change_record == None: msg = "Unable to perform undo operation without change record." self.logger.error(self.module_name, 'Undo Error: ' + msg) raise tcs_utils.ActionError('%s %s' % (self.module_name, msg)) msg = "Restoring options in /usr/share/X11/app-defaults/XScreenSaver" self.logger.notice(self.module_name, msg) try: tcs_utils.apply_patch(change_record) except tcs_utils.ActionError, err: msg = "Unable to undo previous changes (%s)." % err self.logger.error(self.module_name, 'Undo Error: ' + msg) raise tcs_utils.ActionError('%s %s' % (self.module_name, msg))
def undo(self, change_record=None): """Disable account locking after 3 unsuccessful login attempts.""" result, reason = self.scan() if result == 'Fail': return 0 if not change_record: msg = "Unable to perform undo operation without change record." self.logger.error(self.module_name, 'Undo Error: ' + msg) raise tcs_utils.ActionError('%s %s' % (self.module_name, msg)) try: tcs_utils.apply_patch(change_record) except tcs_utils.ActionError, err: msg = "Unable to undo previous changes (%s)." % err self.logger.error(self.module_name, 'Undo Error: ' + msg) raise tcs_utils.ActionError('%s %s' % (self.module_name, msg))
def undo(self, action_record=None): """ Remove sulogin addition.""" result, reason = self.scan() if result == 'Fail': return 0 if not action_record: msg = "Unable to perform undo operation without change record." self.logger.error(self.module_name, 'Undo Error: ' + msg) raise tcs_utils.ActionError('%s %s' % (self.module_name, msg)) try: tcs_utils.apply_patch(action_record) except tcs_utils.ActionError, err: msg = "Unable to undo previous changes (%s)." % err self.logger.error(self.module_name, 'Undo Error: ' + msg) raise tcs_utils.ActionError('%s %s' % (self.module_name, msg))
def undo(self, change_record=None): """Undo the previous action.""" result, reason, messages = self.scan() if result == 'Fail': return False, reason, messages if not change_record or change_record == "[]" or change_record == "": msg = "Skipping Undo: No change record in state file." self.logger.notice(self.module_name, msg) return False, '', {'messages': [msg]} try: tcs_utils.apply_patch(change_record) except tcs_utils.ActionError, err: msg = "Unable to undo previous changes (%s)." % err self.logger.error(self.module_name, 'Undo Error: ' + msg) raise tcs_utils.ActionError('%s %s' % (self.module_name, msg))
def undo(self, change_record=None): """Undo previous change application.""" result, reason = self.scan() if result == 'Fail': return 0 if not change_record: msg = "Skipping Undo: No change record in state file." self.logger.notice(self.module_name, 'Skipping undo: ' + msg) return 0 try: tcs_utils.apply_patch(change_record) except tcs_utils.ActionError, err: msg = "Unable to undo previous changes (%s)." % err self.logger.error(self.module_name, 'Undo Error: ' + msg) raise tcs_utils.ActionError('%s %s' % (self.module_name, msg))
def undo(self, change_record=None): """Undo the previous action.""" if not change_record: msg = "Unable to perform undo operation without change record." self.logger.error(self.module_name, 'Undo Error: ' + msg) raise tcs_utils.ActionError('%s %s' % (self.module_name, msg)) if change_record == '': msg = "Empty change record supplied - undo has nothing to do" self.logger.warn(self.module_name, 'Undo Error: ' + msg) return False try: tcs_utils.apply_patch(change_record) except tcs_utils.ActionError, err: msg = "Unable to undo previous changes (%s)." % err self.logger.error(self.module_name, 'Undo Error: ' + msg) raise tcs_utils.ActionError('%s %s' % (self.module_name, msg))
def undo(self, change_record=None): """Disable account locking after 3 unsuccessful login attempts.""" (result, reason, messages) = self.scan() if result == False: return False, reason, {} messages = {'messages': []} if not change_record: msg = "Unable to perform undo operation without change record." self.logger.error(self.module_name, 'Undo Error: ' + msg) raise tcs_utils.ActionError('%s %s' % (self.module_name, msg)) # Restore file to what it was before the apply try: tcs_utils.apply_patch(change_record) except tcs_utils.ActionError, err: msg = "Unable to undo previous changes (%s)." % err self.logger.error(self.module_name, 'Undo Error: ' + msg) raise tcs_utils.ActionError('%s %s' % (self.module_name, msg))
def undo(self, change_record=None): """Undo the previous action.""" retval = False allChanges = {} allMessages = [] # oldstyle change record is a simple patchset, and we have no history on the original permissions, so # don't alter them, but we do need to revert the patch the oldway. if not change_record.startswith('{'): msg = "Detected oldstyle change record" self.logger.info(self.module_name, msg) try: tcs_utils.apply_patch(change_record) allChanges = "{}" except tcs_utils.ActionError, err: msg = "Unable to undo previous changes (%s)." % err self.logger.error(self.module_name, 'Undo Error: ' + msg) raise tcs_utils.ActionError('%s %s' % (self.module_name, msg))
def undo(self, change_record=None): """Undo the previous action.""" if not change_record: msg = "Unable to perform undo operation without change record." self.logger.error(self.module_name, 'Undo Error: ' + msg) raise tcs_utils.ActionError('%s %s' % (self.module_name, msg)) # Restore file to what it was before the apply if change_record == "EMPTY": os.unlink(self.__target_file) msg = "Removing '%s'" % self.__target_file else: try: tcs_utils.apply_patch(change_record) except tcs_utils.ActionError, err: msg = "Unable to undo previous changes (%s)." % err self.logger.error(self.module_name, 'Undo Error: ' + msg) raise tcs_utils.ActionError('%s %s' % (self.module_name, msg)) msg = 'audit.rules file restored.'
if change_record == 'empty': if not os.path.isfile(self.__target_file): msg = "Was going to remove %s but it does not exist; undo "\ "not necessary." % self.__target_file self.logger.notice(self.module_name, msg) else: try: os.unlink(self.__target_file) except OSError, err: msg = "Unable to remove %s: %s" % (self.__target_file, str(err)) self.logger.error(self.module_name, 'Undo Error: ' + msg) raise tcs_utils.ActionError('%s %s' % (self.module_name, msg)) return 1 # Restore file to what it was before the apply try: tcs_utils.apply_patch(change_record) except tcs_utils.ActionError, err: msg = "Unable to undo previous changes (%s)." % err self.logger.error(self.module_name, 'Undo Error: ' + msg) raise tcs_utils.ActionError('%s %s' % (self.module_name, msg)) msg = '/etc/logrotate.d/audit configuration file reset' self.logger.notice(self.module_name, 'Undo Performed: ' + msg) return 1
return 1, change_record ########################################################################## def undo(self, change_record=None): """Undo the previous action.""" try: result, reason = self.scan() if result == 'Fail': return 0, '' except tcs_utils.ScanNotApplicable, err: msg = 'module is not applicable for this system' self.logger.error(self.module_name, 'Undo Error: ' + msg) return 0, '' if not change_record or change_record == '': msg = "Skipping Undo: No change record or empty change record in state file." self.logger.notice(self.module_name, 'Skipping undo: ' + msg) return 0 try: tcs_utils.apply_patch(change_record.lstrip()) except tcs_utils.ActionError, err: msg = "Unable to undo previous changes (%s)." % err self.logger.error(self.module_name, 'Undo Error: ' + msg) raise tcs_utils.ActionError('%s %s' % (self.module_name, msg)) msg = 'PATH environment variables in global init scripts restored' self.logger.notice(self.module_name, 'Undo Performed: ' + msg) return 1