commit:     604df91aa544b65a6630b281b8a91d811c24e3f6
Author:     Matthew White <mehw.is.me <AT> inventati <DOT> org>
AuthorDate: Sun Jan  7 06:10:01 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Jan  8 12:32:27 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=604df91a

read_repos_conf: reject ~ postfixed files (aka backup files)

* main.c (read_repos_conf): Exclude backup files (aka files with ~ as
  postfix) from processing when reading the repos_conf directory.

The old behaviour was to process any file found in repos_conf (i.e.
/etc/portage/repos.conf/*), except those beginning with '.'.  This
meant that '.', '..', and '.file' are rejected, but 'file.conf~' is
accepted. Since 'file.conf~' is a backup file, by default it should
rather not be processed.

Bug: https://bugs.gentoo.org/643820
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/main.c b/main.c
index b118ab8..b11fe83 100644
--- a/main.c
+++ b/main.c
@@ -513,6 +513,10 @@ read_repos_conf(const char *configroot, const char 
*repos_conf)
                        if (name[0] == '.')
                                continue;
 
+                       /* Exclude backup files (aka files with ~ as postfix). 
*/
+                       if (name[0] != '\0' && name[strlen(name) - 1] == '~')
+                               continue;
+
 #ifdef DT_UNKNOWN
                        if (confs[i]->d_type != DT_UNKNOWN &&
                            confs[i]->d_type != DT_REG &&

Reply via email to