From 0c464fb5c5746461a72fafb3ac9e95d73a78f7f6 Mon Sep 17 00:00:00 2001 From: Andrew Kiggins Date: Tue, 26 Sep 2023 16:25:18 -0700 Subject: [PATCH] Adds logging and changes return status for bad temp dir: Issue #1028 --- clamd/clamd.c | 6 ++++++ clamd/session.c | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/clamd/clamd.c b/clamd/clamd.c index 796a74e5f5..11e9d3a961 100644 --- a/clamd/clamd.c +++ b/clamd/clamd.c @@ -568,6 +568,12 @@ int main(int argc, char **argv) ret = 1; break; } + + if (stat(CL_ENGINE_TMPDIR, &sb) != 0 && !S_ISDIR(sb.st_mode)) { + logg(LOGG_ERROR, "Current configuration of TemporaryDirectory: %s does not exist, or is not valid", CL_ENGINE_TMPDIR); + ret = 1; + break; + } } cl_engine_set_clcb_hash(engine, hash_callback); diff --git a/clamd/session.c b/clamd/session.c index 4a2e18b8bc..dff12232b3 100644 --- a/clamd/session.c +++ b/clamd/session.c @@ -591,8 +591,10 @@ 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) { + logg(LOGG_ERROR, "Failed to generate file in TemporaryDirectory, filename: %s \n", &conn->filename); + return 1; + } conn->quota = optget(conn->opts, "StreamMaxLength")->numarg; conn->mode = MODE_STREAM; return 0;