Esempio n. 1
0
    def disable_smart_install(self):
        if not utils.check_network_connection():
            FailureUI(self, queryString(ERROR_NO_NETWORK))
        else:
            sts, HPLIP_file = utils.download_from_network(HPLIP_INFO_SITE)
            if sts == 0:
                hplip_si_conf = ConfigBase(HPLIP_file)
                source = hplip_si_conf.get("SMART_INSTALL","url","")
                if not source :
                    FailureUI(self, queryString(ERROR_FAILED_TO_DOWNLOAD_FILE, 0, HPLIP_INFO_SITE))
                    return 

            response_file, smart_install_run = utils.download_from_network(source)
            response_asc, smart_install_asc = utils.download_from_network(source+'.asc')
            
            if response_file == 0   and response_asc == 0:

                gpg_obj = validation.GPG_Verification()
                digsig_sts, error_str = gpg_obj.validate(smart_install_run, smart_install_asc)

                if ERROR_SUCCESS == digsig_sts:
                    sts, out = utils.run("sh %s"%smart_install_run)
                else:
                
                    if QMessageBox.question(self, " ",
                        self.__tr("<b>%s</b><p>Without this, it is not possible to authenticate and validate this tool prior to installation.</p>Do you still want to run Smart Install disabler?" %error_str),
                                            QMessageBox.Yes | QMessageBox.No, QMessageBox.No) == QMessageBox.Yes:
                        # Disabling without verification.
                        sts, out = utils.run("sh %s"%smart_install_run)

            else:
                if response_asc:
                    FailureUI(self, queryString(ERROR_FAILED_TO_DOWNLOAD_FILE, 0, source + ".asc"))
                else:
                    FailureUI(self, queryString(ERROR_FAILED_TO_DOWNLOAD_FILE, 0, source))
Esempio n. 2
0
    def __validatePlugin(self, plugin_file, digsig_file, req_checksum):
        calc_checksum = get_checksum(file(plugin_file, 'r').read())
        log.debug("D/L file checksum=%s" % calc_checksum)
        if req_checksum and req_checksum != calc_checksum:
            return ERROR_CHECKSUM_ERROR, queryString(ERROR_CHECKSUM_ERROR, 0,
                                                     plugin_file)

        gpg_obj = validation.GPG_Verification()
        digsig_sts, error_str = gpg_obj.validate(plugin_file, digsig_file)

        return digsig_sts, error_str
Esempio n. 3
0
def validate(mode, smart_install_run, smart_install_asc, req_checksum=''):

    #Validate Checksum
    calc_checksum = utils.get_checksum(open(smart_install_run, 'r').read())
    log.debug("File checksum=%s" % calc_checksum)

    if req_checksum and req_checksum != calc_checksum:
        return ERROR_FILE_CHECKSUM, queryString(ERROR_CHECKSUM_ERROR, 0,
                                                plugin_file)

    #Validate Digital Signature
    gpg_obj = validation.GPG_Verification()
    digsig_sts, error_str = gpg_obj.validate(smart_install_run,
                                             smart_install_asc)

    return digsig_sts, smart_install_run, smart_install_asc, error_str
Esempio n. 4
0
                        log.bold(
                            "Specified path does not exist. Exiting...%s\n" %
                            download_path))
                    clean_exit(1)
                elif not os.access(download_path, os.R_OK | os.W_OK):
                    log.error(
                        log.bold(
                            "Specified path do not have enough permissions Exiting...%s\n"
                            % download_path))
                    clean_exit(1)
                else:
                    PATH_TO_DOWNLOAD_INSTALLER = download_path
            downloaded_file, digsig_file = download_hplip_installer(
                PATH_TO_DOWNLOAD_INSTALLER, HPLIP_latest_ver)

        gpg_obj = validation.GPG_Verification()
        digsig_sts, error_str = gpg_obj.validate(downloaded_file, digsig_file)

        if digsig_sts != ERROR_SUCCESS:
            if digsig_sts in (ERROR_UNABLE_TO_RECV_KEYS,
                              ERROR_DIGITAL_SIGN_NOT_FOUND,
                              ERROR_DIGITAL_SIGN_BAD):
                if not digital_signature_fail_confirmation(error_str):
                    clean_exit(1)
            else:
                log.error(error_str)
                clean_exit(1)

        CURRENT_WORKING_DIR = os.getcwd()
        os.chdir(PATH_TO_DOWNLOAD_INSTALLER)