diff --git a/clamav-devel/ChangeLog b/clamav-devel/ChangeLog index d6a10a14f..cef6961e1 100644 --- a/clamav-devel/ChangeLog +++ b/clamav-devel/ChangeLog @@ -1,3 +1,8 @@ +Sun Nov 23 23:40:53 CET 2003 (tk) +--------------------------------- + * clamd: redirect the descriptors 1 and 2 to /dev/null by default, to + protect against a lock with Debug when Foreground is not enabled + Sat Nov 22 17:23:10 IST 2003 (njh) ---------------------------------- * clamav-milter: Drop root privileges and support quarantine diff --git a/clamav-devel/clamd/clamd.c b/clamav-devel/clamd/clamd.c index 0570d3967..bb2955deb 100644 --- a/clamav-devel/clamd/clamd.c +++ b/clamav-devel/clamd/clamd.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -222,8 +223,17 @@ void daemonize(void) { int i; - for(i = 0; i <= 2; i++) - close(i); + + if((i = open("/dev/null", O_WRONLY)) == -1) { + logg("!Cannot open /dev/null. Only use Debug if Foreground is enabled.\n"); + for(i = 0; i <= 2; i++) + close(i); + + } else { + close(0); + dup2(i, 1); + dup2(i, 2); + } chdir("/"); diff --git a/clamav-devel/etc/clamav.conf b/clamav-devel/etc/clamav.conf index f5a361d1d..1f83c3adb 100644 --- a/clamav-devel/etc/clamav.conf +++ b/clamav-devel/etc/clamav.conf @@ -2,7 +2,7 @@ ## Example config file for the Clam AV daemon ## Please read the clamav.conf(5) manual before editing this file. ## - + # Comment or remove the line below. Example @@ -43,7 +43,7 @@ Example # Default is the hardcoded directory (mostly /usr/local/share/clamav, # it depends on installation options). #DataDirectory /var/lib/clamav - + # The daemon works in local or network mode. Currently the local mode is # recommended for security reasons. diff --git a/clamav-devel/libclamav/str.c b/clamav-devel/libclamav/str.c index 677e94aa4..c11b5676d 100644 --- a/clamav-devel/libclamav/str.c +++ b/clamav-devel/libclamav/str.c @@ -120,6 +120,9 @@ void cli_chomp(char *string) { if(string[strlen(string) - 1] == 10 || string[strlen(string) - 1 ] == 13) string[strlen(string) -1] = 0; + + if(string[strlen(string) - 1] == '\r') + string[strlen(string) -1] = 0; } char *cli_tok(const char *line, int field, char delimiter)