From fa843306de492204c6a37e83db234de76e03ff9d Mon Sep 17 00:00:00 2001 From: SJ Date: Sat, 11 Feb 2012 23:12:30 +0100 Subject: [PATCH] 0.1.14 fixes --- Makefile.in | 8 +++++--- configure | 9 +++++++-- configure.in | 7 +++++-- etc/Makefile.in | 6 +++--- etc/cron.jobs.in | 2 +- etc/example.conf | 32 ++++++++------------------------ etc/sphinx.conf | 34 +++++++++++++++++----------------- src/Makefile.in | 18 +++--------------- src/cfg.c | 1 - src/cfg.h | 5 ----- src/dirs.c | 7 ------- util/Makefile.in | 36 ++++++++++++++++++++++++++++++++++++ util/gen-iv.pl | 13 +++++++++++++ webui/config.php | 2 +- webui/sign.php | 36 ------------------------------------ 15 files changed, 99 insertions(+), 117 deletions(-) create mode 100644 util/Makefile.in create mode 100755 util/gen-iv.pl delete mode 100644 webui/sign.php diff --git a/Makefile.in b/Makefile.in index 860a3705..53885022 100644 --- a/Makefile.in +++ b/Makefile.in @@ -67,13 +67,15 @@ $(RECURSIVE_TARGETS): installdirs: mkinstalldirs $(srcdir)/mkinstalldirs \ $(DESTDIR)$(bindir) $(DESTDIR)$(sbindir) $(DESTDIR)$(libdir) $(DESTDIR)$(libexecdir)/piler $(DESTDIR)$(sysconfdir) \ - $(DESTDIR)$(datarootdir)/piler $(DESTDIR)$(includedir)/piler $(DESTDIR)$(localstatedir)/piler/store \ - $(DESTDIR)$(localstatedir)/piler/stat $(DESTDIR)$(localstatedir)/piler/tmp + $(DESTDIR)$(localstatedir)/piler/store \ + $(DESTDIR)$(localstatedir)/piler/stat $(DESTDIR)$(localstatedir)/piler/tmp \ + $(DESTDIR)$(localstatedir)/piler/sphinx $(INSTALL) -d -m 0755 -o $(RUNNING_USER) -g $(RUNNING_GROUP) $(DESTDIR)$(localstatedir)/run/piler - $(INSTALL) -d -m 0755 -o $(RUNNING_USER) -g $(RUNNING_GROUP) $(DESTDIR)$(localstatedir)/piler/store + $(INSTALL) -d -m 0700 -o $(RUNNING_USER) -g $(RUNNING_GROUP) $(DESTDIR)$(localstatedir)/piler/store $(INSTALL) -d -m 0755 -o $(RUNNING_USER) -g $(RUNNING_GROUP) $(DESTDIR)$(localstatedir)/piler/stat $(INSTALL) -d -m 0711 -o $(RUNNING_USER) -g $(RUNNING_GROUP) $(DESTDIR)$(localstatedir)/piler/tmp + $(INSTALL) -d -m 0700 -o $(RUNNING_USER) -g $(RUNNING_GROUP) $(DESTDIR)$(localstatedir)/piler/sphinx install-am: diff --git a/configure b/configure index f6b356d1..88c5a8d3 100755 --- a/configure +++ b/configure @@ -604,6 +604,7 @@ LIBOBJS DATADIR CFGDIR MYSQL_CONFIG +iv id_bin libclamav_extra_libs mysql_obj @@ -3400,6 +3401,7 @@ done + have_libclamav="no" have_libtool="no" have_clamd="no" @@ -3421,7 +3423,7 @@ os=`uname -s` id_bin="id" -SUBDIRS="src" +SUBDIRS="src etc util" @@ -4143,13 +4145,15 @@ fi echo "piler data directory: $data_dir/piler" +iv=`util/gen-iv.pl` + echo; echo CFLAGS="$static -O2 -Wall -g" LIBS="$antispam_libs $sunos_libs " OBJS="dirs.o misc.o counters.o cfg.o sig.o decoder.o list.o parser.o parser_utils.o rules.o session.o message.o attachment.o digest.o store.o archive.o tai.o $objs" -ac_config_files="$ac_config_files Makefile src/Makefile etc/Makefile" +ac_config_files="$ac_config_files Makefile src/Makefile etc/Makefile util/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -4857,6 +4861,7 @@ do "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; "etc/Makefile") CONFIG_FILES="$CONFIG_FILES etc/Makefile" ;; + "util/Makefile") CONFIG_FILES="$CONFIG_FILES util/Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac diff --git a/configure.in b/configure.in index fa115931..299d640e 100644 --- a/configure.in +++ b/configure.in @@ -27,6 +27,7 @@ AC_SUBST(mysql_libs) AC_SUBST(mysql_obj) AC_SUBST(libclamav_extra_libs) AC_SUBST(id_bin) +AC_SUBST(iv) have_libclamav="no" have_libtool="no" @@ -50,7 +51,7 @@ os=`uname -s` id_bin="id" dnl SUBDIRS="src etc util perl init.d templates history contrib/stat" -SUBDIRS="src" +SUBDIRS="src etc util" dnl static build @@ -267,12 +268,14 @@ fi echo "piler data directory: $data_dir/piler" +iv=`util/gen-iv.pl` + echo; echo CFLAGS="$static -O2 -Wall -g" LIBS="$antispam_libs $sunos_libs " OBJS="dirs.o misc.o counters.o cfg.o sig.o decoder.o list.o parser.o parser_utils.o rules.o session.o message.o attachment.o digest.o store.o archive.o tai.o $objs" -AC_CONFIG_FILES([Makefile src/Makefile etc/Makefile]) +AC_CONFIG_FILES([Makefile src/Makefile etc/Makefile util/Makefile]) AC_OUTPUT diff --git a/etc/Makefile.in b/etc/Makefile.in index 7317356c..1d70bc17 100644 --- a/etc/Makefile.in +++ b/etc/Makefile.in @@ -26,11 +26,11 @@ INSTALL = @INSTALL@ all: sed -e 's%pidfile=.*%pidfile=$(localstatedir)/run/piler/piler.pid%g' \ - -e 's%workdir=.*%workdir=$(localstatedir)/spool/piler/tmp%g' \ - -e 's%queuedir=.*%queuedir=$(localstatedir)/piler/queue%g' < $(srcdir)/example.conf > $(srcdir)/piler.conf + -e 's%iv=.*%iv=@iv@%g' \ + -e 's%workdir=.*%workdir=$(localstatedir)/piler/tmp%g' < $(srcdir)/example.conf > $(srcdir)/piler.conf install: - if [ ! -f "$(DESTDIR)$(sysconfdir)/piler.conf" ]; then $(INSTALL) -m 0640 $(srcdir)/piler.conf $(DESTDIR)$(sysconfdir)/piler.conf; chgrp $(CLAPF_GROUP) $(DESTDIR)$(sysconfdir)/piler.conf; fi + if [ ! -f "$(DESTDIR)$(sysconfdir)/piler.conf" ]; then $(INSTALL) -m 0640 -g $(RUNNING_GROUP) $(srcdir)/piler.conf $(DESTDIR)$(sysconfdir)/piler.conf; fi clean: rm -f piler.conf cron.jobs diff --git a/etc/cron.jobs.in b/etc/cron.jobs.in index e4787027..fac8511c 100644 --- a/etc/cron.jobs.in +++ b/etc/cron.jobs.in @@ -25,5 +25,5 @@ piler's crontab: sphinx's cronjob: */5 * * * * /usr/local/bin/indexer --quiet delta1 --rotate && sleep 2 && /usr/local/bin/indexer --quiet --merge main1 delta1 --merge-dst-range deleted 0 0 --rotate -*/5 * * * * /usr/local/bin/indexer --quiet tag1 --rotate +*/15 * * * * /usr/local/bin/indexer --quiet tag1 --rotate diff --git a/etc/example.conf b/etc/example.conf index 94783222..a4182dfa 100644 --- a/etc/example.conf +++ b/etc/example.conf @@ -11,6 +11,9 @@ verbosity=1 ; it it was started by root username=piler +; this is a 16 character long vector +iv=**************** + ; number of worker processes, ie. the number of simultaneous smtp connections to piler. number_of_worker_processes=10 @@ -18,7 +21,7 @@ number_of_worker_processes=10 max_requests_per_child=1000 ; SMTP HELO identification string -hostid=av-engine.localhost +hostid=mailarchiver.localhost ; write pid file pidfile=/var/run/piler/piler.pid @@ -32,7 +35,7 @@ clamd_socket=/tmp/clamd session_timeout=420 ; the 2nd parameter of the listen() system call. Please note that this is set -; when clapf starts up and you should restart clapf if you change this variable. +; when piler starts up and you should restart piler if you change this variable. ; Please also note that the meaning of this variable depends on your Unix implementation backlog=20 @@ -68,7 +71,7 @@ spam_header_line= ; memcached stuff ; -; memcached server to use. Currently clapf support only 1 memcached server +; memcached server to use. Currently piler supports only 1 memcached server memcached_servers=127.0.0.1 ; ttl (in secs) of a stored object @@ -82,7 +85,7 @@ update_counters_to_memcached=0 ; this setting is only effective if you have update_counters_to_memcached=1 ; ; hint: if you are using a mysql replicated environment and you do _not_ want -; clapf to write to the replicated database (because you do sync it some other +; piler to write to the replicated database (because you do sync it some other ; way to the master database or you are not interested in keeping the counters ; persistantly at all), then specify a big number here, that fits to the ; "long int" size, eg. 2147483647 @@ -97,26 +100,7 @@ memcached_to_db_interval=900 ;mysqlport=3306 mysqlsocket=/tmp/mysql.sock mysqluser=piler -mysqlpwd=changeme +mysqlpwd=verystrongpassword mysqldb=piler mysql_connect_timeout=2 - -; -; sqlite3 stuff -; - -; If you are using spamdrop (not the clapf daemon), you have two options: -; 1. You may specify this variable, then every user will share this token -; database (=shared database) OR -; 2. comment this variable out, and spamdrop will figure out where the users' -; individual token databases are. -sqlite3=/var/lib/piler/data/tokens.sdb - -; set sqlite3 pragma, see http://www.sqlite.org/pragma.html for more details -; possible values are: -; PRAGMA synchronous = FULL -; PRAGMA synchronous = NORMAL -; PRAGMA synchronous = OFF -sqlite3_pragma=PRAGMA synchronous = OFF - diff --git a/etc/sphinx.conf b/etc/sphinx.conf index b858589d..dd1c8da6 100644 --- a/etc/sphinx.conf +++ b/etc/sphinx.conf @@ -6,9 +6,9 @@ source main { type = mysql sql_host = localhost - sql_db = sphinx - sql_user = sphinx - sql_pass = sphinx + sql_db = piler + sql_user = piler + sql_pass = piler sql_query_pre = SET NAMES utf8 sql_query = SELECT id, `from`, `to`, `fromdomain`, `todomain`, `subject`, `arrived`, `sent`, `body`, `size`, `direction`, `attachments`, `attachment_types` FROM sph_index \ @@ -26,9 +26,9 @@ source delta { type = mysql sql_host = localhost - sql_db = sphinx - sql_user = sphinx - sql_pass = sphinx + sql_db = piler + sql_user = piler + sql_pass = piler sql_query_pre = SET NAMES utf8 sql_query_pre = REPLACE INTO sph_counter SELECT 1, MAX(id) FROM sph_index @@ -52,9 +52,9 @@ source tag { type = mysql sql_host = localhost - sql_db = sphinx - sql_user = sphinx - sql_pass = sphinx + sql_db = piler + sql_user = piler + sql_pass = piler sql_query_pre = SET NAMES utf8 sql_query = SELECT id, `uid`, `tag` FROM `tag` @@ -67,7 +67,7 @@ source tag index main1 { source = main - path = /var/data/main1 + path = /var/piler/sphinx/main1 docinfo = extern charset_type = utf-8 } @@ -76,7 +76,7 @@ index main1 index delta1 { source = delta - path = /var/data/delta1 + path = /var/piler/sphinx/delta1 docinfo = extern charset_type = utf-8 } @@ -85,7 +85,7 @@ index delta1 index tag1 { source = tag - path = /var/data/tag1 + path = /var/piler/sphinx/tag1 docinfo = extern charset_type = utf-8 } @@ -99,14 +99,14 @@ indexer searchd { - listen = 9312 - listen = 9306:mysql41 - log = /var/data/log/searchd.log + listen = 127.0.0.1:9312 + listen = 127.0.0.1:9306:mysql41 + log = /dev/null binlog_path = - query_log = /var/data/log/query.log + ##query_log = read_timeout = 5 max_children = 30 - pid_file = /var/data/log/searchd.pid + pid_file = /var/piler/sphinx/searchd.pid max_matches = 1000 seamless_rotate = 1 preopen_indexes = 1 diff --git a/src/Makefile.in b/src/Makefile.in index 9ea2c92e..2d629243 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -68,30 +68,18 @@ test: test.c libpiler.a install-piler: - $(INSTALL) -d $(DESTDIR)$(bindir) - $(INSTALL) -d $(DESTDIR)$(sbindir) - $(INSTALL) -d $(DESTDIR)$(libdir) $(INSTALL) -m 0644 libpiler.a $(DESTDIR)$(libdir) $(INSTALL) -m 0755 libpiler.so.$(LIBPILER_VERSION) $(DESTDIR)$(libdir) (cd $(DESTDIR)$(libdir) && ln -sf libpiler.so.$(LIBPILER_VERSION) libpiler.so) (cd $(DESTDIR)$(libdir) && ln -sf libpiler.so.$(LIBPILER_VERSION) libpiler.so.$(PILER_VERSION)) - $(INSTALL) -d $(DESTDIR)$(libexecdir)/piler - - $(INSTALL) -d $(DESTDIR)$(datarootdir)/piler - $(INSTALL) -m 0755 piler $(DESTDIR)$(sbindir) $(INSTALL) -m 0755 pilerconf $(DESTDIR)$(sbindir) - $(INSTALL) -m 0755 pilerget $(DESTDIR)$(bindir) - $(INSTALL) -m 0755 pilerimport $(DESTDIR)$(bindir) - - chown $(RUNNING_USER):$(RUNNING_GROUP) $(DESTDIR)$(bindir)/pilerget - chown $(RUNNING_USER):$(RUNNING_GROUP) $(DESTDIR)$(bindir)/pilerimport - chmod +s $(DESTDIR)$(bindir)/pilerget - chmod +s $(DESTDIR)$(bindir)/pilerimport + $(INSTALL) -m 6755 -o $(RUNNING_USER) -g $(RUNNING_GROUP) pilerget $(DESTDIR)$(bindir) + $(INSTALL) -m 6755 -o $(RUNNING_USER) -g $(RUNNING_GROUP) pilerimport $(DESTDIR)$(bindir) clean: - rm -f *.o *.a libpiler.so* piler pilerconf pilerget pilerimport pilertest + rm -f *.o *.a libpiler.so* piler pilerconf pilerget pilerimport pilerexport pilertest distclean: clean rm -f Makefile diff --git a/src/cfg.c b/src/cfg.c index 4e382693..77283a54 100644 --- a/src/cfg.c +++ b/src/cfg.c @@ -86,7 +86,6 @@ struct _parse_rule config_parse_rules[] = { "queuedir", "string", (void*) string_parser, offsetof(struct __config, queuedir), QUEUE_DIR, MAXVAL-1}, { "session_timeout", "integer", (void*) int_parser, offsetof(struct __config, session_timeout), "420", sizeof(int)}, { "spam_header_line", "string", (void*) string_parser, offsetof(struct __config, spam_header_line), "", MAXVAL-1}, - { "sqlite3_pragma", "string", (void*) string_parser, offsetof(struct __config, sqlite3_pragma), "", MAXVAL-1}, { "update_counters_to_memcached", "integer", (void*) int_parser, offsetof(struct __config, update_counters_to_memcached), "0", sizeof(int)}, { "username", "string", (void*) string_parser, offsetof(struct __config, username), "piler", MAXVAL-1}, { "use_antivirus", "integer", (void*) int_parser, offsetof(struct __config, use_antivirus), "1", sizeof(int)}, diff --git a/src/cfg.h b/src/cfg.h index 491af6e8..82334a33 100644 --- a/src/cfg.h +++ b/src/cfg.h @@ -57,11 +57,6 @@ struct __config { char mysqldb[MAXVAL]; int mysql_connect_timeout; - // sqlite3 stuff - - char sqlite3[MAXVAL]; - char sqlite3_pragma[MAXVAL]; - int update_counters_to_memcached; int memcached_to_db_interval; diff --git a/src/dirs.c b/src/dirs.c index ee88558c..19827aba 100644 --- a/src/dirs.c +++ b/src/dirs.c @@ -35,13 +35,6 @@ void check_and_create_directories(struct __config *cfg, uid_t uid, gid_t gid){ } createdir(cfg->queuedir, uid, gid, 0700); - p = strrchr(cfg->sqlite3, '/'); - if(p){ - *p = '\0'; - createdir(cfg->sqlite3, uid, gid, 0755); - *p = '/'; - } - p = strrchr(cfg->pidfile, '/'); if(p){ *p = '\0'; diff --git a/util/Makefile.in b/util/Makefile.in new file mode 100644 index 00000000..fb5f228e --- /dev/null +++ b/util/Makefile.in @@ -0,0 +1,36 @@ +SHELL = @SHELL@ + +prefix = @prefix@ +exec_prefix = @exec_prefix@ +bindir = @bindir@ +sbindir = @sbindir@ +includedir = @includedir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +mandir = @mandir@ +datarootdir = @datarootdir@ +localstatedir = @localstatedir@ + +CC = @CC@ +CFLAGS = @CFLAGS@ @CPPFLAGS@ +DEFS = @defs@ +INCDIR = -I. -I../.. -I../../src @INCDIR@ @mysql_includes@ +LIBDIR = -L. @LIBDIR@ @LDFLAGS@ -L../../src +LIBS = @LIBS@ @mysql_libs@ +RUNNING_USER = @RUNNING_USER@ +RUNNING_GROUP = `@id_bin@ -gn $(RUNNING_USER)` + +INSTALL = @INSTALL@ + +all: + +install: + $(INSTALL) -m 0755 $(srcdir)/ldap_sync.php $(DESTDIR)$(libexecdir)/piler + +clean: + + +distclean: clean + rm -f Makefile diff --git a/util/gen-iv.pl b/util/gen-iv.pl new file mode 100755 index 00000000..25879ccb --- /dev/null +++ b/util/gen-iv.pl @@ -0,0 +1,13 @@ +#!/usr/bin/perl +# + +@x = ('A'..'Z','a'..'z',0..9); +$iv = ""; + +srand; + +for($i=0; $i<16; $i++){ + $iv .= @x[rand @x]; +} + +print $iv; diff --git a/webui/config.php b/webui/config.php index 8d52b4a7..8e72341c 100644 --- a/webui/config.php +++ b/webui/config.php @@ -75,7 +75,7 @@ define('DB_DRIVER', 'mysql'); define('DB_PREFIX', ''); define('DB_HOSTNAME', 'localhost'); define('DB_USERNAME', 'piler'); -define('DB_PASSWORD', 'q57tPYem'); +define('DB_PASSWORD', 'piler'); define('DB_DATABASE', 'piler'); define('TABLE_USER', 'user'); diff --git a/webui/sign.php b/webui/sign.php deleted file mode 100644 index 8ab42ad8..00000000 --- a/webui/sign.php +++ /dev/null @@ -1,36 +0,0 @@ -query("select vcode FROM " . TABLE_META . " WHERE sent >= ? AND sent < ? ORDER BY id ASC", array($ts1, $ts2)); - - -print $query->query . " $ts1, $ts2\n\n"; - - - -foreach ($query->rows as $q) { - $data .= $q['vcode']; -} - -print $data . "\n"; - -$digest = openssl_digest($data, "SHA256"); - -print "$digest\n"; - - -print fetch_url("http://ecrive.net/api/plain?mode=sign&data=$digest"); - -//print fetch_url("http://ecrive.net/api/plain?mode=check&data=$digest&signature=$s");