Skip to content

Commit

Permalink
Merge pull request #1309 from userwiths/issue-1174-FailIfCvdOlderThan…
Browse files Browse the repository at this point in the history
…-error-on-whitelist

 fix: Allow `clamd` to start normally when a whitelist is present.
  • Loading branch information
micahsnyder authored Jul 23, 2024
2 parents 2a5241a + 9a7b186 commit 6c0d644
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
9 changes: 9 additions & 0 deletions clamscan/manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -1251,6 +1251,15 @@ int scanmanager(const struct optstruct *opts)
if ((opt = optget(opts, "database"))->active) {
while (opt) {
if (optget(opts, "fail-if-cvd-older-than")->enabled) {
if (LSTAT(opt->strarg, &sb) == -1) {
logg(LOGG_ERROR, "Can't access database directory/file: %s\n", opt->strarg);
ret = 2;
goto done;
}
if (!S_ISDIR(sb.st_mode) && !CLI_DBEXT_SIGNATURE(opt->strarg)) {
opt = opt->nextarg;
continue;
}
if (check_if_cvd_outdated(opt->strarg, optget(opts, "fail-if-cvd-older-than")->numarg) != CL_SUCCESS) {
ret = 2;
goto done;
Expand Down
2 changes: 1 addition & 1 deletion libclamav/cvd.c
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ cl_error_t cl_cvdgetage(const char *path, time_t *age_seconds)
if (!strcmp(dent->d_name, ".") || !strcmp(dent->d_name, ".."))
continue;

if (!CLI_DBEXT(dent->d_name))
if (!CLI_DBEXT_SIGNATURE(dent->d_name))
continue;

if (ends_with_sep)
Expand Down
8 changes: 8 additions & 0 deletions libclamav/readdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ struct cli_matcher;
cli_strbcasestr(ext, ".ign") || \
cli_strbcasestr(ext, ".ign2") || \
cli_strbcasestr(ext, ".imp"))
#define CLI_DBEXT_SIGNATURE(ext) \
( \
cli_strbcasestr(ext, ".cvd") || \
cli_strbcasestr(ext, ".cld"))
#else
#define CLI_DBEXT(ext) \
( \
Expand Down Expand Up @@ -120,6 +124,10 @@ struct cli_matcher;
cli_strbcasestr(ext, ".ign") || \
cli_strbcasestr(ext, ".ign2") || \
cli_strbcasestr(ext, ".imp"))
#define CLI_DBEXT_SIGNATURE(ext) \
( \
cli_strbcasestr(ext, ".cvd") || \
cli_strbcasestr(ext, ".cld"))
#endif

char *cli_virname(const char *virname, unsigned int official);
Expand Down

0 comments on commit 6c0d644

Please sign in to comment.