/[gentoo-x86]/net-misc/networkmanager/files/networkmanager-0.8.2-fix-tempfiles.patch
Gentoo

Contents of /net-misc/networkmanager/files/networkmanager-0.8.2-fix-tempfiles.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Tue Aug 23 23:17:09 2011 UTC (3 years, 3 months ago) by nirbheek
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
FILE REMOVED
Bump for the 0.9.0 release, go forth and test. Also, remove old ebuilds and unused patches.

(Portage version: 2.2.0_alpha51/cvs/Linux x86_64)

1 From 0376f6b1ceda64e279e64bfb37ab67f0c36478b6 Mon Sep 17 00:00:00 2001
2 From: Jiří Klimeš <jklimes@redhat.com>
3 Date: Wed, 10 Nov 2010 15:21:25 +0000
4 Subject: keyfile: ignore temporary files (bgo #602868)
5
6 Ignore temporary files created by vim editor and temporary files created
7 internally by g_file_set_contents() (mkstemp()) when writing connections.
8 ---
9 diff --git a/system-settings/plugins/keyfile/Makefile.am b/system-settings/plugins/keyfile/Makefile.am
10 index c519adc..128775e 100644
11 --- a/system-settings/plugins/keyfile/Makefile.am
12 +++ b/system-settings/plugins/keyfile/Makefile.am
13 @@ -16,6 +16,8 @@ libkeyfile_io_la_SOURCES = \
14 writer.c \
15 writer.h \
16 errors.c \
17 + utils.c \
18 + utils.h \
19 common.h
20
21 libkeyfile_io_la_CPPFLAGS = \
22 diff --git a/system-settings/plugins/keyfile/common.h b/system-settings/plugins/keyfile/common.h
23 index 7d94a70..6c8f9ce 100644
24 --- a/system-settings/plugins/keyfile/common.h
25 +++ b/system-settings/plugins/keyfile/common.h
26 @@ -23,6 +23,9 @@
27
28 #include <glib.h>
29
30 +#define SWP_TAG ".swp"
31 +#define SWPX_TAG ".swpx"
32 +
33 #define KEYFILE_PLUGIN_NAME "keyfile"
34 #define KEYFILE_PLUGIN_INFO "(c) 2007 - 2010 Red Hat, Inc. To report bugs please use the NetworkManager mailing list."
35
36 diff --git a/system-settings/plugins/keyfile/plugin.c b/system-settings/plugins/keyfile/plugin.c
37 index f57a4b6..5a927ce 100644
38 --- a/system-settings/plugins/keyfile/plugin.c
39 +++ b/system-settings/plugins/keyfile/plugin.c
40 @@ -39,6 +39,7 @@
41 #include "nm-keyfile-connection.h"
42 #include "writer.h"
43 #include "common.h"
44 +#include "utils.h"
45
46 #define CONF_FILE SYSCONFDIR "/NetworkManager/NetworkManager.conf"
47 #define OLD_CONF_FILE SYSCONFDIR "/NetworkManager/nm-system-settings.conf"
48 @@ -89,6 +90,9 @@ read_connections (NMSystemConfigInterface *config)
49 NMKeyfileConnection *connection;
50 char *full_path;
51
52 + if (utils_should_ignore_file (item))
53 + continue;
54 +
55 full_path = g_build_filename (KEYFILE_DIR, item, NULL);
56 PLUGIN_PRINT (KEYFILE_PLUGIN_NAME, "parsing %s ... ", item);
57 connection = nm_keyfile_connection_new (full_path, &error);
58 @@ -192,6 +196,11 @@ dir_changed (GFileMonitor *monitor,
59 GError *error = NULL;
60
61 name = g_file_get_path (file);
62 + if (utils_should_ignore_file (name)) {
63 + g_free (name);
64 + return;
65 + }
66 +
67 connection = g_hash_table_lookup (priv->hash, name);
68
69 switch (event_type) {
70 diff --git a/system-settings/plugins/keyfile/utils.c b/system-settings/plugins/keyfile/utils.c
71 new file mode 100644
72 index 0000000..de64f79
73 --- a/dev/null
74 +++ b/system-settings/plugins/keyfile/utils.c
75 @@ -0,0 +1,97 @@
76 +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
77 +/* NetworkManager system settings service
78 + *
79 + * This program is free software; you can redistribute it and/or modify
80 + * it under the terms of the GNU General Public License as published by
81 + * the Free Software Foundation; either version 2 of the License, or
82 + * (at your option) any later version.
83 + *
84 + * This program is distributed in the hope that it will be useful,
85 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
86 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
87 + * GNU General Public License for more details.
88 + *
89 + * You should have received a copy of the GNU General Public License along
90 + * with this program; if not, write to the Free Software Foundation, Inc.,
91 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
92 + *
93 + * (C) Copyright 2010 Red Hat, Inc.
94 + */
95 +
96 +#include <glib.h>
97 +#include <stdlib.h>
98 +#include <string.h>
99 +#include "utils.h"
100 +
101 +
102 +static const char temp_letters[] =
103 +"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
104 +
105 +/*
106 + * Check '.[a-zA-Z0-9]{6}' file suffix used for temporary files by g_file_set_contents() (mkstemp()).
107 + */
108 +static gboolean
109 +check_mkstemp_suffix (const char *path)
110 +{
111 + const char *ptr;
112 +
113 + g_return_val_if_fail (path != NULL, FALSE);
114 +
115 + /* Matches *.[a-zA-Z0-9]{6} suffix of mkstemp()'s temporary files */
116 + ptr = strrchr (path, '.');
117 + if (ptr && (strspn (ptr + 1, temp_letters) == 6) && (! ptr[7]))
118 + return TRUE;
119 + return FALSE;
120 +}
121 +
122 +static gboolean
123 +check_prefix (const char *base, const char *tag)
124 +{
125 + int len, tag_len;
126 +
127 + g_return_val_if_fail (base != NULL, TRUE);
128 + g_return_val_if_fail (tag != NULL, TRUE);
129 +
130 + len = strlen (base);
131 + tag_len = strlen (tag);
132 + if ((len > tag_len) && !strncasecmp (base, tag, tag_len))
133 + return TRUE;
134 + return FALSE;
135 +}
136 +
137 +static gboolean
138 +check_suffix (const char *base, const char *tag)
139 +{
140 + int len, tag_len;
141 +
142 + g_return_val_if_fail (base != NULL, TRUE);
143 + g_return_val_if_fail (tag != NULL, TRUE);
144 +
145 + len = strlen (base);
146 + tag_len = strlen (tag);
147 + if ((len > tag_len) && !strcasecmp (base + len - tag_len, tag))
148 + return TRUE;
149 + return FALSE;
150 +}
151 +
152 +gboolean
153 +utils_should_ignore_file (const char *filename)
154 +{
155 + char *base;
156 + gboolean ignore = FALSE;
157 +
158 + g_return_val_if_fail (filename != NULL, TRUE);
159 +
160 + base = g_path_get_basename (filename);
161 + g_return_val_if_fail (base != NULL, TRUE);
162 +
163 + /* Ignore files with certain patterns */
164 + if ( (check_prefix (base, ".") && check_suffix (base, SWP_TAG)) /* vim temporary files: .filename.swp */
165 + || (check_prefix (base, ".") && check_suffix (base, SWPX_TAG)) /* vim temporary files: .filename.swpx */
166 + || check_mkstemp_suffix (base)) /* temporary files created by mkstemp() */
167 + ignore = TRUE;
168 +
169 + g_free (base);
170 + return ignore;
171 +}
172 +
173 diff --git a/system-settings/plugins/keyfile/utils.h b/system-settings/plugins/keyfile/utils.h
174 new file mode 100644
175 index 0000000..3c1a610
176 --- a/dev/null
177 +++ b/system-settings/plugins/keyfile/utils.h
178 @@ -0,0 +1,30 @@
179 +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
180 +/* NetworkManager system settings service
181 + *
182 + * This program is free software; you can redistribute it and/or modify
183 + * it under the terms of the GNU General Public License as published by
184 + * the Free Software Foundation; either version 2 of the License, or
185 + * (at your option) any later version.
186 + *
187 + * This program is distributed in the hope that it will be useful,
188 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
189 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
190 + * GNU General Public License for more details.
191 + *
192 + * You should have received a copy of the GNU General Public License along
193 + * with this program; if not, write to the Free Software Foundation, Inc.,
194 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
195 + *
196 + * (C) Copyright 2010 Red Hat, Inc.
197 + */
198 +
199 +#ifndef _UTILS_H_
200 +#define _UTILS_H_
201 +
202 +#include <glib.h>
203 +#include "common.h"
204 +
205 +gboolean utils_should_ignore_file (const char *filename);
206 +
207 +#endif /* _UTILS_H_ */
208 +
209 --
210 cgit v0.8.3-6-g21f6

  ViewVC Help
Powered by ViewVC 1.1.20