Mailing List Archive

Background before reading signatures to avoid boot delay with OpenRC init
Dear Clamav,
I found a problem with the boot being delayed when using OpenRC. I made a new "DaemonizeFaster" option in clamd.conf and a command line option for clamd (as it was simple to add at the same time) to resolve this, see patches below. I wondered if you could add this unless you have a better solution, and of course if you wish to alter this in any way or change the name or description that's fine too. It seems to give the intended effect. Some people might want to wait and load the signatures if they were using on access scanning at boot, but for using clamdscan it is a nuisance. This would make it easy for users to configure and possibly it could be helpful in other usage scenarios, if you didn't want to wait around for it to background itself fully.
https://forum.artixlinux.org/index.php/topic,3855.msg24926.html#msg24926



--- clamd.conf.sample
+++ clamd.conf.sample
@@ -56,6 +56,11 @@
# Default: no
#LogRotate yes
+# If running in background, don't wait for signature loading at start.
+# The command will return before clamd is operational.
+# Default: no
+#DaemonizeFaster yes
+
# Enable Prelude output.
# Default: no
#PreludeEnable yes



--- clamd.conf.5.in
+++ clamd.conf.5.in
@@ -77,6 +77,11 @@
.br
Default: no
.TP
+\fBDaemonizeFaster BOOL\fR
+If running in background, don't wait for signature loading at start. The command will return before clamd is operational.
+.br
+Default: no
+.TP
\fBExtendedDetectionInfo BOOL\fR
Log additional information about the infected file, such as its size and hash, together with the virus name.
.br



--- clamd.c
+++ clamd.c
@@ -468,6 +468,15 @@
if (optget(opts, "disable-cache")->enabled)
cl_engine_set_num(engine, CL_ENGINE_DISABLE_CACHE, 1);
+#ifndef _WIN32
+
+ if (optget(opts, "DaemonizeFaster")->enabled) {
+ if (parentPid != getpid()) {
+ daemonize_signal_parent(parentPid);
+ }
+ }
+#endif
+
/* load the database(s) */
dbdir = optget(opts, "DatabaseDirectory")->strarg;
logg("#Reading databases from %s\n", dbdir);
@@ -814,8 +823,10 @@
* now, since everything is initialized.*/
/*signal the parent process.*/
- if (parentPid != getpid()) {
- daemonize_signal_parent(parentPid);
+ if (!optget(opts, "DaemonizeFaster")->enabled) {
+ if (parentPid != getpid()) {
+ daemonize_signal_parent(parentPid);
+ }
}
#endif
}



--- optparser.c
+++ optparser.c
@@ -239,6 +239,8 @@
{NULL, "deb", 0, CLOPT_TYPE_STRING, NULL, -1, "foo", 0, OPT_CLAMSCAN | OPT_DEPRECATED, "", ""},
/* config file/cmdline options */
+ {"DaemonizeFaster", "DaemonizeFaster", 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMD, "Exit to background before signatures are read", ""},
+
{"AlertExceedsMax", "alert-exceeds-max", 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMD | OPT_CLAMSCAN, "", ""},
{"PreludeEnable", "prelude-enable", 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMD, "Enable prelude", ""},



_______________________________________________

clamav-devel mailing list
clamav-devel@lists.clamav.net
https://lists.clamav.net/mailman/listinfo/clamav-devel

Please submit your patches to our Github: https://github.com/Cisco-Talos/clamav-devel/pulls

Help us build a comprehensive ClamAV guide:
https://github.com/vrtadmin/clamav-faq

http://www.clamav.net/contact.html#ml