ClamAV is an open source (GPLv2) anti-virus toolkit.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
clamav/clamav-milter/clamav-milter.c

488 lines
15 KiB

/*
* Copyright (C) 2013-2024 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
* Copyright (C) 2008-2013 Sourcefire, Inc.
*
Squashed commit of the following: commit 0ddbd1a7117e207b8aa87079568a056691d5eb32 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 17:18:04 2008 +0100 to be committed commit 51f8010a275717b8a56a3ab22d49755899819518 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 15:18:40 2008 +0100 mangle body commit cd38463f4739f4a7778b6bf294cfb2166024656e Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 14:43:39 2008 +0100 parse clamd result commit 7b8a39495e59ac745342455f8e9aab09951d1041 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 03:19:45 2008 +0100 handle calloc shifts commit a58b732af99f9e3f18d2327e977432f1117028ee Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 02:07:19 2008 +0100 spam added, local is b0rked commit 22604b4b037cfdbc92d6b29986652e2f004bd1f3 Author: acab <acab@albe.digitalfuture.it> Date: Wed Nov 26 19:44:59 2008 +0100 free/close stuff commit 33a02aed984981d3e80ca4930a482f702624f08f Author: aCaB <acab@digitalfuture.it> Date: Wed Nov 26 03:11:29 2008 +0100 skeleton ready commit 4630d9902ee74b6137abf6526c6a9ad3e41fc597 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 22:59:41 2008 +0100 need to rebase commit 083f5f98aecfce2763870f20ae97643d5683613a Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 22:45:11 2008 +0100 in body() commit 08f040f67de1264810953415c0a47c95ec9acff0 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 19:51:15 2008 +0100 clamfi commit bc08fe8f72580b8be81791a7c03ec38952781af7 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 16:47:17 2008 +0100 adding milter commit 34dcebd9294a059f2c45ec9d1817bdb75f423cb3 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 00:35:11 2008 +0100 netcode works, fix to cfgparser commit 3cc0997d907e817954328c60e43cdcca0667d6f3 Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 23:46:05 2008 +0100 socket probe commit 0c3bbd6d03f8df931cb114b07150cd0b7dcd0aff Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 19:02:06 2008 +0100 nonblock started commit a1193ff0de0d0a3d9212d833110236b1329c1f2e Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 11:17:41 2008 +0100 legacy options commit 90519c59ff8a4f44fceaf84e8c40116254c73045 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 23 19:41:26 2008 +0100 sockets pool commit 897b0c5f82503530ba3fbb2fcc3a9c007488e90a Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 23 01:02:59 2008 +0100 Logging done commit 4cf3a218756271c74782a1649f728e1c6e977ae5 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 23:31:34 2008 +0100 Config done commit 93b271579f680286c697476c00d8eec7effb2fc4 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 22:50:42 2008 +0100 Sanitise config file options commit bf5e81b8561b258daaef134894761fa80d44f5b1 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 20:25:06 2008 +0100 cfgparser hacks to allow for milter own conf commit 8924e93b2567a1f378c2177b4011b67631b49cc1 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 19:03:45 2008 +0100 command line parser commit d2180e370f75948b6ce12f89979bda9e92ccd5f8 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 16:36:37 2008 +0100 restart from scratch commit 249d6cdbddbea622c949753aafbf48e526e0ef4d Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 19:39:12 2008 +0100 more diversion commit b948990103867b59c749da88d6384128c1e5e6d3 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 17:31:42 2008 +0100 milter separation (milter) commit 6dc259a5d4f8f6e4428953055510382160ef8df4 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 17:23:14 2008 +0100 milter separation git-svn: trunk@4519
17 years ago
* Author: aCaB <acab@clamav.net>
*
* This program is free software; you can redistribute it and/or modify
Squashed commit of the following: commit 0ddbd1a7117e207b8aa87079568a056691d5eb32 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 17:18:04 2008 +0100 to be committed commit 51f8010a275717b8a56a3ab22d49755899819518 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 15:18:40 2008 +0100 mangle body commit cd38463f4739f4a7778b6bf294cfb2166024656e Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 14:43:39 2008 +0100 parse clamd result commit 7b8a39495e59ac745342455f8e9aab09951d1041 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 03:19:45 2008 +0100 handle calloc shifts commit a58b732af99f9e3f18d2327e977432f1117028ee Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 02:07:19 2008 +0100 spam added, local is b0rked commit 22604b4b037cfdbc92d6b29986652e2f004bd1f3 Author: acab <acab@albe.digitalfuture.it> Date: Wed Nov 26 19:44:59 2008 +0100 free/close stuff commit 33a02aed984981d3e80ca4930a482f702624f08f Author: aCaB <acab@digitalfuture.it> Date: Wed Nov 26 03:11:29 2008 +0100 skeleton ready commit 4630d9902ee74b6137abf6526c6a9ad3e41fc597 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 22:59:41 2008 +0100 need to rebase commit 083f5f98aecfce2763870f20ae97643d5683613a Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 22:45:11 2008 +0100 in body() commit 08f040f67de1264810953415c0a47c95ec9acff0 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 19:51:15 2008 +0100 clamfi commit bc08fe8f72580b8be81791a7c03ec38952781af7 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 16:47:17 2008 +0100 adding milter commit 34dcebd9294a059f2c45ec9d1817bdb75f423cb3 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 00:35:11 2008 +0100 netcode works, fix to cfgparser commit 3cc0997d907e817954328c60e43cdcca0667d6f3 Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 23:46:05 2008 +0100 socket probe commit 0c3bbd6d03f8df931cb114b07150cd0b7dcd0aff Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 19:02:06 2008 +0100 nonblock started commit a1193ff0de0d0a3d9212d833110236b1329c1f2e Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 11:17:41 2008 +0100 legacy options commit 90519c59ff8a4f44fceaf84e8c40116254c73045 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 23 19:41:26 2008 +0100 sockets pool commit 897b0c5f82503530ba3fbb2fcc3a9c007488e90a Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 23 01:02:59 2008 +0100 Logging done commit 4cf3a218756271c74782a1649f728e1c6e977ae5 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 23:31:34 2008 +0100 Config done commit 93b271579f680286c697476c00d8eec7effb2fc4 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 22:50:42 2008 +0100 Sanitise config file options commit bf5e81b8561b258daaef134894761fa80d44f5b1 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 20:25:06 2008 +0100 cfgparser hacks to allow for milter own conf commit 8924e93b2567a1f378c2177b4011b67631b49cc1 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 19:03:45 2008 +0100 command line parser commit d2180e370f75948b6ce12f89979bda9e92ccd5f8 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 16:36:37 2008 +0100 restart from scratch commit 249d6cdbddbea622c949753aafbf48e526e0ef4d Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 19:39:12 2008 +0100 more diversion commit b948990103867b59c749da88d6384128c1e5e6d3 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 17:31:42 2008 +0100 milter separation (milter) commit 6dc259a5d4f8f6e4428953055510382160ef8df4 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 17:23:14 2008 +0100 milter separation git-svn: trunk@4519
17 years ago
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#if HAVE_CONFIG_H
#include "clamav-config.h"
#endif
#include <stdio.h>
Squashed commit of the following: commit 0ddbd1a7117e207b8aa87079568a056691d5eb32 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 17:18:04 2008 +0100 to be committed commit 51f8010a275717b8a56a3ab22d49755899819518 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 15:18:40 2008 +0100 mangle body commit cd38463f4739f4a7778b6bf294cfb2166024656e Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 14:43:39 2008 +0100 parse clamd result commit 7b8a39495e59ac745342455f8e9aab09951d1041 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 03:19:45 2008 +0100 handle calloc shifts commit a58b732af99f9e3f18d2327e977432f1117028ee Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 02:07:19 2008 +0100 spam added, local is b0rked commit 22604b4b037cfdbc92d6b29986652e2f004bd1f3 Author: acab <acab@albe.digitalfuture.it> Date: Wed Nov 26 19:44:59 2008 +0100 free/close stuff commit 33a02aed984981d3e80ca4930a482f702624f08f Author: aCaB <acab@digitalfuture.it> Date: Wed Nov 26 03:11:29 2008 +0100 skeleton ready commit 4630d9902ee74b6137abf6526c6a9ad3e41fc597 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 22:59:41 2008 +0100 need to rebase commit 083f5f98aecfce2763870f20ae97643d5683613a Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 22:45:11 2008 +0100 in body() commit 08f040f67de1264810953415c0a47c95ec9acff0 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 19:51:15 2008 +0100 clamfi commit bc08fe8f72580b8be81791a7c03ec38952781af7 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 16:47:17 2008 +0100 adding milter commit 34dcebd9294a059f2c45ec9d1817bdb75f423cb3 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 00:35:11 2008 +0100 netcode works, fix to cfgparser commit 3cc0997d907e817954328c60e43cdcca0667d6f3 Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 23:46:05 2008 +0100 socket probe commit 0c3bbd6d03f8df931cb114b07150cd0b7dcd0aff Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 19:02:06 2008 +0100 nonblock started commit a1193ff0de0d0a3d9212d833110236b1329c1f2e Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 11:17:41 2008 +0100 legacy options commit 90519c59ff8a4f44fceaf84e8c40116254c73045 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 23 19:41:26 2008 +0100 sockets pool commit 897b0c5f82503530ba3fbb2fcc3a9c007488e90a Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 23 01:02:59 2008 +0100 Logging done commit 4cf3a218756271c74782a1649f728e1c6e977ae5 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 23:31:34 2008 +0100 Config done commit 93b271579f680286c697476c00d8eec7effb2fc4 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 22:50:42 2008 +0100 Sanitise config file options commit bf5e81b8561b258daaef134894761fa80d44f5b1 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 20:25:06 2008 +0100 cfgparser hacks to allow for milter own conf commit 8924e93b2567a1f378c2177b4011b67631b49cc1 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 19:03:45 2008 +0100 command line parser commit d2180e370f75948b6ce12f89979bda9e92ccd5f8 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 16:36:37 2008 +0100 restart from scratch commit 249d6cdbddbea622c949753aafbf48e526e0ef4d Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 19:39:12 2008 +0100 more diversion commit b948990103867b59c749da88d6384128c1e5e6d3 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 17:31:42 2008 +0100 milter separation (milter) commit 6dc259a5d4f8f6e4428953055510382160ef8df4 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 17:23:14 2008 +0100 milter separation git-svn: trunk@4519
17 years ago
#include <sys/types.h>
#include <unistd.h>
#include <pwd.h>
#include <grp.h>
Squashed commit of the following: commit 0ddbd1a7117e207b8aa87079568a056691d5eb32 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 17:18:04 2008 +0100 to be committed commit 51f8010a275717b8a56a3ab22d49755899819518 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 15:18:40 2008 +0100 mangle body commit cd38463f4739f4a7778b6bf294cfb2166024656e Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 14:43:39 2008 +0100 parse clamd result commit 7b8a39495e59ac745342455f8e9aab09951d1041 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 03:19:45 2008 +0100 handle calloc shifts commit a58b732af99f9e3f18d2327e977432f1117028ee Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 02:07:19 2008 +0100 spam added, local is b0rked commit 22604b4b037cfdbc92d6b29986652e2f004bd1f3 Author: acab <acab@albe.digitalfuture.it> Date: Wed Nov 26 19:44:59 2008 +0100 free/close stuff commit 33a02aed984981d3e80ca4930a482f702624f08f Author: aCaB <acab@digitalfuture.it> Date: Wed Nov 26 03:11:29 2008 +0100 skeleton ready commit 4630d9902ee74b6137abf6526c6a9ad3e41fc597 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 22:59:41 2008 +0100 need to rebase commit 083f5f98aecfce2763870f20ae97643d5683613a Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 22:45:11 2008 +0100 in body() commit 08f040f67de1264810953415c0a47c95ec9acff0 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 19:51:15 2008 +0100 clamfi commit bc08fe8f72580b8be81791a7c03ec38952781af7 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 16:47:17 2008 +0100 adding milter commit 34dcebd9294a059f2c45ec9d1817bdb75f423cb3 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 00:35:11 2008 +0100 netcode works, fix to cfgparser commit 3cc0997d907e817954328c60e43cdcca0667d6f3 Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 23:46:05 2008 +0100 socket probe commit 0c3bbd6d03f8df931cb114b07150cd0b7dcd0aff Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 19:02:06 2008 +0100 nonblock started commit a1193ff0de0d0a3d9212d833110236b1329c1f2e Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 11:17:41 2008 +0100 legacy options commit 90519c59ff8a4f44fceaf84e8c40116254c73045 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 23 19:41:26 2008 +0100 sockets pool commit 897b0c5f82503530ba3fbb2fcc3a9c007488e90a Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 23 01:02:59 2008 +0100 Logging done commit 4cf3a218756271c74782a1649f728e1c6e977ae5 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 23:31:34 2008 +0100 Config done commit 93b271579f680286c697476c00d8eec7effb2fc4 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 22:50:42 2008 +0100 Sanitise config file options commit bf5e81b8561b258daaef134894761fa80d44f5b1 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 20:25:06 2008 +0100 cfgparser hacks to allow for milter own conf commit 8924e93b2567a1f378c2177b4011b67631b49cc1 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 19:03:45 2008 +0100 command line parser commit d2180e370f75948b6ce12f89979bda9e92ccd5f8 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 16:36:37 2008 +0100 restart from scratch commit 249d6cdbddbea622c949753aafbf48e526e0ef4d Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 19:39:12 2008 +0100 more diversion commit b948990103867b59c749da88d6384128c1e5e6d3 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 17:31:42 2008 +0100 milter separation (milter) commit 6dc259a5d4f8f6e4428953055510382160ef8df4 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 17:23:14 2008 +0100 milter separation git-svn: trunk@4519
17 years ago
#include <string.h>
#include <signal.h>
#include <pthread.h>
#ifdef USE_SYSLOG
#include <syslog.h>
#endif
Squashed commit of the following: commit 0ddbd1a7117e207b8aa87079568a056691d5eb32 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 17:18:04 2008 +0100 to be committed commit 51f8010a275717b8a56a3ab22d49755899819518 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 15:18:40 2008 +0100 mangle body commit cd38463f4739f4a7778b6bf294cfb2166024656e Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 14:43:39 2008 +0100 parse clamd result commit 7b8a39495e59ac745342455f8e9aab09951d1041 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 03:19:45 2008 +0100 handle calloc shifts commit a58b732af99f9e3f18d2327e977432f1117028ee Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 02:07:19 2008 +0100 spam added, local is b0rked commit 22604b4b037cfdbc92d6b29986652e2f004bd1f3 Author: acab <acab@albe.digitalfuture.it> Date: Wed Nov 26 19:44:59 2008 +0100 free/close stuff commit 33a02aed984981d3e80ca4930a482f702624f08f Author: aCaB <acab@digitalfuture.it> Date: Wed Nov 26 03:11:29 2008 +0100 skeleton ready commit 4630d9902ee74b6137abf6526c6a9ad3e41fc597 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 22:59:41 2008 +0100 need to rebase commit 083f5f98aecfce2763870f20ae97643d5683613a Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 22:45:11 2008 +0100 in body() commit 08f040f67de1264810953415c0a47c95ec9acff0 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 19:51:15 2008 +0100 clamfi commit bc08fe8f72580b8be81791a7c03ec38952781af7 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 16:47:17 2008 +0100 adding milter commit 34dcebd9294a059f2c45ec9d1817bdb75f423cb3 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 00:35:11 2008 +0100 netcode works, fix to cfgparser commit 3cc0997d907e817954328c60e43cdcca0667d6f3 Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 23:46:05 2008 +0100 socket probe commit 0c3bbd6d03f8df931cb114b07150cd0b7dcd0aff Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 19:02:06 2008 +0100 nonblock started commit a1193ff0de0d0a3d9212d833110236b1329c1f2e Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 11:17:41 2008 +0100 legacy options commit 90519c59ff8a4f44fceaf84e8c40116254c73045 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 23 19:41:26 2008 +0100 sockets pool commit 897b0c5f82503530ba3fbb2fcc3a9c007488e90a Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 23 01:02:59 2008 +0100 Logging done commit 4cf3a218756271c74782a1649f728e1c6e977ae5 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 23:31:34 2008 +0100 Config done commit 93b271579f680286c697476c00d8eec7effb2fc4 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 22:50:42 2008 +0100 Sanitise config file options commit bf5e81b8561b258daaef134894761fa80d44f5b1 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 20:25:06 2008 +0100 cfgparser hacks to allow for milter own conf commit 8924e93b2567a1f378c2177b4011b67631b49cc1 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 19:03:45 2008 +0100 command line parser commit d2180e370f75948b6ce12f89979bda9e92ccd5f8 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 16:36:37 2008 +0100 restart from scratch commit 249d6cdbddbea622c949753aafbf48e526e0ef4d Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 19:39:12 2008 +0100 more diversion commit b948990103867b59c749da88d6384128c1e5e6d3 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 17:31:42 2008 +0100 milter separation (milter) commit 6dc259a5d4f8f6e4428953055510382160ef8df4 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 17:23:14 2008 +0100 milter separation git-svn: trunk@4519
17 years ago
#include <time.h>
#include <libmilter/mfapi.h>
Add CMake build tooling This patch adds experimental-quality CMake build tooling. The libmspack build required a modification to use "" instead of <> for header #includes. This will hopefully be included in the libmspack upstream project when adding CMake build tooling to libmspack. Removed use of libltdl when using CMake. Flex & Bison are now required to build. If -DMAINTAINER_MODE, then GPERF is also required, though it currently doesn't actually do anything. TODO! I found that the autotools build system was generating the lexer output but not actually compiling it, instead using previously generated (and manually renamed) lexer c source. As a consequence, changes to the .l and .y files weren't making it into the build. To resolve this, I removed generated flex/bison files and fixed the tooling to use the freshly generated files. Flex and bison are now required build tools. On Windows, this adds a dependency on the winflexbison package, which can be obtained using Chocolatey or may be manually installed. CMake tooling only has partial support for building with external LLVM library, and no support for the internal LLVM (to be removed in the future). I.e. The CMake build currently only supports the bytecode interpreter. Many files used include paths relative to the top source directory or relative to the current project, rather than relative to each build target. Modern CMake support requires including internal dependency headers the same way you would external dependency headers (albeit with "" instead of <>). This meant correcting all header includes to be relative to the build targets and not relative to the workspace. For example, ... ```c include "../libclamav/clamav.h" include "clamd/clamd_others.h" ``` ... becomes: ```c // libclamav include "clamav.h" // clamd include "clamd_others.h" ``` Fixes header name conflicts by renaming a few of the files. Converted the "shared" code into a static library, which depends on libclamav. The ironically named "shared" static library provides features common to the ClamAV apps which are not required in libclamav itself and are not intended for use by downstream projects. This change was required for correct modern CMake practices but was also required to use the automake "subdir-objects" option. This eliminates warnings when running autoreconf which, in the next version of autoconf & automake are likely to break the build. libclamav used to build in multiple stages where an earlier stage is a static library containing utils required by the "shared" code. Linking clamdscan and clamdtop with this libclamav utils static lib allowed these two apps to function without libclamav. While this is nice in theory, the practical gains are minimal and it complicates the build system. As such, the autotools and CMake tooling was simplified for improved maintainability and this feature was thrown out. clamdtop and clamdscan now require libclamav to function. Removed the nopthreads version of the autotools libclamav_internal_utils static library and added pthread linking to a couple apps that may have issues building on some platforms without it, with the intention of removing needless complexity from the source. Kept the regular version of libclamav_internal_utils.la though it is no longer used anywhere but in libclamav. Added an experimental doxygen build option which attempts to build clamav.h and libfreshclam doxygen html docs. The CMake build tooling also may build the example program(s), which isn't a feature in the Autotools build system. Changed C standard to C90+ due to inline linking issues with socket.h when linking libfreshclam.so on Linux. Generate common.rc for win32. Fix tabs/spaces in shared Makefile.am, and remove vestigial ifndef from misc.c. Add CMake files to the automake dist, so users can try the new CMake tooling w/out having to build from a git clone. clamonacc changes: - Renamed FANOTIFY macro to HAVE_SYS_FANOTIFY_H to better match other similar macros. - Added a new clamav-clamonacc.service systemd unit file, based on the work of ChadDevOps & Aaron Brighton. - Added missing clamonacc man page. Updates to clamdscan man page, add missing options. Remove vestigial CL_NOLIBCLAMAV definitions (all apps now use libclamav). Rename Windows mspack.dll to libmspack.dll so all ClamAV-built libraries have the lib-prefix with Visual Studio as with CMake.
5 years ago
// libclamav
Squashed commit of the following: commit 0ddbd1a7117e207b8aa87079568a056691d5eb32 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 17:18:04 2008 +0100 to be committed commit 51f8010a275717b8a56a3ab22d49755899819518 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 15:18:40 2008 +0100 mangle body commit cd38463f4739f4a7778b6bf294cfb2166024656e Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 14:43:39 2008 +0100 parse clamd result commit 7b8a39495e59ac745342455f8e9aab09951d1041 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 03:19:45 2008 +0100 handle calloc shifts commit a58b732af99f9e3f18d2327e977432f1117028ee Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 02:07:19 2008 +0100 spam added, local is b0rked commit 22604b4b037cfdbc92d6b29986652e2f004bd1f3 Author: acab <acab@albe.digitalfuture.it> Date: Wed Nov 26 19:44:59 2008 +0100 free/close stuff commit 33a02aed984981d3e80ca4930a482f702624f08f Author: aCaB <acab@digitalfuture.it> Date: Wed Nov 26 03:11:29 2008 +0100 skeleton ready commit 4630d9902ee74b6137abf6526c6a9ad3e41fc597 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 22:59:41 2008 +0100 need to rebase commit 083f5f98aecfce2763870f20ae97643d5683613a Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 22:45:11 2008 +0100 in body() commit 08f040f67de1264810953415c0a47c95ec9acff0 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 19:51:15 2008 +0100 clamfi commit bc08fe8f72580b8be81791a7c03ec38952781af7 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 16:47:17 2008 +0100 adding milter commit 34dcebd9294a059f2c45ec9d1817bdb75f423cb3 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 00:35:11 2008 +0100 netcode works, fix to cfgparser commit 3cc0997d907e817954328c60e43cdcca0667d6f3 Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 23:46:05 2008 +0100 socket probe commit 0c3bbd6d03f8df931cb114b07150cd0b7dcd0aff Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 19:02:06 2008 +0100 nonblock started commit a1193ff0de0d0a3d9212d833110236b1329c1f2e Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 11:17:41 2008 +0100 legacy options commit 90519c59ff8a4f44fceaf84e8c40116254c73045 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 23 19:41:26 2008 +0100 sockets pool commit 897b0c5f82503530ba3fbb2fcc3a9c007488e90a Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 23 01:02:59 2008 +0100 Logging done commit 4cf3a218756271c74782a1649f728e1c6e977ae5 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 23:31:34 2008 +0100 Config done commit 93b271579f680286c697476c00d8eec7effb2fc4 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 22:50:42 2008 +0100 Sanitise config file options commit bf5e81b8561b258daaef134894761fa80d44f5b1 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 20:25:06 2008 +0100 cfgparser hacks to allow for milter own conf commit 8924e93b2567a1f378c2177b4011b67631b49cc1 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 19:03:45 2008 +0100 command line parser commit d2180e370f75948b6ce12f89979bda9e92ccd5f8 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 16:36:37 2008 +0100 restart from scratch commit 249d6cdbddbea622c949753aafbf48e526e0ef4d Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 19:39:12 2008 +0100 more diversion commit b948990103867b59c749da88d6384128c1e5e6d3 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 17:31:42 2008 +0100 milter separation (milter) commit 6dc259a5d4f8f6e4428953055510382160ef8df4 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 17:23:14 2008 +0100 milter separation git-svn: trunk@4519
17 years ago
#include "clamav.h"
Add CMake build tooling This patch adds experimental-quality CMake build tooling. The libmspack build required a modification to use "" instead of <> for header #includes. This will hopefully be included in the libmspack upstream project when adding CMake build tooling to libmspack. Removed use of libltdl when using CMake. Flex & Bison are now required to build. If -DMAINTAINER_MODE, then GPERF is also required, though it currently doesn't actually do anything. TODO! I found that the autotools build system was generating the lexer output but not actually compiling it, instead using previously generated (and manually renamed) lexer c source. As a consequence, changes to the .l and .y files weren't making it into the build. To resolve this, I removed generated flex/bison files and fixed the tooling to use the freshly generated files. Flex and bison are now required build tools. On Windows, this adds a dependency on the winflexbison package, which can be obtained using Chocolatey or may be manually installed. CMake tooling only has partial support for building with external LLVM library, and no support for the internal LLVM (to be removed in the future). I.e. The CMake build currently only supports the bytecode interpreter. Many files used include paths relative to the top source directory or relative to the current project, rather than relative to each build target. Modern CMake support requires including internal dependency headers the same way you would external dependency headers (albeit with "" instead of <>). This meant correcting all header includes to be relative to the build targets and not relative to the workspace. For example, ... ```c include "../libclamav/clamav.h" include "clamd/clamd_others.h" ``` ... becomes: ```c // libclamav include "clamav.h" // clamd include "clamd_others.h" ``` Fixes header name conflicts by renaming a few of the files. Converted the "shared" code into a static library, which depends on libclamav. The ironically named "shared" static library provides features common to the ClamAV apps which are not required in libclamav itself and are not intended for use by downstream projects. This change was required for correct modern CMake practices but was also required to use the automake "subdir-objects" option. This eliminates warnings when running autoreconf which, in the next version of autoconf & automake are likely to break the build. libclamav used to build in multiple stages where an earlier stage is a static library containing utils required by the "shared" code. Linking clamdscan and clamdtop with this libclamav utils static lib allowed these two apps to function without libclamav. While this is nice in theory, the practical gains are minimal and it complicates the build system. As such, the autotools and CMake tooling was simplified for improved maintainability and this feature was thrown out. clamdtop and clamdscan now require libclamav to function. Removed the nopthreads version of the autotools libclamav_internal_utils static library and added pthread linking to a couple apps that may have issues building on some platforms without it, with the intention of removing needless complexity from the source. Kept the regular version of libclamav_internal_utils.la though it is no longer used anywhere but in libclamav. Added an experimental doxygen build option which attempts to build clamav.h and libfreshclam doxygen html docs. The CMake build tooling also may build the example program(s), which isn't a feature in the Autotools build system. Changed C standard to C90+ due to inline linking issues with socket.h when linking libfreshclam.so on Linux. Generate common.rc for win32. Fix tabs/spaces in shared Makefile.am, and remove vestigial ifndef from misc.c. Add CMake files to the automake dist, so users can try the new CMake tooling w/out having to build from a git clone. clamonacc changes: - Renamed FANOTIFY macro to HAVE_SYS_FANOTIFY_H to better match other similar macros. - Added a new clamav-clamonacc.service systemd unit file, based on the work of ChadDevOps & Aaron Brighton. - Added missing clamonacc man page. Updates to clamdscan man page, add missing options. Remove vestigial CL_NOLIBCLAMAV definitions (all apps now use libclamav). Rename Windows mspack.dll to libmspack.dll so all ClamAV-built libraries have the lib-prefix with Visual Studio as with CMake.
5 years ago
#include "default.h"
// common
Add CMake build tooling This patch adds experimental-quality CMake build tooling. The libmspack build required a modification to use "" instead of <> for header #includes. This will hopefully be included in the libmspack upstream project when adding CMake build tooling to libmspack. Removed use of libltdl when using CMake. Flex & Bison are now required to build. If -DMAINTAINER_MODE, then GPERF is also required, though it currently doesn't actually do anything. TODO! I found that the autotools build system was generating the lexer output but not actually compiling it, instead using previously generated (and manually renamed) lexer c source. As a consequence, changes to the .l and .y files weren't making it into the build. To resolve this, I removed generated flex/bison files and fixed the tooling to use the freshly generated files. Flex and bison are now required build tools. On Windows, this adds a dependency on the winflexbison package, which can be obtained using Chocolatey or may be manually installed. CMake tooling only has partial support for building with external LLVM library, and no support for the internal LLVM (to be removed in the future). I.e. The CMake build currently only supports the bytecode interpreter. Many files used include paths relative to the top source directory or relative to the current project, rather than relative to each build target. Modern CMake support requires including internal dependency headers the same way you would external dependency headers (albeit with "" instead of <>). This meant correcting all header includes to be relative to the build targets and not relative to the workspace. For example, ... ```c include "../libclamav/clamav.h" include "clamd/clamd_others.h" ``` ... becomes: ```c // libclamav include "clamav.h" // clamd include "clamd_others.h" ``` Fixes header name conflicts by renaming a few of the files. Converted the "shared" code into a static library, which depends on libclamav. The ironically named "shared" static library provides features common to the ClamAV apps which are not required in libclamav itself and are not intended for use by downstream projects. This change was required for correct modern CMake practices but was also required to use the automake "subdir-objects" option. This eliminates warnings when running autoreconf which, in the next version of autoconf & automake are likely to break the build. libclamav used to build in multiple stages where an earlier stage is a static library containing utils required by the "shared" code. Linking clamdscan and clamdtop with this libclamav utils static lib allowed these two apps to function without libclamav. While this is nice in theory, the practical gains are minimal and it complicates the build system. As such, the autotools and CMake tooling was simplified for improved maintainability and this feature was thrown out. clamdtop and clamdscan now require libclamav to function. Removed the nopthreads version of the autotools libclamav_internal_utils static library and added pthread linking to a couple apps that may have issues building on some platforms without it, with the intention of removing needless complexity from the source. Kept the regular version of libclamav_internal_utils.la though it is no longer used anywhere but in libclamav. Added an experimental doxygen build option which attempts to build clamav.h and libfreshclam doxygen html docs. The CMake build tooling also may build the example program(s), which isn't a feature in the Autotools build system. Changed C standard to C90+ due to inline linking issues with socket.h when linking libfreshclam.so on Linux. Generate common.rc for win32. Fix tabs/spaces in shared Makefile.am, and remove vestigial ifndef from misc.c. Add CMake files to the automake dist, so users can try the new CMake tooling w/out having to build from a git clone. clamonacc changes: - Renamed FANOTIFY macro to HAVE_SYS_FANOTIFY_H to better match other similar macros. - Added a new clamav-clamonacc.service systemd unit file, based on the work of ChadDevOps & Aaron Brighton. - Added missing clamonacc man page. Updates to clamdscan man page, add missing options. Remove vestigial CL_NOLIBCLAMAV definitions (all apps now use libclamav). Rename Windows mspack.dll to libmspack.dll so all ClamAV-built libraries have the lib-prefix with Visual Studio as with CMake.
5 years ago
#include "output.h"
#include "optparser.h"
#include "misc.h"
Squashed commit of the following: commit 0ddbd1a7117e207b8aa87079568a056691d5eb32 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 17:18:04 2008 +0100 to be committed commit 51f8010a275717b8a56a3ab22d49755899819518 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 15:18:40 2008 +0100 mangle body commit cd38463f4739f4a7778b6bf294cfb2166024656e Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 14:43:39 2008 +0100 parse clamd result commit 7b8a39495e59ac745342455f8e9aab09951d1041 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 03:19:45 2008 +0100 handle calloc shifts commit a58b732af99f9e3f18d2327e977432f1117028ee Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 02:07:19 2008 +0100 spam added, local is b0rked commit 22604b4b037cfdbc92d6b29986652e2f004bd1f3 Author: acab <acab@albe.digitalfuture.it> Date: Wed Nov 26 19:44:59 2008 +0100 free/close stuff commit 33a02aed984981d3e80ca4930a482f702624f08f Author: aCaB <acab@digitalfuture.it> Date: Wed Nov 26 03:11:29 2008 +0100 skeleton ready commit 4630d9902ee74b6137abf6526c6a9ad3e41fc597 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 22:59:41 2008 +0100 need to rebase commit 083f5f98aecfce2763870f20ae97643d5683613a Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 22:45:11 2008 +0100 in body() commit 08f040f67de1264810953415c0a47c95ec9acff0 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 19:51:15 2008 +0100 clamfi commit bc08fe8f72580b8be81791a7c03ec38952781af7 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 16:47:17 2008 +0100 adding milter commit 34dcebd9294a059f2c45ec9d1817bdb75f423cb3 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 00:35:11 2008 +0100 netcode works, fix to cfgparser commit 3cc0997d907e817954328c60e43cdcca0667d6f3 Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 23:46:05 2008 +0100 socket probe commit 0c3bbd6d03f8df931cb114b07150cd0b7dcd0aff Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 19:02:06 2008 +0100 nonblock started commit a1193ff0de0d0a3d9212d833110236b1329c1f2e Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 11:17:41 2008 +0100 legacy options commit 90519c59ff8a4f44fceaf84e8c40116254c73045 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 23 19:41:26 2008 +0100 sockets pool commit 897b0c5f82503530ba3fbb2fcc3a9c007488e90a Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 23 01:02:59 2008 +0100 Logging done commit 4cf3a218756271c74782a1649f728e1c6e977ae5 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 23:31:34 2008 +0100 Config done commit 93b271579f680286c697476c00d8eec7effb2fc4 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 22:50:42 2008 +0100 Sanitise config file options commit bf5e81b8561b258daaef134894761fa80d44f5b1 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 20:25:06 2008 +0100 cfgparser hacks to allow for milter own conf commit 8924e93b2567a1f378c2177b4011b67631b49cc1 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 19:03:45 2008 +0100 command line parser commit d2180e370f75948b6ce12f89979bda9e92ccd5f8 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 16:36:37 2008 +0100 restart from scratch commit 249d6cdbddbea622c949753aafbf48e526e0ef4d Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 19:39:12 2008 +0100 more diversion commit b948990103867b59c749da88d6384128c1e5e6d3 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 17:31:42 2008 +0100 milter separation (milter) commit 6dc259a5d4f8f6e4428953055510382160ef8df4 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 17:23:14 2008 +0100 milter separation git-svn: trunk@4519
17 years ago
#include "connpool.h"
#include "netcode.h"
#include "clamfi.h"
#include "allow_list.h"
Squashed commit of the following: commit 0ddbd1a7117e207b8aa87079568a056691d5eb32 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 17:18:04 2008 +0100 to be committed commit 51f8010a275717b8a56a3ab22d49755899819518 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 15:18:40 2008 +0100 mangle body commit cd38463f4739f4a7778b6bf294cfb2166024656e Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 14:43:39 2008 +0100 parse clamd result commit 7b8a39495e59ac745342455f8e9aab09951d1041 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 03:19:45 2008 +0100 handle calloc shifts commit a58b732af99f9e3f18d2327e977432f1117028ee Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 02:07:19 2008 +0100 spam added, local is b0rked commit 22604b4b037cfdbc92d6b29986652e2f004bd1f3 Author: acab <acab@albe.digitalfuture.it> Date: Wed Nov 26 19:44:59 2008 +0100 free/close stuff commit 33a02aed984981d3e80ca4930a482f702624f08f Author: aCaB <acab@digitalfuture.it> Date: Wed Nov 26 03:11:29 2008 +0100 skeleton ready commit 4630d9902ee74b6137abf6526c6a9ad3e41fc597 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 22:59:41 2008 +0100 need to rebase commit 083f5f98aecfce2763870f20ae97643d5683613a Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 22:45:11 2008 +0100 in body() commit 08f040f67de1264810953415c0a47c95ec9acff0 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 19:51:15 2008 +0100 clamfi commit bc08fe8f72580b8be81791a7c03ec38952781af7 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 16:47:17 2008 +0100 adding milter commit 34dcebd9294a059f2c45ec9d1817bdb75f423cb3 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 00:35:11 2008 +0100 netcode works, fix to cfgparser commit 3cc0997d907e817954328c60e43cdcca0667d6f3 Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 23:46:05 2008 +0100 socket probe commit 0c3bbd6d03f8df931cb114b07150cd0b7dcd0aff Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 19:02:06 2008 +0100 nonblock started commit a1193ff0de0d0a3d9212d833110236b1329c1f2e Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 11:17:41 2008 +0100 legacy options commit 90519c59ff8a4f44fceaf84e8c40116254c73045 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 23 19:41:26 2008 +0100 sockets pool commit 897b0c5f82503530ba3fbb2fcc3a9c007488e90a Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 23 01:02:59 2008 +0100 Logging done commit 4cf3a218756271c74782a1649f728e1c6e977ae5 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 23:31:34 2008 +0100 Config done commit 93b271579f680286c697476c00d8eec7effb2fc4 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 22:50:42 2008 +0100 Sanitise config file options commit bf5e81b8561b258daaef134894761fa80d44f5b1 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 20:25:06 2008 +0100 cfgparser hacks to allow for milter own conf commit 8924e93b2567a1f378c2177b4011b67631b49cc1 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 19:03:45 2008 +0100 command line parser commit d2180e370f75948b6ce12f89979bda9e92ccd5f8 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 16:36:37 2008 +0100 restart from scratch commit 249d6cdbddbea622c949753aafbf48e526e0ef4d Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 19:39:12 2008 +0100 more diversion commit b948990103867b59c749da88d6384128c1e5e6d3 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 17:31:42 2008 +0100 milter separation (milter) commit 6dc259a5d4f8f6e4428953055510382160ef8df4 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 17:23:14 2008 +0100 milter separation git-svn: trunk@4519
17 years ago
#ifndef _WIN32
#include <sys/wait.h>
#endif
struct smfiDesc descr;
struct optstruct *opts;
static void milter_exit(int sig)
{
const struct optstruct *opt;
logg(LOGG_DEBUG, "clamav-milter: milter_exit, signal %d\n", sig);
#ifndef _WIN32
if ((opt = optget(opts, "MilterSocket"))) {
if (unlink(opt->strarg) == -1)
logg(LOGG_ERROR, "Can't unlink the socket file %s\n", opt->strarg);
else
logg(LOGG_INFO, "Socket file removed.\n");
}
#endif
logg(LOGG_INFO, "clamav-milter: stopped\n");
optfree(opts);
logg_close();
cpool_free();
localnets_free();
allow_list_free();
}
int main(int argc, char **argv)
{
char *my_socket, *pt;
const struct optstruct *opt;
time_t currtime;
mode_t umsk;
pid_t parentPid = getpid();
#ifndef _WIN32
int dropPrivRet = 0;
#endif /* _WIN32 */
Squashed commit of the following: commit 0ddbd1a7117e207b8aa87079568a056691d5eb32 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 17:18:04 2008 +0100 to be committed commit 51f8010a275717b8a56a3ab22d49755899819518 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 15:18:40 2008 +0100 mangle body commit cd38463f4739f4a7778b6bf294cfb2166024656e Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 14:43:39 2008 +0100 parse clamd result commit 7b8a39495e59ac745342455f8e9aab09951d1041 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 03:19:45 2008 +0100 handle calloc shifts commit a58b732af99f9e3f18d2327e977432f1117028ee Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 02:07:19 2008 +0100 spam added, local is b0rked commit 22604b4b037cfdbc92d6b29986652e2f004bd1f3 Author: acab <acab@albe.digitalfuture.it> Date: Wed Nov 26 19:44:59 2008 +0100 free/close stuff commit 33a02aed984981d3e80ca4930a482f702624f08f Author: aCaB <acab@digitalfuture.it> Date: Wed Nov 26 03:11:29 2008 +0100 skeleton ready commit 4630d9902ee74b6137abf6526c6a9ad3e41fc597 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 22:59:41 2008 +0100 need to rebase commit 083f5f98aecfce2763870f20ae97643d5683613a Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 22:45:11 2008 +0100 in body() commit 08f040f67de1264810953415c0a47c95ec9acff0 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 19:51:15 2008 +0100 clamfi commit bc08fe8f72580b8be81791a7c03ec38952781af7 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 16:47:17 2008 +0100 adding milter commit 34dcebd9294a059f2c45ec9d1817bdb75f423cb3 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 00:35:11 2008 +0100 netcode works, fix to cfgparser commit 3cc0997d907e817954328c60e43cdcca0667d6f3 Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 23:46:05 2008 +0100 socket probe commit 0c3bbd6d03f8df931cb114b07150cd0b7dcd0aff Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 19:02:06 2008 +0100 nonblock started commit a1193ff0de0d0a3d9212d833110236b1329c1f2e Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 11:17:41 2008 +0100 legacy options commit 90519c59ff8a4f44fceaf84e8c40116254c73045 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 23 19:41:26 2008 +0100 sockets pool commit 897b0c5f82503530ba3fbb2fcc3a9c007488e90a Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 23 01:02:59 2008 +0100 Logging done commit 4cf3a218756271c74782a1649f728e1c6e977ae5 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 23:31:34 2008 +0100 Config done commit 93b271579f680286c697476c00d8eec7effb2fc4 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 22:50:42 2008 +0100 Sanitise config file options commit bf5e81b8561b258daaef134894761fa80d44f5b1 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 20:25:06 2008 +0100 cfgparser hacks to allow for milter own conf commit 8924e93b2567a1f378c2177b4011b67631b49cc1 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 19:03:45 2008 +0100 command line parser commit d2180e370f75948b6ce12f89979bda9e92ccd5f8 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 16:36:37 2008 +0100 restart from scratch commit 249d6cdbddbea622c949753aafbf48e526e0ef4d Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 19:39:12 2008 +0100 more diversion commit b948990103867b59c749da88d6384128c1e5e6d3 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 17:31:42 2008 +0100 milter separation (milter) commit 6dc259a5d4f8f6e4428953055510382160ef8df4 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 17:23:14 2008 +0100 milter separation git-svn: trunk@4519
17 years ago
sigset_t sigset;
struct sigaction act;
const char *user_name = NULL;
cl_initialize_crypto();
memset(&descr, 0, sizeof(struct smfiDesc));
descr.xxfi_name = "ClamAV"; /* filter name */
descr.xxfi_version = SMFI_VERSION; /* milter version */
descr.xxfi_flags = SMFIF_QUARANTINE; /* flags */
descr.xxfi_connect = clamfi_connect; /* connection info filter */
descr.xxfi_envfrom = clamfi_envfrom; /* envelope sender filter */
descr.xxfi_envrcpt = clamfi_envrcpt; /* envelope recipient filter */
descr.xxfi_header = clamfi_header; /* header filter */
descr.xxfi_body = clamfi_body; /* body block */
descr.xxfi_eom = clamfi_eom; /* end of message */
descr.xxfi_abort = clamfi_abort; /* message aborted */
opts = optparse(NULL, argc, argv, 1, OPT_MILTER, 0, NULL);
if (!opts) {
mprintf(LOGG_ERROR, "Can't parse command line options\n");
return 1;
Squashed commit of the following: commit 0ddbd1a7117e207b8aa87079568a056691d5eb32 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 17:18:04 2008 +0100 to be committed commit 51f8010a275717b8a56a3ab22d49755899819518 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 15:18:40 2008 +0100 mangle body commit cd38463f4739f4a7778b6bf294cfb2166024656e Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 14:43:39 2008 +0100 parse clamd result commit 7b8a39495e59ac745342455f8e9aab09951d1041 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 03:19:45 2008 +0100 handle calloc shifts commit a58b732af99f9e3f18d2327e977432f1117028ee Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 02:07:19 2008 +0100 spam added, local is b0rked commit 22604b4b037cfdbc92d6b29986652e2f004bd1f3 Author: acab <acab@albe.digitalfuture.it> Date: Wed Nov 26 19:44:59 2008 +0100 free/close stuff commit 33a02aed984981d3e80ca4930a482f702624f08f Author: aCaB <acab@digitalfuture.it> Date: Wed Nov 26 03:11:29 2008 +0100 skeleton ready commit 4630d9902ee74b6137abf6526c6a9ad3e41fc597 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 22:59:41 2008 +0100 need to rebase commit 083f5f98aecfce2763870f20ae97643d5683613a Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 22:45:11 2008 +0100 in body() commit 08f040f67de1264810953415c0a47c95ec9acff0 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 19:51:15 2008 +0100 clamfi commit bc08fe8f72580b8be81791a7c03ec38952781af7 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 16:47:17 2008 +0100 adding milter commit 34dcebd9294a059f2c45ec9d1817bdb75f423cb3 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 00:35:11 2008 +0100 netcode works, fix to cfgparser commit 3cc0997d907e817954328c60e43cdcca0667d6f3 Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 23:46:05 2008 +0100 socket probe commit 0c3bbd6d03f8df931cb114b07150cd0b7dcd0aff Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 19:02:06 2008 +0100 nonblock started commit a1193ff0de0d0a3d9212d833110236b1329c1f2e Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 11:17:41 2008 +0100 legacy options commit 90519c59ff8a4f44fceaf84e8c40116254c73045 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 23 19:41:26 2008 +0100 sockets pool commit 897b0c5f82503530ba3fbb2fcc3a9c007488e90a Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 23 01:02:59 2008 +0100 Logging done commit 4cf3a218756271c74782a1649f728e1c6e977ae5 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 23:31:34 2008 +0100 Config done commit 93b271579f680286c697476c00d8eec7effb2fc4 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 22:50:42 2008 +0100 Sanitise config file options commit bf5e81b8561b258daaef134894761fa80d44f5b1 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 20:25:06 2008 +0100 cfgparser hacks to allow for milter own conf commit 8924e93b2567a1f378c2177b4011b67631b49cc1 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 19:03:45 2008 +0100 command line parser commit d2180e370f75948b6ce12f89979bda9e92ccd5f8 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 16:36:37 2008 +0100 restart from scratch commit 249d6cdbddbea622c949753aafbf48e526e0ef4d Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 19:39:12 2008 +0100 more diversion commit b948990103867b59c749da88d6384128c1e5e6d3 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 17:31:42 2008 +0100 milter separation (milter) commit 6dc259a5d4f8f6e4428953055510382160ef8df4 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 17:23:14 2008 +0100 milter separation git-svn: trunk@4519
17 years ago
}
if (optget(opts, "help")->enabled) {
printf("\n");
printf(" Clam AntiVirus: Milter Mail Scanner %s\n", get_version());
printf(" By The ClamAV Team: https://www.clamav.net/about.html#credits\n");
printf(" (C) 2024 Cisco Systems, Inc.\n");
printf("\n");
printf(" %s [-c <config-file>]\n\n", argv[0]);
printf("\n");
printf(" --help -h Show this help\n");
printf(" --version -V Show version\n");
printf(" --config-file <file> -c Read configuration from file\n");
printf(" --pid=FILE -p FILE Write the daemon's pid to FILE\n");
printf("\n");
optfree(opts);
return 0;
Squashed commit of the following: commit 0ddbd1a7117e207b8aa87079568a056691d5eb32 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 17:18:04 2008 +0100 to be committed commit 51f8010a275717b8a56a3ab22d49755899819518 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 15:18:40 2008 +0100 mangle body commit cd38463f4739f4a7778b6bf294cfb2166024656e Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 14:43:39 2008 +0100 parse clamd result commit 7b8a39495e59ac745342455f8e9aab09951d1041 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 03:19:45 2008 +0100 handle calloc shifts commit a58b732af99f9e3f18d2327e977432f1117028ee Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 02:07:19 2008 +0100 spam added, local is b0rked commit 22604b4b037cfdbc92d6b29986652e2f004bd1f3 Author: acab <acab@albe.digitalfuture.it> Date: Wed Nov 26 19:44:59 2008 +0100 free/close stuff commit 33a02aed984981d3e80ca4930a482f702624f08f Author: aCaB <acab@digitalfuture.it> Date: Wed Nov 26 03:11:29 2008 +0100 skeleton ready commit 4630d9902ee74b6137abf6526c6a9ad3e41fc597 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 22:59:41 2008 +0100 need to rebase commit 083f5f98aecfce2763870f20ae97643d5683613a Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 22:45:11 2008 +0100 in body() commit 08f040f67de1264810953415c0a47c95ec9acff0 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 19:51:15 2008 +0100 clamfi commit bc08fe8f72580b8be81791a7c03ec38952781af7 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 16:47:17 2008 +0100 adding milter commit 34dcebd9294a059f2c45ec9d1817bdb75f423cb3 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 00:35:11 2008 +0100 netcode works, fix to cfgparser commit 3cc0997d907e817954328c60e43cdcca0667d6f3 Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 23:46:05 2008 +0100 socket probe commit 0c3bbd6d03f8df931cb114b07150cd0b7dcd0aff Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 19:02:06 2008 +0100 nonblock started commit a1193ff0de0d0a3d9212d833110236b1329c1f2e Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 11:17:41 2008 +0100 legacy options commit 90519c59ff8a4f44fceaf84e8c40116254c73045 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 23 19:41:26 2008 +0100 sockets pool commit 897b0c5f82503530ba3fbb2fcc3a9c007488e90a Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 23 01:02:59 2008 +0100 Logging done commit 4cf3a218756271c74782a1649f728e1c6e977ae5 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 23:31:34 2008 +0100 Config done commit 93b271579f680286c697476c00d8eec7effb2fc4 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 22:50:42 2008 +0100 Sanitise config file options commit bf5e81b8561b258daaef134894761fa80d44f5b1 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 20:25:06 2008 +0100 cfgparser hacks to allow for milter own conf commit 8924e93b2567a1f378c2177b4011b67631b49cc1 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 19:03:45 2008 +0100 command line parser commit d2180e370f75948b6ce12f89979bda9e92ccd5f8 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 16:36:37 2008 +0100 restart from scratch commit 249d6cdbddbea622c949753aafbf48e526e0ef4d Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 19:39:12 2008 +0100 more diversion commit b948990103867b59c749da88d6384128c1e5e6d3 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 17:31:42 2008 +0100 milter separation (milter) commit 6dc259a5d4f8f6e4428953055510382160ef8df4 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 17:23:14 2008 +0100 milter separation git-svn: trunk@4519
17 years ago
}
if (opts->filename) {
int x;
for (x = 0; opts->filename[x]; x++)
mprintf(LOGG_WARNING, "Ignoring option %s\n", opts->filename[x]);
}
Squashed commit of the following: commit 0ddbd1a7117e207b8aa87079568a056691d5eb32 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 17:18:04 2008 +0100 to be committed commit 51f8010a275717b8a56a3ab22d49755899819518 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 15:18:40 2008 +0100 mangle body commit cd38463f4739f4a7778b6bf294cfb2166024656e Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 14:43:39 2008 +0100 parse clamd result commit 7b8a39495e59ac745342455f8e9aab09951d1041 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 03:19:45 2008 +0100 handle calloc shifts commit a58b732af99f9e3f18d2327e977432f1117028ee Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 02:07:19 2008 +0100 spam added, local is b0rked commit 22604b4b037cfdbc92d6b29986652e2f004bd1f3 Author: acab <acab@albe.digitalfuture.it> Date: Wed Nov 26 19:44:59 2008 +0100 free/close stuff commit 33a02aed984981d3e80ca4930a482f702624f08f Author: aCaB <acab@digitalfuture.it> Date: Wed Nov 26 03:11:29 2008 +0100 skeleton ready commit 4630d9902ee74b6137abf6526c6a9ad3e41fc597 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 22:59:41 2008 +0100 need to rebase commit 083f5f98aecfce2763870f20ae97643d5683613a Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 22:45:11 2008 +0100 in body() commit 08f040f67de1264810953415c0a47c95ec9acff0 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 19:51:15 2008 +0100 clamfi commit bc08fe8f72580b8be81791a7c03ec38952781af7 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 16:47:17 2008 +0100 adding milter commit 34dcebd9294a059f2c45ec9d1817bdb75f423cb3 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 00:35:11 2008 +0100 netcode works, fix to cfgparser commit 3cc0997d907e817954328c60e43cdcca0667d6f3 Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 23:46:05 2008 +0100 socket probe commit 0c3bbd6d03f8df931cb114b07150cd0b7dcd0aff Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 19:02:06 2008 +0100 nonblock started commit a1193ff0de0d0a3d9212d833110236b1329c1f2e Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 11:17:41 2008 +0100 legacy options commit 90519c59ff8a4f44fceaf84e8c40116254c73045 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 23 19:41:26 2008 +0100 sockets pool commit 897b0c5f82503530ba3fbb2fcc3a9c007488e90a Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 23 01:02:59 2008 +0100 Logging done commit 4cf3a218756271c74782a1649f728e1c6e977ae5 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 23:31:34 2008 +0100 Config done commit 93b271579f680286c697476c00d8eec7effb2fc4 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 22:50:42 2008 +0100 Sanitise config file options commit bf5e81b8561b258daaef134894761fa80d44f5b1 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 20:25:06 2008 +0100 cfgparser hacks to allow for milter own conf commit 8924e93b2567a1f378c2177b4011b67631b49cc1 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 19:03:45 2008 +0100 command line parser commit d2180e370f75948b6ce12f89979bda9e92ccd5f8 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 16:36:37 2008 +0100 restart from scratch commit 249d6cdbddbea622c949753aafbf48e526e0ef4d Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 19:39:12 2008 +0100 more diversion commit b948990103867b59c749da88d6384128c1e5e6d3 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 17:31:42 2008 +0100 milter separation (milter) commit 6dc259a5d4f8f6e4428953055510382160ef8df4 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 17:23:14 2008 +0100 milter separation git-svn: trunk@4519
17 years ago
if (optget(opts, "version")->enabled) {
printf("clamav-milter %s\n", get_version());
optfree(opts);
return 0;
Squashed commit of the following: commit 0ddbd1a7117e207b8aa87079568a056691d5eb32 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 17:18:04 2008 +0100 to be committed commit 51f8010a275717b8a56a3ab22d49755899819518 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 15:18:40 2008 +0100 mangle body commit cd38463f4739f4a7778b6bf294cfb2166024656e Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 14:43:39 2008 +0100 parse clamd result commit 7b8a39495e59ac745342455f8e9aab09951d1041 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 03:19:45 2008 +0100 handle calloc shifts commit a58b732af99f9e3f18d2327e977432f1117028ee Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 02:07:19 2008 +0100 spam added, local is b0rked commit 22604b4b037cfdbc92d6b29986652e2f004bd1f3 Author: acab <acab@albe.digitalfuture.it> Date: Wed Nov 26 19:44:59 2008 +0100 free/close stuff commit 33a02aed984981d3e80ca4930a482f702624f08f Author: aCaB <acab@digitalfuture.it> Date: Wed Nov 26 03:11:29 2008 +0100 skeleton ready commit 4630d9902ee74b6137abf6526c6a9ad3e41fc597 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 22:59:41 2008 +0100 need to rebase commit 083f5f98aecfce2763870f20ae97643d5683613a Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 22:45:11 2008 +0100 in body() commit 08f040f67de1264810953415c0a47c95ec9acff0 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 19:51:15 2008 +0100 clamfi commit bc08fe8f72580b8be81791a7c03ec38952781af7 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 16:47:17 2008 +0100 adding milter commit 34dcebd9294a059f2c45ec9d1817bdb75f423cb3 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 00:35:11 2008 +0100 netcode works, fix to cfgparser commit 3cc0997d907e817954328c60e43cdcca0667d6f3 Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 23:46:05 2008 +0100 socket probe commit 0c3bbd6d03f8df931cb114b07150cd0b7dcd0aff Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 19:02:06 2008 +0100 nonblock started commit a1193ff0de0d0a3d9212d833110236b1329c1f2e Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 11:17:41 2008 +0100 legacy options commit 90519c59ff8a4f44fceaf84e8c40116254c73045 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 23 19:41:26 2008 +0100 sockets pool commit 897b0c5f82503530ba3fbb2fcc3a9c007488e90a Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 23 01:02:59 2008 +0100 Logging done commit 4cf3a218756271c74782a1649f728e1c6e977ae5 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 23:31:34 2008 +0100 Config done commit 93b271579f680286c697476c00d8eec7effb2fc4 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 22:50:42 2008 +0100 Sanitise config file options commit bf5e81b8561b258daaef134894761fa80d44f5b1 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 20:25:06 2008 +0100 cfgparser hacks to allow for milter own conf commit 8924e93b2567a1f378c2177b4011b67631b49cc1 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 19:03:45 2008 +0100 command line parser commit d2180e370f75948b6ce12f89979bda9e92ccd5f8 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 16:36:37 2008 +0100 restart from scratch commit 249d6cdbddbea622c949753aafbf48e526e0ef4d Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 19:39:12 2008 +0100 more diversion commit b948990103867b59c749da88d6384128c1e5e6d3 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 17:31:42 2008 +0100 milter separation (milter) commit 6dc259a5d4f8f6e4428953055510382160ef8df4 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 17:23:14 2008 +0100 milter separation git-svn: trunk@4519
17 years ago
}
pt = strdup(optget(opts, "config-file")->strarg);
if (pt == NULL) {
printf("Unable to allocate memory for config file\n");
return 1;
}
if ((opts = optparse(pt, 0, NULL, 1, OPT_MILTER, 0, opts)) == NULL) {
printf("%s: cannot parse config file %s\n", argv[0], pt);
free(pt);
return 1;
Squashed commit of the following: commit 0ddbd1a7117e207b8aa87079568a056691d5eb32 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 17:18:04 2008 +0100 to be committed commit 51f8010a275717b8a56a3ab22d49755899819518 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 15:18:40 2008 +0100 mangle body commit cd38463f4739f4a7778b6bf294cfb2166024656e Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 14:43:39 2008 +0100 parse clamd result commit 7b8a39495e59ac745342455f8e9aab09951d1041 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 03:19:45 2008 +0100 handle calloc shifts commit a58b732af99f9e3f18d2327e977432f1117028ee Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 02:07:19 2008 +0100 spam added, local is b0rked commit 22604b4b037cfdbc92d6b29986652e2f004bd1f3 Author: acab <acab@albe.digitalfuture.it> Date: Wed Nov 26 19:44:59 2008 +0100 free/close stuff commit 33a02aed984981d3e80ca4930a482f702624f08f Author: aCaB <acab@digitalfuture.it> Date: Wed Nov 26 03:11:29 2008 +0100 skeleton ready commit 4630d9902ee74b6137abf6526c6a9ad3e41fc597 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 22:59:41 2008 +0100 need to rebase commit 083f5f98aecfce2763870f20ae97643d5683613a Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 22:45:11 2008 +0100 in body() commit 08f040f67de1264810953415c0a47c95ec9acff0 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 19:51:15 2008 +0100 clamfi commit bc08fe8f72580b8be81791a7c03ec38952781af7 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 16:47:17 2008 +0100 adding milter commit 34dcebd9294a059f2c45ec9d1817bdb75f423cb3 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 00:35:11 2008 +0100 netcode works, fix to cfgparser commit 3cc0997d907e817954328c60e43cdcca0667d6f3 Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 23:46:05 2008 +0100 socket probe commit 0c3bbd6d03f8df931cb114b07150cd0b7dcd0aff Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 19:02:06 2008 +0100 nonblock started commit a1193ff0de0d0a3d9212d833110236b1329c1f2e Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 11:17:41 2008 +0100 legacy options commit 90519c59ff8a4f44fceaf84e8c40116254c73045 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 23 19:41:26 2008 +0100 sockets pool commit 897b0c5f82503530ba3fbb2fcc3a9c007488e90a Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 23 01:02:59 2008 +0100 Logging done commit 4cf3a218756271c74782a1649f728e1c6e977ae5 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 23:31:34 2008 +0100 Config done commit 93b271579f680286c697476c00d8eec7effb2fc4 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 22:50:42 2008 +0100 Sanitise config file options commit bf5e81b8561b258daaef134894761fa80d44f5b1 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 20:25:06 2008 +0100 cfgparser hacks to allow for milter own conf commit 8924e93b2567a1f378c2177b4011b67631b49cc1 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 19:03:45 2008 +0100 command line parser commit d2180e370f75948b6ce12f89979bda9e92ccd5f8 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 16:36:37 2008 +0100 restart from scratch commit 249d6cdbddbea622c949753aafbf48e526e0ef4d Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 19:39:12 2008 +0100 more diversion commit b948990103867b59c749da88d6384128c1e5e6d3 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 17:31:42 2008 +0100 milter separation (milter) commit 6dc259a5d4f8f6e4428953055510382160ef8df4 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 17:23:14 2008 +0100 milter separation git-svn: trunk@4519
17 years ago
}
free(pt);
if ((opt = optget(opts, "User"))->enabled) {
user_name = opt->strarg;
}
if ((opt = optget(opts, "Chroot"))->enabled) {
if (chdir(opt->strarg) != 0) {
logg(LOGG_ERROR, "Cannot change directory to %s\n", opt->strarg);
return 1;
}
if (chroot(opt->strarg) != 0) {
logg(LOGG_ERROR, "chroot to %s failed. Are you root?\n", opt->strarg);
return 1;
}
}
pt = optget(opts, "AddHeader")->strarg;
if (strcasecmp(pt, "No")) {
char myname[255];
if (((opt = optget(opts, "ReportHostname"))->enabled &&
strncpy(myname, opt->strarg, sizeof(myname) - 1)) ||
!gethostname(myname, sizeof(myname) - 1)) {
myname[sizeof(myname) - 1] = '\0';
snprintf(xvirushdr, sizeof(xvirushdr), "clamav-milter %s at %s",
get_version(), myname);
} else {
snprintf(xvirushdr, sizeof(xvirushdr), "clamav-milter %s",
get_version());
}
xvirushdr[sizeof(xvirushdr) - 1] = '\0';
descr.xxfi_flags |= SMFIF_ADDHDRS;
if (strcasecmp(pt, "Add")) { /* Replace or Yes */
descr.xxfi_flags |= SMFIF_CHGHDRS;
addxvirus = 1;
} else { /* Add */
addxvirus = 2;
}
}
if (!(my_socket = optget(opts, "MilterSocket")->strarg)) {
logg(LOGG_ERROR, "Please configure the MilterSocket directive\n");
logg_close();
optfree(opts);
return 1;
}
if (smfi_setconn(my_socket) == MI_FAILURE) {
logg(LOGG_ERROR, "smfi_setconn failed\n");
logg_close();
optfree(opts);
return 1;
}
if (smfi_register(descr) == MI_FAILURE) {
logg(LOGG_ERROR, "smfi_register failed\n");
logg_close();
optfree(opts);
return 1;
}
opt = optget(opts, "FixStaleSocket");
umsk = umask(0777); /* socket is created with 000 to avoid races */
if (smfi_opensocket(opt->enabled) == MI_FAILURE) {
logg(LOGG_ERROR, "Failed to create socket %s\n", my_socket);
logg_close();
optfree(opts);
return 1;
}
umask(umsk); /* restore umask */
if (strncmp(my_socket, "inet:", 5) && strncmp(my_socket, "inet6:", 6)) {
/* set group ownership and perms on the local socket */
char *sock_name = my_socket;
mode_t sock_mode;
if (!strncmp(my_socket, "unix:", 5))
sock_name += 5;
if (!strncmp(my_socket, "local:", 6))
sock_name += 6;
if (*my_socket == ':')
sock_name++;
if (optget(opts, "MilterSocketGroup")->enabled) {
char *gname = optget(opts, "MilterSocketGroup")->strarg, *end;
gid_t sock_gid = strtol(gname, &end, 10);
if (*end) {
struct group *pgrp = getgrnam(gname);
if (!pgrp) {
logg(LOGG_ERROR, "Unknown group %s\n", gname);
logg_close();
optfree(opts);
return 1;
}
sock_gid = pgrp->gr_gid;
}
if (chown(sock_name, -1, sock_gid)) {
logg(LOGG_ERROR, "Failed to change socket ownership to group %s\n", gname);
logg_close();
optfree(opts);
return 1;
}
}
if (NULL != user_name) {
struct passwd *user;
if ((user = getpwnam(user_name)) == NULL) {
logg(LOGG_INFO, "ERROR: Can't get information about user %s.\n",
user_name);
logg_close();
optfree(opts);
return 1;
}
if (chown(sock_name, user->pw_uid, -1)) {
logg(LOGG_ERROR, "Failed to change socket ownership to user %s\n", user->pw_name);
optfree(opts);
logg_close();
return 1;
}
}
if (optget(opts, "MilterSocketMode")->enabled) {
char *end;
sock_mode = strtol(optget(opts, "MilterSocketMode")->strarg, &end, 8);
if (*end) {
logg(LOGG_ERROR, "Invalid MilterSocketMode %s\n", optget(opts, "MilterSocketMode")->strarg);
logg_close();
optfree(opts);
return 1;
}
} else
sock_mode = 0777 & ~umsk;
if (chmod(sock_name, sock_mode & 0666)) {
logg(LOGG_ERROR, "Cannot set milter socket permission to %s\n", optget(opts, "MilterSocketMode")->strarg);
logg_close();
optfree(opts);
return 1;
}
}
logg_lock = !optget(opts, "LogFileUnlock")->enabled;
logg_time = optget(opts, "LogTime")->enabled;
logg_size = optget(opts, "LogFileMaxSize")->numarg;
logg_verbose = mprintf_verbose = optget(opts, "LogVerbose")->enabled;
if (logg_size)
logg_rotate = optget(opts, "LogRotate")->enabled;
if ((opt = optget(opts, "LogFile"))->enabled) {
logg_file = opt->strarg;
if (!cli_is_abspath(logg_file)) {
fprintf(stderr, "ERROR: LogFile requires full path.\n");
logg_close();
optfree(opts);
return 1;
}
Squashed commit of the following: commit 0ddbd1a7117e207b8aa87079568a056691d5eb32 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 17:18:04 2008 +0100 to be committed commit 51f8010a275717b8a56a3ab22d49755899819518 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 15:18:40 2008 +0100 mangle body commit cd38463f4739f4a7778b6bf294cfb2166024656e Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 14:43:39 2008 +0100 parse clamd result commit 7b8a39495e59ac745342455f8e9aab09951d1041 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 03:19:45 2008 +0100 handle calloc shifts commit a58b732af99f9e3f18d2327e977432f1117028ee Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 02:07:19 2008 +0100 spam added, local is b0rked commit 22604b4b037cfdbc92d6b29986652e2f004bd1f3 Author: acab <acab@albe.digitalfuture.it> Date: Wed Nov 26 19:44:59 2008 +0100 free/close stuff commit 33a02aed984981d3e80ca4930a482f702624f08f Author: aCaB <acab@digitalfuture.it> Date: Wed Nov 26 03:11:29 2008 +0100 skeleton ready commit 4630d9902ee74b6137abf6526c6a9ad3e41fc597 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 22:59:41 2008 +0100 need to rebase commit 083f5f98aecfce2763870f20ae97643d5683613a Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 22:45:11 2008 +0100 in body() commit 08f040f67de1264810953415c0a47c95ec9acff0 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 19:51:15 2008 +0100 clamfi commit bc08fe8f72580b8be81791a7c03ec38952781af7 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 16:47:17 2008 +0100 adding milter commit 34dcebd9294a059f2c45ec9d1817bdb75f423cb3 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 00:35:11 2008 +0100 netcode works, fix to cfgparser commit 3cc0997d907e817954328c60e43cdcca0667d6f3 Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 23:46:05 2008 +0100 socket probe commit 0c3bbd6d03f8df931cb114b07150cd0b7dcd0aff Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 19:02:06 2008 +0100 nonblock started commit a1193ff0de0d0a3d9212d833110236b1329c1f2e Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 11:17:41 2008 +0100 legacy options commit 90519c59ff8a4f44fceaf84e8c40116254c73045 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 23 19:41:26 2008 +0100 sockets pool commit 897b0c5f82503530ba3fbb2fcc3a9c007488e90a Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 23 01:02:59 2008 +0100 Logging done commit 4cf3a218756271c74782a1649f728e1c6e977ae5 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 23:31:34 2008 +0100 Config done commit 93b271579f680286c697476c00d8eec7effb2fc4 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 22:50:42 2008 +0100 Sanitise config file options commit bf5e81b8561b258daaef134894761fa80d44f5b1 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 20:25:06 2008 +0100 cfgparser hacks to allow for milter own conf commit 8924e93b2567a1f378c2177b4011b67631b49cc1 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 19:03:45 2008 +0100 command line parser commit d2180e370f75948b6ce12f89979bda9e92ccd5f8 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 16:36:37 2008 +0100 restart from scratch commit 249d6cdbddbea622c949753aafbf48e526e0ef4d Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 19:39:12 2008 +0100 more diversion commit b948990103867b59c749da88d6384128c1e5e6d3 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 17:31:42 2008 +0100 milter separation (milter) commit 6dc259a5d4f8f6e4428953055510382160ef8df4 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 17:23:14 2008 +0100 milter separation git-svn: trunk@4519
17 years ago
} else
logg_file = NULL;
#if defined(USE_SYSLOG) && !defined(C_AIX)
if (optget(opts, "LogSyslog")->enabled) {
int fac;
opt = optget(opts, "LogFacility");
if ((fac = logg_facility(opt->strarg)) == -1) {
logg(LOGG_ERROR, "LogFacility: %s: No such facility.\n", opt->strarg);
logg_close();
optfree(opts);
return 1;
}
openlog("clamav-milter", LOG_PID, fac);
logg_syslog = 1;
Squashed commit of the following: commit 0ddbd1a7117e207b8aa87079568a056691d5eb32 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 17:18:04 2008 +0100 to be committed commit 51f8010a275717b8a56a3ab22d49755899819518 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 15:18:40 2008 +0100 mangle body commit cd38463f4739f4a7778b6bf294cfb2166024656e Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 14:43:39 2008 +0100 parse clamd result commit 7b8a39495e59ac745342455f8e9aab09951d1041 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 03:19:45 2008 +0100 handle calloc shifts commit a58b732af99f9e3f18d2327e977432f1117028ee Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 02:07:19 2008 +0100 spam added, local is b0rked commit 22604b4b037cfdbc92d6b29986652e2f004bd1f3 Author: acab <acab@albe.digitalfuture.it> Date: Wed Nov 26 19:44:59 2008 +0100 free/close stuff commit 33a02aed984981d3e80ca4930a482f702624f08f Author: aCaB <acab@digitalfuture.it> Date: Wed Nov 26 03:11:29 2008 +0100 skeleton ready commit 4630d9902ee74b6137abf6526c6a9ad3e41fc597 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 22:59:41 2008 +0100 need to rebase commit 083f5f98aecfce2763870f20ae97643d5683613a Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 22:45:11 2008 +0100 in body() commit 08f040f67de1264810953415c0a47c95ec9acff0 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 19:51:15 2008 +0100 clamfi commit bc08fe8f72580b8be81791a7c03ec38952781af7 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 16:47:17 2008 +0100 adding milter commit 34dcebd9294a059f2c45ec9d1817bdb75f423cb3 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 00:35:11 2008 +0100 netcode works, fix to cfgparser commit 3cc0997d907e817954328c60e43cdcca0667d6f3 Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 23:46:05 2008 +0100 socket probe commit 0c3bbd6d03f8df931cb114b07150cd0b7dcd0aff Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 19:02:06 2008 +0100 nonblock started commit a1193ff0de0d0a3d9212d833110236b1329c1f2e Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 11:17:41 2008 +0100 legacy options commit 90519c59ff8a4f44fceaf84e8c40116254c73045 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 23 19:41:26 2008 +0100 sockets pool commit 897b0c5f82503530ba3fbb2fcc3a9c007488e90a Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 23 01:02:59 2008 +0100 Logging done commit 4cf3a218756271c74782a1649f728e1c6e977ae5 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 23:31:34 2008 +0100 Config done commit 93b271579f680286c697476c00d8eec7effb2fc4 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 22:50:42 2008 +0100 Sanitise config file options commit bf5e81b8561b258daaef134894761fa80d44f5b1 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 20:25:06 2008 +0100 cfgparser hacks to allow for milter own conf commit 8924e93b2567a1f378c2177b4011b67631b49cc1 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 19:03:45 2008 +0100 command line parser commit d2180e370f75948b6ce12f89979bda9e92ccd5f8 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 16:36:37 2008 +0100 restart from scratch commit 249d6cdbddbea622c949753aafbf48e526e0ef4d Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 19:39:12 2008 +0100 more diversion commit b948990103867b59c749da88d6384128c1e5e6d3 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 17:31:42 2008 +0100 milter separation (milter) commit 6dc259a5d4f8f6e4428953055510382160ef8df4 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 17:23:14 2008 +0100 milter separation git-svn: trunk@4519
17 years ago
}
#endif
time(&currtime);
if (logg(LOGG_INFO_NF, "+++ Started at %s", ctime(&currtime))) {
fprintf(stderr, "ERROR: Can't initialize the internal logger\n");
logg_close();
optfree(opts);
return 1;
}
if ((opt = optget(opts, "TemporaryDirectory"))->enabled)
tempdir = opt->strarg;
if (localnets_init(opts) || init_actions(opts)) {
logg_close();
optfree(opts);
return 1;
}
if (((opt = optget(opts, "Whitelist"))->enabled || (opt = optget(opts, "AllowList"))->enabled) && allow_list_init(opt->strarg)) {
localnets_free();
logg_close();
optfree(opts);
return 1;
}
if ((opt = optget(opts, "SkipAuthenticated"))->enabled && smtpauth_init(opt->strarg)) {
localnets_free();
allow_list_free();
logg_close();
optfree(opts);
return 1;
}
14 years ago
multircpt = optget(opts, "SupportMultipleRecipients")->enabled;
#ifndef _WIN32
if (!optget(opts, "Foreground")->enabled) {
if (-1 == daemonize_parent_wait(user_name, logg_file)) {
logg(LOGG_ERROR, "daemonize() failed\n");
localnets_free();
allow_list_free();
cpool_free();
logg_close();
optfree(opts);
return 1;
}
if (chdir("/") == -1) {
logg(LOGG_WARNING, "Can't change current working directory to root\n");
}
}
sigfillset(&sigset);
sigdelset(&sigset, SIGUSR1);
sigdelset(&sigset, SIGFPE);
sigdelset(&sigset, SIGILL);
sigdelset(&sigset, SIGSEGV);
#ifdef SIGBUS
sigdelset(&sigset, SIGBUS);
#endif
pthread_sigmask(SIG_SETMASK, &sigset, NULL);
memset(&act, 0, sizeof(struct sigaction));
act.sa_handler = milter_exit;
sigfillset(&(act.sa_mask));
sigaction(SIGUSR1, &act, NULL);
sigaction(SIGSEGV, &act, NULL);
#endif /* _WIN32 */
maxfilesize = optget(opts, "MaxFileSize")->numarg;
if (!maxfilesize) {
logg(LOGG_WARNING, "Invalid MaxFileSize, using default (%d)\n", CLI_DEFAULT_MAXFILESIZE);
maxfilesize = CLI_DEFAULT_MAXFILESIZE;
15 years ago
}
readtimeout = optget(opts, "ReadTimeout")->numarg;
cpool_init(opts);
Squashed commit of the following: commit 0ddbd1a7117e207b8aa87079568a056691d5eb32 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 17:18:04 2008 +0100 to be committed commit 51f8010a275717b8a56a3ab22d49755899819518 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 15:18:40 2008 +0100 mangle body commit cd38463f4739f4a7778b6bf294cfb2166024656e Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 14:43:39 2008 +0100 parse clamd result commit 7b8a39495e59ac745342455f8e9aab09951d1041 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 03:19:45 2008 +0100 handle calloc shifts commit a58b732af99f9e3f18d2327e977432f1117028ee Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 02:07:19 2008 +0100 spam added, local is b0rked commit 22604b4b037cfdbc92d6b29986652e2f004bd1f3 Author: acab <acab@albe.digitalfuture.it> Date: Wed Nov 26 19:44:59 2008 +0100 free/close stuff commit 33a02aed984981d3e80ca4930a482f702624f08f Author: aCaB <acab@digitalfuture.it> Date: Wed Nov 26 03:11:29 2008 +0100 skeleton ready commit 4630d9902ee74b6137abf6526c6a9ad3e41fc597 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 22:59:41 2008 +0100 need to rebase commit 083f5f98aecfce2763870f20ae97643d5683613a Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 22:45:11 2008 +0100 in body() commit 08f040f67de1264810953415c0a47c95ec9acff0 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 19:51:15 2008 +0100 clamfi commit bc08fe8f72580b8be81791a7c03ec38952781af7 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 16:47:17 2008 +0100 adding milter commit 34dcebd9294a059f2c45ec9d1817bdb75f423cb3 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 00:35:11 2008 +0100 netcode works, fix to cfgparser commit 3cc0997d907e817954328c60e43cdcca0667d6f3 Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 23:46:05 2008 +0100 socket probe commit 0c3bbd6d03f8df931cb114b07150cd0b7dcd0aff Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 19:02:06 2008 +0100 nonblock started commit a1193ff0de0d0a3d9212d833110236b1329c1f2e Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 11:17:41 2008 +0100 legacy options commit 90519c59ff8a4f44fceaf84e8c40116254c73045 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 23 19:41:26 2008 +0100 sockets pool commit 897b0c5f82503530ba3fbb2fcc3a9c007488e90a Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 23 01:02:59 2008 +0100 Logging done commit 4cf3a218756271c74782a1649f728e1c6e977ae5 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 23:31:34 2008 +0100 Config done commit 93b271579f680286c697476c00d8eec7effb2fc4 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 22:50:42 2008 +0100 Sanitise config file options commit bf5e81b8561b258daaef134894761fa80d44f5b1 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 20:25:06 2008 +0100 cfgparser hacks to allow for milter own conf commit 8924e93b2567a1f378c2177b4011b67631b49cc1 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 19:03:45 2008 +0100 command line parser commit d2180e370f75948b6ce12f89979bda9e92ccd5f8 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 16:36:37 2008 +0100 restart from scratch commit 249d6cdbddbea622c949753aafbf48e526e0ef4d Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 19:39:12 2008 +0100 more diversion commit b948990103867b59c749da88d6384128c1e5e6d3 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 17:31:42 2008 +0100 milter separation (milter) commit 6dc259a5d4f8f6e4428953055510382160ef8df4 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 17:23:14 2008 +0100 milter separation git-svn: trunk@4519
17 years ago
if (!cp) {
logg(LOGG_ERROR, "Failed to init the socket pool\n");
localnets_free();
allow_list_free();
logg_close();
optfree(opts);
return 1;
}
if ((opt = optget(opts, "PidFile"))->enabled) {
FILE *fd;
mode_t old_umask = umask(0022);
int err = 0;
if ((fd = fopen(opt->strarg, "w")) == NULL) {
logg(LOGG_ERROR, "Can't save PID in file %s\n", opt->strarg);
err = 1;
} else {
if (fprintf(fd, "%u\n", (unsigned int)getpid()) < 0) {
logg(LOGG_ERROR, "Can't save PID in file %s\n", opt->strarg);
err = 1;
}
fclose(fd);
}
umask(old_umask);
#ifndef _WIN32
if (0 == err) {
/*If the file has already been created by a different user, it will just be
* rewritten by us, but not change the ownership, so do that explicitly.
*/
if (0 == geteuid()) {
struct passwd *pw = getpwuid(0);
int ret = lchown(opt->strarg, pw->pw_uid, pw->pw_gid);
if (ret) {
logg(LOGG_ERROR, "Can't change ownership of PID file %s '%s'\n", opt->strarg, strerror(errno));
err = 1;
}
}
}
#endif /*_WIN32*/
if (err) {
localnets_free();
allow_list_free();
logg_close();
optfree(opts);
return 2;
}
}
#ifndef _WIN32
dropPrivRet = drop_privileges(user_name, logg_file);
if (dropPrivRet) {
optfree(opts);
return dropPrivRet;
}
/* We have been daemonized, and initialization is done. Signal
* the parent process so that it can exit cleanly.
*/
if (parentPid != getpid()) { // we have been daemonized
daemonize_signal_parent(parentPid);
}
#endif
return smfi_main();
}
/*
Squashed commit of the following: commit 0ddbd1a7117e207b8aa87079568a056691d5eb32 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 17:18:04 2008 +0100 to be committed commit 51f8010a275717b8a56a3ab22d49755899819518 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 15:18:40 2008 +0100 mangle body commit cd38463f4739f4a7778b6bf294cfb2166024656e Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 14:43:39 2008 +0100 parse clamd result commit 7b8a39495e59ac745342455f8e9aab09951d1041 Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 03:19:45 2008 +0100 handle calloc shifts commit a58b732af99f9e3f18d2327e977432f1117028ee Author: acab <acab@1337ness.(none)> Date: Thu Nov 27 02:07:19 2008 +0100 spam added, local is b0rked commit 22604b4b037cfdbc92d6b29986652e2f004bd1f3 Author: acab <acab@albe.digitalfuture.it> Date: Wed Nov 26 19:44:59 2008 +0100 free/close stuff commit 33a02aed984981d3e80ca4930a482f702624f08f Author: aCaB <acab@digitalfuture.it> Date: Wed Nov 26 03:11:29 2008 +0100 skeleton ready commit 4630d9902ee74b6137abf6526c6a9ad3e41fc597 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 22:59:41 2008 +0100 need to rebase commit 083f5f98aecfce2763870f20ae97643d5683613a Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 22:45:11 2008 +0100 in body() commit 08f040f67de1264810953415c0a47c95ec9acff0 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 19:51:15 2008 +0100 clamfi commit bc08fe8f72580b8be81791a7c03ec38952781af7 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 16:47:17 2008 +0100 adding milter commit 34dcebd9294a059f2c45ec9d1817bdb75f423cb3 Author: aCaB <acab@digitalfuture.it> Date: Tue Nov 25 00:35:11 2008 +0100 netcode works, fix to cfgparser commit 3cc0997d907e817954328c60e43cdcca0667d6f3 Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 23:46:05 2008 +0100 socket probe commit 0c3bbd6d03f8df931cb114b07150cd0b7dcd0aff Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 19:02:06 2008 +0100 nonblock started commit a1193ff0de0d0a3d9212d833110236b1329c1f2e Author: aCaB <acab@digitalfuture.it> Date: Mon Nov 24 11:17:41 2008 +0100 legacy options commit 90519c59ff8a4f44fceaf84e8c40116254c73045 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 23 19:41:26 2008 +0100 sockets pool commit 897b0c5f82503530ba3fbb2fcc3a9c007488e90a Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 23 01:02:59 2008 +0100 Logging done commit 4cf3a218756271c74782a1649f728e1c6e977ae5 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 23:31:34 2008 +0100 Config done commit 93b271579f680286c697476c00d8eec7effb2fc4 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 22:50:42 2008 +0100 Sanitise config file options commit bf5e81b8561b258daaef134894761fa80d44f5b1 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 20:25:06 2008 +0100 cfgparser hacks to allow for milter own conf commit 8924e93b2567a1f378c2177b4011b67631b49cc1 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 19:03:45 2008 +0100 command line parser commit d2180e370f75948b6ce12f89979bda9e92ccd5f8 Author: aCaB <acab@digitalfuture.it> Date: Sat Nov 22 16:36:37 2008 +0100 restart from scratch commit 249d6cdbddbea622c949753aafbf48e526e0ef4d Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 19:39:12 2008 +0100 more diversion commit b948990103867b59c749da88d6384128c1e5e6d3 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 17:31:42 2008 +0100 milter separation (milter) commit 6dc259a5d4f8f6e4428953055510382160ef8df4 Author: aCaB <acab@digitalfuture.it> Date: Sun Nov 16 17:23:14 2008 +0100 milter separation git-svn: trunk@4519
17 years ago
* Local Variables:
* mode: c
* c-basic-offset: 4
* tab-width: 8
* End:
* vim: set cindent smartindent autoindent softtabstop=4 shiftwidth=4 tabstop=8:
*/