From 8c1f8aa016faee3fa151d134c3544b2dd5bab832 Mon Sep 17 00:00:00 2001
From: Ján Sáreník <jajomojo@gmail.com>
Date: Sat, 5 Jun 2021 18:24:57 +0200
Subject: run-parts: permit dot later in file name
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
See https://gist.github.com/andyshinn/3ae01fa13cb64c9d36e7#gistcomment-2044506
To test:
mkdir /tmp/testrp
printf "#!/bin/sh\necho test\n" > /tmp/testrp/test.sh
chmod a+x /tmp/testrp/*
busybox run-parts /tmp/testrp
test
mv /tmp/testrp/test.sh /tmp/testrp/.test.sh
busybox run-parts /tmp/testrp
# no output
function old new delta
act 190 200 +10
Signed-off-by: Ján Sáreník <jajomojo@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
---
debianutils/run_parts.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
(limited to 'debianutils')
diff --git a/debianutils/run_parts.c b/debianutils/run_parts.c
index 585a4b58f..f528c88ff 100644
--- a/debianutils/run_parts.c
+++ b/debianutils/run_parts.c
@@ -113,13 +113,24 @@ enum {
};
/* Is this a valid filename (upper/lower alpha, digits,
- * underscores, and hyphens only?)
+ * underscores, hyphens, and non-leading dots only?)
*/
static bool invalid_name(const char *c)
{
c = bb_basename(c);
- while (*c && (isalnum(*c) || *c == '_' || *c == '-'))
+ if (*c == '.')
+ return *c;
+
+ /* Debian run-parts 4.8.3, manpage:
+ * "...the names must consist entirely of ASCII letters,
+ * ASCII digits, ASCII underscores, and ASCII minus-hyphens.
+ * However, the name must not begin with a period."
+ * The last sentence is a giveaway that something is fishy
+ * (why mention leading dot if dots are not allowed anyway?).
+ * Yes, you guessed it right: in fact non-leading dots ARE allowed.
+ */
+ while (isalnum(*c) || *c == '_' || *c == '-' || *c == '.')
c++;
return *c; /* TRUE (!0) if terminating NUL is not reached */
--
cgit v1.2.3-55-g6feb