[Clamav-devel] Patch for OnAccessIncludePath traversal across file systems

Arthur Ramsey arthurramsey19 at gmail.com
Thu Oct 10 18:15:29 EDT 2019


Don’t expect this to get accepted but would like some feedback since this is my 1st time doing much of anything in C.  I think this could be a useful feature but should probably be a non-default option.

This patch is against 1.101.4.

--- a/clamd/onaccess_hash.c
+++ b/clamd/onaccess_hash.c
@@ -33,6 +33,7 @@
#include <string.h>
#include <errno.h>
#include <stdbool.h>
+#include <mntent.h>

#include <sys/fanotify.h>

@@ -622,6 +623,22 @@ int onas_ht_add_hierarchy(struct onas_ht *ht, const char *pathname) {
     if (!elem) return CL_EMEM;

     if (onas_ht_insert(ht, elem)) return -1;
+
+        char buf[10240];
+        struct mntent ent;
+        struct mntent *mntent;
+        FILE *mountinfo;
+        mountinfo = setmntent("/proc/mounts", "r");
+        if (mountinfo == NULL) {
+            logg("!ScanOnAccess: setmntent failed\n");
+            return CL_EARG;
+        }
+        while ((mntent = getmntent_r(mountinfo, &ent, buf, sizeof(buf))) != NULL) {
+            if (strcmp(curr->fts_path, pathname) != 0 && strcmp(curr->fts_path, mntent->mnt_dir) == 0) {
+                onas_ht_add_hierarchy(ht, curr->fts_path);
+            }
+        }
+        endmntent(mountinfo);
  }

  _priv_fts_close(ftsp);

For more context seet: https://lists.gt.net/clamav/users/77314.


More information about the clamav-devel mailing list