dispatcher: minor cleanup ignoring dispatcher scripts by filename
authorThomas Haller <thaller@redhat.com>
Sat, 13 Feb 2016 14:23:21 +0000 (15:23 +0100)
committerThomas Haller <thaller@redhat.com>
Sun, 21 Feb 2016 17:31:39 +0000 (18:31 +0100)
callouts/nm-dispatcher.c

index 440f01a..755d581 100644 (file)
@@ -495,7 +495,13 @@ check_permissions (struct stat *s, const char **out_error_msg)
 static gboolean
 check_filename (const char *file_name)
 {
-       char *bad_suffixes[] = { "~", ".rpmsave", ".rpmorig", ".rpmnew", NULL };
+       static const char *bad_suffixes[] = {
+               "~",
+               ".rpmsave",
+               ".rpmorig",
+               ".rpmnew",
+               ".swp",
+       };
        char *tmp;
        guint i;
 
@@ -503,12 +509,12 @@ check_filename (const char *file_name)
 
        if (file_name[0] == '.')
                return FALSE;
-       for (i = 0; bad_suffixes[i]; i++) {
+       for (i = 0; i < G_N_ELEMENTS (bad_suffixes); i++) {
                if (g_str_has_suffix (file_name, bad_suffixes[i]))
                        return FALSE;
        }
        tmp = g_strrstr (file_name, ".dpkg-");
-       if (tmp && (tmp == strrchr (file_name, '.')))
+       if (tmp && !strchr (&tmp[1], '.'))
                return FALSE;
        return TRUE;
 }