[PATCH 3/3] amavisd: recognize rar archives with encrypted metadata
Philipp Gesang
philipp.gesang at intra2net.com
Mon Sep 11 14:08:06 CEST 2017
For RAR archives created with the “hp” switch, file listings are
impossible and unrar expects being given a password. Determine
that we’re dealing with an encrypted file and set the flags
accordingly.
Signed-off-by: Philipp Gesang <philipp.gesang at intra2net.com>
---
amavisd | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/amavisd b/amavisd
index 1f975c9..c400002 100755
--- a/amavisd
+++ b/amavisd
@@ -32266,7 +32266,7 @@ sub do_unrar($$$;$) {
# unrar exit codes: SUCCESS=0, WARNING=1, FATAL_ERROR=2, CRC_ERROR=3,
# LOCK_ERROR=4, WRITE_ERROR=5, OPEN_ERROR=6, USER_ERROR=7, MEMORY_ERROR=8,
# CREATE_ERROR=9, USER_BREAK=255
- my(@list); my $hypcount = 0; my $encryptedcount = 0;
+ my(@list); my $hypcount = 0; my $encryptedcount = 0; my $encryptedmeta = 0;
my $lcnt = 0; my $member_name; my $bytes = 0; my $last_line;
my $item_num = 0; my $parent_placement = $part->mime_placement;
my $retval = 1; my $fn = $part->full_name; my($proc_fh,$pid);
@@ -32288,6 +32288,12 @@ sub do_unrar($$$;$) {
} elsif ($ln =~ /^------/) {
$hypcount++;
last if $hypcount >= 2;
+ } elsif ($hypcount < 1 &&
+ $ln =~ /^Details: RAR 5, encrypted headers/) {
+ do_log(4,"do_unrar: %s", $ln);
+ $part->attributes_add('U','C');
+ $encryptedmeta = 1;
+ last;
} elsif ($hypcount < 1 && $ln =~ /^Encrypted file:/) {
do_log(4,"do_unrar: %s", $ln);
$part->attributes_add('U','C');
@@ -32375,6 +32381,10 @@ sub do_unrar($$$;$) {
} elsif (proc_status_ok($rv,$err, 1) && @list && $bytes > 0) {
# WARNING, probably still ok
do_log(4,"do_unrar: warning, %s", exit_status_str($rv,$err));
+ } elsif ($encryptedmeta == 1) {
+ do_log(1,
+ "do_unrar: %s, archive metadata is encrypted, archive retained",
+ $part->base_name);
} elsif (!proc_status_ok($rv,$err)) {
die("can't get a list of archive members: " .
exit_status_str($rv,$err) ."; ".$last_line);
--
2.11.1
More information about the amavis-users
mailing list