From 591586619cf78f8a0e00cd5d2f8166831799c8b8 Mon Sep 17 00:00:00 2001 From: Tom Hale Date: Tue, 22 Apr 2025 01:11:13 +0200 Subject: [PATCH 1/3] ssh_filter_btrbk.sh: support zstd `--long[=#] --adapt` Allow for `zstd`-specific options to be set: - `stream_compress_long` - `stream_compress_adapt` --- ssh_filter_btrbk.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ssh_filter_btrbk.sh b/ssh_filter_btrbk.sh index 0817563..7234311 100755 --- a/ssh_filter_btrbk.sh +++ b/ssh_filter_btrbk.sh @@ -78,8 +78,8 @@ reject_filtered_cmd() path_match="(${path_match}|${path_match_legacy})" if [ -n "${allow_compress}" ]; then - decompress_match="(${compress_list}) -d -c( -[pT][0-9]+)?" - compress_match="(${compress_list}) -c( -[0-9])?( -[pT][0-9]+)?" + decompress_match="(${compress_list}) -d -c( -[pT][0-9]+)?( --long(=[0-9]+)?)?( --adapt)?" + compress_match="(${compress_list}) -c( -[0-9])?( -[pT][0-9]+)?( --long(=[0-9]+)?)?( --adapt)?" else decompress_match= compress_match= @@ -102,12 +102,12 @@ reject_filtered_cmd() # when an error occurred. allow_stream_match="^${stream_in_match}${allow_cmd_match}${stream_out_match}" - if printf '%s' "${SSH_ORIGINAL_COMMAND}" | grep -E "${allow_stream_match}" >/dev/null 2>/dev/null; then + if printf '%s' "${SSH_ORIGINAL_COMMAND}" | grep -E -- "${allow_stream_match}" >/dev/null 2>/dev/null; then return 0 fi exact_cmd_match="^(${allow_exact_list})$"; - if printf '%s' "${SSH_ORIGINAL_COMMAND}" | grep -E "${exact_cmd_match}" >/dev/null 2>/dev/null; then + if printf '%s' "${SSH_ORIGINAL_COMMAND}" | grep -E -- "${exact_cmd_match}" >/dev/null 2>/dev/null; then return 0 fi From e68430cbe8083478d1781df99f9445beb2038bc9 Mon Sep 17 00:00:00 2001 From: Tom Hale Date: Tue, 22 Apr 2025 03:21:02 +0200 Subject: [PATCH 2/3] Use grep -q rather than producing output to /dev/null --- ssh_filter_btrbk.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ssh_filter_btrbk.sh b/ssh_filter_btrbk.sh index 7234311..be9eb96 100755 --- a/ssh_filter_btrbk.sh +++ b/ssh_filter_btrbk.sh @@ -102,12 +102,12 @@ reject_filtered_cmd() # when an error occurred. allow_stream_match="^${stream_in_match}${allow_cmd_match}${stream_out_match}" - if printf '%s' "${SSH_ORIGINAL_COMMAND}" | grep -E -- "${allow_stream_match}" >/dev/null 2>/dev/null; then + if printf '%s' "${SSH_ORIGINAL_COMMAND}" | grep -Eq -- "${allow_stream_match}"; then return 0 fi exact_cmd_match="^(${allow_exact_list})$"; - if printf '%s' "${SSH_ORIGINAL_COMMAND}" | grep -E -- "${exact_cmd_match}" >/dev/null 2>/dev/null; then + if printf '%s' "${SSH_ORIGINAL_COMMAND}" | grep -Eq -- "${exact_cmd_match}"; then return 0 fi From 03c1d7fb1ae6e483b5472cdb384b48cd6c315e88 Mon Sep 17 00:00:00 2001 From: Tom Hale Date: Fri, 25 Apr 2025 09:59:17 +0200 Subject: [PATCH 3/3] Allow 2 digits as argument to compressor's `-c` Support compression `-c` argument with more than one digit (eg zstd compression levels 10 to 22) --- ssh_filter_btrbk.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ssh_filter_btrbk.sh b/ssh_filter_btrbk.sh index be9eb96..b9b4a36 100755 --- a/ssh_filter_btrbk.sh +++ b/ssh_filter_btrbk.sh @@ -79,7 +79,7 @@ reject_filtered_cmd() if [ -n "${allow_compress}" ]; then decompress_match="(${compress_list}) -d -c( -[pT][0-9]+)?( --long(=[0-9]+)?)?( --adapt)?" - compress_match="(${compress_list}) -c( -[0-9])?( -[pT][0-9]+)?( --long(=[0-9]+)?)?( --adapt)?" + compress_match="(${compress_list}) -c( -[0-9]{1,2})?( -[pT][0-9]+)?( --long(=[0-9]+)?)?( --adapt)?" else decompress_match= compress_match=