|
|
f0b10e |
From 1b14752bebbdecbb7c89c7fe03853bdf4dff6f64 Mon Sep 17 00:00:00 2001
|
|
|
f0b10e |
From: Andreas Schneider <asn@samba.org>
|
|
|
f0b10e |
Date: Wed, 9 Feb 2022 16:33:10 +0100
|
|
|
f0b10e |
Subject: [PATCH 1/6] selftest: Do not force -d0 for smbd/nmbd/winbindd
|
|
|
f0b10e |
|
|
|
f0b10e |
We have the env variable SERVER_LOG_LEVEL which allows you to change
|
|
|
f0b10e |
the log level on the command line. If we force -d0 this will not work.
|
|
|
f0b10e |
|
|
|
f0b10e |
make test TESTS="samba" SERVER_LOG_LEVEL=10
|
|
|
f0b10e |
|
|
|
f0b10e |
Signed-off-by: Andreas Schneider <asn@samba.org>
|
|
|
f0b10e |
Reviewed-by: Jeremy Allison <jra@samba.org>
|
|
|
f0b10e |
(cherry picked from commit 9693f7ea7383c6a51ab58b7c8255b30206f18a3b)
|
|
|
f0b10e |
---
|
|
|
f0b10e |
selftest/target/Samba3.pm | 2 +-
|
|
|
f0b10e |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
f0b10e |
|
|
|
f0b10e |
diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
|
|
|
f0b10e |
index b901fd2677a..64a9a791a61 100755
|
|
|
f0b10e |
--- a/selftest/target/Samba3.pm
|
|
|
f0b10e |
+++ b/selftest/target/Samba3.pm
|
|
|
f0b10e |
@@ -2153,7 +2153,7 @@ sub make_bin_cmd
|
|
|
f0b10e |
{
|
|
|
f0b10e |
my ($self, $binary, $env_vars, $options, $valgrind, $dont_log_stdout) = @_;
|
|
|
f0b10e |
|
|
|
f0b10e |
- my @optargs = ("-d0");
|
|
|
f0b10e |
+ my @optargs = ();
|
|
|
f0b10e |
if (defined($options)) {
|
|
|
f0b10e |
@optargs = split(/ /, $options);
|
|
|
f0b10e |
}
|
|
|
f0b10e |
--
|
|
|
f0b10e |
2.34.1
|
|
|
f0b10e |
|
|
|
f0b10e |
|
|
|
f0b10e |
From 22c2899dfc787736c19857997291c151886b7ac0 Mon Sep 17 00:00:00 2001
|
|
|
f0b10e |
From: =?UTF-8?q?Pavel=20Filipensk=C3=BD?= <pfilipen@redhat.com>
|
|
|
f0b10e |
Date: Tue, 8 Feb 2022 12:07:03 +0100
|
|
|
f0b10e |
Subject: [PATCH 2/6] s3:modules: Implement dummy virus scanner that uses
|
|
|
f0b10e |
filename matching
|
|
|
f0b10e |
MIME-Version: 1.0
|
|
|
f0b10e |
Content-Type: text/plain; charset=UTF-8
|
|
|
f0b10e |
Content-Transfer-Encoding: 8bit
|
|
|
f0b10e |
|
|
|
f0b10e |
Bug: https://bugzilla.samba.org/show_bug.cgi?id=14971
|
|
|
f0b10e |
|
|
|
f0b10e |
Signed-off-by: Pavel Filipenský <pfilipen@redhat.com>
|
|
|
f0b10e |
Reviewed-by: Jeremy Allison <jra@samba.org>
|
|
|
f0b10e |
Reviewed-by: Andreas Schneider <asn@samba.org>
|
|
|
f0b10e |
(cherry picked from commit 9f34babec7c6aca3d91f226705d3b3996792e5f1)
|
|
|
f0b10e |
---
|
|
|
f0b10e |
source3/modules/vfs_virusfilter.c | 12 +++++
|
|
|
f0b10e |
source3/modules/vfs_virusfilter_common.h | 4 ++
|
|
|
f0b10e |
source3/modules/vfs_virusfilter_dummy.c | 58 ++++++++++++++++++++++++
|
|
|
f0b10e |
source3/modules/wscript_build | 1 +
|
|
|
f0b10e |
4 files changed, 75 insertions(+)
|
|
|
f0b10e |
create mode 100644 source3/modules/vfs_virusfilter_dummy.c
|
|
|
f0b10e |
|
|
|
f0b10e |
diff --git a/source3/modules/vfs_virusfilter.c b/source3/modules/vfs_virusfilter.c
|
|
|
f0b10e |
index 9fafe4e5d41..e6cbee7cd45 100644
|
|
|
f0b10e |
--- a/source3/modules/vfs_virusfilter.c
|
|
|
f0b10e |
+++ b/source3/modules/vfs_virusfilter.c
|
|
|
f0b10e |
@@ -35,12 +35,14 @@
|
|
|
f0b10e |
|
|
|
f0b10e |
enum virusfilter_scanner_enum {
|
|
|
f0b10e |
VIRUSFILTER_SCANNER_CLAMAV,
|
|
|
f0b10e |
+ VIRUSFILTER_SCANNER_DUMMY,
|
|
|
f0b10e |
VIRUSFILTER_SCANNER_FSAV,
|
|
|
f0b10e |
VIRUSFILTER_SCANNER_SOPHOS
|
|
|
f0b10e |
};
|
|
|
f0b10e |
|
|
|
f0b10e |
static const struct enum_list scanner_list[] = {
|
|
|
f0b10e |
{ VIRUSFILTER_SCANNER_CLAMAV, "clamav" },
|
|
|
f0b10e |
+ { VIRUSFILTER_SCANNER_DUMMY, "dummy" },
|
|
|
f0b10e |
{ VIRUSFILTER_SCANNER_FSAV, "fsav" },
|
|
|
f0b10e |
{ VIRUSFILTER_SCANNER_SOPHOS, "sophos" },
|
|
|
f0b10e |
{ -1, NULL }
|
|
|
f0b10e |
@@ -199,6 +201,7 @@ static int virusfilter_vfs_connect(
|
|
|
f0b10e |
int snum = SNUM(handle->conn);
|
|
|
f0b10e |
struct virusfilter_config *config = NULL;
|
|
|
f0b10e |
const char *exclude_files = NULL;
|
|
|
f0b10e |
+ const char *infected_files = NULL;
|
|
|
f0b10e |
const char *temp_quarantine_dir_mode = NULL;
|
|
|
f0b10e |
const char *infected_file_command = NULL;
|
|
|
f0b10e |
const char *scan_error_command = NULL;
|
|
|
f0b10e |
@@ -255,6 +258,12 @@ static int virusfilter_vfs_connect(
|
|
|
f0b10e |
set_namearray(&config->exclude_files, exclude_files);
|
|
|
f0b10e |
}
|
|
|
f0b10e |
|
|
|
f0b10e |
+ infected_files = lp_parm_const_string(
|
|
|
f0b10e |
+ snum, "virusfilter", "infected files", NULL);
|
|
|
f0b10e |
+ if (infected_files != NULL) {
|
|
|
f0b10e |
+ set_namearray(&config->infected_files, infected_files);
|
|
|
f0b10e |
+ }
|
|
|
f0b10e |
+
|
|
|
f0b10e |
config->cache_entry_limit = lp_parm_int(
|
|
|
f0b10e |
snum, "virusfilter", "cache entry limit", 100);
|
|
|
f0b10e |
|
|
|
f0b10e |
@@ -537,6 +546,9 @@ static int virusfilter_vfs_connect(
|
|
|
f0b10e |
case VIRUSFILTER_SCANNER_CLAMAV:
|
|
|
f0b10e |
ret = virusfilter_clamav_init(config);
|
|
|
f0b10e |
break;
|
|
|
f0b10e |
+ case VIRUSFILTER_SCANNER_DUMMY:
|
|
|
f0b10e |
+ ret = virusfilter_dummy_init(config);
|
|
|
f0b10e |
+ break;
|
|
|
f0b10e |
default:
|
|
|
f0b10e |
DBG_ERR("Unhandled scanner %d\n", backend);
|
|
|
f0b10e |
return -1;
|
|
|
f0b10e |
diff --git a/source3/modules/vfs_virusfilter_common.h b/source3/modules/vfs_virusfilter_common.h
|
|
|
f0b10e |
index f71b0b949a7..463a9d74e9c 100644
|
|
|
f0b10e |
--- a/source3/modules/vfs_virusfilter_common.h
|
|
|
f0b10e |
+++ b/source3/modules/vfs_virusfilter_common.h
|
|
|
f0b10e |
@@ -83,6 +83,9 @@ struct virusfilter_config {
|
|
|
f0b10e |
/* Exclude files */
|
|
|
f0b10e |
name_compare_entry *exclude_files;
|
|
|
f0b10e |
|
|
|
f0b10e |
+ /* Infected files */
|
|
|
f0b10e |
+ name_compare_entry *infected_files;
|
|
|
f0b10e |
+
|
|
|
f0b10e |
/* Scan result cache */
|
|
|
f0b10e |
struct virusfilter_cache *cache;
|
|
|
f0b10e |
int cache_entry_limit;
|
|
|
f0b10e |
@@ -149,5 +152,6 @@ struct virusfilter_backend {
|
|
|
f0b10e |
int virusfilter_sophos_init(struct virusfilter_config *config);
|
|
|
f0b10e |
int virusfilter_fsav_init(struct virusfilter_config *config);
|
|
|
f0b10e |
int virusfilter_clamav_init(struct virusfilter_config *config);
|
|
|
f0b10e |
+int virusfilter_dummy_init(struct virusfilter_config *config);
|
|
|
f0b10e |
|
|
|
f0b10e |
#endif /* _VIRUSFILTER_COMMON_H */
|
|
|
f0b10e |
diff --git a/source3/modules/vfs_virusfilter_dummy.c b/source3/modules/vfs_virusfilter_dummy.c
|
|
|
f0b10e |
new file mode 100644
|
|
|
f0b10e |
index 00000000000..03405cd6629
|
|
|
f0b10e |
--- /dev/null
|
|
|
f0b10e |
+++ b/source3/modules/vfs_virusfilter_dummy.c
|
|
|
f0b10e |
@@ -0,0 +1,58 @@
|
|
|
f0b10e |
+/*
|
|
|
f0b10e |
+ Samba-VirusFilter VFS modules
|
|
|
f0b10e |
+ Dummy scanner with infected files support.
|
|
|
f0b10e |
+ Copyright (C) 2022 Pavel Filipenský <pfilipen@redhat.com>
|
|
|
f0b10e |
+
|
|
|
f0b10e |
+ This program is free software; you can redistribute it and/or modify
|
|
|
f0b10e |
+ it under the terms of the GNU General Public License as published by
|
|
|
f0b10e |
+ the Free Software Foundation; either version 3 of the License, or
|
|
|
f0b10e |
+ (at your option) any later version.
|
|
|
f0b10e |
+
|
|
|
f0b10e |
+ This program is distributed in the hope that it will be useful,
|
|
|
f0b10e |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
f0b10e |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
f0b10e |
+ GNU General Public License for more details.
|
|
|
f0b10e |
+
|
|
|
f0b10e |
+ You should have received a copy of the GNU General Public License
|
|
|
f0b10e |
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
f0b10e |
+*/
|
|
|
f0b10e |
+
|
|
|
f0b10e |
+#include "modules/vfs_virusfilter_utils.h"
|
|
|
f0b10e |
+
|
|
|
f0b10e |
+static virusfilter_result virusfilter_dummy_scan(
|
|
|
f0b10e |
+ struct vfs_handle_struct *handle,
|
|
|
f0b10e |
+ struct virusfilter_config *config,
|
|
|
f0b10e |
+ const struct files_struct *fsp,
|
|
|
f0b10e |
+ char **reportp)
|
|
|
f0b10e |
+{
|
|
|
f0b10e |
+ bool ok;
|
|
|
f0b10e |
+
|
|
|
f0b10e |
+ DBG_INFO("Scanning file: %s\n", fsp_str_dbg(fsp));
|
|
|
f0b10e |
+ ok = is_in_path(fsp->fsp_name->base_name,
|
|
|
f0b10e |
+ config->infected_files,
|
|
|
f0b10e |
+ false);
|
|
|
f0b10e |
+ return ok ? VIRUSFILTER_RESULT_INFECTED : VIRUSFILTER_RESULT_CLEAN;
|
|
|
f0b10e |
+}
|
|
|
f0b10e |
+
|
|
|
f0b10e |
+static struct virusfilter_backend_fns virusfilter_backend_dummy = {
|
|
|
f0b10e |
+ .connect = NULL,
|
|
|
f0b10e |
+ .disconnect = NULL,
|
|
|
f0b10e |
+ .scan_init = NULL,
|
|
|
f0b10e |
+ .scan = virusfilter_dummy_scan,
|
|
|
f0b10e |
+ .scan_end = NULL,
|
|
|
f0b10e |
+};
|
|
|
f0b10e |
+
|
|
|
f0b10e |
+int virusfilter_dummy_init(struct virusfilter_config *config)
|
|
|
f0b10e |
+{
|
|
|
f0b10e |
+ struct virusfilter_backend *backend = NULL;
|
|
|
f0b10e |
+
|
|
|
f0b10e |
+ backend = talloc_zero(config, struct virusfilter_backend);
|
|
|
f0b10e |
+ if (backend == NULL) {
|
|
|
f0b10e |
+ return -1;
|
|
|
f0b10e |
+ }
|
|
|
f0b10e |
+
|
|
|
f0b10e |
+ backend->fns = &virusfilter_backend_dummy;
|
|
|
f0b10e |
+ backend->name = "dummy";
|
|
|
f0b10e |
+ config->backend = backend;
|
|
|
f0b10e |
+ return 0;
|
|
|
f0b10e |
+}
|
|
|
f0b10e |
diff --git a/source3/modules/wscript_build b/source3/modules/wscript_build
|
|
|
f0b10e |
index 40df4539392..ff318c3fa06 100644
|
|
|
f0b10e |
--- a/source3/modules/wscript_build
|
|
|
f0b10e |
+++ b/source3/modules/wscript_build
|
|
|
f0b10e |
@@ -591,6 +591,7 @@ bld.SAMBA3_MODULE('vfs_virusfilter',
|
|
|
f0b10e |
vfs_virusfilter_sophos.c
|
|
|
f0b10e |
vfs_virusfilter_fsav.c
|
|
|
f0b10e |
vfs_virusfilter_clamav.c
|
|
|
f0b10e |
+ vfs_virusfilter_dummy.c
|
|
|
f0b10e |
''',
|
|
|
f0b10e |
deps='samba-util VFS_VIRUSFILTER_UTILS',
|
|
|
f0b10e |
init_function='',
|
|
|
f0b10e |
--
|
|
|
f0b10e |
2.34.1
|
|
|
f0b10e |
|
|
|
f0b10e |
|
|
|
f0b10e |
From a813dc2adec352a85ec526ac9a3ec67139b730d3 Mon Sep 17 00:00:00 2001
|
|
|
f0b10e |
From: =?UTF-8?q?Pavel=20Filipensk=C3=BD?= <pfilipen@redhat.com>
|
|
|
f0b10e |
Date: Tue, 8 Feb 2022 22:35:29 +0100
|
|
|
f0b10e |
Subject: [PATCH 3/6] docs-xml:manpages: Document 'dummy' virusfilter and
|
|
|
f0b10e |
'virusfilter:infected files'
|
|
|
f0b10e |
MIME-Version: 1.0
|
|
|
f0b10e |
Content-Type: text/plain; charset=UTF-8
|
|
|
f0b10e |
Content-Transfer-Encoding: 8bit
|
|
|
f0b10e |
|
|
|
f0b10e |
Bug: https://bugzilla.samba.org/show_bug.cgi?id=14971
|
|
|
f0b10e |
|
|
|
f0b10e |
Signed-off-by: Pavel Filipenský <pfilipen@redhat.com>
|
|
|
f0b10e |
Reviewed-by: Jeremy Allison <jra@samba.org>
|
|
|
f0b10e |
Reviewed-by: Andreas Schneider <asn@samba.org>
|
|
|
f0b10e |
(cherry picked from commit 2fd518e5cc63221c162c9b3f8526b9b7c9e34969)
|
|
|
f0b10e |
---
|
|
|
f0b10e |
docs-xml/manpages/vfs_virusfilter.8.xml | 12 ++++++++++++
|
|
|
f0b10e |
1 file changed, 12 insertions(+)
|
|
|
f0b10e |
|
|
|
f0b10e |
diff --git a/docs-xml/manpages/vfs_virusfilter.8.xml b/docs-xml/manpages/vfs_virusfilter.8.xml
|
|
|
f0b10e |
index 329a35af68a..88f91d73a42 100644
|
|
|
f0b10e |
--- a/docs-xml/manpages/vfs_virusfilter.8.xml
|
|
|
f0b10e |
+++ b/docs-xml/manpages/vfs_virusfilter.8.xml
|
|
|
f0b10e |
@@ -48,6 +48,10 @@
|
|
|
f0b10e |
scanner</para></listitem>
|
|
|
f0b10e |
<listitem><para><emphasis>clamav</emphasis>, the ClamAV
|
|
|
f0b10e |
scanner</para></listitem>
|
|
|
f0b10e |
+ <listitem><para><emphasis>dummy</emphasis>, dummy scanner used in
|
|
|
f0b10e |
+ tests. Checks against the <emphasis>infected files</emphasis>
|
|
|
f0b10e |
+ parameter and flags any name that matches as infected.
|
|
|
f0b10e |
+ </para></listitem>
|
|
|
f0b10e |
</itemizedlist>
|
|
|
f0b10e |
</listitem>
|
|
|
f0b10e |
</varlistentry>
|
|
|
f0b10e |
@@ -264,6 +268,14 @@
|
|
|
f0b10e |
</listitem>
|
|
|
f0b10e |
</varlistentry>
|
|
|
f0b10e |
|
|
|
f0b10e |
+ <varlistentry>
|
|
|
f0b10e |
+ <term>virusfilter:infected files = empty</term>
|
|
|
f0b10e |
+ <listitem>
|
|
|
f0b10e |
+ <para>Files that virusfilter <emphasis>dummy</emphasis> flags as infected.</para>
|
|
|
f0b10e |
+ <para>If this option is not set, the default is empty.</para>
|
|
|
f0b10e |
+ </listitem>
|
|
|
f0b10e |
+ </varlistentry>
|
|
|
f0b10e |
+
|
|
|
f0b10e |
<varlistentry>
|
|
|
f0b10e |
<term>virusfilter:block access on error = false</term>
|
|
|
f0b10e |
<listitem>
|
|
|
f0b10e |
--
|
|
|
f0b10e |
2.34.1
|
|
|
f0b10e |
|
|
|
f0b10e |
|
|
|
f0b10e |
From b67c6fe07a506627439c6ffd07e687befbc122ba Mon Sep 17 00:00:00 2001
|
|
|
f0b10e |
From: =?UTF-8?q?Pavel=20Filipensk=C3=BD?= <pfilipen@redhat.com>
|
|
|
f0b10e |
Date: Tue, 8 Feb 2022 15:34:56 +0100
|
|
|
f0b10e |
Subject: [PATCH 4/6] selftest: Fix trailing whitespace in Samba3.pm
|
|
|
f0b10e |
MIME-Version: 1.0
|
|
|
f0b10e |
Content-Type: text/plain; charset=UTF-8
|
|
|
f0b10e |
Content-Transfer-Encoding: 8bit
|
|
|
f0b10e |
|
|
|
f0b10e |
Bug: https://bugzilla.samba.org/show_bug.cgi?id=14971
|
|
|
f0b10e |
|
|
|
f0b10e |
Signed-off-by: Pavel Filipenský <pfilipen@redhat.com>
|
|
|
f0b10e |
Reviewed-by: Jeremy Allison <jra@samba.org>
|
|
|
f0b10e |
Reviewed-by: Andreas Schneider <asn@samba.org>
|
|
|
f0b10e |
(cherry picked from commit 547b4c595a8513a4be99177edbaa39ce43840f7a)
|
|
|
f0b10e |
---
|
|
|
f0b10e |
selftest/target/Samba3.pm | 6 +++---
|
|
|
f0b10e |
1 file changed, 3 insertions(+), 3 deletions(-)
|
|
|
f0b10e |
|
|
|
f0b10e |
diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
|
|
|
f0b10e |
index 64a9a791a61..7584a0e7ba9 100755
|
|
|
f0b10e |
--- a/selftest/target/Samba3.pm
|
|
|
f0b10e |
+++ b/selftest/target/Samba3.pm
|
|
|
f0b10e |
@@ -188,7 +188,7 @@ sub getlog_env_app($$$)
|
|
|
f0b10e |
close(LOG);
|
|
|
f0b10e |
|
|
|
f0b10e |
return "" if $out eq $title;
|
|
|
f0b10e |
-
|
|
|
f0b10e |
+
|
|
|
f0b10e |
return $out;
|
|
|
f0b10e |
}
|
|
|
f0b10e |
|
|
|
f0b10e |
@@ -2426,7 +2426,7 @@ sub provision($$)
|
|
|
f0b10e |
my $nmbdsockdir="$prefix_abs/nmbd";
|
|
|
f0b10e |
unlink($nmbdsockdir);
|
|
|
f0b10e |
|
|
|
f0b10e |
- ##
|
|
|
f0b10e |
+ ##
|
|
|
f0b10e |
## create the test directory layout
|
|
|
f0b10e |
##
|
|
|
f0b10e |
die ("prefix_abs = ''") if $prefix_abs eq "";
|
|
|
f0b10e |
@@ -3290,7 +3290,7 @@ sub provision($$)
|
|
|
f0b10e |
unless (open(PASSWD, ">$nss_wrapper_passwd")) {
|
|
|
f0b10e |
warn("Unable to open $nss_wrapper_passwd");
|
|
|
f0b10e |
return undef;
|
|
|
f0b10e |
- }
|
|
|
f0b10e |
+ }
|
|
|
f0b10e |
print PASSWD "nobody:x:$uid_nobody:$gid_nobody:nobody gecos:$prefix_abs:/bin/false
|
|
|
f0b10e |
$unix_name:x:$unix_uid:$unix_gids[0]:$unix_name gecos:$prefix_abs:/bin/false
|
|
|
f0b10e |
pdbtest:x:$uid_pdbtest:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
|
|
|
f0b10e |
--
|
|
|
f0b10e |
2.34.1
|
|
|
f0b10e |
|
|
|
f0b10e |
|
|
|
f0b10e |
From b558d8f8be4459fa9e588486984c4cadf65ede12 Mon Sep 17 00:00:00 2001
|
|
|
f0b10e |
From: =?UTF-8?q?Pavel=20Filipensk=C3=BD?= <pfilipen@redhat.com>
|
|
|
f0b10e |
Date: Tue, 8 Feb 2022 15:35:48 +0100
|
|
|
f0b10e |
Subject: [PATCH 5/6] s3:selftest: Add test for virus scanner
|
|
|
f0b10e |
MIME-Version: 1.0
|
|
|
f0b10e |
Content-Type: text/plain; charset=UTF-8
|
|
|
f0b10e |
Content-Transfer-Encoding: 8bit
|
|
|
f0b10e |
|
|
|
f0b10e |
Bug: https://bugzilla.samba.org/show_bug.cgi?id=14971
|
|
|
f0b10e |
|
|
|
f0b10e |
Signed-off-by: Pavel Filipenský <pfilipen@redhat.com>
|
|
|
f0b10e |
|
|
|
f0b10e |
Pair-Programmed-With: Andreas Schneider <asn@samba.org>
|
|
|
f0b10e |
Reviewed-by: Jeremy Allison <jra@samba.org>
|
|
|
f0b10e |
Reviewed-by: Andreas Schneider <asn@samba.org>
|
|
|
f0b10e |
(cherry picked from commit a25c714c34d3e00e0f3c29d2acfa98cf9cdbc544)
|
|
|
f0b10e |
---
|
|
|
f0b10e |
selftest/knownfail.d/virus_scanner | 2 +
|
|
|
f0b10e |
selftest/target/Samba3.pm | 12 ++
|
|
|
f0b10e |
source3/script/tests/test_virus_scanner.sh | 124 +++++++++++++++++++++
|
|
|
f0b10e |
source3/selftest/tests.py | 9 ++
|
|
|
f0b10e |
4 files changed, 147 insertions(+)
|
|
|
f0b10e |
create mode 100644 selftest/knownfail.d/virus_scanner
|
|
|
f0b10e |
create mode 100755 source3/script/tests/test_virus_scanner.sh
|
|
|
f0b10e |
|
|
|
f0b10e |
diff --git a/selftest/knownfail.d/virus_scanner b/selftest/knownfail.d/virus_scanner
|
|
|
f0b10e |
new file mode 100644
|
|
|
f0b10e |
index 00000000000..6df3fd20627
|
|
|
f0b10e |
--- /dev/null
|
|
|
f0b10e |
+++ b/selftest/knownfail.d/virus_scanner
|
|
|
f0b10e |
@@ -0,0 +1,2 @@
|
|
|
f0b10e |
+^samba3.blackbox.virus_scanner.check_infected_read # test download infected file ('vfs objects = virusfilter')
|
|
|
f0b10e |
+^samba3.blackbox.virus_scanner.check_infected_write # test upload infected file ('vfs objects = virusfilter')
|
|
|
f0b10e |
diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
|
|
|
f0b10e |
index 7584a0e7ba9..c1d0c60d96a 100755
|
|
|
f0b10e |
--- a/selftest/target/Samba3.pm
|
|
|
f0b10e |
+++ b/selftest/target/Samba3.pm
|
|
|
f0b10e |
@@ -1688,6 +1688,9 @@ sub setup_fileserver
|
|
|
f0b10e |
my $veto_sharedir="$share_dir/veto";
|
|
|
f0b10e |
push(@dirs,$veto_sharedir);
|
|
|
f0b10e |
|
|
|
f0b10e |
+ my $virusfilter_sharedir="$share_dir/virusfilter";
|
|
|
f0b10e |
+ push(@dirs,$virusfilter_sharedir);
|
|
|
f0b10e |
+
|
|
|
f0b10e |
my $ip4 = Samba::get_ipv4_addr("FILESERVER");
|
|
|
f0b10e |
my $fileserver_options = "
|
|
|
f0b10e |
kernel change notify = yes
|
|
|
f0b10e |
@@ -1813,6 +1816,15 @@ sub setup_fileserver
|
|
|
f0b10e |
path = $veto_sharedir
|
|
|
f0b10e |
delete veto files = yes
|
|
|
f0b10e |
|
|
|
f0b10e |
+[virusfilter]
|
|
|
f0b10e |
+ path = $virusfilter_sharedir
|
|
|
f0b10e |
+ vfs objects = acl_xattr virusfilter
|
|
|
f0b10e |
+ virusfilter:scanner = dummy
|
|
|
f0b10e |
+ virusfilter:min file size = 0
|
|
|
f0b10e |
+ virusfilter:infected files = *infected*
|
|
|
f0b10e |
+ virusfilter:infected file action = rename
|
|
|
f0b10e |
+ virusfilter:scan on close = yes
|
|
|
f0b10e |
+
|
|
|
f0b10e |
[homes]
|
|
|
f0b10e |
comment = Home directories
|
|
|
f0b10e |
browseable = No
|
|
|
f0b10e |
diff --git a/source3/script/tests/test_virus_scanner.sh b/source3/script/tests/test_virus_scanner.sh
|
|
|
f0b10e |
new file mode 100755
|
|
|
f0b10e |
index 00000000000..2234ea6ca89
|
|
|
f0b10e |
--- /dev/null
|
|
|
f0b10e |
+++ b/source3/script/tests/test_virus_scanner.sh
|
|
|
f0b10e |
@@ -0,0 +1,124 @@
|
|
|
f0b10e |
+#!/bin/sh
|
|
|
f0b10e |
+# Copyright (c) 2022 Pavel Filipenský <pfilipen@redhat.com>
|
|
|
f0b10e |
+# shellcheck disable=1091
|
|
|
f0b10e |
+
|
|
|
f0b10e |
+if [ $# -lt 4 ]; then
|
|
|
f0b10e |
+cat <
|
|
|
f0b10e |
+Usage: $0 SERVER_IP SHARE LOCAL_PATH SMBCLIENT
|
|
|
f0b10e |
+EOF
|
|
|
f0b10e |
+exit 1;
|
|
|
f0b10e |
+fi
|
|
|
f0b10e |
+
|
|
|
f0b10e |
+SERVER_IP=${1}
|
|
|
f0b10e |
+SHARE=${2}
|
|
|
f0b10e |
+LOCAL_PATH=${3}
|
|
|
f0b10e |
+SMBCLIENT=${4}
|
|
|
f0b10e |
+
|
|
|
f0b10e |
+SMBCLIENT="${VALGRIND} ${SMBCLIENT}"
|
|
|
f0b10e |
+
|
|
|
f0b10e |
+failed=0
|
|
|
f0b10e |
+sharedir="${LOCAL_PATH}/${SHARE}"
|
|
|
f0b10e |
+
|
|
|
f0b10e |
+incdir="$(dirname "$0")/../../../testprogs/blackbox"
|
|
|
f0b10e |
+. "${incdir}/subunit.sh"
|
|
|
f0b10e |
+
|
|
|
f0b10e |
+check_infected_read()
|
|
|
f0b10e |
+{
|
|
|
f0b10e |
+ rm -rf "${sharedir:?}"/*
|
|
|
f0b10e |
+
|
|
|
f0b10e |
+ if ! touch "${sharedir}/infected.txt"; then
|
|
|
f0b10e |
+ echo "ERROR: Cannot create ${sharedir}/infected.txt"
|
|
|
f0b10e |
+ return 1
|
|
|
f0b10e |
+ fi
|
|
|
f0b10e |
+
|
|
|
f0b10e |
+ ${SMBCLIENT} "//${SERVER_IP}/${SHARE}" -U"${USER}"%"${PASSWORD}" -c "get infected.txt ${sharedir}/infected.download.txt"
|
|
|
f0b10e |
+
|
|
|
f0b10e |
+ # check that virusfilter:rename prefix/suffix was added
|
|
|
f0b10e |
+ if [ ! -f "${sharedir}/virusfilter.infected.txt.infected" ]; then
|
|
|
f0b10e |
+ echo "ERROR: ${sharedir}/virusfilter.infected.txt.infected is missing."
|
|
|
f0b10e |
+ return 1
|
|
|
f0b10e |
+ fi
|
|
|
f0b10e |
+
|
|
|
f0b10e |
+ # check that file was not downloaded
|
|
|
f0b10e |
+ if [ -f "${sharedir}/infected.download.txt" ]; then
|
|
|
f0b10e |
+ echo "ERROR: {sharedir}/infected.download.txt should not exist."
|
|
|
f0b10e |
+ return 1
|
|
|
f0b10e |
+ fi
|
|
|
f0b10e |
+
|
|
|
f0b10e |
+ return 0
|
|
|
f0b10e |
+}
|
|
|
f0b10e |
+
|
|
|
f0b10e |
+check_infected_write()
|
|
|
f0b10e |
+{
|
|
|
f0b10e |
+ rm -rf "${sharedir:?}"/*
|
|
|
f0b10e |
+ smbfile=infected.upload.txt
|
|
|
f0b10e |
+ smbfilerenamed="virusfilter.${smbfile}.infected"
|
|
|
f0b10e |
+
|
|
|
f0b10e |
+ # non empty file is needed
|
|
|
f0b10e |
+ # vsf_virusfilter performs a scan only if fsp->fsp_flags.modified
|
|
|
f0b10e |
+ if ! echo "Hello Virus!" > "${sharedir}/infected.txt"; then
|
|
|
f0b10e |
+ echo "ERROR: Cannot create ${sharedir}/infected.txt"
|
|
|
f0b10e |
+ return 1
|
|
|
f0b10e |
+ fi
|
|
|
f0b10e |
+
|
|
|
f0b10e |
+ ${SMBCLIENT} "//${SERVER_IP}/${SHARE}" -U"${USER}"%"${PASSWORD}" -c "put ${sharedir}/infected.txt ${smbfile}"
|
|
|
f0b10e |
+
|
|
|
f0b10e |
+ # check that virusfilter:rename prefix/suffix was added
|
|
|
f0b10e |
+ if [ ! -f "${sharedir}/${smbfilerenamed}" ]; then
|
|
|
f0b10e |
+ echo "ERROR: ${sharedir}/${smbfilerenamed} is missing."
|
|
|
f0b10e |
+ return 1
|
|
|
f0b10e |
+ fi
|
|
|
f0b10e |
+
|
|
|
f0b10e |
+ # check that file was not uploaded
|
|
|
f0b10e |
+ if [ -f "${sharedir}/infected.upload.txt" ]; then
|
|
|
f0b10e |
+ echo "ERROR: {sharedir}/${smbfile} should not exist."
|
|
|
f0b10e |
+ return 1
|
|
|
f0b10e |
+ fi
|
|
|
f0b10e |
+
|
|
|
f0b10e |
+ return 0
|
|
|
f0b10e |
+}
|
|
|
f0b10e |
+
|
|
|
f0b10e |
+check_healthy_read()
|
|
|
f0b10e |
+{
|
|
|
f0b10e |
+ rm -rf "${sharedir:?}"/*
|
|
|
f0b10e |
+
|
|
|
f0b10e |
+ if ! echo "Hello Samba!" > "${sharedir}/healthy.txt"; then
|
|
|
f0b10e |
+ echo "ERROR: Cannot create ${sharedir}/healthy.txt"
|
|
|
f0b10e |
+ return 1
|
|
|
f0b10e |
+ fi
|
|
|
f0b10e |
+
|
|
|
f0b10e |
+ ${SMBCLIENT} //"${SERVER_IP}"/"${SHARE}" -U"${USER}"%"${PASSWORD}" -c "get healthy.txt ${sharedir}/healthy.download.txt"
|
|
|
f0b10e |
+
|
|
|
f0b10e |
+ if ! cmp "${sharedir}/healthy.txt" "${sharedir}/healthy.download.txt"; then
|
|
|
f0b10e |
+ echo "ERROR: cmp ${sharedir}/healthy.txt ${sharedir}/healthy.download.txt FAILED"
|
|
|
f0b10e |
+ return 1
|
|
|
f0b10e |
+ fi
|
|
|
f0b10e |
+
|
|
|
f0b10e |
+ return 0
|
|
|
f0b10e |
+}
|
|
|
f0b10e |
+
|
|
|
f0b10e |
+check_healthy_write()
|
|
|
f0b10e |
+{
|
|
|
f0b10e |
+ rm -rf "${sharedir:?}"/*
|
|
|
f0b10e |
+
|
|
|
f0b10e |
+ if ! echo "Hello Samba!" > "${sharedir}/healthy.txt"; then
|
|
|
f0b10e |
+ echo "ERROR: Cannot create ${sharedir}/healthy.txt"
|
|
|
f0b10e |
+ return 1
|
|
|
f0b10e |
+ fi
|
|
|
f0b10e |
+
|
|
|
f0b10e |
+ ${SMBCLIENT} //"${SERVER_IP}"/"${SHARE}" -U"${USER}"%"${PASSWORD}" -c "put ${sharedir}/healthy.txt healthy.upload.txt"
|
|
|
f0b10e |
+
|
|
|
f0b10e |
+ if ! cmp "${sharedir}/healthy.txt" "${sharedir}/healthy.upload.txt"; then
|
|
|
f0b10e |
+ echo "ERROR: cmp ${sharedir}/healthy.txt ${sharedir}/healthy.upload.txt FAILED"
|
|
|
f0b10e |
+ return 1
|
|
|
f0b10e |
+ fi
|
|
|
f0b10e |
+
|
|
|
f0b10e |
+ return 0
|
|
|
f0b10e |
+}
|
|
|
f0b10e |
+
|
|
|
f0b10e |
+testit "check_infected_read" check_infected_read || failed=$((failed + 1))
|
|
|
f0b10e |
+testit "check_infected_write" check_infected_write || failed=$((failed + 1))
|
|
|
f0b10e |
+testit "check_healthy_read" check_healthy_read || failed=$((failed + 1))
|
|
|
f0b10e |
+testit "check_healthy_write" check_healthy_write || failed=$((failed + 1))
|
|
|
f0b10e |
+
|
|
|
f0b10e |
+testok "$0" "$failed"
|
|
|
f0b10e |
diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
|
|
|
f0b10e |
index 701be011f70..6b146c76381 100755
|
|
|
f0b10e |
--- a/source3/selftest/tests.py
|
|
|
f0b10e |
+++ b/source3/selftest/tests.py
|
|
|
f0b10e |
@@ -1240,6 +1240,15 @@ plantestsuite("samba3.blackbox.smbXsrv_client_dead_rec", "fileserver:local",
|
|
|
f0b10e |
'$SERVER_IP',
|
|
|
f0b10e |
"tmp"])
|
|
|
f0b10e |
|
|
|
f0b10e |
+env = 'fileserver'
|
|
|
f0b10e |
+plantestsuite("samba3.blackbox.virus_scanner", "%s:local" % (env),
|
|
|
f0b10e |
+ [os.path.join(samba3srcdir,
|
|
|
f0b10e |
+ "script/tests/test_virus_scanner.sh"),
|
|
|
f0b10e |
+ '$SERVER_IP',
|
|
|
f0b10e |
+ "virusfilter",
|
|
|
f0b10e |
+ '$LOCAL_PATH',
|
|
|
f0b10e |
+ smbclient3])
|
|
|
f0b10e |
+
|
|
|
f0b10e |
for env in ['fileserver', 'simpleserver']:
|
|
|
f0b10e |
plantestsuite("samba3.blackbox.smbclient.encryption", env,
|
|
|
f0b10e |
[os.path.join(samba3srcdir, "script/tests/test_smbclient_encryption.sh"),
|
|
|
f0b10e |
--
|
|
|
f0b10e |
2.34.1
|
|
|
f0b10e |
|
|
|
f0b10e |
|
|
|
f0b10e |
From 275139352e854c7b01a53014b16673c8c7254fa9 Mon Sep 17 00:00:00 2001
|
|
|
f0b10e |
From: =?UTF-8?q?Pavel=20Filipensk=C3=BD?= <pfilipen@redhat.com>
|
|
|
f0b10e |
Date: Mon, 7 Feb 2022 23:06:10 +0100
|
|
|
f0b10e |
Subject: [PATCH 6/6] s3:modules: Fix virusfilter_vfs_openat
|
|
|
f0b10e |
MIME-Version: 1.0
|
|
|
f0b10e |
Content-Type: text/plain; charset=UTF-8
|
|
|
f0b10e |
Content-Transfer-Encoding: 8bit
|
|
|
f0b10e |
|
|
|
f0b10e |
Bug: https://bugzilla.samba.org/show_bug.cgi?id=14971
|
|
|
f0b10e |
|
|
|
f0b10e |
Signed-off-by: Pavel Filipenský <pfilipen@redhat.com>
|
|
|
f0b10e |
|
|
|
f0b10e |
Pair-Programmed-With: Andreas Schneider <asn@samba.org>
|
|
|
f0b10e |
Reviewed-by: Jeremy Allison <jra@samba.org>
|
|
|
f0b10e |
Reviewed-by: Andreas Schneider <asn@samba.org>
|
|
|
f0b10e |
|
|
|
f0b10e |
Autobuild-User(master): Jeremy Allison <jra@samba.org>
|
|
|
f0b10e |
Autobuild-Date(master): Thu Feb 10 22:09:06 UTC 2022 on sn-devel-184
|
|
|
f0b10e |
|
|
|
f0b10e |
(cherry picked from commit 3f1c958f6fa9d2991185f4e281a377a295d09f9c)
|
|
|
f0b10e |
---
|
|
|
f0b10e |
selftest/knownfail.d/virus_scanner | 2 --
|
|
|
f0b10e |
source3/modules/vfs_virusfilter.c | 6 +++---
|
|
|
f0b10e |
2 files changed, 3 insertions(+), 5 deletions(-)
|
|
|
f0b10e |
delete mode 100644 selftest/knownfail.d/virus_scanner
|
|
|
f0b10e |
|
|
|
f0b10e |
diff --git a/selftest/knownfail.d/virus_scanner b/selftest/knownfail.d/virus_scanner
|
|
|
f0b10e |
deleted file mode 100644
|
|
|
f0b10e |
index 6df3fd20627..00000000000
|
|
|
f0b10e |
--- a/selftest/knownfail.d/virus_scanner
|
|
|
f0b10e |
+++ /dev/null
|
|
|
f0b10e |
@@ -1,2 +0,0 @@
|
|
|
f0b10e |
-^samba3.blackbox.virus_scanner.check_infected_read # test download infected file ('vfs objects = virusfilter')
|
|
|
f0b10e |
-^samba3.blackbox.virus_scanner.check_infected_write # test upload infected file ('vfs objects = virusfilter')
|
|
|
f0b10e |
diff --git a/source3/modules/vfs_virusfilter.c b/source3/modules/vfs_virusfilter.c
|
|
|
f0b10e |
index e6cbee7cd45..d1554967ad1 100644
|
|
|
f0b10e |
--- a/source3/modules/vfs_virusfilter.c
|
|
|
f0b10e |
+++ b/source3/modules/vfs_virusfilter.c
|
|
|
f0b10e |
@@ -1309,21 +1309,21 @@ static int virusfilter_vfs_openat(struct vfs_handle_struct *handle,
|
|
|
f0b10e |
*/
|
|
|
f0b10e |
goto virusfilter_vfs_open_next;
|
|
|
f0b10e |
}
|
|
|
f0b10e |
- ret = S_ISREG(smb_fname->st.st_ex_mode);
|
|
|
f0b10e |
+ ret = S_ISREG(sbuf.st_ex_mode);
|
|
|
f0b10e |
if (ret == 0) {
|
|
|
f0b10e |
DBG_INFO("Not scanned: Directory or special file: %s/%s\n",
|
|
|
f0b10e |
cwd_fname, fname);
|
|
|
f0b10e |
goto virusfilter_vfs_open_next;
|
|
|
f0b10e |
}
|
|
|
f0b10e |
if (config->max_file_size > 0 &&
|
|
|
f0b10e |
- smb_fname->st.st_ex_size > config->max_file_size)
|
|
|
f0b10e |
+ sbuf.st_ex_size > config->max_file_size)
|
|
|
f0b10e |
{
|
|
|
f0b10e |
DBG_INFO("Not scanned: file size > max file size: %s/%s\n",
|
|
|
f0b10e |
cwd_fname, fname);
|
|
|
f0b10e |
goto virusfilter_vfs_open_next;
|
|
|
f0b10e |
}
|
|
|
f0b10e |
if (config->min_file_size > 0 &&
|
|
|
f0b10e |
- smb_fname->st.st_ex_size < config->min_file_size)
|
|
|
f0b10e |
+ sbuf.st_ex_size < config->min_file_size)
|
|
|
f0b10e |
{
|
|
|
f0b10e |
DBG_INFO("Not scanned: file size < min file size: %s/%s\n",
|
|
|
f0b10e |
cwd_fname, fname);
|
|
|
f0b10e |
--
|
|
|
f0b10e |
2.34.1
|
|
|
f0b10e |
|