示例#1
0
    def _initialize(self):
        hubQ.send_message(self.__class__.__name__, _("Probing storage..."))

        threadMgr.wait(constants.THREAD_STORAGE)

        hubQ.send_message(self.__class__.__name__,
                          _(METADATA_DOWNLOAD_MESSAGE))

        threadMgr.wait(constants.THREAD_PAYLOAD)

        added = False

        # If there's no fallback mirror to use, we should just disable that option
        # in the UI.
        if not self.payload.mirrorEnabled:
            self._protocolComboBox.remove(PROTOCOL_MIRROR)

        # If we've previously set up to use a CD/DVD method, the media has
        # already been mounted by payload.setup.  We can't try to mount it
        # again.  So just use what we already know to create the selector.
        # Otherwise, check to see if there's anything available.
        if self.data.method.method == "cdrom":
            self._cdrom = self.payload.install_device
        elif not flags.automatedInstall:
            self._cdrom = opticalInstallMedia(self.storage.devicetree)

        if self._cdrom:
            fire_gtk_action(self._autodetectDeviceLabel.set_text,
                            _("Device: %s") % self._cdrom.name)
            fire_gtk_action(
                self._autodetectLabel.set_text,
                _("Label: %s") %
                (getattr(self._cdrom.format, "label", "") or ""))
            added = True

        if self.data.method.method == "harddrive":
            self._currentIsoFile = self.payload.ISOImage

        # These UI elements default to not being showable.  If optical install
        # media were found, mark them to be shown.
        if added:
            gtk_call_once(self._autodetectBox.set_no_show_all, False)
            gtk_call_once(self._autodetectButton.set_no_show_all, False)

        # Add the mirror manager URL in as the default for HTTP and HTTPS.
        # We'll override this later in the refresh() method, if they've already
        # provided a URL.
        # FIXME

        self._reset_repoStore()

        self._ready = True
        hubQ.send_ready(self.__class__.__name__, False)
示例#2
0
    def _initialize(self):
        hubQ.send_message(self.__class__.__name__, _("Probing storage..."))

        threadMgr.wait(constants.THREAD_STORAGE)

        hubQ.send_message(self.__class__.__name__, _(METADATA_DOWNLOAD_MESSAGE))

        threadMgr.wait(constants.THREAD_PAYLOAD)

        added = False

        # If there's no fallback mirror to use, we should just disable that option
        # in the UI.
        if not self.payload.mirrorEnabled:
            self._protocolComboBox.remove(PROTOCOL_MIRROR)

        # If we've previously set up to use a CD/DVD method, the media has
        # already been mounted by payload.setup.  We can't try to mount it
        # again.  So just use what we already know to create the selector.
        # Otherwise, check to see if there's anything available.
        if self.data.method.method == "cdrom":
            self._cdrom = self.payload.install_device
        elif not flags.automatedInstall:
            self._cdrom = opticalInstallMedia(self.storage.devicetree)

        if self._cdrom:
            fire_gtk_action(self._autodetectDeviceLabel.set_text, _("Device: %s") % self._cdrom.name)
            fire_gtk_action(self._autodetectLabel.set_text, _("Label: %s") % (getattr(self._cdrom.format, "label", "") or ""))
            added = True

        if self.data.method.method == "harddrive":
            self._currentIsoFile = self.payload.ISOImage

        # These UI elements default to not being showable.  If optical install
        # media were found, mark them to be shown.
        if added:
            gtk_call_once(self._autodetectBox.set_no_show_all, False)
            gtk_call_once(self._autodetectButton.set_no_show_all, False)

        # Add the mirror manager URL in as the default for HTTP and HTTPS.
        # We'll override this later in the refresh() method, if they've already
        # provided a URL.
        # FIXME

        self._reset_repoStore()

        self._ready = True
        # Wait to make sure the other threads are done before sending ready, otherwise
        # the spoke may not be set sensitive by _handleCompleteness in the hub.
        while not self.ready:
            time.sleep(1)
        hubQ.send_ready(self.__class__.__name__, False)
示例#3
0
    def _init_after_data_fetch(self, wait_for):
        """
        Waits for data fetching to be finished, extracts it (if needed),
        populates the stores and evaluates pre-installation fixes from the
        content and marks the spoke as ready in the end.

        :param wait_for: name of the thread to wait for (if any)
        :type wait_for: str or None

        """

        try:
            threadMgr.wait(wait_for)
        except data_fetch.DataFetchError:
            self._data_fetch_failed()
            with self._fetch_flag_lock:
                self._fetching = False
            return
        finally:
            # stop the spinner in any case
            fire_gtk_action(self._progress_spinner.stop)

        if self._addon_data.fingerprint:
            hash_obj = utils.get_hashing_algorithm(
                self._addon_data.fingerprint)
            digest = utils.get_file_fingerprint(
                self._addon_data.raw_preinst_content_path, hash_obj)
            if digest != self._addon_data.fingerprint:
                self._integrity_check_failed()
                # fetching done
                with self._fetch_flag_lock:
                    self._fetching = False
                return

        # RPM is an archive at this phase
        if self._addon_data.content_type in ("archive", "rpm"):
            # extract the content
            try:
                fpaths = common.extract_data(
                    self._addon_data.raw_preinst_content_path,
                    common.INSTALLATION_CONTENT_DIR,
                    [self._addon_data.content_path])
            except common.ExtractionError as err:
                self._extraction_failed(err.message)
                # fetching done
                with self._fetch_flag_lock:
                    self._fetching = False
                return

            # and populate missing fields
            self._content_handling_cls, files = content_handling.explore_content_files(
                fpaths)
            files = common.strip_content_dir(files)

            # pylint: disable-msg=E1103
            self._addon_data.content_path = self._addon_data.content_path or files.xccdf
            self._addon_data.cpe_path = self._addon_data.cpe_path or files.cpe
            self._addon_data.tailoring_path = (self._addon_data.tailoring_path
                                               or files.tailoring)
        elif self._addon_data.content_type == "datastream":
            self._content_handling_cls = content_handling.DataStreamHandler
        elif self._addon_data.content_type == "scap-security-guide":
            self._content_handling_cls = content_handling.BenchmarkHandler
        else:
            raise common.OSCAPaddonError("Unsupported content type")

        try:
            self._content_handler = self._content_handling_cls(
                self._addon_data.preinst_content_path,
                self._addon_data.preinst_tailoring_path)
        except content_handling.ContentHandlingError:
            self._invalid_content()
            # fetching done
            with self._fetch_flag_lock:
                self._fetching = False

            return

        if self._using_ds:
            # populate the stores from items from the content
            self._ds_checklists = self._content_handler.get_data_streams_checklists(
            )
            add_ds_ids = GtkActionList()
            add_ds_ids.add_action(self._ds_store.clear)
            for dstream in self._ds_checklists.keys():
                add_ds_ids.add_action(self._add_ds_id, dstream)
            add_ds_ids.fire()

        self._update_ids_visibility()

        # refresh UI elements
        self.refresh()

        # let all initialization and configuration happen before we evaluate
        # the setup
        if not self._anaconda_spokes_initialized.is_set():
            # only wait (and log the messages) if the event is not set yet
            log.debug(
                "OSCAP addon: waiting for all Anaconda spokes to be initialized"
            )
            self._anaconda_spokes_initialized.wait()
            log.debug(
                "OSCAP addon: all Anaconda spokes have been initialized - continuing"
            )

        # try to switch to the chosen profile (if any)
        selected = self._switch_profile()

        if self._addon_data.profile_id and not selected:
            # profile ID given, but it was impossible to select it -> invalid
            # profile ID given
            self._invalid_profile_id()
            return

        # initialize the self._addon_data.rule_data
        self._addon_data.rule_data = self._rule_data

        # update the message store with the messages
        self._update_message_store()

        # all initialized, we can now let user set parameters
        fire_gtk_action(self._main_notebook.set_current_page, SET_PARAMS_PAGE)

        # and use control buttons
        fire_gtk_action(really_show, self._control_buttons)

        # fetching done
        with self._fetch_flag_lock:
            self._fetching = False

        # no error
        self._set_error(None)
示例#4
0
    def _init_after_data_fetch(self, wait_for):
        """
        Waits for data fetching to be finished, extracts it (if needed),
        populates the stores and evaluates pre-installation fixes from the
        content and marks the spoke as ready in the end.

        :param wait_for: name of the thread to wait for (if any)
        :type wait_for: str or None

        """

        try:
            threadMgr.wait(wait_for)
        except data_fetch.DataFetchError:
            self._data_fetch_failed()
            with self._fetch_flag_lock:
                self._fetching = False
            return
        finally:
            # stop the spinner in any case
            fire_gtk_action(self._progress_spinner.stop)

        if self._addon_data.fingerprint:
            hash_obj = utils.get_hashing_algorithm(self._addon_data.fingerprint)
            digest = utils.get_file_fingerprint(self._addon_data.raw_preinst_content_path,
                                                hash_obj)
            if digest != self._addon_data.fingerprint:
                self._integrity_check_failed()
                # fetching done
                with self._fetch_flag_lock:
                    self._fetching = False
                return

        # RPM is an archive at this phase
        if self._addon_data.content_type in ("archive", "rpm"):
            # extract the content
            try:
                fpaths = common.extract_data(self._addon_data.raw_preinst_content_path,
                                             common.INSTALLATION_CONTENT_DIR,
                                             [self._addon_data.content_path])
            except common.ExtractionError as err:
                self._extraction_failed(str(err))
                # fetching done
                with self._fetch_flag_lock:
                    self._fetching = False
                return

            # and populate missing fields
            self._content_handling_cls, files = content_handling.explore_content_files(fpaths)
            files = common.strip_content_dir(files)

            # pylint: disable-msg=E1103
            self._addon_data.content_path = self._addon_data.content_path or files.xccdf
            self._addon_data.cpe_path = self._addon_data.cpe_path or files.cpe
            self._addon_data.tailoring_path = (self._addon_data.tailoring_path or
                                               files.tailoring)
        elif self._addon_data.content_type == "datastream":
            self._content_handling_cls = content_handling.DataStreamHandler
        elif self._addon_data.content_type == "scap-security-guide":
            self._content_handling_cls = content_handling.BenchmarkHandler
        else:
            raise common.OSCAPaddonError("Unsupported content type")

        try:
            self._content_handler = self._content_handling_cls(self._addon_data.preinst_content_path,
                                                               self._addon_data.preinst_tailoring_path)
        except content_handling.ContentHandlingError:
            self._invalid_content()
            # fetching done
            with self._fetch_flag_lock:
                self._fetching = False

            return

        if self._using_ds:
            # populate the stores from items from the content
            self._ds_checklists = self._content_handler.get_data_streams_checklists()
            add_ds_ids = GtkActionList()
            add_ds_ids.add_action(self._ds_store.clear)
            for dstream in self._ds_checklists.keys():
                add_ds_ids.add_action(self._add_ds_id, dstream)
            add_ds_ids.fire()

        self._update_ids_visibility()

        # refresh UI elements
        self.refresh()

        # let all initialization and configuration happen before we evaluate
        # the setup
        if not self._anaconda_spokes_initialized.is_set():
            # only wait (and log the messages) if the event is not set yet
            log.debug("OSCAP addon: waiting for all Anaconda spokes to be initialized")
            self._anaconda_spokes_initialized.wait()
            log.debug("OSCAP addon: all Anaconda spokes have been initialized - continuing")

        # try to switch to the chosen profile (if any)
        selected = self._switch_profile()

        if self._addon_data.profile_id and not selected:
            # profile ID given, but it was impossible to select it -> invalid
            # profile ID given
            self._invalid_profile_id()
            return

        # initialize the self._addon_data.rule_data
        self._addon_data.rule_data = self._rule_data

        # update the message store with the messages
        self._update_message_store()

        # all initialized, we can now let user set parameters
        fire_gtk_action(self._main_notebook.set_current_page, SET_PARAMS_PAGE)

        # and use control buttons
        fire_gtk_action(really_show, self._control_buttons)

        # fetching done
        with self._fetch_flag_lock:
            self._fetching = False

        # no error
        self._set_error(None)
示例#5
0
 def update_progress_label(msg):
     fire_gtk_action(self._progress_label.set_text(msg))
示例#6
0
    def _init_after_data_fetch(self, wait_for):
        """
        Waits for data fetching to be finished, extracts it (if needed),
        populates the stores and evaluates pre-installation fixes from the
        content and marks the spoke as ready in the end.

        :param wait_for: name of the thread to wait for (if any)
        :type wait_for: str or None

        """
        def update_progress_label(msg):
            fire_gtk_action(self._progress_label.set_text(msg))

        content_path = None
        actually_fetched_content = wait_for is not None

        if actually_fetched_content:
            content_path = common.get_raw_preinst_content_path(self._policy_data)

        content = self.content_bringer.finish_content_fetch(
            wait_for, self._policy_data.fingerprint, update_progress_label,
            content_path, self._handle_error)
        if not content:
            with self._fetch_flag_lock:
                self._fetching = False
            return

        fire_gtk_action(self._progress_spinner.stop)
        fire_gtk_action(
            self._progress_label.set_text,
            _("Fetch complete, analyzing data."))

        try:
            if actually_fetched_content:
                self.content_bringer.use_downloaded_content(content)

            preinst_content_path = common.get_preinst_content_path(self._policy_data)
            preinst_tailoring_path = common.get_preinst_tailoring_path(self._policy_data)

            msg = f"Opening SCAP content at {preinst_content_path}"
            if self._policy_data.tailoring_path:
                msg += f" with tailoring {preinst_tailoring_path}"
            else:
                msg += " without considering tailoring"
            log.info("OSCAP Addon: " + msg)

            self._content_handler = scap_content_handler.SCAPContentHandler(
                preinst_content_path,
                preinst_tailoring_path)
        except Exception as e:
            log.error(str(e))
            self._invalid_content()
            # fetching done
            with self._fetch_flag_lock:
                self._fetching = False

            return

        log.info("OSCAP Addon: Done with analysis")

        self._ds_checklists = self._content_handler.get_data_streams_checklists()
        if self._using_ds:
            # populate the stores from items from the content
            add_ds_ids = GtkActionList()
            add_ds_ids.add_action(self._ds_store.clear)
            for dstream in self._ds_checklists.keys():
                add_ds_ids.add_action(self._add_ds_id, dstream)
            add_ds_ids.fire()

        self._update_ids_visibility()

        # refresh UI elements
        self._refresh_ui()

        # let all initialization and configuration happen before we evaluate
        # the setup
        if not self._anaconda_spokes_initialized.is_set():
            # only wait (and log the messages) if the event is not set yet
            log.debug("OSCAP addon: waiting for all Anaconda spokes to be initialized")
            self._anaconda_spokes_initialized.wait()
            log.debug("OSCAP addon: all Anaconda spokes have been initialized - continuing")

        # try to switch to the chosen profile (if any)
        selected = self._switch_profile()

        if self._policy_data.profile_id and not selected:
            # profile ID given, but it was impossible to select it -> invalid
            # profile ID given
            self._invalid_profile_id()
            return

        # update the message store with the messages
        self._update_message_store()

        # all initialized, we can now let user set parameters
        fire_gtk_action(self._main_notebook.set_current_page, SET_PARAMS_PAGE)

        # and use control buttons
        fire_gtk_action(really_show, self._control_buttons)

        # fetching done
        with self._fetch_flag_lock:
            self._fetching = False

        # no error
        self._set_error(None)
示例#7
0
    def _init_after_data_fetch(self, wait_for):
        """
        Waits for data fetching to be finished, extracts it (if needed),
        populates the stores and evaluates pre-installation fixes from the
        content and marks the spoke as ready in the end.

        :param wait_for: name of the thread to wait for (if any)
        :type wait_for: str or None

        """

        try:
            threadMgr.wait(wait_for)
        except data_fetch.DataFetchError:
            self._data_fetch_failed()
            with self._fetch_flag_lock:
                self._fetching = False
            return
        finally:
            # stop the spinner in any case
            fire_gtk_action(self._progress_spinner.stop)

        if self._addon_data.fingerprint:
            hash_obj = utils.get_hashing_algorithm(self._addon_data.fingerprint)
            digest = utils.get_file_fingerprint(\
                                       self._addon_data.raw_preinst_content_path,
                                       hash_obj)
            if digest != self._addon_data.fingerprint:
                msg = _("Integrity check failed")
                raise content_handling.ContentCheckError(msg)

        # RPM is an archive at this phase
        if self._addon_data.content_type in ("archive", "rpm"):
            # extract the content
            try:
                fpaths = common.extract_data(\
                                    self._addon_data.raw_preinst_content_path,
                                    common.INSTALLATION_CONTENT_DIR,
                                    [self._addon_data.xccdf_path])
            except common.ExtractionError as err:
                self._extraction_failed(err.message)
                # fetching done
                with self._fetch_flag_lock:
                    self._fetching = False
                return

            # and populate missing fields
            self._content_handling_cls, files = \
                                 content_handling.explore_content_files(fpaths)
            files = common.strip_content_dir(files)

            # pylint: disable-msg=E1103
            self._addon_data.xccdf_path = self._addon_data.xccdf_path or files.xccdf
            self._addon_data.cpe_path = self._addon_data.cpe_path or files.cpe
            self._addon_data.tailoring_path = (self._addon_data.tailoring_path or
                                               files.tailoring)
        elif self._addon_data.content_type == "datastream":
            self._content_handling_cls = content_handling.DataStreamHandler
        elif self._addon_data.content_type == "scap-security-guide":
            self._content_handling_cls = content_handling.BenchmarkHandler
        else:
            raise common.OSCAPaddonError("Unsupported content type")

        try:
            self._content_handler = self._content_handling_cls(\
                                      self._addon_data.preinst_content_path,
                                      self._addon_data.preinst_tailoring_path)
        except content_handling.ContentHandlingError:
            self._invalid_content()
            # fetching done
            with self._fetch_flag_lock:
                self._fetching = False
            return

        if self._using_ds:
            # populate the stores from items from the content
            self._ds_checklists = self._content_handler.get_data_streams_checklists()
            for dstream in self._ds_checklists.iterkeys():
                self._add_ds_id(dstream)
        else:
            # hide the labels and comboboxes for datastream-id and xccdf-id
            # selection
            fire_gtk_action(really_hide, self._ids_box)

        # refresh UI elements
        self.refresh()

        # try to switch to the chosen profile (if any)
        self._switch_profile()

        # initialize the self._addon_data.rule_data
        self._addon_data.rule_data = self._rule_data

        # update the message store with the messages
        self._update_message_store()

        # no more being unitialized
        self._unitialized_status = None
        self._ready = True

        # all initialized, we can now let user set parameters
        self._main_notebook.set_current_page(SET_PARAMS_PAGE)

        # and use control buttons
        really_show(self._control_buttons)

        # pylint: disable-msg=E1101
        hubQ.send_ready(self.__class__.__name__, True)
        hubQ.send_message(self.__class__.__name__, self.status)

        # fetching done
        with self._fetch_flag_lock:
            self._fetching = False