Re: How do you change the file decoder in amavisd-new?

Dominic Raferd <[email protected]>
Newsgroups gmane.mail.virus.amavis.user
Message-ID <[email protected]>
On 29/08/2021 04:03, Nick Tait wrote:
>
> Hi there.
>
> Apologies for resending this, but I discovered I had a problem with my 
> DKIM signature on the original email, so it may have been blocked by 
> many list recipients...
>
> I've recently upgraded my email relay, which has amavisd-new 
> installed, and when amavis starts up it logs all the file types which 
> it doesn't have decoders for. Looking at the amavisd-new script, I can 
> see that @decoders is set to:
>
>       @decoders = (
>         ['mail', \&Amavis::Unpackers::do_mime_decode],
>     #   [[qw(asc uue hqx ync)], \&Amavis::Unpackers::do_ascii],  # not
>     safe
>         ['F', \&Amavis::Unpackers::do_uncompress, \$unfreeze],
>                  # ['unfreeze', 'freeze -d', 'melt', 'fcat'] ],
>         ['Z', \&Amavis::Unpackers::do_uncompress, \$uncompress],
>                  # ['uncompress', 'gzip -d', 'zcat'] ],
>         ['gz', \&Amavis::Unpackers::do_uncompress, \$gunzip],
>         ['gz', \&Amavis::Unpackers::do_gunzip],
>         ['bz2', \&Amavis::Unpackers::do_uncompress, \$bunzip2],
>         ['xz', \&Amavis::Unpackers::do_uncompress,
>                  ['xzdec', 'xz -dc', 'unxz -c', 'xzcat'] ],
>         ['lzma', \&Amavis::Unpackers::do_uncompress,
>                  ['lzmadec', 'xz -dc --format=lzma',
>                   'lzma -dc', 'unlzma -c', 'lzcat', 'lzmadec'] ],
>         ['lrz', \&Amavis::Unpackers::do_uncompress,
>                  ['lrzip -q -k -d -o -', 'lrzcat -q -k'] ],
>         ['lzo', \&Amavis::Unpackers::do_uncompress, \$unlzop],
>         ['lz4', \&Amavis::Unpackers::do_uncompress, ['lz4c -d'] ],
>         ['rpm', \&Amavis::Unpackers::do_uncompress, \$rpm2cpio],
>                  # ['rpm2cpio.pl', 'rpm2cpio'] ],
>         [['cpio','tar'], \&Amavis::Unpackers::do_pax_cpio, \$pax],
>                  # ['/usr/local/heirloom/usr/5bin/pax', 'pax',
>     'gcpio', 'cpio'] ],
>     #   ['tar', \&Amavis::Unpackers::do_tar],  # no longer supported
>         ['deb', \&Amavis::Unpackers::do_ar, \$ar],
>     #   ['a', \&Amavis::Unpackers::do_ar, \$ar], #unpacking .a seems
>     an overkill
>         ['rar', \&Amavis::Unpackers::do_unrar, \$unrar],  # ['unrar',
>     'rar']
>         ['arj', \&Amavis::Unpackers::do_unarj, \$unarj],  # ['unarj',
>     'arj']
>         ['arc', \&Amavis::Unpackers::do_arc,   \$arc],    #
>     ['nomarch', 'arc']
>         ['zoo', \&Amavis::Unpackers::do_zoo,   \$zoo],    # ['zoo',
>     'unzoo']
>         ['doc', \&Amavis::Unpackers::do_ole,   \$ripole],
>         ['cab', \&Amavis::Unpackers::do_cabextract, \$cabextract],
>         ['tnef', \&Amavis::Unpackers::do_tnef_ext, \$tnef],
>         ['tnef', \&Amavis::Unpackers::do_tnef],
>     #   ['lha', \&Amavis::Unpackers::do_lha,   \$lha],  # not safe,
>     use 7z instead
>     #   ['sit', \&Amavis::Unpackers::do_unstuff, \$unstuff],  # not safe
>         [['zip','kmz'], \&Amavis::Unpackers::do_7zip,  ['7za', '7z'] ],
>         [['zip','kmz'], \&Amavis::Unpackers::do_unzip],
>         ['7z', \&Amavis::Unpackers::do_7zip,  ['7zr', '7za', '7z'] ],
>         [[qw(gz bz2 Z tar)],
>     \&Amavis::Unpackers::do_7zip,  ['7za', '7z'] ],
>         [[qw(xz lzma jar cpio arj rar swf lha iso cab deb rpm)],
>     \&Amavis::Unpackers::do_7zip,  '7z' ],
>         ['exe', \&Amavis::Unpackers::do_executable, \$unrar, \$lha,
>     \$unarj],
>       ); 
>
> Which seems to say that 7z can be used for the following file extensions:
>
>     zip kmz
>     7z
>     gz bz2 Z tar
>     xz lzma jar cpio arj rar swf lha iso cab deb rpm
>
> So after installing p7zip-full and p7zip-rar packages, which provide 
> the 7z program (and also 7zr and 7za), I'm curious why I still see 
> warnings for rpm, rar, arj and cab:
>
>     Aug 29 13:13:39 mx amavis[10781]: No ext program for   .rpm,
>     tried: rpm2cpio.pl, rpm2cpio
>     Aug 29 13:13:39 mx amavis[10781]: No ext program for   .rar,
>     tried: unrar-free
>     Aug 29 13:13:39 mx amavis[10781]: No ext program for   .arj,
>     tried: arj, unarj
>     Aug 29 13:13:39 mx amavis[10781]: No ext program for   .cab,
>     tried: cabextract
>
> Does this mean that 7z isn't going to be used for these file types? 
> And if so, is there something I can do to get amavis to use 7z for 
> these file types?
>
> Or should these messages just be ignored?
>
> And on a related note, I know (on Windows at least) 7-zip can handle 
> self-extracting exe files, although I notice that the "man 7z" manual 
> page doesn't mention EXE files. So I wonder whether exe should or 
> shouldn't be added to the list of files that 7z can handle in a future 
> version of amavis?
>
You can set @decoders yourself (e.g. in /etc/amavis/conf.d/50-user).

I let ClamAV do the unpacking for extensions that it can handle (see 
https://www.clamav.net/documents/introduction), but I have:

[[qw(jar swf lha rpm)], \&do_7zip,  '7z' ],

and with $log_level = 1 when I reload amavis I see:

2021-08-29 09:06:01 streamingbats amavis[2976]: Found decoder for    
.jar  at /usr/bin/7z
2021-08-29 09:06:01 streamingbats amavis[2976]: Found decoder for    
.swf  at /usr/bin/7z
2021-08-29 09:06:01 streamingbats amavis[2976]: Found decoder for    
.lha  at /usr/bin/7z
2021-08-29 09:06:01 streamingbats amavis[2976]: Found decoder for    
.rpm  at /usr/bin/7z

Maybe your 7z is installed in a place that amavis cannot find?

Workaround: since rar, arj and cab are all handled by ClamAV you could 
remove them. That just leaves rpm for which you could install rpm2cpio?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.