Skip to content

Commit

Permalink
ClamD: Log an error message and exit 1 for bad temp dir
Browse files Browse the repository at this point in the history
If `TemporaryDirectory` in `clamd.conf` does not exist, ClamD will now
print an error message and exit with exit code 1. 

Fixes: #1028
  • Loading branch information
Kiggins26 authored Oct 16, 2023
1 parent 0f9de9e commit 6f82ba4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 7 additions & 0 deletions clamd/clamd.c
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,13 @@ int main(int argc, char **argv)
ret = 1;
break;
}

STATBUF sb;
if (CLAMSTAT(opt->strarg, &sb) != 0 && !S_ISDIR(sb.st_mode)) {
logg(LOGG_ERROR, "Current configuration of TemporaryDirectory: %s does not exist, or is not valid \n", opt->strarg);
ret = 1;
break;
}
}

cl_engine_set_clcb_hash(engine, hash_callback);
Expand Down
5 changes: 3 additions & 2 deletions clamd/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -591,8 +591,9 @@ int execute_or_dispatch_command(client_conn_t *conn, enum commands cmd, const ch
}
case COMMAND_INSTREAM: {
int rc = cli_gentempfd(optget(conn->opts, "TemporaryDirectory")->strarg, &conn->filename, &conn->scanfd);
if (rc != CL_SUCCESS)
return rc;
if (rc != CL_SUCCESS) {
return 1;
}
conn->quota = optget(conn->opts, "StreamMaxLength")->numarg;
conn->mode = MODE_STREAM;
return 0;
Expand Down

0 comments on commit 6f82ba4

Please sign in to comment.