From 6f82ba42523d3a0d9506ad8501f0d847305b5c81 Mon Sep 17 00:00:00 2001 From: Andrew Kiggins <30563055+Kiggins26@users.noreply.github.com> Date: Mon, 16 Oct 2023 15:15:11 -0700 Subject: [PATCH] ClamD: Log an error message and exit 1 for bad temp dir If `TemporaryDirectory` in `clamd.conf` does not exist, ClamD will now print an error message and exit with exit code 1. Fixes: #1028 --- clamd/clamd.c | 7 +++++++ clamd/session.c | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/clamd/clamd.c b/clamd/clamd.c index 796a74e5f5..4d92e81813 100644 --- a/clamd/clamd.c +++ b/clamd/clamd.c @@ -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); diff --git a/clamd/session.c b/clamd/session.c index 4a2e18b8bc..1b11459d3c 100644 --- a/clamd/session.c +++ b/clamd/session.c @@ -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;