def _update_message_store(self, report_only=False): """ Updates the message store with messages from rule evaluation. :param report_only: wheter to do changes in configuration or just report :type report_only: bool """ if not self._rule_data: # RuleData instance not initialized, cannot do anything return self._message_store.clear() messages = self._rule_data.eval_rules(self.data, self._storage, report_only) if not messages: # no messages from the rules, add a message informing about that if not self._active_profile: # because of no profile message = common.RuleMessage(common.MESSAGE_TYPE_INFO, _("No profile selected")) else: # because of no pre-inst rules message = common.RuleMessage(common.MESSAGE_TYPE_INFO, _("No rules for the pre-installation phase")) self._add_message(message) # nothing more to be done return for msg in messages: self._add_message(msg)
def _resolve_rootpw_issues(self, messages, report_only): """Mitigate root password issues (which are not fatal in GUI)""" fatal_rootpw_msgs = [msg for msg in messages if msg.origin == rule_handling.PasswdRules and msg.type == common.MESSAGE_TYPE_FATAL] if fatal_rootpw_msgs: for msg in fatal_rootpw_msgs: # cannot just change the message type because it is a namedtuple messages.remove(msg) messages.append(common.RuleMessage(self.__class__, common.MESSAGE_TYPE_WARNING, msg.text)) if not report_only: self.__old_root_pw = self.data.rootpw.password self.data.rootpw.password = None self.__old_root_pw_seen = self.data.rootpw.seen self.data.rootpw.seen = False
def _switch_dry_run(self, dry_run): self._choose_button.set_sensitive(not dry_run) if dry_run: # no profile can be selected in the dry-run mode self._unselect_profile(self._active_profile) # no messages in the dry-run mode self._message_store.clear() message = common.RuleMessage(common.MESSAGE_TYPE_INFO, _("Not applying security policy")) self._add_message(message) else: # mark the active profile as selected self._select_profile(self._active_profile) self._update_message_store()
def _resolve_rootpw_issues(self, messages, report_only): """Mitigate root password issues (which are not fatal in GUI)""" fatal_rootpw_msgs = [ msg for msg in messages if msg.origin == rule_handling.PasswdRules and msg.type == common.MESSAGE_TYPE_FATAL] if fatal_rootpw_msgs: for msg in fatal_rootpw_msgs: # cannot just change the message type because it is a namedtuple messages.remove(msg) msg = common.RuleMessage( self.__class__, common.MESSAGE_TYPE_WARNING, msg.text) messages.append(msg) passwords_can_be_fixed = False if not report_only and passwords_can_be_fixed: users_proxy = USERS.get_proxy() self.__old_root_pw = users_proxy.RootPassword self.data.rootpw.password = None self.__old_root_pw_seen = users_proxy.IsRootpwKickstarted self.data.rootpw.seen = False