From Denis Karpelevich: I've setup Samba in RHEL8.4 to use ClamAV to scan files on open(). Samba v4.13.3 works fine and hands files over to ClamAV to be scanned. Trying to open an eicar.txt virus test file is successfully denied: virusfilter_clamav_scan_init: clamd: Connected virusfilter_clamav_scan: Scanning file: /srv/virustest/eicar.txt virusfilter_clamav_scan_end: clamd: Disconnecting virusfilter_scan: Scan result: Infected: /srv/virustest/eicar.txt: Eicar-Signature ... After upgrading to Samba v4.14.5 the file will not be scanned anymore. Output from debug log: virusfilter_vfs_openat: Not scanned: Directory or special file: /srv/virustest/eicar.txt I can't see why it should be some kind of special file now. S_ISREG reports type file correctly when testing with a simple C program. Version-Release number of selected component (if applicable): $ smbd -V Version 4.14.5 How reproducible: Upgrade from Samba 4.13.3 to 4.14.5 =========== Patch will follow.
Just a quick guess on the raw patch. ------------------------------------- diff --git a/source3/modules/vfs_virusfilter.c b/source3/modules/vfs_virusfilter.c index 524e7dfbad9..36988b7393e 100644 --- a/source3/modules/vfs_virusfilter.c +++ b/source3/modules/vfs_virusfilter.c @@ -1292,7 +1292,7 @@ static int virusfilter_vfs_openat(struct vfs_handle_struct *handle, */ goto virusfilter_vfs_open_next; } - ret = S_ISREG(smb_fname->st.st_ex_mode); + ret = S_ISREG(sbuf.st_ex_mode); if (ret == 0) { DBG_INFO("Not scanned: Directory or special file: %s/%s\n", cwd_fname, fname); --------------------------------------- Yeah ?
Yeah ? ... Bingo !
(In reply to Pavel Fiipenský from comment #2) But you also added tests ! This is *glorious* :-).
This bug was referenced in samba master: 9f34babec7c6aca3d91f226705d3b3996792e5f1 2fd518e5cc63221c162c9b3f8526b9b7c9e34969 547b4c595a8513a4be99177edbaa39ce43840f7a a25c714c34d3e00e0f3c29d2acfa98cf9cdbc544 3f1c958f6fa9d2991185f4e281a377a295d09f9c
Created attachment 17157 [details] patch for v4-15 cherry-picked from master
Created attachment 17158 [details] patch for v4-16 cherry-picked from master
Comment on attachment 17158 [details] patch for v4-16 This is *NOT* the version the went into master. It still has the: +static virusfilter_result virusfilter_dummy_scan( + struct vfs_handle_struct *handle, + struct virusfilter_config *config, + const struct files_struct *fsp, + char **reportp) +{ + char *cwd_fname = fsp->conn->cwd_fsp->fsp_name->base_name; + const char *fname = fsp->fsp_name->base_name; code in it. Please cherry-pick from the right place.
Comment on attachment 17157 [details] patch for v4-15 This is *NOT* the version the went into master. It still has the: +static virusfilter_result virusfilter_dummy_scan( + struct vfs_handle_struct *handle, + struct virusfilter_config *config, + const struct files_struct *fsp, + char **reportp) +{ + char *cwd_fname = fsp->conn->cwd_fsp->fsp_name->base_name; + const char *fname = fsp->fsp_name->base_name; code in it. Please cherry-pick from the right place.
Created attachment 17159 [details] patch for v4-15 Now cherry-pick from origin/master
Created attachment 17160 [details] patch for v4-16 cherry-picked from origin/master
Jule, please apply the patches to the corresponding branches. Thanks! :-)
Pushed to autobuild-v4-{16,15}-test.
This bug was referenced in samba v4-15-test: b78a62a1f9f501b400366710d571765afe66277a 517266c75d071d41b33042db164f4f1cb7b3a5d3 a117fca9196e83640cec1c36ea90516afec8114b a47cc2161569557bdb5c8c4ab896dd727e2de999 1d0ba38822398f9df66ca9e1b6e620d07b026c92
This bug was referenced in samba v4-16-test: 174fcd9f6b34fcbb7dfe1571097118bdc82ae2f6 db32ea07caa75623d0e4e82cd7971e50dc53dc99 e95306ed8e3023419bef683264d7232a17d3eb8d 63f6fac589e0fb210521e80111f53a8914a5f1a0 e1e2bae551ebf031634c3b33a7fe3cb9fad7e8ee
Closing out bug report. Thanks!
This bug was referenced in samba v4-16-stable (Release samba-4.16.0rc3): 174fcd9f6b34fcbb7dfe1571097118bdc82ae2f6 db32ea07caa75623d0e4e82cd7971e50dc53dc99 e95306ed8e3023419bef683264d7232a17d3eb8d 63f6fac589e0fb210521e80111f53a8914a5f1a0 e1e2bae551ebf031634c3b33a7fe3cb9fad7e8ee
Created attachment 17174 [details] patch for v4-14 It is fixing a regression of v4-14.
Comment on attachment 17174 [details] patch for v4-14 LGTM
Pushed to autobuild-v4-14-test.
This bug was referenced in samba v4-14-test: 043f4b274b35417a60e6a2d21d50adfe2fca68f2 e7c419d83971ed4c0bde3768a9f37b12f16234c3 ae703cd4bcbab36c3b2c344405254f22b9c81e2c babfb2279544a0052a02898ab25eee19fee3566c 3d90f070894dda79f77f72b72c9310a6d5f8d8af
Closing out bug report. Thanks again!
Comment on attachment 17174 [details] patch for v4-14 LGTM.
This bug was referenced in samba v4-15-stable (Release samba-4.15.6): b78a62a1f9f501b400366710d571765afe66277a 517266c75d071d41b33042db164f4f1cb7b3a5d3 a117fca9196e83640cec1c36ea90516afec8114b a47cc2161569557bdb5c8c4ab896dd727e2de999 1d0ba38822398f9df66ca9e1b6e620d07b026c92
This bug was referenced in samba v4-14-stable (Release samba-4.14.13): 043f4b274b35417a60e6a2d21d50adfe2fca68f2 e7c419d83971ed4c0bde3768a9f37b12f16234c3 ae703cd4bcbab36c3b2c344405254f22b9c81e2c babfb2279544a0052a02898ab25eee19fee3566c 3d90f070894dda79f77f72b72c9310a6d5f8d8af