...
|
...
|
@@ -589,6 +589,9 @@ void *onas_ddd_th(void *arg) {
|
589
|
589
|
} else if (event->mask & IN_MOVED_TO) {
|
590
|
590
|
onas_ddd_handle_in_moved_to(ctx, path, child_path, event, wd, in_mask);
|
591
|
591
|
}
|
|
592
|
+
|
|
593
|
+ free(child_path);
|
|
594
|
+ child_path = NULL;
|
592
|
595
|
}
|
593
|
596
|
}
|
594
|
597
|
}
|
...
|
...
|
@@ -616,21 +619,21 @@ static void onas_ddd_handle_in_delete(struct onas_context *ctx,
|
616
|
616
|
static void onas_ddd_handle_in_moved_from(struct onas_context *ctx,
|
617
|
617
|
const char *path, const char *child_path, const struct inotify_event *event, int wd) {
|
618
|
618
|
|
619
|
|
- struct stat s;
|
620
|
|
- if (stat(child_path, &s) == 0 && S_ISREG(s.st_mode)) return;
|
621
|
|
- if (!(event->mask & IN_ISDIR)) return;
|
|
619
|
+ struct stat s;
|
|
620
|
+ if (stat(child_path, &s) == 0 && S_ISREG(s.st_mode)) return;
|
|
621
|
+ if (!(event->mask & IN_ISDIR)) return;
|
622
|
622
|
|
623
|
623
|
logg("*ClamInotif: MOVED_FROM - removing %s from %s with wd:%d\n", child_path, path, wd);
|
624
|
624
|
onas_ddd_unwatch(child_path, ctx->fan_fd, onas_in_fd);
|
625
|
|
- onas_ht_rm_hierarchy(ddd_ht, child_path, strlen(child_path), 0);
|
|
625
|
+ onas_ht_rm_hierarchy(ddd_ht, child_path, strlen(child_path), 0);
|
626
|
626
|
|
627
|
|
- return;
|
|
627
|
+ return;
|
628
|
628
|
}
|
629
|
629
|
|
630
|
630
|
static void onas_ddd_handle_in_create(struct onas_context *ctx,
|
631
|
631
|
const char *path, const char *child_path, const struct inotify_event *event, int wd, uint64_t in_mask) {
|
632
|
632
|
|
633
|
|
- struct stat s;
|
|
633
|
+ struct stat s;
|
634
|
634
|
|
635
|
635
|
if (optget(ctx->clamdopts, "OnAccessExtraScanning")->enabled) {
|
636
|
636
|
if(stat(child_path, &s) == 0 && S_ISREG(s.st_mode)) {
|
...
|
...
|
@@ -645,22 +648,22 @@ static void onas_ddd_handle_in_create(struct onas_context *ctx,
|
645
|
645
|
}
|
646
|
646
|
}
|
647
|
647
|
else
|
648
|
|
- {
|
649
|
|
- if (stat(child_path, &s) == 0 && S_ISREG(s.st_mode)) return;
|
650
|
|
- if (!(event->mask & IN_ISDIR)) return;
|
|
648
|
+ {
|
|
649
|
+ if (stat(child_path, &s) == 0 && S_ISREG(s.st_mode)) return;
|
|
650
|
+ if (!(event->mask & IN_ISDIR)) return;
|
651
|
651
|
|
652
|
652
|
logg("*ClamInotif: MOVED_TO - adding %s to %s with wd:%d\n", child_path, path, wd);
|
653
|
|
- onas_ht_add_hierarchy(ddd_ht, child_path);
|
|
653
|
+ onas_ht_add_hierarchy(ddd_ht, child_path);
|
654
|
654
|
onas_ddd_watch(child_path, ctx->fan_fd, ctx->fan_mask, onas_in_fd, in_mask);
|
655
|
|
- }
|
|
655
|
+ }
|
656
|
656
|
|
657
|
|
- return;
|
|
657
|
+ return;
|
658
|
658
|
}
|
659
|
659
|
|
660
|
660
|
static void onas_ddd_handle_in_moved_to(struct onas_context *ctx,
|
661
|
661
|
const char *path, const char *child_path, const struct inotify_event *event, int wd, uint64_t in_mask) {
|
662
|
662
|
|
663
|
|
- struct stat s;
|
|
663
|
+ struct stat s;
|
664
|
664
|
if (optget(ctx->clamdopts, "OnAccessExtraScanning")->enabled) {
|
665
|
665
|
if(stat(child_path, &s) == 0 && S_ISREG(s.st_mode)) {
|
666
|
666
|
onas_ddd_handle_extra_scanning(ctx, child_path, ONAS_SCTH_B_FILE);
|
...
|
...
|
@@ -674,15 +677,15 @@ static void onas_ddd_handle_in_moved_to(struct onas_context *ctx,
|
674
|
674
|
|
675
|
675
|
}
|
676
|
676
|
} else {
|
677
|
|
- if (stat(child_path, &s) == 0 && S_ISREG(s.st_mode)) return;
|
678
|
|
- if (!(event->mask & IN_ISDIR)) return;
|
|
677
|
+ if (stat(child_path, &s) == 0 && S_ISREG(s.st_mode)) return;
|
|
678
|
+ if (!(event->mask & IN_ISDIR)) return;
|
679
|
679
|
|
680
|
680
|
logg("*ClamInotif: MOVED_TO - adding %s to %s with wd:%d\n", child_path, path, wd);
|
681
|
|
- onas_ht_add_hierarchy(ddd_ht, child_path);
|
|
681
|
+ onas_ht_add_hierarchy(ddd_ht, child_path);
|
682
|
682
|
onas_ddd_watch(child_path, ctx->fan_fd, ctx->fan_mask, onas_in_fd, in_mask);
|
683
|
|
- }
|
|
683
|
+ }
|
684
|
684
|
|
685
|
|
- return;
|
|
685
|
+ return;
|
686
|
686
|
}
|
687
|
687
|
|
688
|
688
|
static void onas_ddd_handle_extra_scanning(struct onas_context *ctx, const char *pathname, int extra_options) {
|
...
|
...
|
@@ -703,16 +706,16 @@ static void onas_ddd_handle_extra_scanning(struct onas_context *ctx, const char
|
703
|
703
|
/* inotify specific stuffs */
|
704
|
704
|
event_data->bool_opts |= ONAS_SCTH_B_INOTIFY;
|
705
|
705
|
extra_options & ONAS_SCTH_B_FILE ? event_data->bool_opts |= ONAS_SCTH_B_FILE : extra_options;
|
706
|
|
- extra_options & ONAS_SCTH_B_DIR ? event_data->bool_opts |= ONAS_SCTH_B_DIR : extra_options;
|
|
706
|
+ extra_options & ONAS_SCTH_B_DIR ? event_data->bool_opts |= ONAS_SCTH_B_DIR : extra_options;
|
707
|
707
|
|
708
|
708
|
logg("*ClamInotif: attempting to feed consumer queue\n");
|
709
|
709
|
/* feed consumer queue */
|
710
|
710
|
if (CL_SUCCESS != onas_queue_event(event_data)) {
|
711
|
711
|
logg("!ClamInotif: error occurred while feeding consumer queue extra event ... continuing ...\n");
|
712
|
712
|
return;
|
713
|
|
- }
|
|
713
|
+ }
|
714
|
714
|
|
715
|
|
- return;
|
|
715
|
+ return;
|
716
|
716
|
}
|
717
|
717
|
|
718
|
718
|
static void onas_ddd_exit(void *arg) {
|