Blob Blame History Raw
From 19be7214e0da708ce3491a039a23b4d2c5ba1b92 Mon Sep 17 00:00:00 2001
From: Matyas Selmeci <matyas@cs.wisc.edu>
Date: Thu, 2 Nov 2017 15:58:16 -0500
Subject: [PATCH 1/3] Do not ignore config.d files with a . in the name

This fixes a regression where files like
`/etc/gridftp.d/gridftp-hdfs.conf` were getting ignored.  Since the
intent of the original change was to keep .rpmnew and .rpmsave files
from being read, search specifically for `.rpm` instead.
---
 globus_i_gfs_config.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/globus_i_gfs_config.c b/globus_i_gfs_config.c
index eace237b42..faed95b583 100644
--- a/globus_i_gfs_config.c
+++ b/globus_i_gfs_config.c
@@ -493,8 +493,8 @@ static const globus_l_gfs_config_option_t option_list[] =
  {"config_dir", "config_dir", NULL, "C", NULL, GLOBUS_L_GFS_CONFIG_STRING, 0, NULL,
      "Path to directory holding configuration files that should be loaded. Files "
      "will be loaded in alphabetical order, and in the event of duplicate parameters "
-     "the last loaded file will take precedence.  Files with a '.' in the name "
-     "(file.bak, file.rpmsave, etc.) will be ignored.  Note that the main "
+     "the last loaded file will take precedence.  Backup files and files created by "
+     "package updates (e.g. file.rpmsave) will be ignored.  Note that the main "
      "configuration file, if one exists, will always be loaded last.", NULL, NULL,GLOBUS_FALSE, NULL},
  {"config_base_path", "config_base_path", NULL, "config-base-path", NULL, GLOBUS_L_GFS_CONFIG_STRING, 0, NULL,
      "Base path to use when config and log path options are not full paths. "
@@ -1160,9 +1160,10 @@ globus_l_gfs_config_load_config_dir(
         {
             char *                      full_path;
             
-            /* skip any file with a '.': hidden, . or ..
-             and files like .rpm*, .deb*, .bak*, etc */
-            if(strchr(entries[i]->d_name, '.') != NULL)
+            /* skip hidden and . or ..
+             and files possibly created by updates .rpmsave or .rpmnew */
+            if(*entries[i]->d_name == '.' ||
+                strstr(entries[i]->d_name, '.rpm') != NULL)
             {
                 free(entries[i]);
                 continue;

From 7ef0c5cf702cffcc2003fc5d122cf9687fab1b4b Mon Sep 17 00:00:00 2001
From: Matyas Selmeci <matyas@cs.wisc.edu>
Date: Fri, 3 Nov 2017 10:44:38 -0500
Subject: [PATCH 2/3] Be more selective in what config files we skip

---
 globus_i_gfs_config.c | 42 ++++++++++++++++++++++++++------
 1 file changed, 35 insertions(+), 7 deletions(-)

diff --git a/globus_i_gfs_config.c b/globus_i_gfs_config.c
index faed95b583..57255f3291 100644
--- a/globus_i_gfs_config.c
+++ b/globus_i_gfs_config.c
@@ -1159,19 +1159,47 @@ globus_l_gfs_config_load_config_dir(
         for(i = 0; i < count && result == GLOBUS_SUCCESS; i++)
         {
             char *                      full_path;
-            
-            /* skip hidden and . or ..
-             and files possibly created by updates .rpmsave or .rpmnew */
-            if(*entries[i]->d_name == '.' ||
-                strstr(entries[i]->d_name, '.rpm') != NULL)
+            char *                      filename;
+            char *                      fileext;
+            char *                      backupsuffix;
+
+            filename = entries[i]->d_name;
+
+
+            /* skip windows backup files (.bak) and backups created
+               by package managers (.rpmsave, .rpmnew, etc.) */
+            fileext = strrchr(filename, '.');
+            if(fileext &&
+                (! strcmp(fileext, ".bak")       ||
+                 ! strcmp(fileext, ".dpkg-dist") ||
+                 ! strcmp(fileext, ".dpkg-new")  ||
+                 ! strcmp(fileext, ".dpkg-old")  ||
+                 ! strcmp(fileext, ".rpmnew")    ||
+                 ! strcmp(fileext, ".rpmsave")))
             {
                 free(entries[i]);
                 continue;
             }
-            
+
+            /* skip unix backup files */
+            backupsuffix = strrchr(filename, '~');
+            if(backupsuffix && ! strcmp(backupsuffix, "~"))
+            {
+                free(entries[i]);
+                continue;
+            }
+
+            /* skip unix hidden files */
+            if(*filename == '.')
+            {
+                free(entries[i]);
+                continue;
+            }
+
+
             full_path = malloc(PATH_MAX);
             rc = snprintf(
-                full_path, PATH_MAX, "%s/%s", conf_dir, entries[i]->d_name);
+                full_path, PATH_MAX, "%s/%s", conf_dir, filename);
 
             if(!envs_only)
             {

From ba117479a0facf4a485d6953a8d73680c679fd08 Mon Sep 17 00:00:00 2001
From: Matyas Selmeci <matyas@cs.wisc.edu>
Date: Fri, 3 Nov 2017 11:56:52 -0500
Subject: [PATCH 3/3] Update manual with new config.d ignore rules

---
 globus-gridftp-server.8 | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/globus-gridftp-server.8 b/globus-gridftp-server.8
index 848ae8b300..6e6c29c00d 100644
--- a/globus-gridftp-server.8
+++ b/globus-gridftp-server.8
@@ -961,9 +961,8 @@ Path to main configuration file that should be loaded\&. Otherwise will attempt
 .PP
 \fB\-C string\fR
 .RS 4
-Path to directory holding configuration files that should be loaded\&. Files will be loaded in alphabetical order, and in the event of duplicate parameters the last loaded file will take precedence\&. Files with a
-\fI\&.\fR
-in the name (file\&.bak, file\&.rpmsave, etc\&.) will be ignored\&. Note that the main configuration file, if one exists, will always be loaded last\&.
+Path to directory holding configuration files that should be loaded\&. Files will be loaded in alphabetical order, and in the event of duplicate parameters the last loaded file will take precedence\&. Backup files and files created by package updates (e.g. file\&.rpmsave) will be ignored\&.
+Note that the main configuration file, if one exists, will always be loaded last\&.
 .sp
 This option can also be set in the configuration file as
 config_dir\&.