ifcfg-rh: ignore temporary files with ';[a-fA-F0-9]{8}' suffix created by rpm (rh #598203)

This commit is contained in:
Jiří Klimeš 2010-11-02 12:15:54 +01:00
parent 4501e33b85
commit 6e067a9d2b
2 changed files with 26 additions and 4 deletions

View file

@ -15,7 +15,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* (C) Copyright 2008 - 2009 Red Hat, Inc.
* (C) Copyright 2008 - 2010 Red Hat, Inc.
*/
#ifndef __COMMON_H__
@ -39,7 +39,7 @@
#define IFCFG_DIR SYSCONFDIR"/sysconfig/network-scripts"
#define IFCFG_PLUGIN_NAME "ifcfg-rh"
#define IFCFG_PLUGIN_INFO "(c) 2007 - 2008 Red Hat, Inc. To report bugs please use the NetworkManager mailing list."
#define IFCFG_PLUGIN_INFO "(c) 2007 - 2010 Red Hat, Inc. To report bugs please use the NetworkManager mailing list."
#define TYPE_ETHERNET "Ethernet"
#define TYPE_WIRELESS "Wireless"

View file

@ -15,7 +15,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* (C) Copyright 2008 - 2009 Red Hat, Inc.
* (C) Copyright 2008 - 2010 Red Hat, Inc.
*/
#include <glib.h>
@ -115,6 +115,27 @@ utils_hexstr2bin (const char *hex, size_t len)
/* End from hostap */
/*
* Check ';[a-fA-F0-9]{8}' file suffix used for temporary files by rpm when
* installing packages.
*
* Implementation taken from upstart.
*/
static gboolean
check_rpm_temp_suffix (const char *path)
{
const char *ptr;
g_return_val_if_fail (path != NULL, FALSE);
/* Matches *;[a-fA-F0-9]{8}; used by rpm */
ptr = strrchr (path, ';');
if (ptr && (strspn (ptr + 1, "abcdefABCDEF0123456789") == 8)
&& (! ptr[9]))
return TRUE;
return FALSE;
}
static gboolean
check_suffix (const char *base, const char *tag)
{
@ -162,7 +183,8 @@ utils_should_ignore_file (const char *filename, gboolean only_ifcfg)
&& !check_suffix (base, REJ_TAG)
&& !check_suffix (base, RPMNEW_TAG)
&& !check_suffix (base, AUGNEW_TAG)
&& !check_suffix (base, AUGTMP_TAG))
&& !check_suffix (base, AUGTMP_TAG)
&& !check_rpm_temp_suffix (base))
ignore = FALSE;
g_free (base);