mirror of
https://github.com/Cisco-Talos/clamav.git
synced 2025-10-19 10:23:17 +00:00
bb12620: freshclam clean up tmp dir with EXIT_1
When using --on-update-execute=EXIT_1 freshclam doesn't clean up the temporary directory where it downloaded and tested the new database. This patch moves the command execution to happen after temp-cleanup.
This commit is contained in:
parent
3a7a20c323
commit
6b08dda088
4 changed files with 28 additions and 18 deletions
|
@ -148,6 +148,7 @@ DatabaseMirror database.clamav.net
|
|||
#NotifyClamd /path/to/clamd.conf
|
||||
|
||||
# Run command after successful database update.
|
||||
# Use EXIT_1 to return 1 after successful database update.
|
||||
# Default: disabled
|
||||
#OnUpdateExecute command
|
||||
|
||||
|
|
|
@ -184,7 +184,8 @@ static void help(void)
|
|||
printf(" --datadir=DIRECTORY Download new databases into DIRECTORY\n");
|
||||
printf(" --daemon-notify[=/path/clamd.conf] Send RELOAD command to clamd\n");
|
||||
printf(" --local-address=IP -a IP Bind to IP for HTTP downloads\n");
|
||||
printf(" --on-update-execute=COMMAND Execute COMMAND after successful update\n");
|
||||
printf(" --on-update-execute=COMMAND Execute COMMAND after successful update.\n");
|
||||
printf(" Use EXIT_1 to return 1 after successful database update.\n");
|
||||
printf(" --on-error-execute=COMMAND Execute COMMAND if errors occurred\n");
|
||||
printf(" --on-outdated-execute=COMMAND Execute COMMAND when software is outdated\n");
|
||||
printf(" --update-db=DBNAME Only update database DBNAME\n");
|
||||
|
@ -1480,18 +1481,11 @@ fc_error_t perform_database_update(
|
|||
}
|
||||
|
||||
if (0 < nTotalUpdated) {
|
||||
if (NULL != notifyClamd)
|
||||
if (NULL != notifyClamd) {
|
||||
notify(notifyClamd);
|
||||
|
||||
if (NULL != onUpdateExecute) {
|
||||
execute("OnUpdateExecute", onUpdateExecute, bDaemonized);
|
||||
}
|
||||
}
|
||||
|
||||
if ((NULL != newVersion) && (NULL != onOutdatedExecute)) {
|
||||
executeIfNewVersion(onOutdatedExecute, newVersion, bDaemonized);
|
||||
}
|
||||
|
||||
status = FC_SUCCESS;
|
||||
|
||||
done:
|
||||
|
@ -1502,6 +1496,20 @@ done:
|
|||
cli_rmdirs(g_freshclamTempDirectory);
|
||||
}
|
||||
}
|
||||
|
||||
if (FC_SUCCESS == status) {
|
||||
/* Run Execute commands after we clean up the temp directory,
|
||||
* in case they want us to EXIT */
|
||||
if (0 < nTotalUpdated) {
|
||||
if (NULL != onUpdateExecute) {
|
||||
execute("OnUpdateExecute", onUpdateExecute, bDaemonized);
|
||||
}
|
||||
}
|
||||
if ((NULL != newVersion) && (NULL != onOutdatedExecute)) {
|
||||
executeIfNewVersion(onOutdatedExecute, newVersion, bDaemonized);
|
||||
}
|
||||
}
|
||||
|
||||
if (NULL != dnsUpdateInfo) {
|
||||
free(dnsUpdateInfo);
|
||||
}
|
||||
|
|
|
@ -84,19 +84,19 @@ char _CONFDIR_CLAMD[MAX_PATH] = BACKUP_CONFDIR "\\clamd.conf";
|
|||
char _CONFDIR_FRESHCLAM[MAX_PATH] = BACKUP_CONFDIR "\\freshclam.conf";
|
||||
char _CONFDIR_MILTER[MAX_PATH] = BACKUP_CONFDIR "\\clamav-milter.conf";
|
||||
|
||||
#define CONST_DATADIR _DATADIR
|
||||
#define CONST_CONFDIR _CONFDIR
|
||||
#define CONST_CONFDIR_CLAMD _CONFDIR_CLAMD
|
||||
#define CONST_DATADIR _DATADIR
|
||||
#define CONST_CONFDIR _CONFDIR
|
||||
#define CONST_CONFDIR_CLAMD _CONFDIR_CLAMD
|
||||
#define CONST_CONFDIR_FRESHCLAM _CONFDIR_FRESHCLAM
|
||||
#define CONST_CONFDIR_MILTER _CONFDIR_MILTER
|
||||
#define CONST_CONFDIR_MILTER _CONFDIR_MILTER
|
||||
|
||||
#else
|
||||
|
||||
#define CONST_DATADIR DATADIR
|
||||
#define CONST_CONFDIR CONFDIR
|
||||
#define CONST_CONFDIR_CLAMD CONFDIR_CLAMD
|
||||
#define CONST_DATADIR DATADIR
|
||||
#define CONST_CONFDIR CONFDIR
|
||||
#define CONST_CONFDIR_CLAMD CONFDIR_CLAMD
|
||||
#define CONST_CONFDIR_FRESHCLAM CONFDIR_FRESHCLAM
|
||||
#define CONST_CONFDIR_MILTER CONFDIR_MILTER
|
||||
#define CONST_CONFDIR_MILTER CONFDIR_MILTER
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -531,7 +531,7 @@ const struct clam_option __clam_options[] = {
|
|||
|
||||
{"NotifyClamd", "daemon-notify", 0, CLOPT_TYPE_STRING, NULL, -1, CONST_CONFDIR_CLAMD, 0, OPT_FRESHCLAM, "Send the RELOAD command to clamd after a successful update.", "yes"},
|
||||
|
||||
{"OnUpdateExecute", "on-update-execute", 0, CLOPT_TYPE_STRING, NULL, -1, NULL, 0, OPT_FRESHCLAM, "Run a command after a successful database update.", "command"},
|
||||
{"OnUpdateExecute", "on-update-execute", 0, CLOPT_TYPE_STRING, NULL, -1, NULL, 0, OPT_FRESHCLAM, "Run a command after a successful database update. Use EXIT_1 to return 1 after successful database update.", "command"},
|
||||
|
||||
{"OnErrorExecute", "on-error-execute", 0, CLOPT_TYPE_STRING, NULL, -1, NULL, 0, OPT_FRESHCLAM, "Run a command when a database update error occurs.", "command"},
|
||||
|
||||
|
|
|
@ -145,6 +145,7 @@ DatabaseMirror database.clamav.net
|
|||
#NotifyClamd "C:\Program Files\ClamAV\clamd.conf"
|
||||
|
||||
# Run command after successful database update.
|
||||
# Use EXIT_1 to return 1 after successful database update.
|
||||
# Default: disabled
|
||||
#OnUpdateExecute command
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue