def pre_transaction(self):
        if not self.base.transaction:
            return

        try:
            bus = SystemBus()
            self._snapper = Interface(bus.get_object('org.opensuse.Snapper',
                                      '/org/opensuse/Snapper'),
                                      dbus_interface='org.opensuse.Snapper')
        except DBusException as e:
            logger.critical(
                "snapper: " + _("connect to snapperd failed: %s"), e
            )
            return

        try:
            logger.debug(
                "snapper: " + _("creating pre_snapshot")
            )
            self._pre_snap_number = self._snapper.CreatePreSnapshot("root", self.description,
                                                                    "number", {})
            self._pre_snap_created = True
            logger.debug(
                "snapper: " + _("created pre_snapshot %d"), self._pre_snap_number
            )
        except DBusException as e:
            logger.critical(
                "snapper: " + _("creating pre_snapshot failed: %s"), e
            )
 def resolved(self):
     tmp = []
     for trans_item in self.base.transaction:
         tmp.append(trans_item.installs())
     for packages in tmp:
         for pkg in packages:
             logger.debug(_("Adding '{}' to list of handling " "packages for rpmconf").format(pkg.name))
             self.packages.append(pkg.name)
    def resolved(self):
        if not self._interactive:
            return

        for pkg in self.base.transaction.install_set:
            logger.debug(
                _("Adding '{}' to list of handling "
                  "packages for rpmconf").format(pkg.name))
            self.packages.append(pkg.name)
    def resolved(self):
        if not self._interactive:
            return

        for pkg in self.base.transaction.install_set:
            logger.debug(
                _("Adding '{}' to list of handling "
                  "packages for rpmconf").format(pkg.name))
            self.packages.append(pkg.name)
Beispiel #5
0
 def resolved(self):
     tmp = []
     for trans_item in self.base.transaction:
         tmp.append(trans_item.installs())
     for packages in tmp:
         for pkg in packages:
             logger.debug(
                 _("Adding '{}' to list of handling "
                   "packages for rpmconf").format(pkg.name))
             self.packages.append(pkg.name)
Beispiel #6
0
    def transaction(self):
        """
        Call after successful transaction
        See https://dnf.readthedocs.io/en/latest/api_plugins.html
        """

        # Don't run rkhunter when preparing chroot for mock
        if self.base.conf.installroot != "/":
            return

        # Don't run rkhunter when "nothing to do"
        if not self.base.transaction:
            return

        # Only run rkhunter when auto_propupd is set to 1
        # in /etc/dnf/plugins/rkhunter.conf
        if self.auto_propupd:

            # Custom rkhunter config has precedence when defined
            # in /etc/dnf/plugins/rkhunter.conf
            # If no custom and no local rkhunter config file is used,
            # use the main one
            for config in [
                    self.custom_config,
                    "/etc/rkhunter.conf.local",
                    "/etc/rkhunter.conf",
            ]:
                if config and os.path.exists(config):
                    logger.debug("{}: Found rkhunter config {}".format(
                        os.path.abspath(__file__), config))
                    if parse_config(config):
                        try:
                            subprocess.run(["/usr/bin/rkhunter", "--propupd"],
                                           check=True)
                        except subprocess.CalledProcessError as e:
                            logger.warning(
                                "{}: Error running rkhunter, {}".format(
                                    os.path.abspath(__file__), e))
                        return

            logger.warning("{}: No valid rkhunter config file found".format(
                os.path.abspath(__file__)))
Beispiel #7
0
    def pre_transaction(self):
        if not self.base.transaction:
            return

        try:
            bus = SystemBus()
            self._snapper = Interface(bus.get_object('org.opensuse.Snapper',
                                                     '/org/opensuse/Snapper'),
                                      dbus_interface='org.opensuse.Snapper')
        except DBusException as e:
            logger.critical("snapper: " + _("connect to snapperd failed: %s"),
                            e)
            return

        try:
            logger.debug("snapper: " + _("creating pre_snapshot"))
            self._pre_snap_number = self._snapper.CreatePreSnapshot(
                "root", self.description, "number", {})
            self._pre_snap_created = True
            logger.debug("snapper: " + _("created pre_snapshot %d"),
                         self._pre_snap_number)
        except DBusException as e:
            logger.critical(
                "snapper: " + _("creating pre_snapshot failed: %s"), e)
Beispiel #8
0
    def transaction(self):
        if not self._pre_snap_created:
            logger.debug("snapper: " + _(
                "skipping post_snapshot because creation of pre_snapshot failed"
            ))
            return

        try:
            logger.debug("snapper: " + _("creating post_snapshot"))
            snap_post_number = self._snapper.CreatePostSnapshot(
                "root", self._pre_snap_number, self.description, "number", {})
            logger.debug("snapper: " + _("created post_snapshot %d"),
                         snap_post_number)
        except DBusException as e:
            logger.critical(
                "snapper: " + _("creating post_snapshot failed: %s"), e)
Beispiel #9
0
    def transaction(self):
        if not self._interactive:
            logger.debug(
                _("rpmconf plugin will not run "
                  "in non-interactive mode"))
            return

        rconf = rpmconf.RpmConf(packages=self.packages,
                                frontend=self.frontend,
                                diff=self.diff)
        try:
            rconf.run()
        except SystemExit as e:
            if e.code == errno.ENOENT:
                logger.debug(
                    _("ignoring sys.exit from rpmconf "
                      "due to missing MERGE variable"))
            elif e.code == errno.EINTR:
                logger.debug(
                    _("ignoring sys.exit from rpmconf "
                      "due to missing file"))
    def transaction(self):
        if not self._interactive:
            logger.debug(_("rpmconf plugin will not run "
                           "in non-interactive mode"))
            return

        rconf = rpmconf.RpmConf(
            packages=self.packages,
            frontend=self.frontend,
            diff=self.diff)
        try:
            rconf.run()
        except SystemExit as e:
            if e.code == errno.ENOENT:
                logger.debug(
                    _("ignoring sys.exit from rpmconf "
                      "due to missing MERGE variable"))
            elif e.code == errno.EINTR:
                logger.debug(
                    _("ignoring sys.exit from rpmconf "
                      "due to missing file"))
    def transaction(self):
        if not self.base.transaction:
            return

        if not self._pre_snap_created:
            logger.debug(
                "snapper: " + _("skipping post_snapshot because creation of pre_snapshot failed")
            )
            return

        try:
            logger.debug(
                "snapper: " + _("creating post_snapshot")
            )
            snap_post_number = self._snapper.CreatePostSnapshot("root", self._pre_snap_number,
                                                                self.description, "number", {})
            logger.debug(
                "snapper: " + _("created post_snapshot %d"), snap_post_number
            )
        except DBusException as e:
            logger.critical(
                "snapper: " + _("creating post_snapshot failed: %s"), e
            )