git-svn: trunk@3446
Nigel Horne authored on 2007/12/21 08:27:07... | ... |
@@ -1,3 +1,7 @@ |
1 |
+Thu Dec 20 22:48:35 GMT 2007 (njh) |
|
2 |
+---------------------------------- |
|
3 |
+ * clamav-milter: Removed calls to cli_*msg() |
|
4 |
+ |
|
1 | 5 |
Thu Dec 20 12:09:22 GMT 2007 (njh) |
2 | 6 |
---------------------------------- |
3 | 7 |
* clamav-milter: Fix handling of 2nd and subsequent SIGUSR2 calls |
... | ... |
@@ -1198,10 +1198,12 @@ main(int argc, char **argv) |
1198 | 1198 |
|
1199 | 1199 |
if(setuid(user->pw_uid) < 0) |
1200 | 1200 |
perror(cpt->strarg); |
1201 |
+#ifdef CL_DEBUG |
|
1201 | 1202 |
else |
1202 |
- logg(_("Running as user %s (UID %d, GID %d)\n"), |
|
1203 |
+ printf(_("Running as user %s (UID %d, GID %d)\n"), |
|
1203 | 1204 |
cpt->strarg, (int)user->pw_uid, |
1204 | 1205 |
(int)user->pw_gid); |
1206 |
+#endif |
|
1205 | 1207 |
|
1206 | 1208 |
/* |
1207 | 1209 |
* Note, some O/Ss (e.g. OpenBSD/Fedora Linux) FORCE |
... | ... |
@@ -1261,7 +1263,7 @@ main(int argc, char **argv) |
1261 | 1261 |
} |
1262 | 1262 |
} |
1263 | 1263 |
} else |
1264 |
- logg(_("^%s: running as root is not recommended (check \"User\" in %s)\n"), argv[0], cfgfile); |
|
1264 |
+ printf(_("^%s: running as root is not recommended (check \"User\" in %s)\n"), argv[0], cfgfile); |
|
1265 | 1265 |
} else if(iface) { |
1266 | 1266 |
fprintf(stderr, _("%s: Only root can set an interface for --broadcast\n"), argv[0]); |
1267 | 1267 |
return EX_USAGE; |
... | ... |
@@ -1559,7 +1561,9 @@ main(int argc, char **argv) |
1559 | 1559 |
free(hostname); |
1560 | 1560 |
} |
1561 | 1561 |
|
1562 |
- logg("numServers: %d\n", numServers); |
|
1562 |
+#ifdef CL_DEBUG |
|
1563 |
+ printf("numServers: %d\n", numServers); |
|
1564 |
+#endif |
|
1563 | 1565 |
|
1564 | 1566 |
serverIPs = (in_addr_t *)cli_malloc(numServers * sizeof(in_addr_t)); |
1565 | 1567 |
if(serverIPs == NULL) |
... | ... |
@@ -1634,7 +1638,7 @@ main(int argc, char **argv) |
1634 | 1634 |
break; |
1635 | 1635 |
if(checkClamd(1)) /* will try all servers */ |
1636 | 1636 |
break; |
1637 |
- logg(_("Waiting for clamd to come up\n")); |
|
1637 |
+ puts(_("Waiting for clamd to come up")); |
|
1638 | 1638 |
/* |
1639 | 1639 |
* something to do as the system starts |
1640 | 1640 |
*/ |
... | ... |
@@ -1648,13 +1652,13 @@ main(int argc, char **argv) |
1648 | 1648 |
if(pingServer(i)) |
1649 | 1649 |
activeServers++; |
1650 | 1650 |
else { |
1651 |
- logg(_("^Can't talk to clamd server %s on port %d\n"), |
|
1651 |
+ printf(_("Can't talk to clamd server %s on port %d\n"), |
|
1652 | 1652 |
hostname, tcpSocket); |
1653 | 1653 |
if(serverIPs[i] == htonl(INADDR_LOOPBACK)) { |
1654 | 1654 |
if(cfgopt(copt, "TCPAddr")->enabled) |
1655 |
- cli_warnmsg(_("Check the value for TCPAddr in %s\n"), cfgfile); |
|
1655 |
+ printf(_("Check the value for TCPAddr in %s\n"), cfgfile); |
|
1656 | 1656 |
} else |
1657 |
- cli_warnmsg(_("Check the value for TCPAddr in clamd.conf on %s\n"), hostname); |
|
1657 |
+ printf(_("Check the value for TCPAddr in clamd.conf on %s\n"), hostname); |
|
1658 | 1658 |
} |
1659 | 1659 |
#endif |
1660 | 1660 |
|
... | ... |
@@ -1670,15 +1674,14 @@ main(int argc, char **argv) |
1670 | 1670 |
if(createSession(i) < 0) |
1671 | 1671 |
return EX_UNAVAILABLE; |
1672 | 1672 |
if(activeServers == 0) { |
1673 |
- logg(_("!Can't find any clamd server\n")); |
|
1674 |
- cli_warnmsg(_("Check your entry for TCPSocket in %s\n"), |
|
1673 |
+ fprintf(stderr, _("Check your entry for TCPSocket in %s\n"), |
|
1675 | 1674 |
cfgfile); |
1676 | 1675 |
} |
1677 | 1676 |
#else |
1678 | 1677 |
if(activeServers == 0) { |
1679 |
- cli_errmsg(_("Check your entry for TCPSocket in %s\n"), |
|
1678 |
+ fprintf(stderr, _("Check your entry for TCPSocket in %s\n"), |
|
1680 | 1679 |
cfgfile); |
1681 |
- logg(_("!Can't find any clamd server\n")); |
|
1680 |
+ fputs(_("Can't find any clamd server\n"), stderr); |
|
1682 | 1681 |
return EX_CONFIG; |
1683 | 1682 |
} |
1684 | 1683 |
last_failed_pings = (time_t *)cli_calloc(numServers, sizeof(time_t)); |
... | ... |
@@ -2034,14 +2037,14 @@ main(int argc, char **argv) |
2034 | 2034 |
} |
2035 | 2035 |
|
2036 | 2036 |
if(smfi_register(smfilter) == MI_FAILURE) { |
2037 |
- cli_errmsg("smfi_register failure, ensure that you have linked against the correct version of sendmail\n"); |
|
2037 |
+ fprintf(stderr, "smfi_register failure, ensure that you have linked against the correct version of sendmail\n"); |
|
2038 | 2038 |
return EX_UNAVAILABLE; |
2039 | 2039 |
} |
2040 | 2040 |
|
2041 | 2041 |
#if ((SENDMAIL_VERSION_A > 8) || ((SENDMAIL_VERSION_A == 8) && (SENDMAIL_VERSION_B >= 13))) |
2042 | 2042 |
if(smfi_opensocket(1) == MI_FAILURE) { |
2043 | 2043 |
perror(port); |
2044 |
- cli_errmsg("Can't open/create %s\n", port); |
|
2044 |
+ fprintf(stderr, "Can't open/create %s\n", port); |
|
2045 | 2045 |
return EX_CONFIG; |
2046 | 2046 |
} |
2047 | 2047 |
#endif |
... | ... |
@@ -2091,7 +2094,8 @@ main(int argc, char **argv) |
2091 | 2091 |
#endif |
2092 | 2092 |
|
2093 | 2093 |
(void)signal(SIGSEGV, sigsegv); |
2094 |
- (void)signal(SIGHUP, sighup); |
|
2094 |
+ if(!logg_foreground) |
|
2095 |
+ (void)signal(SIGHUP, sighup); |
|
2095 | 2096 |
if(!external) |
2096 | 2097 |
(void)signal(SIGUSR2, sigusr2); |
2097 | 2098 |
|
... | ... |
@@ -5888,14 +5892,18 @@ sigsegv(int sig) |
5888 | 5888 |
static void |
5889 | 5889 |
sighup(int sig) |
5890 | 5890 |
{ |
5891 |
- const struct cfgstruct *cpt; |
|
5891 |
+ extern FILE *logg_fd; |
|
5892 | 5892 |
|
5893 | 5893 |
signal(SIGHUP, sighup); |
5894 | 5894 |
|
5895 |
+ if(!(cfgopt(copt, "LogFile"))->enabled) |
|
5896 |
+ return; |
|
5897 |
+ |
|
5895 | 5898 |
logg("SIGHUP caught: re-opening log file\n"); |
5896 | 5899 |
logg_close(); |
5897 |
- if(!logg_file && (cpt = cfgopt(copt, "LogFile"))->enabled) |
|
5898 |
- logg_file = cpt->strarg; |
|
5900 |
+ logg("*Log file re-opened\n"); |
|
5901 |
+ close(2); |
|
5902 |
+ dup(fileno(logg_fd)); |
|
5899 | 5903 |
} |
5900 | 5904 |
|
5901 | 5905 |
static void |
... | ... |
@@ -5919,7 +5927,7 @@ print_trace(void) |
5919 | 5919 |
size = backtrace(array, BACKTRACE_SIZE); |
5920 | 5920 |
strings = backtrace_symbols(array, size); |
5921 | 5921 |
|
5922 |
- cli_dbgmsg("Backtrace of pid %d:\n", pid); |
|
5922 |
+ logg("*Backtrace of pid %d:\n", pid); |
|
5923 | 5923 |
|
5924 | 5924 |
for(i = 0; i < size; i++) |
5925 | 5925 |
logg("bt[%u]: %s", i, strings[i]); |
... | ... |
@@ -6018,7 +6026,7 @@ isWhitelisted(const char *emailaddress, int to) |
6018 | 6018 |
static table_t *to_whitelist, *from_whitelist; /* never freed */ |
6019 | 6019 |
table_t *table; |
6020 | 6020 |
|
6021 |
- cli_dbgmsg("isWhitelisted %s\n", emailaddress); |
|
6021 |
+ logg("*isWhitelisted %s\n", emailaddress); |
|
6022 | 6022 |
|
6023 | 6023 |
/* |
6024 | 6024 |
* Don't scan messages to the quarantine email address |
... | ... |
@@ -6117,7 +6125,7 @@ isBlacklisted(const char *ip_address) |
6117 | 6117 |
/* Blacklisting not being used */ |
6118 | 6118 |
return 0; |
6119 | 6119 |
|
6120 |
- cli_dbgmsg("isBlacklisted %s\n", ip_address); |
|
6120 |
+ logg("*isBlacklisted %s\n", ip_address); |
|
6121 | 6121 |
|
6122 | 6122 |
if(isLocal(ip_address)) |
6123 | 6123 |
return 0; |
... | ... |
@@ -6574,7 +6582,7 @@ black_hole(const struct privdata *privdata) |
6574 | 6574 |
FILE *sendmail; |
6575 | 6575 |
char buf[BUFSIZ]; |
6576 | 6576 |
|
6577 |
- cli_dbgmsg("Calling \"%s -bv %s\"\n", SENDMAIL_BIN, *to); |
|
6577 |
+ logg("*Calling \"%s -bv %s\"\n", SENDMAIL_BIN, *to); |
|
6578 | 6578 |
|
6579 | 6579 |
if(pipe(pv) < 0) { |
6580 | 6580 |
perror("pipe"); |
... | ... |
@@ -6619,7 +6627,7 @@ black_hole(const struct privdata *privdata) |
6619 | 6619 |
if(cli_chomp(buf) == 0) |
6620 | 6620 |
continue; |
6621 | 6621 |
|
6622 |
- cli_dbgmsg("sendmail output: %s\n", buf); |
|
6622 |
+ logg("*sendmail output: %s\n", buf); |
|
6623 | 6623 |
|
6624 | 6624 |
if(strstr(buf, "... deliverable: mailer ")) { |
6625 | 6625 |
const char *p = strstr(buf, ", user "); |
... | ... |
@@ -6809,9 +6817,9 @@ nonblock_connect(int sock, const struct sockaddr_in *sin, const char *hostname) |
6809 | 6809 |
flags = fcntl(sock, F_GETFL, 0); |
6810 | 6810 |
|
6811 | 6811 |
if(flags == -1L) |
6812 |
- cli_warnmsg("getfl: %s\n", strerror(errno)); |
|
6812 |
+ logg("^getfl: %s\n", strerror(errno)); |
|
6813 | 6813 |
else if(fcntl(sock, F_SETFL, (long)(flags | O_NONBLOCK)) < 0) |
6814 |
- cli_warnmsg("setfl: %s\n", strerror(errno)); |
|
6814 |
+ logg("^setfl: %s\n", strerror(errno)); |
|
6815 | 6815 |
#else |
6816 | 6816 |
flags = -1L; |
6817 | 6817 |
#endif |
... | ... |
@@ -6819,18 +6827,18 @@ nonblock_connect(int sock, const struct sockaddr_in *sin, const char *hostname) |
6819 | 6819 |
switch(errno) { |
6820 | 6820 |
case EALREADY: |
6821 | 6821 |
case EINPROGRESS: |
6822 |
- cli_dbgmsg("%s: connect: %s\n", hostname, |
|
6822 |
+ logg("*%s: connect: %s\n", hostname, |
|
6823 | 6823 |
strerror(errno)); |
6824 | 6824 |
break; /* wait for connection */ |
6825 | 6825 |
case EISCONN: |
6826 | 6826 |
return 0; /* connected */ |
6827 | 6827 |
default: |
6828 |
- cli_warnmsg("%s: connect: %s\n", |
|
6829 |
- hostname, strerror(errno)); |
|
6828 |
+ logg("^%s: connect: %s\n", hostname, |
|
6829 |
+ strerror(errno)); |
|
6830 | 6830 |
#ifdef F_SETFL |
6831 | 6831 |
if(flags != -1L) |
6832 | 6832 |
if(fcntl(sock, F_SETFL, flags)) |
6833 |
- cli_warnmsg("f_setfl: %s\n", strerror(errno)); |
|
6833 |
+ logg("^f_setfl: %s\n", strerror(errno)); |
|
6834 | 6834 |
#endif |
6835 | 6835 |
return -1; /* failed */ |
6836 | 6836 |
} |
... | ... |
@@ -6838,7 +6846,7 @@ nonblock_connect(int sock, const struct sockaddr_in *sin, const char *hostname) |
6838 | 6838 |
#ifdef F_SETFL |
6839 | 6839 |
if(flags != -1L) |
6840 | 6840 |
if(fcntl(sock, F_SETFL, flags)) |
6841 |
- cli_warnmsg("f_setfl: %s\n", strerror(errno)); |
|
6841 |
+ logg("^f_setfl: %s\n", strerror(errno)); |
|
6842 | 6842 |
#endif |
6843 | 6843 |
return connect_error(sock, hostname); |
6844 | 6844 |
} |
... | ... |
@@ -6860,7 +6868,7 @@ nonblock_connect(int sock, const struct sockaddr_in *sin, const char *hostname) |
6860 | 6860 |
(now.tv_sec > timeout.tv_sec); |
6861 | 6861 |
|
6862 | 6862 |
if(t) { |
6863 |
- cli_warnmsg("%s: connect timeout (%d secs)\n", |
|
6863 |
+ logg("^%s: connect timeout (%d secs)\n", |
|
6864 | 6864 |
hostname, CONNECT_TIMEOUT); |
6865 | 6865 |
break; |
6866 | 6866 |
} |
... | ... |
@@ -6879,27 +6887,27 @@ nonblock_connect(int sock, const struct sockaddr_in *sin, const char *hostname) |
6879 | 6879 |
|
6880 | 6880 |
n = select(numfd, 0, &fds, 0, &waittime); |
6881 | 6881 |
if(n < 0) { |
6882 |
- cli_warnmsg("%s: select attempt %d %s\n", |
|
6882 |
+ logg("^%s: select attempt %d %s\n", |
|
6883 | 6883 |
hostname, select_failures, strerror(errno)); |
6884 | 6884 |
if(--select_failures >= 0) |
6885 | 6885 |
continue; /* not timed-out, try again */ |
6886 | 6886 |
break; /* failed */ |
6887 | 6887 |
} |
6888 | 6888 |
|
6889 |
- cli_dbgmsg("%s: select = %d\n", hostname, n); |
|
6889 |
+ logg("*%s: select = %d\n", hostname, n); |
|
6890 | 6890 |
|
6891 | 6891 |
if(n) { |
6892 | 6892 |
#ifdef F_SETFL |
6893 | 6893 |
if(flags != -1L) |
6894 | 6894 |
if(fcntl(sock, F_SETFL, flags)) |
6895 |
- cli_warnmsg("f_setfl: %s\n", strerror(errno)); |
|
6895 |
+ logg("^f_setfl: %s\n", strerror(errno)); |
|
6896 | 6896 |
#endif |
6897 | 6897 |
return connect_error(sock, hostname); |
6898 | 6898 |
} |
6899 | 6899 |
|
6900 | 6900 |
/* timeout */ |
6901 | 6901 |
if(attempts++ == NONBLOCK_MAX_ATTEMPTS) { |
6902 |
- cli_warnmsg("timeout connecting to %s\n", hostname); |
|
6902 |
+ logg("^timeout connecting to %s\n", hostname); |
|
6903 | 6903 |
break; |
6904 | 6904 |
} |
6905 | 6905 |
} |
... | ... |
@@ -6907,7 +6915,7 @@ nonblock_connect(int sock, const struct sockaddr_in *sin, const char *hostname) |
6907 | 6907 |
#ifdef F_SETFL |
6908 | 6908 |
if(flags != -1L) |
6909 | 6909 |
if(fcntl(sock, F_SETFL, flags)) |
6910 |
- cli_warnmsg("f_setfl: %s\n", strerror(errno)); |
|
6910 |
+ logg("^f_setfl: %s\n", strerror(errno)); |
|
6911 | 6911 |
#endif |
6912 | 6912 |
return -1; /* failed */ |
6913 | 6913 |
} |
... | ... |
@@ -6922,7 +6930,7 @@ connect_error(int sock, const char *hostname) |
6922 | 6922 |
getsockopt(sock, SOL_SOCKET, SO_ERROR, &optval, &optlen); |
6923 | 6923 |
|
6924 | 6924 |
if(optval) { |
6925 |
- cli_warnmsg("%s: %s\n", hostname, strerror(optval)); |
|
6925 |
+ logg("^%s: %s\n", hostname, strerror(optval)); |
|
6926 | 6926 |
return -1; |
6927 | 6927 |
} |
6928 | 6928 |
#endif |