daemon: reject shell-active hook expansions

(cherry picked from commit 00160f76b8)
This commit is contained in:
Andrew Tridgell committed 2026-08-02 21:28:47 +10:00
1 parent 592d438ecf
commit 30bd52e0cd
1 file changed
+2 -3
+2 -3
View File
@@ -175,14 +175,13 @@ enum shell_quote_context {
* context-aware escaping is correct for exactly one level of shell parsing,
* and a hook such as `sh -c '... %RSYNC_USER_NAME% ...'` re-parses the word in
* a second shell that sees the value bare. Peer-supplied values carrying any
* of these are refused instead. Word-splitting and glob characters are left
* alone: they cannot execute anything, and paths legitimately contain them. */
* of these are refused instead. */
static int shell_unsafe_value(const char *val)
{
const char *s;
for (s = val; *s; s++) {
if (strchr("'\"`$\\;&|<>()", *s)
if (strchr("'\"`$\\;&|<>()*?[]# ", *s)
|| (unsigned char)*s < 0x20 || (unsigned char)*s == 0x7f)
return 1;
}