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