Exemple #1
0
def retrace(args):
    # we might not get these var if called from backtrace
    local, remote, auth = False, False, False

    if hasattr(args, "local"):
        local = args.local
    if hasattr(args, "remote"):
        remote = args.remote
    if hasattr(args, "force"):
        force = args.force

    prob = match_get_problem(args.MATCH, auth=args.auth)
    if hasattr(prob, "backtrace") and not force:
        print(_("Problem already has a backtrace"))
        print(_("Run abrt retrace with -f/--force to retrace again"))
        ret = ask_yes_no(_("Show backtrace?"))
        if ret:
            print(fmt_problems(prob, fmt=config.BACKTRACE_FMT))
    elif not isinstance(prob, problem.Ccpp):
        print(_("No retracing possible for this problem type"))
    else:
        if not (local or remote):  # ask..
            ret = ask_yes_no(
                _(
                    "Upload core dump and perform remote"
                    " retracing? (It may contain sensitive data)."
                    " If your answer is 'No', a stack trace will"
                    " be generated locally. Local retracing"
                    " requires downloading potentially large amount"
                    " of debuginfo data"
                )
            )

            if ret:
                remote = True
            else:
                local = True

        prob.chown()

        if remote:
            print(_("Remote retracing"))
            run_event("analyze_RetraceServer", prob)
        else:
            print(_("Local retracing"))
            run_event("analyze_LocalGDB", prob)
Exemple #2
0
    def run(self, arguments):
        # We don’t get these bad boys when invoked by the “backtrace” command.
        local = getattr(arguments, 'local', False)
        remote = getattr(arguments, 'remote', False)
        force = getattr(arguments, 'force', False)

        problems = match_get_problems(arguments.patterns,
                                      authenticate=arguments.authenticate,
                                      executables=arguments.executables,
                                      components=arguments.components,
                                      since=arguments.since,
                                      until=arguments.until,
                                      n_latest=arguments.n_latest,
                                      not_reported=arguments.not_reported)
        for problem in problems:
            if hasattr(problem, 'backtrace') and not force:
                print(_('Problem already has a backtrace'))
                print(_('Run abrt retrace with -f/--force to retrace again'))
                if ask_yes_no(_('Show backtrace?')):
                    print(format_problems(problem, fmt=config.BACKTRACE_FMT))
            elif not isinstance(problem, Ccpp):
                print(_('No retracing possible for this problem type'))
            else:
                if not (local or remote):
                    ret = ask_yes_no(
                        _('Upload core dump and perform remote'
                          ' retracing? (It may contain sensitive data).'
                          ' If your answer is \'No\', a stack trace will'
                          ' be generated locally. Local retracing'
                          ' requires downloading potentially large amount'
                          ' of debuginfo data'))

                    if ret:
                        remote = True
                    else:
                        local = True

                problem.chown()

                if remote:
                    print(_('Remote retracing'))
                    run_event('analyze_RetraceServer', problem)
                else:
                    print(_('Local retracing'))
                    run_event('analyze_LocalGDB', problem)
Exemple #3
0
def retrace(args):
    # we might not get these var if called from backtrace
    local, remote, auth = False, False, False

    if hasattr(args, 'local'):
        local = args.local
    if hasattr(args, 'remote'):
        remote = args.remote
    if hasattr(args, 'force'):
        force = args.force

    prob = match_get_problem(args.MATCH, auth=args.auth)
    if hasattr(prob, 'backtrace') and not force:
        print(_('Problem already has a backtrace'))
        print(_('Run abrt retrace with -f/--force to retrace again'))
        ret = ask_yes_no(_('Show backtrace?'))
        if ret:
            print(fmt_problems(prob, fmt=config.BACKTRACE_FMT))
    elif not isinstance(prob, problem.Ccpp):
        print(_('No retracing possible for this problem type'))
    else:
        if not (local or remote):  # ask..
            ret = ask_yes_no(
                _('Upload core dump and perform remote'
                  ' retracing? (It may contain sensitive data).'
                  ' If your answer is \'No\', a stack trace will'
                  ' be generated locally. Local retracing'
                  ' requires downloading potentially large amount'
                  ' of debuginfo data'))

            if ret:
                remote = True
            else:
                local = True

        prob.chown()

        if remote:
            print(_('Remote retracing'))
            run_event('analyze_RetraceServer', prob)
        else:
            print(_('Local retracing'))
            run_event('analyze_LocalGDB', prob)
Exemple #4
0
def backtrace(args):
    prob = match_get_problem(args.MATCH, auth=args.auth)
    if hasattr(prob, 'backtrace'):
        print(fmt_problems(prob, fmt=config.BACKTRACE_FMT))
    else:
        print(_('Problem has no backtrace'))
        if isinstance(prob, problem.Ccpp):
            ret = ask_yes_no(_('Start retracing process?'))
            if ret:
                retrace(args)
                print(fmt_problems(prob, fmt=config.BACKTRACE_FMT))
Exemple #5
0
def remove(args):
    prob = match_get_problem(args.MATCH, auth=args.auth)
    print(fmt_problems(prob, fmt=config.FULL_FMT))

    ret = True
    if not args.f and (args.i or args.MATCH == 'last'):
        # force prompt for last problem to avoid accidents
        ret = ask_yes_no(_('Are you sure you want to delete this problem?'))

    if ret:
        prob.delete()
        print(_('Removed'))
Exemple #6
0
    def run(self, arguments):
        problems = match_get_problems(arguments.patterns,
                                      authenticate=arguments.authenticate,
                                      executables=arguments.executables,
                                      components=arguments.components,
                                      since=arguments.since,
                                      until=arguments.until,
                                      n_latest=arguments.n_latest,
                                      not_reported=arguments.not_reported)
        for problem in problems:
            print(format_problems(problem, fmt=config.FULL_FMT), '\n')

            if not arguments.force:
                if not ask_yes_no(
                        _('Are you sure you want to delete this problem?')):
                    continue

            problem.delete()
            print(_('Removed'), '\n')
Exemple #7
0
 def run(self, arguments):
     problems = match_get_problems(arguments.patterns,
                                   authenticate=arguments.authenticate,
                                   executables=arguments.executables,
                                   components=arguments.components,
                                   since=arguments.since,
                                   until=arguments.until,
                                   n_latest=arguments.n_latest,
                                   not_reported=arguments.not_reported)
     for problem in problems:
         if hasattr(problem, 'backtrace'):
             print(format_problems(problem, fmt=config.BACKTRACE_FMT))
         else:
             print(_('Problem has no backtrace'))
             if isinstance(problem, Ccpp):
                 if ask_yes_no(_('Start retracing process?')):
                     run_command('retrace', arguments)
                     print(
                         format_problems(problem, fmt=config.BACKTRACE_FMT))
Exemple #8
0
    def download(self, files, download_exact_files=False):
        """
        Downloads rpms shipping given files into a temporary directory

        Arguments:
            file - a list of files to download
            download_exact_files - extract only specified files

        Returns:
            RETURN_OK if all goes well.
            RETURN_FAILURE in case it cannot set up either of the directories.
        """

        # nothing to download?
        if not files:
            return RETURN_FAILURE

        # set up tmp and cache dirs so that we can check free space in both
        retval = self.setup_tmp_dirs()
        if retval != RETURN_OK:
            return retval

        if not self.find_packages_run:
            self.find_packages(files)

        if verbose != 0 or len(self.not_found) != 0:
            print(
                _("Can't find packages for {0} debuginfo files").format(
                    len(self.not_found)))

        if verbose != 0 or len(self.package_files_dict) != 0:
            print(
                _("Packages to download: {0}").format(
                    len(self.package_files_dict)))
            question = _(
                "Downloading {0:.2f}Mb, installed size: {1:.2f}Mb. Continue?") \
                .format(self.todownload_size / (1024 * 1024),
                        self.installed_size / (1024 * 1024))

            if not self.noninteractive and not ask_yes_no(question):
                print(_("Download cancelled by user"))
                return RETURN_CANCEL_BY_USER

            # check if there is enough free space in both tmp and cache
            res = os.statvfs(self.tmpdir)
            tmp_space = float(res.f_bsize * res.f_bavail) / (1024 * 1024)
            if (self.todownload_size / (1024 * 1024)) > tmp_space:
                question = _("Warning: Not enough free space in tmp dir '{0}'"
                             " ({1:.2f}Mb left). Continue?").format(
                                 self.tmpdir, tmp_space)

                if not self.noninteractive and not ask_yes_no(question):
                    print(_("Download cancelled by user"))
                    return RETURN_CANCEL_BY_USER

            res = os.statvfs(self.cachedir)
            cache_space = float(res.f_bsize * res.f_bavail) / (1024 * 1024)
            if (self.installed_size / (1024 * 1024)) > cache_space:
                question = _("Warning: Not enough free space in cache dir "
                             "'{0}' ({1:.2f}Mb left). Continue?").format(
                                 self.cachedir, cache_space)

                if not self.noninteractive and not ask_yes_no(question):
                    print(_("Download cancelled by user"))
                    return RETURN_CANCEL_BY_USER

        progress_observer = DownloadProgress(len(self.package_files_dict))
        self.initialize_progress(progress_observer)

        for pkg, files in self.package_files_dict.items():
            # Download
            package_full_path, err = self.download_package(pkg)

            if err:
                # I observed a zero-length file left on error,
                # which prevents cleanup later. Fix it:
                try:
                    if package_full_path is not None:
                        os.unlink(package_full_path)
                except OSError:
                    pass
                print(_("Downloading package {0} failed").format(pkg))
            else:
                unpack_result = unpack_rpm(package_full_path,
                                           files,
                                           self.tmpdir,
                                           self.cachedir,
                                           exact_files=download_exact_files)

                if unpack_result == RETURN_FAILURE:
                    # recursively delete the temp dir on failure
                    print(_("Unpacking failed, aborting download..."))

                    s = os.stat(self.cachedir)
                    abrt = pwd.getpwnam("abrt")
                    if (s.st_uid != abrt.pw_uid) or (s.st_gid != abrt.pw_gid):
                        print(
                            _("'{0}' must be owned by abrt. "
                              "Please run '# chown -R abrt.abrt {0}' "
                              "to fix the issue.").format(self.cachedir))

                    clean_up(self.tmpdir)
                    return RETURN_FAILURE

                if not self.keeprpms:
                    log1("keeprpms = False, removing %s", package_full_path)
                    os.unlink(package_full_path)

            progress_observer.downloaded_pkgs += 1

        if not self.keeprpms and os.path.exists(self.tmpdir):
            # Was: "All downloaded packages have been extracted, removing..."
            # but it was appearing even if no packages were in fact extracted
            # (say, when there was one package, and it has download error).
            print(_("Removing {0}").format(self.tmpdir))
            try:
                os.rmdir(self.tmpdir)
            except OSError:
                error_msg(
                    _("Can't remove {0}, probably contains an error log").
                    format(self.tmpdir))

        return RETURN_OK
Exemple #9
0
                not_found.append(debuginfo_path)

        # connect our progress update callback
        dnlcb = MyDownloadCallback(total_pkgs)
        self.repos.setProgressBar(dnlcb)
        self.repos.setMirrorFailureCallback(downloadErrorCallback)

        if verbose != 0 or len(not_found) != 0:
            print _("Can't find packages for {0} debuginfo files").format(len(not_found))
        if verbose != 0 or total_pkgs != 0:
            print _("Packages to download: {0}").format(total_pkgs)
            question = _("Downloading {0:.2f}Mb, installed size: {1:.2f}Mb. Continue?").format(
                         todownload_size / (1024*1024),
                         installed_size / (1024*1024)
                        )
            if self.noninteractive == False and not ask_yes_no(question):
                print _("Download cancelled by user")
                return RETURN_CANCEL_BY_USER
            # set up tmp and cache dirs so that we can check free space in both
            retval = self.setup_tmp_dirs()
            if retval != RETURN_OK:
                return retval
            # check if there is enough free space in both tmp and cache
            res = os.statvfs(self.tmpdir)
            tmp_space = float(res.f_bsize * res.f_bavail) / (1024*1024)
            if (todownload_size / (1024*1024)) > tmp_space:
                question = _("Warning: Not enough free space in tmp dir '{0}'"
                             " ({1:.2f}Mb left). Continue?").format(
                    self.tmpdir, tmp_space)
                if not self.noninteractive and not ask_yes_no(question):
                    print _("Download cancelled by user")
Exemple #10
0
    def download(self, files, download_exact_files=False):
        """
        Downloads rpms shipping given files into a temporary directory

        Arguments:
            file - a list of files to download
            download_exact_files - extract only specified files

        Returns:
            RETURN_OK if all goes well.
            RETURN_FAILURE in case it cannot set up either of the directories.
        """

        # nothing to download?
        if not files:
            return RETURN_FAILURE

        # set up tmp and cache dirs so that we can check free space in both
        retval = self.setup_tmp_dirs()
        if retval != RETURN_OK:
            return retval

        print(_("Initializing package manager"))
        self.prepare()
        #if verbose == 0:
        #    # this suppress yum messages about setting up repositories
        #    mute_stdout()

        # This takes some time, let user know what we are doing
        print(_("Setting up repositories"))
        self.initialize_repositories()

        #if verbose == 0:
        #    # re-enable the output to stdout
        #    unmute_stdout()

        print(_("Looking for needed packages in repositories"))
        package_files_dict, not_found, todownload_size, installed_size = self.triage(files)

        if verbose != 0 or len(not_found) != 0:
            print(_("Can't find packages for {0} debuginfo files").format(len(not_found)))

        if verbose != 0 or len(package_files_dict) != 0:
            print(_("Packages to download: {0}").format(len(package_files_dict)))
            question = _(
                "Downloading {0:.2f}Mb, installed size: {1:.2f}Mb. Continue?") \
                .format(todownload_size / (1024 * 1024),
                        installed_size / (1024 * 1024))

            if not self.noninteractive and not ask_yes_no(question):
                print(_("Download cancelled by user"))
                return RETURN_CANCEL_BY_USER

            # check if there is enough free space in both tmp and cache
            res = os.statvfs(self.tmpdir)
            tmp_space = float(res.f_bsize * res.f_bavail) / (1024 * 1024)
            if (todownload_size / (1024 * 1024)) > tmp_space:
                question = _("Warning: Not enough free space in tmp dir '{0}'"
                             " ({1:.2f}Mb left). Continue?").format(
                                 self.tmpdir, tmp_space)

                if not self.noninteractive and not ask_yes_no(question):
                    print(_("Download cancelled by user"))
                    return RETURN_CANCEL_BY_USER

            res = os.statvfs(self.cachedir)
            cache_space = float(res.f_bsize * res.f_bavail) / (1024 * 1024)
            if (installed_size / (1024 * 1024)) > cache_space:
                question = _("Warning: Not enough free space in cache dir "
                             "'{0}' ({1:.2f}Mb left). Continue?").format(
                                 self.cachedir, cache_space)

                if not self.noninteractive and not ask_yes_no(question):
                    print(_("Download cancelled by user"))
                    return RETURN_CANCEL_BY_USER

        progress_observer = DownloadProgress(len(package_files_dict))
        self.initialize_progress(progress_observer)

        for pkg, files in package_files_dict.items():
            # Download
            package_full_path, err = self.download_package(pkg)

            if err:
                # I observed a zero-length file left on error,
                # which prevents cleanup later. Fix it:
                try:
                    os.unlink(package_full_path)
                except OSError:
                    pass
                print(_("Downloading package {0} failed").format(pkg))
            else:
                unpack_result = unpack_rpm(package_full_path, files, self.tmpdir,
                                           self.cachedir, exact_files=download_exact_files)

                if unpack_result == RETURN_FAILURE:
                    # recursively delete the temp dir on failure
                    print(_("Unpacking failed, aborting download..."))

                    s = os.stat(self.cachedir)
                    abrt = pwd.getpwnam("abrt")
                    if (s.st_uid != abrt.pw_uid) or (s.st_gid != abrt.pw_gid):
                        print(_("'{0}' must be owned by abrt. "
                                "Please run '# chown -R abrt.abrt {0}' "
                                "to fix the issue.").format(self.cachedir))

                    clean_up(self.tmpdir)
                    return RETURN_FAILURE

                if not self.keeprpms:
                    log1("keeprpms = False, removing %s", package_full_path)
                    os.unlink(package_full_path)

            progress_observer.downloaded_pkgs += 1

        if not self.keeprpms and os.path.exists(self.tmpdir):
            # Was: "All downloaded packages have been extracted, removing..."
            # but it was appearing even if no packages were in fact extracted
            # (say, when there was one package, and it has download error).
            print(_("Removing {0}").format(self.tmpdir))
            try:
                os.rmdir(self.tmpdir)
            except OSError:
                error_msg(_("Can't remove {0}, probably contains an error log").format(self.tmpdir))

        return RETURN_OK
Exemple #11
0
    def download(self, files, download_exact_files=False):
        """
        Downloads rpms shipping given files into a temporary directory

        Arguments:
            file - a list of files to download
            download_exact_files - extract only specified files

        Returns:
            RETURN_OK if all goes well.
            RETURN_FAILURE in case it cannot set up either of the directories.
        """

        # nothing to download?
        if not files:
            return RETURN_FAILURE

        # set up tmp and cache dirs so that we can check free space in both
        retval = self.setup_tmp_dirs()
        if retval != RETURN_OK:
            return retval

        print(_("Initializing package manager"))
        self.prepare()
        #if verbose == 0:
        #    # this suppress yum messages about setting up repositories
        #    mute_stdout()

        # This takes some time, let user know what we are doing
        print(_("Setting up repositories"))
        self.initialize_repositories()

        #if verbose == 0:
        #    # re-enable the output to stdout
        #    unmute_stdout()

        print(_("Looking for needed packages in repositories"))
        package_files_dict, not_found, todownload_size, installed_size = self.triage(files)

        if verbose != 0 or len(not_found) != 0:
            print(_("Can't find packages for {0} debuginfo files").format(len(not_found)))
        if verbose != 0 or len(package_files_dict) != 0:
            print(_("Packages to download: {0}").format(len(package_files_dict)))
            question = _("Downloading {0:.2f}Mb, installed size: {1:.2f}Mb. Continue?").format(
                         todownload_size / (1024*1024),
                         installed_size / (1024*1024)
                        )
            if self.noninteractive == False and not ask_yes_no(question):
                print(_("Download cancelled by user"))
                return RETURN_CANCEL_BY_USER
            # check if there is enough free space in both tmp and cache
            res = os.statvfs(self.tmpdir)
            tmp_space = float(res.f_bsize * res.f_bavail) / (1024*1024)
            if (todownload_size / (1024*1024)) > tmp_space:
                question = _("Warning: Not enough free space in tmp dir '{0}'"
                             " ({1:.2f}Mb left). Continue?").format(
                    self.tmpdir, tmp_space)
                if not self.noninteractive and not ask_yes_no(question):
                    print(_("Download cancelled by user"))
                    return RETURN_CANCEL_BY_USER
            res = os.statvfs(self.cachedir)
            cache_space = float(res.f_bsize * res.f_bavail) / (1024*1024)
            if (installed_size / (1024*1024)) > cache_space:
                question = _("Warning: Not enough free space in cache dir "
                             "'{0}' ({1:.2f}Mb left). Continue?").format(
                    self.cachedir, cache_space)
                if not self.noninteractive and not ask_yes_no(question):
                    print(_("Download cancelled by user"))
                    return RETURN_CANCEL_BY_USER

        progress_observer = DownloadProgress(len(package_files_dict))
        self.initialize_progress(progress_observer)

        for pkg, files in package_files_dict.items():
            # Download
            package_full_path, err = self.download_package(pkg)

            if err:
                # I observed a zero-length file left on error,
                # which prevents cleanup later. Fix it:
                try:
                    os.unlink(package_full_path)
                except OSError:
                    pass
                print(_("Downloading package {0} failed").format(pkg))
            else:
                unpack_result = unpack_rpm(package_full_path, files, self.tmpdir,
                                           self.cachedir, exact_files=download_exact_files)

                if unpack_result == RETURN_FAILURE:
                    # recursively delete the temp dir on failure
                    print(_("Unpacking failed, aborting download..."))
                    clean_up(self.tmpdir)
                    return RETURN_FAILURE

                if not self.keeprpms:
                    log1("keeprpms = False, removing %s", package_full_path)
                    os.unlink(package_full_path)

            progress_observer.downloaded_pkgs += 1

        if not self.keeprpms and os.path.exists(self.tmpdir):
            # Was: "All downloaded packages have been extracted, removing..."
            # but it was appearing even if no packages were in fact extracted
            # (say, when there was one package, and it has download error).
            print(_("Removing {0}").format(self.tmpdir))
            try:
                os.rmdir(self.tmpdir)
            except OSError:
                error_msg(_("Can't remove {0}, probably contains an error log").format(self.tmpdir))

        return RETURN_OK