It works, looks good to me except one small thing.

You can use g_list_search_full(list, VALUE, (GCompareFunc)g_strcmp) instead of 
own is_string_in_list(list, VALUE).

On Wednesday, February 20, 2013 03:50:22 PM Jiri Moskovcak wrote:
> ---
>  src/daemon/abrt-action-save-package-data.c    | 50
> +++++++++++++++++++++------ src/daemon/abrt-action-save-package-data.conf |
>  3 ++
>  2 files changed, 43 insertions(+), 10 deletions(-)
> 
> diff --git a/src/daemon/abrt-action-save-package-data.c
> b/src/daemon/abrt-action-save-package-data.c index 8921b6c..8060d16 100644
> --- a/src/daemon/abrt-action-save-package-data.c
> +++ b/src/daemon/abrt-action-save-package-data.c
> @@ -25,6 +25,7 @@ static GList *settings_setOpenGPGPublicKeys = NULL;
>  static GList *settings_setBlackListedPkgs = NULL;
>  static GList *settings_setBlackListedPaths = NULL;
>  static bool   settings_bProcessUnpackaged = false;
> +static GList *settings_Interpreters = NULL;
> 
>  static GList *parse_list(const char* list)
>  {
> @@ -88,6 +89,13 @@ static void ParseCommon(map_string_h *settings, const
> char *conf_filename) g_hash_table_remove(settings, "ProcessUnpackaged");
>      }
> 
> +    value = g_hash_table_lookup(settings, "Interpreters");
> +    if (value)
> +    {
> +        settings_Interpreters = parse_list(value);
> +        g_hash_table_remove(settings, "Interpreters");
> +    }
> +
>      GHashTableIter iter;
>      char *name;
>      /*char *value; - already declared */
> @@ -181,6 +189,17 @@ static bool is_path_blacklisted(const char *path)
>      return false;
>  }
> 
> +static bool is_string_in_list(GList *list, const char *string)
> +{
> +    GList *li;
> +    for (li = list; li != NULL; li = g_list_next(li))
> +    {
> +        if (strcmp((char *)li->data, string) == 0)
> +            return true;
> +    }
> +    return false;
> +}
> +
>  static struct pkg_envra *get_script_name(const char *cmdline, char
> **executable) {
>  // TODO: we don't verify that python executable is not modified
> @@ -282,12 +301,27 @@ static int SavePackageDescriptionToDebugDump(const
> char *dump_dir_name) else
>          basename = executable;
> 
> -    if (!strcmp(basename, "python")
> -        || !strcmp(basename, "perl"))
> +    /* if basename is known interpreter, we want to blame the running
> script +     * not the interpreter
> +     */
> +    if (is_string_in_list(settings_Interpreters, basename))
>      {
>          struct pkg_envra *script_pkg = get_script_name(cmdline,
> &executable); if (!script_pkg)
> -            goto ret;
> +        {
> +            /* none or unknown script, and config says we don't care about
> +             * unpackaged things
> +             */
> +            if (!settings_bProcessUnpackaged)
> +                goto ret;
> +
> +            /* unpackaged script, but the settings says we want to keep it
> +             * bz plugin wont allow to report this anyway, because
> component +             * is missing, so there is no reason to mark it as
> not_reportable +             * someone might want to use abrt to report it
> using ftp +             */
> +            goto ret0;
> +        }
> 
>          free_pkg_envra(pkg_name);
>          pkg_name = script_pkg;
> @@ -296,15 +330,11 @@ static int SavePackageDescriptionToDebugDump(const
> char *dump_dir_name) package_short_name = xasprintf("%s",
> pkg_name->p_name);
>      VERB2 log("Package:'%s' short:'%s'", pkg_name->p_nvr,
> package_short_name);
> 
> -    GList *li;
> 
> -    for (li = settings_setBlackListedPkgs; li != NULL; li =
> g_list_next(li)) +    if (is_string_in_list(settings_setBlackListedPkgs,
> package_short_name)) {
> -        if (strcmp((char*)li->data, package_short_name) == 0)
> -        {
> -            log("Blacklisted package '%s'", package_short_name);
> -            goto ret; /* return 1 (failure) */
> -        }
> +        log("Blacklisted package '%s'", package_short_name);
> +        goto ret; /* return 1 (failure) */
>      }
> 
>      if (settings_bOpenGPGCheck)
> diff --git a/src/daemon/abrt-action-save-package-data.conf
> b/src/daemon/abrt-action-save-package-data.conf index 643259a..3d35bb6
> 100644
> --- a/src/daemon/abrt-action-save-package-data.conf
> +++ b/src/daemon/abrt-action-save-package-data.conf
> @@ -16,3 +16,6 @@ ProcessUnpackaged = no
>  # Blacklisted executable paths (shell patterns)
>  #
>  BlackListedPaths = /usr/share/doc/*, */example*, /usr/bin/nspluginviewer,
> /usr/lib/xulrunner-*/plugin-container +
> +# interpreters names
> +Interpreters = python2, python2.7, python, python3, python3.3, perl,
> perl5.16.2

Reply via email to