Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial commit

  • Loading branch information...
commit 52049b90d1d97789299f345a1fe5b4924ad23c2a 0 parents
@pehlert authored
Showing with 3,211 additions and 0 deletions.
  1. +1 −0  .gitignore
  2. +12 −0 README.md
  3. +8 −0 metadata.rb
  4. +35 −0 recipes/amavis.rb
  5. +15 −0 recipes/clamav.rb
  6. +707 −0 recipes/default.rb
  7. +62 −0 recipes/dovecot.rb
  8. +39 −0 recipes/postfix.rb
  9. +35 −0 recipes/postfixadmin.rb
  10. +10 −0 recipes/spamassassin.rb
  11. +758 −0 templates/default/amavis/basic.erb
  12. +127 −0 templates/default/dovecot/10-auth.conf.erb
  13. +56 −0 templates/default/dovecot/10-director.conf.erb
  14. +83 −0 templates/default/dovecot/10-logging.conf.erb
  15. +345 −0 templates/default/dovecot/10-mail.conf.erb
  16. +111 −0 templates/default/dovecot/10-master.conf.erb
  17. +41 −0 templates/default/dovecot/10-ssl.conf.erb
  18. +48 −0 templates/default/dovecot/15-lda.conf.erb
  19. +58 −0 templates/default/dovecot/20-imap.conf.erb
  20. +73 −0 templates/default/dovecot/20-managesieve.conf.erb
  21. +19 −0 templates/default/dovecot/90-acl.conf.erb
  22. +11 −0 templates/default/dovecot/90-plugin.conf.erb
  23. +75 −0 templates/default/dovecot/90-quota.conf.erb
  24. +63 −0 templates/default/dovecot/90-sieve.conf.erb
  25. +16 −0 templates/default/dovecot/auth-master.conf.ext.erb
  26. +15 −0 templates/default/dovecot/auth-sql.conf.ext.erb
  27. +16 −0 templates/default/dovecot/dovecot-sql.conf.ext.erb
  28. +25 −0 templates/default/dovecot/dovecot.conf.erb
  29. +105 −0 templates/default/postfix/main.cf.erb
  30. +84 −0 templates/default/postfix/master.cf.erb
  31. +6 −0 templates/default/postfix/pgsql_relay_domain_maps.cf.erb
  32. +6 −0 templates/default/postfix/pgsql_virtual_alias_maps.cf.erb
  33. +5 −0 templates/default/postfix/pgsql_virtual_domain_maps.cf.erb
  34. +6 −0 templates/default/postfix/pgsql_virtual_mailbox_maps.cf.erb
  35. +104 −0 templates/default/postfixadmin/config.local.php.erb
  36. +31 −0 templates/default/spamassassin/default.erb
1  .gitignore
@@ -0,0 +1 @@
+metadata.json
12 README.md
@@ -0,0 +1,12 @@
+Description
+===========
+
+Requirements
+============
+
+Attributes
+==========
+
+Usage
+=====
+
8 metadata.rb
@@ -0,0 +1,8 @@
+maintainer "Pascal Ehlert"
+maintainer_email "pascal@hacksrus.net"
+license "All rights reserved"
+description "Installs and configures a full mail server stack with postfix, dovecot, clamav, spamassassin, amavis and postfixadmin"
+long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
+depends "database"
+depends "lighttpd"
+version "0.1.0"
35 recipes/amavis.rb
@@ -0,0 +1,35 @@
+package "amavisd-new"
+
+default_config = %w(01-debian
+ 05-domain_id
+ 05-node_id
+ 15-av_scanners
+ 15-content_filter_mode
+ 20-debian_defaults
+ 21-ubuntu_defaults
+ 25-amavis_helpers
+ 30-template_localization
+ 40-policy_banks
+ 50-user)
+
+default_config.each do |filename|
+ file "/etc/amavis/conf.d/#{filename}" do
+ action :delete
+
+ notifies :restart, "service[amavis]"
+ end
+end
+
+template "/etc/amavis/conf.d/01-basic" do
+ source "amavis/basic.erb"
+ owner "root"
+ group "root"
+ mode 0644
+
+ notifies :restart, "service[amavis]"
+end
+
+service "amavis" do
+ supports [:restart]
+ action [:enable, :start]
+end
15 recipes/clamav.rb
@@ -0,0 +1,15 @@
+# NOTE: amavisd recipe must have been run before we get here!
+
+package "clamav-daemon"
+
+# Add user clamav to amavis group to make them play together!
+group "amavis" do
+ members ['clamav']
+ append true
+end
+
+service "clamav" do
+ service_name "clamav-daemon"
+ supports :status => true, :restart => true, :reload => true
+ action [:enable, :restart]
+end
707 recipes/default.rb
@@ -0,0 +1,707 @@
+#
+# Cookbook Name:: mailserver
+# Recipe:: default
+#
+# Copyright 2012, Rod Mayler Group
+#
+# All rights reserved - Do Not Redistribute
+#
+
+# Generate the required databases on all db servers
+::Chef::Recipe.send(:include, Opscode::OpenSSL::Password)
+
+include_recipe "database"
+
+# generate all passwords
+node.set_unless['mailserver']['db_mailadmin_password'] = secure_password
+node.set_unless['mailserver']['db_mailauth_password'] = secure_password
+
+db_connection = { :host => 'localhost', :username => 'postgres', :password => node[:postgresql][:password][:postgres] }
+
+postgresql_database_user 'mailadmin' do
+ connection db_connection
+ password node['mailserver']['db_mailadmin_password']
+ action :create
+end
+
+postgresql_database_user 'mailauth' do
+ connection db_connection
+ password node['mailserver']['db_mailauth_password']
+ action :create
+end
+
+postgresql_database 'mailconfig' do
+ connection db_connection
+ action :create
+end
+
+mailconfig_sql = <<END
+--
+-- Name: admin; Type: TABLE; Schema: public; Owner: mailadmin; Tablespace:
+--
+
+CREATE TABLE admin (
+ username character varying(255) NOT NULL,
+ password character varying(255) DEFAULT ''::character varying NOT NULL,
+ created timestamp with time zone DEFAULT now(),
+ modified timestamp with time zone DEFAULT now(),
+ active boolean DEFAULT true NOT NULL
+);
+
+
+ALTER TABLE public.admin OWNER TO mailadmin;
+
+--
+-- Name: TABLE admin; Type: COMMENT; Schema: public; Owner: mailadmin
+--
+
+COMMENT ON TABLE admin IS 'Postfix Admin - Virtual Admins';
+
+
+--
+-- Name: alias; Type: TABLE; Schema: public; Owner: mailadmin; Tablespace:
+--
+
+CREATE TABLE alias (
+ address character varying(255) NOT NULL,
+ goto text NOT NULL,
+ domain character varying(255) NOT NULL,
+ created timestamp with time zone DEFAULT now(),
+ modified timestamp with time zone DEFAULT now(),
+ active boolean DEFAULT true NOT NULL
+);
+
+
+ALTER TABLE public.alias OWNER TO mailadmin;
+
+--
+-- Name: TABLE alias; Type: COMMENT; Schema: public; Owner: mailadmin
+--
+
+COMMENT ON TABLE alias IS 'Postfix Admin - Virtual Aliases';
+
+
+--
+-- Name: alias_domain; Type: TABLE; Schema: public; Owner: mailadmin; Tablespace:
+--
+
+CREATE TABLE alias_domain (
+ alias_domain character varying(255) NOT NULL,
+ target_domain character varying(255) NOT NULL,
+ created timestamp with time zone DEFAULT now(),
+ modified timestamp with time zone DEFAULT now(),
+ active boolean DEFAULT true NOT NULL
+);
+
+
+ALTER TABLE public.alias_domain OWNER TO mailadmin;
+
+--
+-- Name: TABLE alias_domain; Type: COMMENT; Schema: public; Owner: mailadmin
+--
+
+COMMENT ON TABLE alias_domain IS 'Postfix Admin - Domain Aliases';
+
+
+--
+-- Name: config; Type: TABLE; Schema: public; Owner: mailadmin; Tablespace:
+--
+
+CREATE TABLE config (
+ id integer NOT NULL,
+ name character varying(20) NOT NULL,
+ value character varying(20) NOT NULL
+);
+
+
+ALTER TABLE public.config OWNER TO mailadmin;
+
+--
+-- Name: config_id_seq; Type: SEQUENCE; Schema: public; Owner: mailadmin
+--
+
+CREATE SEQUENCE config_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MAXVALUE
+ NO MINVALUE
+ CACHE 1;
+
+
+ALTER TABLE public.config_id_seq OWNER TO mailadmin;
+
+--
+-- Name: config_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: mailadmin
+--
+
+ALTER SEQUENCE config_id_seq OWNED BY config.id;
+
+
+--
+-- Name: domain; Type: TABLE; Schema: public; Owner: mailadmin; Tablespace:
+--
+
+CREATE TABLE domain (
+ domain character varying(255) NOT NULL,
+ description character varying(255) DEFAULT ''::character varying NOT NULL,
+ aliases integer DEFAULT 0 NOT NULL,
+ mailboxes integer DEFAULT 0 NOT NULL,
+ maxquota integer DEFAULT 0 NOT NULL,
+ quota integer DEFAULT 0 NOT NULL,
+ transport character varying(255) DEFAULT NULL::character varying,
+ backupmx boolean DEFAULT false NOT NULL,
+ created timestamp with time zone DEFAULT now(),
+ modified timestamp with time zone DEFAULT now(),
+ active boolean DEFAULT true NOT NULL
+);
+
+
+ALTER TABLE public.domain OWNER TO mailadmin;
+
+--
+-- Name: TABLE domain; Type: COMMENT; Schema: public; Owner: mailadmin
+--
+
+COMMENT ON TABLE domain IS 'Postfix Admin - Virtual Domains';
+
+
+--
+-- Name: domain_admins; Type: TABLE; Schema: public; Owner: mailadmin; Tablespace:
+--
+
+CREATE TABLE domain_admins (
+ username character varying(255) NOT NULL,
+ domain character varying(255) NOT NULL,
+ created timestamp with time zone DEFAULT now(),
+ active boolean DEFAULT true NOT NULL
+);
+
+
+ALTER TABLE public.domain_admins OWNER TO mailadmin;
+
+--
+-- Name: TABLE domain_admins; Type: COMMENT; Schema: public; Owner: mailadmin
+--
+
+COMMENT ON TABLE domain_admins IS 'Postfix Admin - Domain Admins';
+
+
+--
+-- Name: fetchmail; Type: TABLE; Schema: public; Owner: mailadmin; Tablespace:
+--
+
+CREATE TABLE fetchmail (
+ id integer NOT NULL,
+ mailbox character varying(255) DEFAULT ''::character varying NOT NULL,
+ src_server character varying(255) DEFAULT ''::character varying NOT NULL,
+ src_auth character varying(15) NOT NULL,
+ src_user character varying(255) DEFAULT ''::character varying NOT NULL,
+ src_password character varying(255) DEFAULT ''::character varying NOT NULL,
+ src_folder character varying(255) DEFAULT ''::character varying NOT NULL,
+ poll_time integer DEFAULT 10 NOT NULL,
+ fetchall boolean DEFAULT false NOT NULL,
+ keep boolean DEFAULT false NOT NULL,
+ protocol character varying(15) NOT NULL,
+ extra_options text,
+ returned_text text,
+ mda character varying(255) DEFAULT ''::character varying NOT NULL,
+ date timestamp with time zone DEFAULT now(),
+ usessl boolean DEFAULT false NOT NULL,
+ CONSTRAINT fetchmail_protocol_check CHECK (((protocol)::text = ANY ((ARRAY['POP3'::character varying, 'IMAP'::character varying, 'POP2'::character varying, 'ETRN'::character varying, 'AUTO'::character varying])::text[]))),
+ CONSTRAINT fetchmail_src_auth_check CHECK (((src_auth)::text = ANY ((ARRAY['password'::character varying, 'kerberos_v5'::character varying, 'kerberos'::character varying, 'kerberos_v4'::character varying, 'gssapi'::character varying, 'cram-md5'::character varying, 'otp'::character varying, 'ntlm'::character varying, 'msn'::character varying, 'ssh'::character varying, 'any'::character varying])::text[])))
+);
+
+
+ALTER TABLE public.fetchmail OWNER TO mailadmin;
+
+--
+-- Name: fetchmail_id_seq; Type: SEQUENCE; Schema: public; Owner: mailadmin
+--
+
+CREATE SEQUENCE fetchmail_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MAXVALUE
+ NO MINVALUE
+ CACHE 1;
+
+
+ALTER TABLE public.fetchmail_id_seq OWNER TO mailadmin;
+
+--
+-- Name: fetchmail_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: mailadmin
+--
+
+ALTER SEQUENCE fetchmail_id_seq OWNED BY fetchmail.id;
+
+
+--
+-- Name: log; Type: TABLE; Schema: public; Owner: mailadmin; Tablespace:
+--
+
+CREATE TABLE log (
+ "timestamp" timestamp with time zone DEFAULT now(),
+ username character varying(255) DEFAULT ''::character varying NOT NULL,
+ domain character varying(255) DEFAULT ''::character varying NOT NULL,
+ action character varying(255) DEFAULT ''::character varying NOT NULL,
+ data text DEFAULT ''::text NOT NULL
+);
+
+
+ALTER TABLE public.log OWNER TO mailadmin;
+
+--
+-- Name: TABLE log; Type: COMMENT; Schema: public; Owner: mailadmin
+--
+
+COMMENT ON TABLE log IS 'Postfix Admin - Log';
+
+
+--
+-- Name: mailbox; Type: TABLE; Schema: public; Owner: mailadmin; Tablespace:
+--
+
+CREATE TABLE mailbox (
+ username character varying(255) NOT NULL,
+ password character varying(255) DEFAULT ''::character varying NOT NULL,
+ name character varying(255) DEFAULT ''::character varying NOT NULL,
+ maildir character varying(255) DEFAULT ''::character varying NOT NULL,
+ quota integer DEFAULT 0 NOT NULL,
+ created timestamp with time zone DEFAULT now(),
+ modified timestamp with time zone DEFAULT now(),
+ active boolean DEFAULT true NOT NULL,
+ domain character varying(255),
+ local_part character varying(255) NOT NULL
+);
+
+
+ALTER TABLE public.mailbox OWNER TO mailadmin;
+
+--
+-- Name: TABLE mailbox; Type: COMMENT; Schema: public; Owner: mailadmin
+--
+
+COMMENT ON TABLE mailbox IS 'Postfix Admin - Virtual Mailboxes';
+
+
+--
+-- Name: quota; Type: TABLE; Schema: public; Owner: mailadmin; Tablespace:
+--
+
+CREATE TABLE quota (
+ username character varying(255) NOT NULL,
+ path character varying(100) NOT NULL,
+ current bigint
+);
+
+
+ALTER TABLE public.quota OWNER TO mailadmin;
+
+--
+-- Name: quota2; Type: TABLE; Schema: public; Owner: mailadmin; Tablespace:
+--
+
+CREATE TABLE quota2 (
+ username character varying(100) NOT NULL,
+ bytes bigint DEFAULT 0 NOT NULL,
+ messages integer DEFAULT 0 NOT NULL
+);
+
+
+ALTER TABLE public.quota2 OWNER TO mailadmin;
+
+--
+-- Name: vacation; Type: TABLE; Schema: public; Owner: mailadmin; Tablespace:
+--
+
+CREATE TABLE vacation (
+ email character varying(255) NOT NULL,
+ subject character varying(255) NOT NULL,
+ body text DEFAULT ''::text NOT NULL,
+ created timestamp with time zone DEFAULT now(),
+ active boolean DEFAULT true NOT NULL,
+ domain character varying(255)
+);
+
+
+ALTER TABLE public.vacation OWNER TO mailadmin;
+
+--
+-- Name: vacation_notification; Type: TABLE; Schema: public; Owner: mailadmin; Tablespace:
+--
+
+CREATE TABLE vacation_notification (
+ on_vacation character varying(255) NOT NULL,
+ notified character varying(255) NOT NULL,
+ notified_at timestamp with time zone DEFAULT now() NOT NULL
+);
+
+
+ALTER TABLE public.vacation_notification OWNER TO mailadmin;
+
+--
+-- Name: id; Type: DEFAULT; Schema: public; Owner: mailadmin
+--
+
+ALTER TABLE ONLY config ALTER COLUMN id SET DEFAULT nextval('config_id_seq'::regclass);
+
+
+--
+-- Name: id; Type: DEFAULT; Schema: public; Owner: mailadmin
+--
+
+ALTER TABLE ONLY fetchmail ALTER COLUMN id SET DEFAULT nextval('fetchmail_id_seq'::regclass);
+
+
+--
+-- Name: admin_key; Type: CONSTRAINT; Schema: public; Owner: mailadmin; Tablespace:
+--
+
+ALTER TABLE ONLY admin
+ ADD CONSTRAINT admin_key PRIMARY KEY (username);
+
+
+--
+-- Name: alias_domain_pkey; Type: CONSTRAINT; Schema: public; Owner: mailadmin; Tablespace:
+--
+
+ALTER TABLE ONLY alias_domain
+ ADD CONSTRAINT alias_domain_pkey PRIMARY KEY (alias_domain);
+
+
+--
+-- Name: alias_key; Type: CONSTRAINT; Schema: public; Owner: mailadmin; Tablespace:
+--
+
+ALTER TABLE ONLY alias
+ ADD CONSTRAINT alias_key PRIMARY KEY (address);
+
+
+--
+-- Name: config_name_key; Type: CONSTRAINT; Schema: public; Owner: mailadmin; Tablespace:
+--
+
+ALTER TABLE ONLY config
+ ADD CONSTRAINT config_name_key UNIQUE (name);
+
+
+--
+-- Name: config_pkey; Type: CONSTRAINT; Schema: public; Owner: mailadmin; Tablespace:
+--
+
+ALTER TABLE ONLY config
+ ADD CONSTRAINT config_pkey PRIMARY KEY (id);
+
+
+--
+-- Name: domain_key; Type: CONSTRAINT; Schema: public; Owner: mailadmin; Tablespace:
+--
+
+ALTER TABLE ONLY domain
+ ADD CONSTRAINT domain_key PRIMARY KEY (domain);
+
+
+--
+-- Name: fetchmail_pkey; Type: CONSTRAINT; Schema: public; Owner: mailadmin; Tablespace:
+--
+
+ALTER TABLE ONLY fetchmail
+ ADD CONSTRAINT fetchmail_pkey PRIMARY KEY (id);
+
+
+--
+-- Name: mailbox_key; Type: CONSTRAINT; Schema: public; Owner: mailadmin; Tablespace:
+--
+
+ALTER TABLE ONLY mailbox
+ ADD CONSTRAINT mailbox_key PRIMARY KEY (username);
+
+
+--
+-- Name: quota2_pkey; Type: CONSTRAINT; Schema: public; Owner: mailadmin; Tablespace:
+--
+
+ALTER TABLE ONLY quota2
+ ADD CONSTRAINT quota2_pkey PRIMARY KEY (username);
+
+
+--
+-- Name: quota_pkey; Type: CONSTRAINT; Schema: public; Owner: mailadmin; Tablespace:
+--
+
+ALTER TABLE ONLY quota
+ ADD CONSTRAINT quota_pkey PRIMARY KEY (username, path);
+
+
+--
+-- Name: vacation_notification_pkey; Type: CONSTRAINT; Schema: public; Owner: mailadmin; Tablespace:
+--
+
+ALTER TABLE ONLY vacation_notification
+ ADD CONSTRAINT vacation_notification_pkey PRIMARY KEY (on_vacation, notified);
+
+
+--
+-- Name: vacation_pkey; Type: CONSTRAINT; Schema: public; Owner: mailadmin; Tablespace:
+--
+
+ALTER TABLE ONLY vacation
+ ADD CONSTRAINT vacation_pkey PRIMARY KEY (email);
+
+
+--
+-- Name: alias_address_active; Type: INDEX; Schema: public; Owner: mailadmin; Tablespace:
+--
+
+CREATE INDEX alias_address_active ON alias USING btree (address, active);
+
+
+--
+-- Name: alias_domain_active; Type: INDEX; Schema: public; Owner: mailadmin; Tablespace:
+--
+
+CREATE INDEX alias_domain_active ON alias_domain USING btree (alias_domain, active);
+
+
+--
+-- Name: alias_domain_idx; Type: INDEX; Schema: public; Owner: mailadmin; Tablespace:
+--
+
+CREATE INDEX alias_domain_idx ON alias USING btree (domain);
+
+
+--
+-- Name: domain_domain_active; Type: INDEX; Schema: public; Owner: mailadmin; Tablespace:
+--
+
+CREATE INDEX domain_domain_active ON domain USING btree (domain, active);
+
+
+--
+-- Name: mailbox_domain_idx; Type: INDEX; Schema: public; Owner: mailadmin; Tablespace:
+--
+
+CREATE INDEX mailbox_domain_idx ON mailbox USING btree (domain);
+
+
+--
+-- Name: mailbox_username_active; Type: INDEX; Schema: public; Owner: mailadmin; Tablespace:
+--
+
+CREATE INDEX mailbox_username_active ON mailbox USING btree (username, active);
+
+
+--
+-- Name: vacation_email_active; Type: INDEX; Schema: public; Owner: mailadmin; Tablespace:
+--
+
+CREATE INDEX vacation_email_active ON vacation USING btree (email, active);
+
+
+--
+-- Name: alias_domain_alias_domain_fkey; Type: FK CONSTRAINT; Schema: public; Owner: mailadmin
+--
+
+ALTER TABLE ONLY alias_domain
+ ADD CONSTRAINT alias_domain_alias_domain_fkey FOREIGN KEY (alias_domain) REFERENCES domain(domain) ON DELETE CASCADE;
+
+
+--
+-- Name: alias_domain_fkey; Type: FK CONSTRAINT; Schema: public; Owner: mailadmin
+--
+
+ALTER TABLE ONLY alias
+ ADD CONSTRAINT alias_domain_fkey FOREIGN KEY (domain) REFERENCES domain(domain);
+
+
+--
+-- Name: alias_domain_target_domain_fkey; Type: FK CONSTRAINT; Schema: public; Owner: mailadmin
+--
+
+ALTER TABLE ONLY alias_domain
+ ADD CONSTRAINT alias_domain_target_domain_fkey FOREIGN KEY (target_domain) REFERENCES domain(domain) ON DELETE CASCADE;
+
+
+--
+-- Name: domain_admins_domain_fkey; Type: FK CONSTRAINT; Schema: public; Owner: mailadmin
+--
+
+ALTER TABLE ONLY domain_admins
+ ADD CONSTRAINT domain_admins_domain_fkey FOREIGN KEY (domain) REFERENCES domain(domain);
+
+
+--
+-- Name: mailbox_domain_fkey1; Type: FK CONSTRAINT; Schema: public; Owner: mailadmin
+--
+
+ALTER TABLE ONLY mailbox
+ ADD CONSTRAINT mailbox_domain_fkey1 FOREIGN KEY (domain) REFERENCES domain(domain);
+
+
+--
+-- Name: vacation_domain_fkey1; Type: FK CONSTRAINT; Schema: public; Owner: mailadmin
+--
+
+ALTER TABLE ONLY vacation
+ ADD CONSTRAINT vacation_domain_fkey1 FOREIGN KEY (domain) REFERENCES domain(domain);
+
+
+--
+-- Name: vacation_notification_on_vacation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: mailadmin
+--
+
+ALTER TABLE ONLY vacation_notification
+ ADD CONSTRAINT vacation_notification_on_vacation_fkey FOREIGN KEY (on_vacation) REFERENCES vacation(email) ON DELETE CASCADE;
+
+
+--
+-- Name: public; Type: ACL; Schema: -; Owner: postgres
+--
+
+REVOKE ALL ON SCHEMA public FROM PUBLIC;
+REVOKE ALL ON SCHEMA public FROM postgres;
+GRANT ALL ON SCHEMA public TO postgres;
+GRANT ALL ON SCHEMA public TO PUBLIC;
+
+
+--
+-- Name: admin; Type: ACL; Schema: public; Owner: mailadmin
+--
+
+REVOKE ALL ON TABLE admin FROM PUBLIC;
+REVOKE ALL ON TABLE admin FROM mailadmin;
+GRANT ALL ON TABLE admin TO mailadmin;
+GRANT SELECT ON TABLE admin TO mailauth;
+
+
+--
+-- Name: alias; Type: ACL; Schema: public; Owner: mailadmin
+--
+
+REVOKE ALL ON TABLE alias FROM PUBLIC;
+REVOKE ALL ON TABLE alias FROM mailadmin;
+GRANT ALL ON TABLE alias TO mailadmin;
+GRANT SELECT ON TABLE alias TO mailauth;
+
+
+--
+-- Name: config; Type: ACL; Schema: public; Owner: mailadmin
+--
+
+REVOKE ALL ON TABLE config FROM PUBLIC;
+REVOKE ALL ON TABLE config FROM mailadmin;
+GRANT ALL ON TABLE config TO mailadmin;
+GRANT SELECT ON TABLE config TO mailauth;
+
+
+--
+-- Name: config_id_seq; Type: ACL; Schema: public; Owner: mailadmin
+--
+
+REVOKE ALL ON SEQUENCE config_id_seq FROM PUBLIC;
+REVOKE ALL ON SEQUENCE config_id_seq FROM mailadmin;
+GRANT ALL ON SEQUENCE config_id_seq TO mailadmin;
+GRANT SELECT ON SEQUENCE config_id_seq TO mailauth;
+
+
+--
+-- Name: domain; Type: ACL; Schema: public; Owner: mailadmin
+--
+
+REVOKE ALL ON TABLE domain FROM PUBLIC;
+REVOKE ALL ON TABLE domain FROM mailadmin;
+GRANT ALL ON TABLE domain TO mailadmin;
+GRANT SELECT ON TABLE domain TO mailauth;
+
+
+--
+-- Name: domain_admins; Type: ACL; Schema: public; Owner: mailadmin
+--
+
+REVOKE ALL ON TABLE domain_admins FROM PUBLIC;
+REVOKE ALL ON TABLE domain_admins FROM mailadmin;
+GRANT ALL ON TABLE domain_admins TO mailadmin;
+GRANT SELECT ON TABLE domain_admins TO mailauth;
+
+
+--
+-- Name: fetchmail; Type: ACL; Schema: public; Owner: mailadmin
+--
+
+REVOKE ALL ON TABLE fetchmail FROM PUBLIC;
+REVOKE ALL ON TABLE fetchmail FROM mailadmin;
+GRANT ALL ON TABLE fetchmail TO mailadmin;
+GRANT SELECT ON TABLE fetchmail TO mailauth;
+
+
+--
+-- Name: fetchmail_id_seq; Type: ACL; Schema: public; Owner: mailadmin
+--
+
+REVOKE ALL ON SEQUENCE fetchmail_id_seq FROM PUBLIC;
+REVOKE ALL ON SEQUENCE fetchmail_id_seq FROM mailadmin;
+GRANT ALL ON SEQUENCE fetchmail_id_seq TO mailadmin;
+GRANT SELECT ON SEQUENCE fetchmail_id_seq TO mailauth;
+
+
+--
+-- Name: log; Type: ACL; Schema: public; Owner: mailadmin
+--
+
+REVOKE ALL ON TABLE log FROM PUBLIC;
+REVOKE ALL ON TABLE log FROM mailadmin;
+GRANT ALL ON TABLE log TO mailadmin;
+GRANT SELECT ON TABLE log TO mailauth;
+
+
+--
+-- Name: mailbox; Type: ACL; Schema: public; Owner: mailadmin
+--
+
+REVOKE ALL ON TABLE mailbox FROM PUBLIC;
+REVOKE ALL ON TABLE mailbox FROM mailadmin;
+GRANT ALL ON TABLE mailbox TO mailadmin;
+GRANT SELECT ON TABLE mailbox TO mailauth;
+
+
+--
+-- Name: vacation; Type: ACL; Schema: public; Owner: mailadmin
+--
+
+REVOKE ALL ON TABLE vacation FROM PUBLIC;
+REVOKE ALL ON TABLE vacation FROM mailadmin;
+GRANT ALL ON TABLE vacation TO mailadmin;
+GRANT SELECT ON TABLE vacation TO mailauth;
+
+
+--
+-- Name: vacation_notification; Type: ACL; Schema: public; Owner: mailadmin
+--
+
+REVOKE ALL ON TABLE vacation_notification FROM PUBLIC;
+REVOKE ALL ON TABLE vacation_notification FROM mailadmin;
+GRANT ALL ON TABLE vacation_notification TO mailadmin;
+GRANT SELECT ON TABLE vacation_notification TO mailauth;
+
+
+--
+-- PostgreSQL database dump complete
+--
+
+END
+
+# This will run the query to create the basic structure every time the database state changes (should happen only once on creation)
+postgresql_database 'mailconfig-create-tables' do
+ database_name "mailconfig"
+ connection db_connection
+ sql mailconfig_sql
+ action :nothing
+ subscribes :query, resources("postgresql_database[mailconfig]"), :immediately
+end
+
+include_recipe "mailserver::dovecot"
+include_recipe "mailserver::amavis"
+include_recipe "mailserver::clamav"
+include_recipe "mailserver::spamassassin"
+include_recipe "mailserver::postfix"
+include_recipe "mailserver::postfixadmin"
62 recipes/dovecot.rb
@@ -0,0 +1,62 @@
+%w(dovecot-common dovecot-imapd dovecot-sieve dovecot-pgsql dovecot-managesieved).each do |pkg|
+ package pkg
+end
+
+group "dovenull" do
+ members ['dovenull']
+end
+
+# Users and groups have changed here and our templates rely on ohai's attributes.
+# Reload them!
+ohai "reload" do
+ action :reload
+end
+
+directory "/var/mail" do
+ owner "dovenull"
+ group "dovenull"
+ mode 0700
+end
+
+service "dovecot" do
+ supports :status => true, :restart => true, :reload => true
+ action :enable
+end
+
+template "/etc/dovecot/dovecot.conf" do
+ source "dovecot/dovecot.conf.erb"
+ mode 0644
+ owner "root"
+ group "root"
+ notifies :restart, resources(:service => "dovecot")
+end
+
+template "/etc/dovecot/dovecot-sql.conf.ext" do
+ source "dovecot/dovecot-sql.conf.ext.erb"
+ mode 0600
+ owner "root"
+ group "root"
+ notifies :restart, resources(:service => "dovecot")
+end
+
+# Setup the conf.d files
+%w(10-auth 10-director 10-logging 10-mail 10-master 10-ssl 15-lda 20-imap 20-managesieve 90-acl 90-plugin 90-quota 90-sieve).each do |file|
+ template "/etc/dovecot/conf.d/#{file}.conf" do
+ source "dovecot/#{file}.conf.erb"
+ mode 0644
+ owner "root"
+ group "root"
+ notifies :restart, resources(:service => "dovecot")
+ end
+end
+
+%w(master sql).each do |file|
+ template "/etc/dovecot/conf.d/auth-#{file}.conf.ext" do
+ source "dovecot/auth-#{file}.conf.ext.erb"
+ mode 0644
+ owner "root"
+ group "root"
+ notifies :restart, resources(:service => "dovecot")
+ end
+end
+
39 recipes/postfix.rb
@@ -0,0 +1,39 @@
+%w(postfix postfix-pgsql libsasl2-2).each do |pkg|
+ package pkg
+end
+
+service "postfix" do
+ supports :status => true, :restart => true, :reload => true
+ action :enable
+end
+
+template "/etc/postfix/main.cf" do
+ source "postfix/main.cf.erb"
+ mode 0644
+ owner "root"
+ group "root"
+ notifies :restart, resources(:service => "postfix")
+end
+
+template "/etc/postfix/master.cf" do
+ source "postfix/master.cf.erb"
+ mode 0644
+ owner "root"
+ group "root"
+ notifies :restart, resources(:service => "postfix")
+end
+
+# Setup the virtual maps
+%w(pgsql_relay_domain pgsql_virtual_alias pgsql_virtual_domain pgsql_virtual_mailbox).each do |file|
+ template "/etc/postfix/#{file}_maps.cf" do
+ source "postfix/#{file}_maps.cf.erb"
+ mode 0600
+ owner "root"
+ group "root"
+ notifies :restart, resources(:service => "postfix")
+ end
+end
+
+service "postfix" do
+ action :start
+end
35 recipes/postfixadmin.rb
@@ -0,0 +1,35 @@
+include_recipe "lighttpd::php"
+
+VERSION = "2.3.5"
+
+# Dependencies
+%w(php5-imap php5-pgsql).each do |pkg|
+ package pkg
+end
+
+remote_file "#{Chef::Config[:file_cache_path]}/postfixadmin-#{VERSION}.tar.gz" do
+ source "http://sourceforge.net/projects/postfixadmin/files/postfixadmin/postfixadmin-#{VERSION}/postfixadmin-#{VERSION}.tar.gz/download"
+ checksum "9a72ed8d827fa2c7f641001f2aa87814"
+ mode "0644"
+ not_if { File.exists?("/var/www/postfixadmin-#{VERSION}") }
+ notifies :run, "execute[unpack postfixadmin]", :immediately
+end
+
+execute "unpack postfixadmin" do
+ command "tar xzvf #{Chef::Config[:file_cache_path]}/postfixadmin-#{VERSION}.tar.gz -C /var/www"
+ action :nothing
+end
+
+template "/var/www/postfixadmin-#{VERSION}/config.local.php" do
+ source "postfixadmin/config.local.php.erb"
+ mode 0644
+ owner "www-data"
+ group "www-data"
+end
+
+lighttpd_vhost "postfixadmin" do
+ host "admin.#{node[:fqdn]}"
+ document_root "/var/www/postfixadmin-#{VERSION}"
+ action [:create, :enable]
+ notifies :restart, "service[lighttpd]"
+end
10 recipes/spamassassin.rb
@@ -0,0 +1,10 @@
+%w(spamassassin razor pyzor).each do |pkg|
+ package pkg
+end
+
+template "/etc/default/spamassassin" do
+ source "spamassassin/default.erb"
+ mode 0644
+ owner "root"
+ group "root"
+end
758 templates/default/amavis/basic.erb
@@ -0,0 +1,758 @@
+use strict;
+
+$max_servers = 2; # num of pre-forked children (2..30 is common), -m
+$daemon_user = 'amavis'; # (no default; customary: vscan or amavis), -u
+$daemon_group = 'amavis'; # (no default; customary: vscan or amavis), -g
+
+$mydomain = '<%= node.domain %>'; # a convenient default for other settings
+$myhostname = '<%= node.fqdn %>';
+
+$MYHOME = '/var/lib/amavis'; # a convenient default for other settings, -H
+$TEMPBASE = "$MYHOME/tmp"; # working directory, needs to exist, -T
+$ENV{TMPDIR} = $TEMPBASE; # environment variable TMPDIR, used by SA, etc.
+$QUARANTINEDIR = "$MYHOME/quarantine"; # -Q
+$pid_file = "/var/run/amavis/amavisd.pid"; # -P
+
+$log_level = 1; # verbosity 0..5, -d
+$log_recip_templ = undef; # disable by-recipient level-0 log entries
+$DO_SYSLOG = 1; # log via syslogd (preferred)
+$syslog_facility = 'mail'; # Syslog facility as a string
+ # e.g.: mail, daemon, user, local0, ... local7
+
+$enable_db = 1; # enable use of BerkeleyDB/libdb (SNMP and nanny)
+$nanny_details_level = 2; # nanny verbosity: 1: traditional, 2: detailed
+$enable_dkim_verification = 0; # enable DKIM signatures verification
+$enable_dkim_signing = 0; # load DKIM signing code, keys defined by dkim_key
+
+@local_domains_maps = ( ["hacksrus.net", "dadark.de", "odadata.eu", "10-stars-casino.de", "siedlungsshow.com", "slotwin.de", "rodmayler.de"] ); # list of all local domains
+
+@bypass_virus_checks_maps = (
+ \%bypass_virus_checks, \@bypass_virus_checks_acl, \$bypass_virus_checks_re);
+
+
+@bypass_spam_checks_maps = (
+ \%bypass_spam_checks, \@bypass_spam_checks_acl, \$bypass_spam_checks_re);
+
+@mynetworks = qw( 127.0.0.0/8 [::1] [FE80::]/10 [FEC0::]/10
+ 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16 );
+
+$unix_socketname = "$MYHOME/amavisd.sock"; # amavisd-release or amavis-milter
+ # option(s) -p overrides $inet_socket_port and $unix_socketname
+
+$inet_socket_port = 10024; # listen on this local TCP port(s)
+
+$policy_bank{'MYNETS'} = { # mail originating from @mynetworks
+ originating => 1, # is true in MYNETS by default, but let's make it explicit
+ os_fingerprint_method => undef, # don't query p0f for internal clients
+};
+
+# it is up to MTA to re-route mail from authenticated roaming users or
+# from internal hosts to a dedicated TCP port (such as 10026) for filtering
+$interface_policy{'10026'} = 'ORIGINATING';
+
+$policy_bank{'ORIGINATING'} = { # mail supposedly originating from our users
+ originating => 1, # declare that mail was submitted by our smtp client
+ allow_disclaimers => 1, # enables disclaimer insertion if available
+ # notify administrator of locally originating malware
+ virus_admin_maps => ["virusalert\@$mydomain"],
+ spam_admin_maps => ["virusalert\@$mydomain"],
+ warnbadhsender => 1,
+ # forward to a smtpd service providing DKIM signing service
+ forward_method => 'smtp:[127.0.0.1]:10027',
+ # force MTA conversion to 7-bit (e.g. before DKIM signing)
+ smtpd_discard_ehlo_keywords => ['8BITMIME'],
+ bypass_banned_checks_maps => [1], # allow sending any file names and types
+ terminate_dsn_on_notify_success => 0, # don't remove NOTIFY=SUCCESS option
+};
+
+$interface_policy{'SOCK'} = 'AM.PDP-SOCK'; # only applies with $unix_socketname
+
+# Use with amavis-release over a socket or with Petr Rehor's amavis-milter.c
+# (with amavis-milter.c from this package or old amavis.c client use 'AM.CL'):
+$policy_bank{'AM.PDP-SOCK'} = {
+ protocol => 'AM.PDP',
+ auth_required_release => 0, # do not require secret_id for amavisd-release
+};
+
+$sa_tag_level_deflt = -999; # add spam info headers if at, or above that level
+$sa_tag2_level_deflt = 6.2; # add 'spam detected' headers at that level
+$sa_kill_level_deflt = 6.9; # triggers spam evasive actions (e.g. blocks mail)
+$sa_dsn_cutoff_level = 10; # spam level beyond which a DSN is not sent
+$sa_crediblefrom_dsn_cutoff_level = 18; # likewise, but for a likely valid From
+# $sa_quarantine_cutoff_level = 25; # spam level beyond which quarantine is off
+$penpals_bonus_score = 8; # (no effect without a @storage_sql_dsn database)
+$penpals_threshold_high = $sa_kill_level_deflt; # don't waste time on hi spam
+$bounce_killer_score = 100; # spam score points to add for joe-jobbed bounces
+
+$sa_mail_body_size_limit = 400*1024; # don't waste time on SA if mail is larger
+$sa_local_tests_only = 0; # only tests which do not require internet access?
+
+# @lookup_sql_dsn =
+# ( ['DBI:mysql:database=mail;host=127.0.0.1;port=3306', 'user1', 'passwd1'],
+# ['DBI:mysql:database=mail;host=host2', 'username2', 'password2'],
+# ["DBI:SQLite:dbname=$MYHOME/sql/mail_prefs.sqlite", '', ''] );
+# @storage_sql_dsn = @lookup_sql_dsn; # none, same, or separate database
+
+# $timestamp_fmt_mysql = 1; # if using MySQL *and* msgs.time_iso is TIMESTAMP;
+# defaults to 0, which is good for non-MySQL or if msgs.time_iso is CHAR(16)
+
+$virus_admin = "virusalert\@$mydomain"; # notifications recip.
+
+$mailfrom_notify_admin = "virusalert\@$mydomain"; # notifications sender
+$mailfrom_notify_recip = "virusalert\@$mydomain"; # notifications sender
+$mailfrom_notify_spamadmin = "spam.police\@$mydomain"; # notifications sender
+$mailfrom_to_quarantine = ''; # null return path; uses original sender if undef
+
+@addr_extension_virus_maps = ('virus');
+@addr_extension_banned_maps = ('banned');
+@addr_extension_spam_maps = ('spam');
+@addr_extension_bad_header_maps = ('badh');
+# $recipient_delimiter = '+'; # undef disables address extensions altogether
+# when enabling addr extensions do also Postfix/main.cf: recipient_delimiter=+
+
+$path = '/usr/local/sbin:/usr/local/bin:/usr/sbin:/sbin:/usr/bin:/bin';
+# $dspam = 'dspam';
+
+$MAXLEVELS = 14;
+$MAXFILES = 1500;
+$MIN_EXPANSION_QUOTA = 100*1024; # bytes (default undef, not enforced)
+$MAX_EXPANSION_QUOTA = 300*1024*1024; # bytes (default undef, not enforced)
+
+#$sa_spam_subject_tag = '***Spam*** ';
+$defang_virus = 1; # MIME-wrap passed infected mail
+$defang_banned = 1; # MIME-wrap passed mail containing banned name
+# for defanging bad headers only turn on certain minor contents categories:
+$defang_by_ccat{CC_BADH.",3"} = 1; # NUL or CR character in header
+$defang_by_ccat{CC_BADH.",5"} = 1; # header line longer than 998 characters
+$defang_by_ccat{CC_BADH.",6"} = 1; # header field syntax error
+
+
+# OTHER MORE COMMON SETTINGS (defaults may suffice):
+
+# $final_virus_destiny = D_DISCARD;
+# $final_banned_destiny = D_DISCARD;
+$final_spam_destiny = D_PASS; #!!! D_DISCARD / D_REJECT
+$final_bad_header_destiny = D_PASS;
+# $bad_header_quarantine_method = undef;
+
+# REMAINING IMPORTANT VARIABLES ARE LISTED HERE BECAUSE OF LONGER ASSIGNMENTS
+
+@keep_decoded_original_maps = (new_RE(
+ qr'^MAIL$', # retain full original message for virus checking
+ qr'^MAIL-UNDECIPHERABLE$', # recheck full mail if it contains undecipherables
+ qr'^(ASCII(?! cpio)|text|uuencoded|xxencoded|binhex)'i,
+# qr'^Zip archive data', # don't trust Archive::Zip
+));
+
+
+$banned_filename_re = new_RE(
+
+### BLOCKED ANYWHERE
+# qr'^UNDECIPHERABLE$', # is or contains any undecipherable components
+ qr'^\.(exe-ms|dll)$', # banned file(1) types, rudimentary
+# qr'^\.(exe|lha|cab|dll)$', # banned file(1) types
+
+### BLOCK THE FOLLOWING, EXCEPT WITHIN UNIX ARCHIVES:
+# [ qr'^\.(gz|bz2)$' => 0 ], # allow any in gzip or bzip2
+ [ qr'^\.(rpm|cpio|tar)$' => 0 ], # allow any in Unix-type archives
+
+ qr'.\.(pif|scr)$'i, # banned extensions - rudimentary
+# qr'^\.zip$', # block zip type
+
+### BLOCK THE FOLLOWING, EXCEPT WITHIN ARCHIVES:
+# [ qr'^\.(zip|rar|arc|arj|zoo)$'=> 0 ], # allow any within these archives
+
+ qr'^application/x-msdownload$'i, # block these MIME types
+ qr'^application/x-msdos-program$'i,
+ qr'^application/hta$'i,
+
+# qr'^message/partial$'i, # rfc2046 MIME type
+# qr'^message/external-body$'i, # rfc2046 MIME type
+
+# qr'^(application/x-msmetafile|image/x-wmf)$'i, # Windows Metafile MIME type
+# qr'^\.wmf$', # Windows Metafile file(1) type
+
+ # block certain double extensions in filenames
+ qr'^(?!cid:).*\.[^./]*[A-Za-z][^./]*\.\s*(exe|vbs|pif|scr|bat|cmd|com|cpl|dll)[.\s]*$'i,
+
+# qr'\{[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}\}?'i, # Class ID CLSID, strict
+# qr'\{[0-9a-z]{4,}(-[0-9a-z]{4,}){0,7}\}?'i, # Class ID extension CLSID, loose
+
+ qr'.\.(exe|vbs|pif|scr|cpl)$'i, # banned extension - basic
+# qr'.\.(exe|vbs|pif|scr|cpl|bat|cmd|com)$'i, # banned extension - basic+cmd
+# qr'.\.(ade|adp|app|bas|bat|chm|cmd|com|cpl|crt|emf|exe|fxp|grp|hlp|hta|
+# inf|ini|ins|isp|js|jse|lib|lnk|mda|mdb|mde|mdt|mdw|mdz|msc|msi|
+# msp|mst|ocx|ops|pcd|pif|prg|reg|scr|sct|shb|shs|sys|vb|vbe|vbs|vxd|
+# wmf|wsc|wsf|wsh)$'ix, # banned extensions - long
+# qr'.\.(asd|asf|asx|url|vcs|wmd|wmz)$'i, # consider also
+# qr'.\.(ani|cur|ico)$'i, # banned cursors and icons filename
+# qr'^\.ani$', # banned animated cursor file(1) type
+# qr'.\.(mim|b64|bhx|hqx|xxe|uu|uue)$'i, # banned extension - WinZip vulnerab.
+);
+# See http://support.microsoft.com/default.aspx?scid=kb;EN-US;q262631
+# and http://www.cknow.com/vtutor/vtextensions.htm
+
+
+# ENVELOPE SENDER SOFT-WHITELISTING / SOFT-BLACKLISTING
+
+@score_sender_maps = ({ # a by-recipient hash lookup table,
+ # results from all matching recipient tables are summed
+
+# ## per-recipient personal tables (NOTE: positive: black, negative: white)
+# 'user1@example.com' => [{'bla-mobile.press@example.com' => 10.0}],
+# 'user3@example.com' => [{'.ebay.com' => -3.0}],
+# 'user4@example.com' => [{'cleargreen@cleargreen.com' => -7.0,
+# '.cleargreen.com' => -5.0}],
+
+ ## site-wide opinions about senders (the '.' matches any recipient)
+ '.' => [ # the _first_ matching sender determines the score boost
+
+ new_RE( # regexp-type lookup table, just happens to be all soft-blacklist
+ [qr'^(bulkmail|offers|cheapbenefits|earnmoney|foryou)@'i => 5.0],
+ [qr'^(greatcasino|investments|lose_weight_today|market\.alert)@'i=> 5.0],
+ [qr'^(money2you|MyGreenCard|new\.tld\.registry|opt-out|opt-in)@'i=> 5.0],
+ [qr'^(optin|saveonlsmoking2002k|specialoffer|specialoffers)@'i => 5.0],
+ [qr'^(stockalert|stopsnoring|wantsome|workathome|yesitsfree)@'i => 5.0],
+ [qr'^(your_friend|greatoffers)@'i => 5.0],
+ [qr'^(inkjetplanet|marketopt|MakeMoney)\d*@'i => 5.0],
+ ),
+
+# read_hash("/var/amavis/sender_scores_sitewide"),
+
+ { # a hash-type lookup table (associative array)
+ 'nobody@cert.org' => -3.0,
+ 'cert-advisory@us-cert.gov' => -3.0,
+ 'owner-alert@iss.net' => -3.0,
+ 'slashdot@slashdot.org' => -3.0,
+ 'securityfocus.com' => -3.0,
+ 'ntbugtraq@listserv.ntbugtraq.com' => -3.0,
+ 'security-alerts@linuxsecurity.com' => -3.0,
+ 'mailman-announce-admin@python.org' => -3.0,
+ 'amavis-user-admin@lists.sourceforge.net'=> -3.0,
+ 'amavis-user-bounces@lists.sourceforge.net' => -3.0,
+ 'spamassassin.apache.org' => -3.0,
+ 'notification-return@lists.sophos.com' => -3.0,
+ 'owner-postfix-users@postfix.org' => -3.0,
+ 'owner-postfix-announce@postfix.org' => -3.0,
+ 'owner-sendmail-announce@lists.sendmail.org' => -3.0,
+ 'sendmail-announce-request@lists.sendmail.org' => -3.0,
+ 'donotreply@sendmail.org' => -3.0,
+ 'ca+envelope@sendmail.org' => -3.0,
+ 'noreply@freshmeat.net' => -3.0,
+ 'owner-technews@postel.acm.org' => -3.0,
+ 'ietf-123-owner@loki.ietf.org' => -3.0,
+ 'cvs-commits-list-admin@gnome.org' => -3.0,
+ 'rt-users-admin@lists.fsck.com' => -3.0,
+ 'clp-request@comp.nus.edu.sg' => -3.0,
+ 'surveys-errors@lists.nua.ie' => -3.0,
+ 'emailnews@genomeweb.com' => -5.0,
+ 'yahoo-dev-null@yahoo-inc.com' => -3.0,
+ 'returns.groups.yahoo.com' => -3.0,
+ 'clusternews@linuxnetworx.com' => -3.0,
+ lc('lvs-users-admin@LinuxVirtualServer.org') => -3.0,
+ lc('owner-textbreakingnews@CNNIMAIL12.CNN.COM') => -5.0,
+
+ # soft-blacklisting (positive score)
+ 'sender@example.net' => 3.0,
+ '.example.net' => 1.0,
+
+ },
+ ], # end of site-wide tables
+});
+
+
+@decoders = (
+ ['mail', \&do_mime_decode],
+# ['asc', \&do_ascii],
+# ['uue', \&do_ascii],
+# ['hqx', \&do_ascii],
+# ['ync', \&do_ascii],
+ ['F', \&do_uncompress, ['unfreeze','freeze -d','melt','fcat'] ],
+ ['Z', \&do_uncompress, ['uncompress','gzip -d','zcat'] ],
+ ['gz', \&do_uncompress, 'gzip -d'],
+ ['gz', \&do_gunzip],
+ ['bz2', \&do_uncompress, 'bzip2 -d'],
+ ['xz', \&Amavis::Unpackers::do_uncompress,
+ ['xzdec'. 'xz -dc', 'unxz -c', 'xzcat'] ],
+ ['lzma', \&Amavis::Unpackers::do_uncompress,
+ ['lzmadec', 'xz -dc --format=lzma',
+ 'lzma -dc', 'unlzma -c', 'lzcat', 'lzmadec'] ],
+ ['lzo', \&do_uncompress, 'lzop -d'],
+ ['rpm', \&do_uncompress, ['rpm2cpio.pl','rpm2cpio'] ],
+ ['cpio', \&do_pax_cpio, ['pax','gcpio','cpio'] ],
+ ['tar', \&do_pax_cpio, ['pax','gcpio','cpio'] ],
+ ['deb', \&do_ar, 'ar'],
+# ['a', \&do_ar, 'ar'], # unpacking .a seems an overkill
+ ['zip', \&do_unzip],
+ ['7z', \&do_7zip, ['7zr','7za','7z'] ],
+ ['rar', \&do_unrar, ['rar','unrar'] ],
+ ['arj', \&do_unarj, ['arj','unarj'] ],
+ ['arc', \&do_arc, ['nomarch','arc'] ],
+ ['zoo', \&do_zoo, ['zoo','unzoo'] ],
+ ['lha', \&do_lha, 'lha'],
+# ['doc', \&do_ole, 'ripole'],
+ ['cab', \&do_cabextract, 'cabextract'],
+ ['tnef', \&do_tnef_ext, 'tnef'],
+ ['tnef', \&do_tnef],
+# ['sit', \&do_unstuff, 'unstuff'], # broken/unsafe decoder
+ ['exe', \&do_executable, ['rar','unrar'], 'lha', ['arj','unarj'] ],
+);
+
+
+@av_scanners = (
+
+# ### http://www.sophos.com/
+# ['Sophos-SSSP',
+# \&ask_daemon, ["{}", 'sssp:/var/run/savdi/sssp.sock'],
+# # or: ["{}", 'sssp:[127.0.0.1]:4010'],
+# qr/^DONE OK\b/m, qr/^VIRUS\b/m, qr/^VIRUS\s*(\S*)/m ],
+
+# ### http://www.clanfield.info/sophie/ (http://www.vanja.com/tools/sophie/)
+# ['Sophie',
+# \&ask_daemon, ["{}/\n", 'sophie:/var/run/sophie'],
+# qr/(?x)^ 0+ ( : | [\000\r\n]* $)/, qr/(?x)^ 1 ( : | [\000\r\n]* $)/,
+# qr/(?x)^ [-+]? \d+ : (.*?) [\000\r\n]* $/m ],
+
+# ### http://www.csupomona.edu/~henson/www/projects/SAVI-Perl/
+# ['Sophos SAVI', \&ask_daemon, ['{}','savi-perl:'] ],
+
+# ['Avira SAVAPI',
+# \&ask_daemon, ["*", 'savapi:/var/tmp/.savapi3', 'product-id'],
+# qr/^(200|210)/m, qr/^(310|420|319)/m,
+# qr/^(?:310|420)[,\s]*(?:.* <<< )?(.+?)(?: ; |$)/m
+# settings for the SAVAPI3.conf: ArchiveScan=1, HeurLevel=2, MailboxScan=1
+
+# ### http://www.clamav.net/
+['ClamAV-clamd',
+ \&ask_daemon, ["CONTSCAN {}\n", "/var/run/clamav/clamd.ctl"],
+ qr/\bOK$/m, qr/\bFOUND$/m,
+ qr/^.*?: (?!Infected Archive)(.*) FOUND$/m ],
+# NOTE: run clamd under the same user as amavisd, or run it under its own
+# uid such as clamav, add user clamav to the amavis group, and then add
+# AllowSupplementaryGroups to clamd.conf;
+# NOTE: match socket name (LocalSocket) in clamav.conf to the socket name in
+# this entry; when running chrooted one may prefer socket "$MYHOME/clamd".
+
+# ### http://www.clamav.net/ and CPAN (memory-hungry! clamd is preferred)
+# # note that Mail::ClamAV requires perl to be build with threading!
+# ['Mail::ClamAV', \&ask_daemon, ['{}','clamav-perl:'],
+# [0], [1], qr/^INFECTED: (.+)/m],
+
+# ### http://www.openantivirus.org/
+# ['OpenAntiVirus ScannerDaemon (OAV)',
+# \&ask_daemon, ["SCAN {}\n", '127.0.0.1:8127'],
+# qr/^OK/m, qr/^FOUND: /m, qr/^FOUND: (.+)/m ],
+
+# ### http://www.vanja.com/tools/trophie/
+# ['Trophie',
+# \&ask_daemon, ["{}/\n", 'trophie:/var/run/trophie'],
+# qr/(?x)^ 0+ ( : | [\000\r\n]* $)/m, qr/(?x)^ 1 ( : | [\000\r\n]* $)/m,
+# qr/(?x)^ [-+]? \d+ : (.*?) [\000\r\n]* $/m ],
+
+# ### http://www.grisoft.com/
+# ['AVG Anti-Virus',
+# \&ask_daemon, ["SCAN {}\n", '127.0.0.1:55555'],
+# qr/^200/m, qr/^403/m, qr/^403 .*?: ([^\r\n]+)/m ],
+
+# ### http://www.f-prot.com/
+# ['F-Prot fpscand', # F-PROT Antivirus for BSD/Linux/Solaris, version 6
+# \&ask_daemon,
+# ["SCAN FILE {}/*\n", '127.0.0.1:10200'],
+# qr/^(0|8|64) /m,
+# qr/^([1235679]|1[01345]) |<[^>:]*(?i)(infected|suspicious|unwanted)/m,
+# qr/(?i)<[^>:]*(?:infected|suspicious|unwanted)[^>:]*: ([^>]*)>/m ],
+
+# ### http://www.f-prot.com/
+# ['F-Prot f-protd', # old version
+# \&ask_daemon,
+# ["GET {}/*?-dumb%20-archive%20-packed HTTP/1.0\r\n\r\n",
+# ['127.0.0.1:10200', '127.0.0.1:10201', '127.0.0.1:10202',
+# '127.0.0.1:10203', '127.0.0.1:10204'] ],
+# qr/(?i)<summary[^>]*>clean<\/summary>/m,
+# qr/(?i)<summary[^>]*>infected<\/summary>/m,
+# qr/(?i)<name>(.+)<\/name>/m ],
+
+# ### http://www.sald.com/, http://www.dials.ru/english/, http://www.drweb.ru/
+# ['DrWebD', \&ask_daemon, # DrWebD 4.31 or later
+# [pack('N',1). # DRWEBD_SCAN_CMD
+# pack('N',0x00280001). # DONT_CHANGEMAIL, IS_MAIL, RETURN_VIRUSES
+# pack('N', # path length
+# length("$TEMPBASE/amavis-yyyymmddTHHMMSS-xxxxx/parts/pxxx")).
+# '{}/*'. # path
+# pack('N',0). # content size
+# pack('N',0),
+# '/var/drweb/run/drwebd.sock',
+# # '/var/amavis/var/run/drwebd.sock', # suitable for chroot
+# # '/usr/local/drweb/run/drwebd.sock', # FreeBSD drweb ports default
+# # '127.0.0.1:3000', # or over an inet socket
+# ],
+# qr/\A\x00[\x10\x11][\x00\x10]\x00/sm, # IS_CLEAN,EVAL_KEY; SKIPPED
+# qr/\A\x00[\x00\x01][\x00\x10][\x20\x40\x80]/sm,# KNOWN_V,UNKNOWN_V,V._MODIF
+# qr/\A.{12}(?:infected with )?([^\x00]+)\x00/sm,
+# ],
+# # NOTE: If using amavis-milter, change length to:
+# # length("$TEMPBASE/amavis-milter-xxxxxxxxxxxxxx/parts/pxxx").
+
+ ### http://www.kaspersky.com/ (kav4mailservers)
+ ['KasperskyLab AVP - aveclient',
+ ['/usr/local/kav/bin/aveclient','/usr/local/share/kav/bin/aveclient',
+ '/opt/kav/5.5/kav4mailservers/bin/aveclient','aveclient'],
+ '-p /var/run/aveserver -s {}/*',
+ [0,3,6,8], qr/\b(INFECTED|SUSPICION|SUSPICIOUS)\b/m,
+ qr/(?:INFECTED|WARNING|SUSPICION|SUSPICIOUS) (.+)/m,
+ ],
+ # NOTE: one may prefer [0],[2,3,4,5], depending on how suspicious,
+ # currupted or protected archives are to be handled
+
+ ### http://www.kaspersky.com/
+ ['KasperskyLab AntiViral Toolkit Pro (AVP)', ['avp'],
+ '-* -P -B -Y -O- {}', [0,3,6,8], [2,4], # any use for -A -K ?
+ qr/infected: (.+)/m,
+ sub {chdir('/opt/AVP') or die "Can't chdir to AVP: $!"},
+ sub {chdir($TEMPBASE) or die "Can't chdir back to $TEMPBASE $!"},
+ ],
+
+ ### The kavdaemon and AVPDaemonClient have been removed from Kasperky
+ ### products and replaced by aveserver and aveclient
+ ['KasperskyLab AVPDaemonClient',
+ [ '/opt/AVP/kavdaemon', 'kavdaemon',
+ '/opt/AVP/AvpDaemonClient', 'AvpDaemonClient',
+ '/opt/AVP/AvpTeamDream', 'AvpTeamDream',
+ '/opt/AVP/avpdc', 'avpdc' ],
+ "-f=$TEMPBASE {}", [0,8], [3,4,5,6], qr/infected: ([^\r\n]+)/m ],
+ # change the startup-script in /etc/init.d/kavd to:
+ # DPARMS="-* -Y -dl -f=/var/amavis /var/amavis"
+ # (or perhaps: DPARMS="-I0 -Y -* /var/amavis" )
+ # adjusting /var/amavis above to match your $TEMPBASE.
+ # The '-f=/var/amavis' is needed if not running it as root, so it
+ # can find, read, and write its pid file, etc., see 'man kavdaemon'.
+ # defUnix.prf: there must be an entry "*/var/amavis" (or whatever
+ # directory $TEMPBASE specifies) in the 'Names=' section.
+ # cd /opt/AVP/DaemonClients; configure; cd Sample; make
+ # cp AvpDaemonClient /opt/AVP/
+ # su - amavis -c "${PREFIX}/kavdaemon ${DPARMS}"
+
+ ### http://www.centralcommand.com/
+ ['CentralCommand Vexira (new) vascan',
+ ['vascan','/usr/lib/Vexira/vascan'],
+ "-a s --timeout=60 --temp=$TEMPBASE -y $QUARANTINEDIR ".
+ "--log=/var/log/vascan.log {}",
+ [0,3], [1,2,5],
+ qr/(?x)^\s* (?:virus|iworm|macro|mutant|sequence|trojan)\ found:\ ( [^\]\s']+ )\ \.\.\.\ /m ],
+ # Adjust the path of the binary and the virus database as needed.
+ # 'vascan' does not allow to have the temp directory to be the same as
+ # the quarantine directory, and the quarantine option can not be disabled.
+ # If $QUARANTINEDIR is not used, then another directory must be specified
+ # to appease 'vascan'. Move status 3 to the second list if password
+ # protected files are to be considered infected.
+
+ ### http://www.avira.com/
+ ### old Avira AntiVir 2.x (ex H+BEDV) or old CentralCommand Vexira Antivirus
+ ['Avira AntiVir', ['antivir','vexira'],
+ '--allfiles -noboot -nombr -rs -s -z {}', [0], qr/ALERT:|VIRUS:/m,
+ qr/(?x)^\s* (?: ALERT: \s* (?: \[ | [^']* ' ) |
+ (?i) VIRUS:\ .*?\ virus\ '?) ( [^\]\s']+ )/m ],
+ # NOTE: if you only have a demo version, remove -z and add 214, as in:
+ # '--allfiles -noboot -nombr -rs -s {}', [0,214], qr/ALERT:|VIRUS:/,
+
+ ### http://www.avira.com/
+ ### Avira for UNIX 3.x
+ ['Avira AntiVir', ['avscan'],
+ '-s --batch --alert-action=none {}', [0,4], qr/(?:ALERT|FUND):/m,
+ qr/(?:ALERT|FUND): (?:.* <<< )?(.+?)(?: ; |$)/m ],
+
+ ### http://www.commandsoftware.com/
+ ['Command AntiVirus for Linux', 'csav',
+ '-all -archive -packed {}', [50], [51,52,53],
+ qr/Infection: (.+)/m ],
+
+ ### http://www.symantec.com/
+ ['Symantec CarrierScan via Symantec CommandLineScanner',
+ 'cscmdline', '-a scan -i 1 -v -s 127.0.0.1:7777 {}',
+ qr/^Files Infected:\s+0$/m, qr/^Infected\b/m,
+ qr/^(?:Info|Virus Name):\s+(.+)/m ],
+
+ ### http://www.symantec.com/
+ ['Symantec AntiVirus Scan Engine',
+ 'savsecls', '-server 127.0.0.1:7777 -mode scanrepair -details -verbose {}',
+ [0], qr/^Infected\b/m,
+ qr/^(?:Info|Virus Name):\s+(.+)/m ],
+ # NOTE: check options and patterns to see which entry better applies
+
+# ### http://www.f-secure.com/products/anti-virus/ version 4.65
+# ['F-Secure Antivirus for Linux servers',
+# ['/opt/f-secure/fsav/bin/fsav', 'fsav'],
+# '--delete=no --disinf=no --rename=no --archive=yes --auto=yes '.
+# '--dumb=yes --list=no --mime=yes {}', [0], [3,6,8],
+# qr/(?:infection|Infected|Suspected): (.+)/m ],
+
+ ### http://www.f-secure.com/products/anti-virus/ version 5.52
+ ['F-Secure Antivirus for Linux servers',
+ ['/opt/f-secure/fsav/bin/fsav', 'fsav'],
+ '--virus-action1=report --archive=yes --auto=yes '.
+ '--dumb=yes --list=no --mime=yes {}', [0], [3,4,6,8],
+ qr/(?:infection|Infected|Suspected|Riskware): (.+)/m ],
+ # NOTE: internal archive handling may be switched off by '--archive=no'
+ # to prevent fsav from exiting with status 9 on broken archives
+
+# ### http://www.avast.com/
+# ['avast! Antivirus daemon',
+# \&ask_daemon, # greets with 220, terminate with QUIT
+# ["SCAN {}\015\012QUIT\015\012", '/var/run/avast4/mailscanner.sock'],
+# qr/\t\[\+\]/m, qr/\t\[L\]\t/m, qr/\t\[L\]\t([^[ \t\015\012]+)/m ],
+
+# ### http://www.avast.com/
+# ['avast! Antivirus - Client/Server Version', 'avastlite',
+# '-a /var/run/avast4/mailscanner.sock -n {}', [0], [1],
+# qr/\t\[L\]\t([^[ \t\015\012]+)/m ],
+
+ ['CAI InoculateIT', 'inocucmd', # retired product
+ '-sec -nex {}', [0], [100],
+ qr/was infected by virus (.+)/m ],
+ # see: http://www.flatmtn.com/computer/Linux-Antivirus_CAI.html
+
+ ### http://www3.ca.com/Solutions/Product.asp?ID=156 (ex InoculateIT)
+ ['CAI eTrust Antivirus', 'etrust-wrapper',
+ '-arc -nex -spm h {}', [0], [101],
+ qr/is infected by virus: (.+)/m ],
+ # NOTE: requires suid wrapper around inocmd32; consider flag: -mod reviewer
+ # see http://marc.theaimsgroup.com/?l=amavis-user&m=109229779912783
+
+ ### http://mks.com.pl/english.html
+ ['MkS_Vir for Linux (beta)', ['mks32','mks'],
+ '-s {}/*', [0], [1,2],
+ qr/--[ \t]*(.+)/m ],
+
+ ### http://mks.com.pl/english.html
+ ['MkS_Vir daemon', 'mksscan',
+ '-s -q {}', [0], [1..7],
+ qr/^... (\S+)/m ],
+
+# ### http://www.nod32.com/, version v2.52 (old)
+# ['ESET NOD32 for Linux Mail servers',
+# ['/opt/eset/nod32/bin/nod32cli', 'nod32cli'],
+# '--subdir --files -z --sfx --rtp --adware --unsafe --pattern --heur '.
+# '-w -a --action-on-infected=accept --action-on-uncleanable=accept '.
+# '--action-on-notscanned=accept {}',
+# [0,3], [1,2], qr/virus="([^"]+)"/m ],
+
+# ### http://www.eset.com/, version v2.7 (old)
+# ['ESET NOD32 Linux Mail Server - command line interface',
+# ['/usr/bin/nod32cli', '/opt/eset/nod32/bin/nod32cli', 'nod32cli'],
+# '--subdir {}', [0,3], [1,2], qr/virus="([^"]+)"/m ],
+
+# ### http://www.eset.com/, version 2.71.12
+# ['ESET Software ESETS Command Line Interface',
+# ['/usr/bin/esets_cli', 'esets_cli'],
+# '--subdir {}', [0], [1,2,3], qr/virus="([^"]+)"/m ],
+
+ ### http://www.eset.com/, version 3.0
+ ['ESET Software ESETS Command Line Interface',
+ ['/usr/bin/esets_cli', 'esets_cli'],
+ '--subdir {}', [0], [1,2,3],
+ qr/:\s*action="(?!accepted)[^"]*"\n.*:\s*virus="([^"]*)"/m ],
+
+ ## http://www.nod32.com/, NOD32LFS version 2.5 and above
+ ['ESET NOD32 for Linux File servers',
+ ['/opt/eset/nod32/sbin/nod32','nod32'],
+ '--files -z --mail --sfx --rtp --adware --unsafe --pattern --heur '.
+ '-w -a --action=1 -b {}',
+ [0], [1,10], qr/^object=.*, virus="(.*?)",/m ],
+
+# Experimental, based on posting from Rado Dibarbora (Dibo) on 2002-05-31
+# ['ESET Software NOD32 Client/Server (NOD32SS)',
+# \&ask_daemon2, # greets with 200, persistent, terminate with QUIT
+# ["SCAN {}/*\r\n", '127.0.0.1:8448' ],
+# qr/^200 File OK/m, qr/^201 /m, qr/^201 (.+)/m ],
+
+ ### http://www.norman.com/products_nvc.shtml
+ ['Norman Virus Control v5 / Linux', 'nvcc',
+ '-c -l:0 -s -u -temp:$TEMPBASE {}', [0,10,11], [1,2,14],
+ qr/(?i).* virus in .* -> \'(.+)\'/m ],
+
+ ### http://www.pandasoftware.com/
+ ['Panda CommandLineSecure 9 for Linux',
+ ['/opt/pavcl/usr/bin/pavcl','pavcl'],
+ '-auto -aex -heu -cmp -nbr -nor -nos -eng -nob {}',
+ qr/Number of files infected[ .]*: 0+(?!\d)/m,
+ qr/Number of files infected[ .]*: 0*[1-9]/m,
+ qr/Found virus :\s*(\S+)/m ],
+ # NOTE: for efficiency, start the Panda in resident mode with 'pavcl -tsr'
+ # before starting amavisd - the bases are then loaded only once at startup.
+ # To reload bases in a signature update script:
+ # /opt/pavcl/usr/bin/pavcl -tsr -ulr; /opt/pavcl/usr/bin/pavcl -tsr
+ # Please review other options of pavcl, for example:
+ # -nomalw, -nojoke, -nodial, -nohackt, -nospyw, -nocookies
+
+# ### http://www.pandasoftware.com/
+# ['Panda Antivirus for Linux', ['pavcl'],
+# '-TSR -aut -aex -heu -cmp -nbr -nor -nso -eng {}',
+# [0], [0x10, 0x30, 0x50, 0x70, 0x90, 0xB0, 0xD0, 0xF0],
+# qr/Found virus :\s*(\S+)/m ],
+
+# GeCAD AV technology is acquired by Microsoft; RAV has been discontinued.
+# Check your RAV license terms before fiddling with the following two lines!
+# ['GeCAD RAV AntiVirus 8', 'ravav',
+# '--all --archive --mail {}', [1], [2,3,4,5], qr/Infected: (.+)/m ],
+# # NOTE: the command line switches changed with scan engine 8.5 !
+# # (btw, assigning stdin to /dev/null causes RAV to fail)
+
+ ### http://www.nai.com/
+ ['NAI McAfee AntiVirus (uvscan)', 'uvscan',
+ '--secure -rv --mime --summary --noboot - {}', [0], [13],
+ qr/(?x) Found (?:
+ \ the\ (.+)\ (?:virus|trojan) |
+ \ (?:virus|trojan)\ or\ variant\ ([^ ]+) |
+ :\ (.+)\ NOT\ a\ virus)/m,
+ # sub {$ENV{LD_PRELOAD}='/lib/libc.so.6'},
+ # sub {delete $ENV{LD_PRELOAD}},
+ ],
+ # NOTE1: with RH9: force the dynamic linker to look at /lib/libc.so.6 before
+ # anything else by setting environment variable LD_PRELOAD=/lib/libc.so.6
+ # and then clear it when finished to avoid confusing anything else.
+ # NOTE2: to treat encrypted files as viruses replace the [13] with:
+ # qr/^\s{5,}(Found|is password-protected|.*(virus|trojan))/
+
+ ### http://www.virusbuster.hu/en/
+ ['VirusBuster', ['vbuster', 'vbengcl'],
+ "{} -ss -i '*' -log=$MYHOME/vbuster.log", [0], [1],
+ qr/: '(.*)' - Virus/m ],
+ # VirusBuster Ltd. does not support the daemon version for the workstation
+ # engine (vbuster-eng-1.12-linux-i386-libc6.tgz) any longer. The names of
+ # binaries, some parameters AND return codes have changed (from 3 to 1).
+ # See also the new Vexira entry 'vascan' which is possibly related.
+
+# ### http://www.virusbuster.hu/en/
+# ['VirusBuster (Client + Daemon)', 'vbengd',
+# '-f -log scandir {}', [0], [3],
+# qr/Virus found = (.*);/m ],
+# # HINT: for an infected file it always returns 3,
+# # although the man-page tells a different story
+
+ ### http://www.cyber.com/
+ ['CyberSoft VFind', 'vfind',
+ '--vexit {}/*', [0], [23], qr/##==>>>> VIRUS ID: CVDL (.+)/m,
+ # sub {$ENV{VSTK_HOME}='/usr/lib/vstk'},
+ ],
+
+ ### http://www.avast.com/
+ ['avast! Antivirus', ['/usr/bin/avastcmd','avastcmd'],
+ '-a -i -n -t=A {}', [0], [1], qr/\binfected by:\s+([^ \t\n\[\]]+)/m ],
+
+ ### http://www.ikarus-software.com/
+ ['Ikarus AntiVirus for Linux', 'ikarus',
+ '{}', [0], [40], qr/Signature (.+) found/m ],
+
+ ### http://www.bitdefender.com/
+ ['BitDefender', 'bdscan', # new version
+ '--action=ignore --no-list {}', qr/^Infected files\s*:\s*0+(?!\d)/m,
+ qr/^(?:Infected files|Identified viruses|Suspect files)\s*:\s*0*[1-9]/m,
+ qr/(?:suspected|infected)\s*:\s*(.*)(?:\033|$)/m ],
+
+ ### http://www.bitdefender.com/
+ ['BitDefender', 'bdc', # old version
+ '--arc --mail {}', qr/^Infected files *:0+(?!\d)/m,
+ qr/^(?:Infected files|Identified viruses|Suspect files) *:0*[1-9]/m,
+ qr/(?:suspected|infected): (.*)(?:\033|$)/m ],
+ # consider also: --all --nowarn --alev=15 --flev=15. The --all argument may
+ # not apply to your version of bdc, check documentation and see 'bdc --help'
+
+ ### ArcaVir for Linux and Unix http://www.arcabit.pl/
+ ['ArcaVir for Linux', ['arcacmd','arcacmd.static'],
+ '-v 1 -summary 0 -s {}', [0], [1,2],
+ qr/(?:VIR|WIR):[ \t]*(.+)/m ],
+
+# ### a generic SMTP-client interface to a SMTP-based virus scanner
+# ['av_smtp', \&ask_av_smtp,
+# ['{}', 'smtp:[127.0.0.1]:5525', 'dummy@localhost'],
+# qr/^2/, qr/^5/, qr/^\s*(.*?)\s*$/m ],
+
+# ['File::Scan', sub {Amavis::AV::ask_av(sub{
+# use File::Scan; my($fn)=@_;
+# my($f)=File::Scan->new(max_txt_size=>0, max_bin_size=>0);
+# my($vname) = $f->scan($fn);
+# $f->error ? (2,"Error: ".$f->error)
+# : ($vname ne '') ? (1,"$vname FOUND") : (0,"Clean")}, @_) },
+# ["{}/*"], [0], [1], qr/^(.*) FOUND$/m ],
+
+# ### fully-fledged checker for JPEG marker segments of invalid length
+# ['check-jpeg',
+# sub { use JpegTester (); Amavis::AV::ask_av(\&JpegTester::test_jpeg, @_) },
+# ["{}/*"], undef, [1], qr/^(bad jpeg: .*)$/m ],
+# # NOTE: place file JpegTester.pm somewhere where Perl can find it,
+# # for example in /usr/local/lib/perl5/site_perl
+
+);
+
+
+@av_scanners_backup = (
+
+ ### http://www.clamav.net/ - backs up clamd or Mail::ClamAV
+ ['ClamAV-clamscan', 'clamscan',
+ "--stdout --no-summary -r --tempdir=$TEMPBASE {}",
+ [0], qr/:.*\sFOUND$/m, qr/^.*?: (?!Infected Archive)(.*) FOUND$/m ],
+
+# ### http://www.clamav.net/ - using remote clamd scanner as a backup
+# ['ClamAV-clamdscan', 'clamdscan',
+# "--stdout --no-summary --config-file=/etc/clamd-client.conf {}",
+# [0], qr/:.*\sFOUND$/m, qr/^.*?: (?!Infected Archive)(.*) FOUND$/m ],
+
+# ['ClamAV-clamd-stream',
+# \&ask_daemon, ["*", 'clamd:/var/run/clamav/clamd'],
+# qr/\bOK$/m, qr/\bFOUND$/m,
+# qr/^.*?: (?!Infected Archive)(.*) FOUND$/m ],
+
+ ### http://www.f-prot.com/ - backs up F-Prot Daemon, V6
+ ['F-PROT Antivirus for UNIX', ['fpscan'],
+ '--report --mount --adware {}', # consider: --applications -s 4 -u 3 -z 10
+ [0,8,64], [1,2,3, 4+1,4+2,4+3, 8+1,8+2,8+3, 12+1,12+2,12+3],
+ qr/^\[Found\s+[^\]]*\]\s+<([^ \t(>]*)/m ],
+
+ ### http://www.f-prot.com/ - backs up F-Prot Daemon (old)
+ ['FRISK F-Prot Antivirus', ['f-prot','f-prot.sh'],
+ '-dumb -archive -packed {}', [0,8], [3,6], # or: [0], [3,6,8],
+ qr/(?:Infection:|security risk named) (.+)|\s+contains\s+(.+)$/m ],
+
+ ### http://www.trendmicro.com/ - backs up Trophie
+ ['Trend Micro FileScanner', ['/etc/iscan/vscan','vscan'],
+ '-za -a {}', [0], qr/Found virus/m, qr/Found virus (.+) in/m ],
+
+ ### http://www.sald.com/, http://drweb.imshop.de/ - backs up DrWebD
+ ['drweb - DrWeb Antivirus', # security LHA hole in Dr.Web 4.33 and earlier
+ ['/usr/local/drweb/drweb', '/opt/drweb/drweb', 'drweb'],
+ '-path={} -al -go -ot -cn -upn -ok-',
+ [0,32], [1,9,33], qr' infected (?:with|by)(?: virus)? (.*)$'m ],
+
+ ### http://www.kaspersky.com/
+ ['Kaspersky Antivirus v5.5',
+ ['/opt/kaspersky/kav4fs/bin/kav4fs-kavscanner',
+ '/opt/kav/5.5/kav4unix/bin/kavscanner',
+ '/opt/kav/5.5/kav4mailservers/bin/kavscanner', 'kavscanner'],
+ '-i0 -xn -xp -mn -R -ePASBME {}/*', [0,10,15], [5,20,21,25],
+ qr/(?:INFECTED|WARNING|SUSPICION|SUSPICIOUS) (.*)/m,
+# sub {chdir('/opt/kav/bin') or die "Can't chdir to kav: $!"},
+# sub {chdir($TEMPBASE) or die "Can't chdir back to $TEMPBASE $!"},
+ ],
+
+# Commented out because the name 'sweep' clashes with Debian and FreeBSD
+# package/port of an audio editor. Make sure the correct 'sweep' is found
+# in the path when enabling.
+#
+# ### http://www.sophos.com/ - backs up Sophie or SAVI-Perl
+# ['Sophos Anti Virus (sweep)', 'sweep',
+# '-nb -f -all -rec -ss -sc -archive -cab -mime -oe -tnef '.
+# '--no-reset-atime {}',
+# [0,2], qr/Virus .*? found/m,
+# qr/^>>> Virus(?: fragment)? '?(.*?)'? found/m,
+# ],
+# # other options to consider: -idedir=/usr/local/sav
+
+# Always succeeds and considers mail clean.
+# Potentially useful when all other scanners fail and it is desirable
+# to let mail continue to flow with no virus checking (when uncommented).
+# ['always-clean', sub {0}],
+
+);
+
+
+1; # insure a defined return value
127 templates/default/dovecot/10-auth.conf.erb
@@ -0,0 +1,127 @@
+##
+## Authentication processes
+##
+
+# Disable LOGIN command and all other plaintext authentications unless
+# SSL/TLS is used (LOGINDISABLED capability). Note that if the remote IP
+# matches the local IP (ie. you're connecting from the same computer), the
+# connection is considered secure and plaintext authentication is allowed.
+disable_plaintext_auth = no
+
+# Authentication cache size (e.g. 10M). 0 means it's disabled. Note that
+# bsdauth, PAM and vpopmail require cache_key to be set for caching to be used.
+auth_cache_size = 10M
+# Time to live for cached data. After TTL expires the cached record is no
+# longer used, *except* if the main database lookup returns internal failure.
+# We also try to handle password changes automatically: If user's previous
+# authentication was successful, but this one wasn't, the cache isn't used.
+# For now this works only with plaintext authentication.
+auth_cache_ttl = 1 hour
+# TTL for negative hits (user not found, password mismatch).
+# 0 disables caching them completely.
+auth_cache_negative_ttl = 0
+
+# Space separated list of realms for SASL authentication mechanisms that need
+# them. You can leave it empty if you don't want to support multiple realms.
+# Many clients simply use the first one listed here, so keep the default realm
+# first.
+#auth_realms =
+
+# Default realm/domain to use if none was specified. This is used for both
+# SASL realms and appending @domain to username in plaintext logins.
+#auth_default_realm =
+
+# List of allowed characters in username. If the user-given username contains
+# a character not listed in here, the login automatically fails. This is just
+# an extra check to make sure user can't exploit any potential quote escaping
+# vulnerabilities with SQL/LDAP databases. If you want to allow all characters,
+# set this value to empty.
+#auth_username_chars = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@
+
+# Username character translations before it's looked up from databases. The
+# value contains series of from -> to characters. For example "#@/@" means
+# that '#' and '/' characters are translated to '@'.
+#auth_username_translation =
+
+# Username formatting before it's looked up from databases. You can use
+# the standard variables here, eg. %Lu would lowercase the username, %n would
+# drop away the domain if it was given, or "%n-AT-%d" would change the '@' into
+# "-AT-". This translation is done after auth_username_translation changes.
+#auth_username_format =
+
+# If you want to allow master users to log in by specifying the master
+# username within the normal username string (ie. not using SASL mechanism's
+# support for it), you can specify the separator character here. The format
+# is then <username><separator><master username>. UW-IMAP uses "*" as the
+# separator, so that could be a good choice.
+#auth_master_user_separator =
+
+# Username to use for users logging in with ANONYMOUS SASL mechanism
+#auth_anonymous_username = anonymous
+
+# Maximum number of dovecot-auth worker processes. They're used to execute
+# blocking passdb and userdb queries (eg. MySQL and PAM). They're
+# automatically created and destroyed as needed.
+#auth_worker_max_count = 30
+
+# Host name to use in GSSAPI principal names. The default is to use the
+# name returned by gethostname(). Use "$ALL" (with quotes) to allow all keytab
+# entries.
+#auth_gssapi_hostname =
+
+# Kerberos keytab to use for the GSSAPI mechanism. Will use the system
+# default (usually /etc/krb5.keytab) if not specified. You may need to change
+# the auth service to run as root to be able to read this file.
+#auth_krb5_keytab =
+
+# Do NTLM and GSS-SPNEGO authentication using Samba's winbind daemon and
+# ntlm_auth helper. <doc/wiki/Authentication/Mechanisms/Winbind.txt>
+#auth_use_winbind = no
+
+# Path for Samba's ntlm_auth helper binary.
+#auth_winbind_helper_path = /usr/bin/ntlm_auth
+
+# Time to delay before replying to failed authentications.
+#auth_failure_delay = 2 secs
+
+# Require a valid SSL client certificate or the authentication fails.
+#auth_ssl_require_client_cert = no
+
+# Take the username from client's SSL certificate, using
+# X509_NAME_get_text_by_NID() which returns the subject's DN's
+# CommonName.
+#auth_ssl_username_from_cert = no
+
+# Space separated list of wanted authentication mechanisms:
+# plain login digest-md5 cram-md5 ntlm rpa apop anonymous gssapi otp skey
+# gss-spnego
+# NOTE: See also disable_plaintext_auth setting.
+auth_mechanisms = plain login
+
+##
+## Password and user databases
+##
+
+#
+# Password database is used to verify user's password (and nothing more).
+# You can have multiple passdbs and userdbs. This is useful if you want to
+# allow both system users (/etc/passwd) and virtual users to login without
+# duplicating the system users into virtual database.
+#
+# <doc/wiki/PasswordDatabase.txt>
+#
+# User database specifies where mails are located and what user/group IDs
+# own them. For single-UID configuration use "static" userdb.
+#
+# <doc/wiki/UserDatabase.txt>
+
+#!include auth-deny.conf.ext
+#!include auth-master.conf.ext
+
+#!include auth-system.conf.ext
+!include auth-sql.conf.ext
+#!include auth-ldap.conf.ext
+#!include auth-passwdfile.conf.ext
+#!include auth-checkpassword.conf.ext
+#!include auth-vpopmail.conf.ext
+#!include auth-static.conf.ext
56 templates/default/dovecot/10-director.conf.erb
@@ -0,0 +1,56 @@
+##
+## Director-specific settings.
+##
+
+# Director can be used by Dovecot proxy to keep a temporary user -> mail server
+# mapping. As long as user has simultaneous connections, the user is always
+# redirected to the same server. Each proxy server is running its own director
+# process, and the directors are communicating the state to each others.
+# Directors are mainly useful with NFS-like setups.
+
+# List of IPs or hostnames to all director servers, including ourself.
+# Ports can be specified as ip:port. The default port is the same as
+# what director service's inet_listener is using.
+#director_servers =
+
+# List of IPs or hostnames to all backend mail servers. Ranges are allowed
+# too, like 10.0.0.10-10.0.0.30.
+#director_mail_servers =
+
+# How long to redirect users to a specific server after it no longer has
+# any connections.
+#director_user_expire = 15 min
+
+# TCP/IP port that accepts doveadm connections (instead of director connections)
+# If you enable this, you'll also need to add inet_listener for the port.
+#director_doveadm_port = 0
+
+# To enable director service, uncomment the modes and assign a port.
+service director {
+ unix_listener login/director {
+ #mode = 0666
+ }
+ fifo_listener login/proxy-notify {
+ #mode = 0666
+ }
+ unix_listener director-userdb {
+ #mode = 0600
+ }
+ inet_listener {
+ #port =
+ }
+}
+
+# Enable director for the wanted login services by telling them to
+# connect to director socket instead of the default login socket:
+service imap-login {
+ #executable = imap-login director
+}
+service pop3-login {
+ #executable = pop3-login director
+}
+
+# Enable director for LMTP proxying:
+protocol lmtp {
+ #auth_socket_path = director-userdb
+}
83 templates/default/dovecot/10-logging.conf.erb
@@ -0,0 +1,83 @@
+##
+## Log destination.
+##
+
+# Log file to use for error messages. "syslog" logs to syslog,
+# /dev/stderr logs to stderr.
+#log_path = syslog
+
+# Log file to use for informational messages. Defaults to log_path.
+#info_log_path =
+# Log file to use for debug messages. Defaults to info_log_path.
+#debug_log_path =
+
+# Syslog facility to use if you're logging to syslog. Usually if you don't
+# want to use "mail", you'll use local0..local7. Also other standard
+# facilities are supported.
+#syslog_facility = mail
+
+##
+## Logging verbosity and debugging.
+##
+
+# Log unsuccessful authentication attempts and the reasons why they failed.
+#auth_verbose = no
+
+# In case of password mismatches, log the attempted password. Valid values are
+# no, plain and sha1. sha1 can be useful for detecting brute force password
+# attempts vs. user simply trying the same password over and over again.
+#auth_verbose_passwords = no
+
+# Even more verbose logging for debugging purposes. Shows for example SQL
+# queries.
+#auth_debug = no
+
+# In case of password mismatches, log the passwords and used scheme so the
+# problem can be debugged. Enabling this also enables auth_debug.
+#auth_debug_passwords = no
+
+# Enable mail process debugging. This can help you figure out why Dovecot
+# isn't finding your mails.
+#mail_debug = no
+
+# Show protocol level SSL errors.
+#verbose_ssl = no
+
+# mail_log plugin provides more event logging for mail processes.
+plugin {
+ # Events to log. Also available: flag_change append
+ #mail_log_events = delete undelete expunge copy mailbox_delete mailbox_rename
+ # Available fields: uid, box, msgid, from, subject, size, vsize, flags
+ # size and vsize are available only for expunge and copy events.
+ #mail_log_fields = uid box msgid size
+}
+
+##
+## Log formatting.
+##
+
+# Prefix for each line written to log file. % codes are in strftime(3)
+# format.
+#log_timestamp = "%b %d %H:%M:%S "
+
+# Space-separated list of elements we want to log. The elements which have
+# a non-empty variable value are joined together to form a comma-separated
+# string.
+#login_log_format_elements = user=<%u> method=%m rip=%r lip=%l mpid=%e %c
+
+# Login log format. %$ contains login_log_format_elements string, %s contains
+# the data we want to log.
+#login_log_format = %$: %s
+
+# Log prefix for mail processes. See doc/wiki/Variables.txt for list of
+# possible variables you can use.
+#mail_log_prefix = "%s(%u): "
+
+# Format to use for logging mail deliveries. You can use variables:
+# %$ - Delivery status message (e.g. "saved to INBOX")
+# %m - Message-ID
+# %s - Subject
+# %f - From address
+# %p - Physical size
+# %w - Virtual size
+#deliver_log_format = msgid=%m: %$
345 templates/default/dovecot/10-mail.conf.erb
@@ -0,0 +1,345 @@
+##
+## Mailbox locations and namespaces
+##
+
+# Location for users' mailboxes. The default is empty, which means that Dovecot
+# tries to find the mailboxes automatically. This won't work if the user
+# doesn't yet have any mail, so you should explicitly tell Dovecot the full
+# location.
+#
+# If you're using mbox, giving a path to the INBOX file (eg. /var/mail/%u)
+# isn't enough. You'll also need to tell Dovecot where the other mailboxes are
+# kept. This is called the "root mail directory", and it must be the first
+# path given in the mail_location setting.
+#
+# There are a few special variables you can use, eg.:
+#
+# %u - username
+# %n - user part in user@domain, same as %u if there's no domain
+# %d - domain part in user@domain, empty if there's no domain
+# %h - home directory
+#
+# See doc/wiki/Variables.txt for full list. Some examples:
+#
+# mail_location = maildir:~/Maildir
+# mail_location = mbox:~/mail:INBOX=/var/mail/%u
+# mail_location = mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/%n
+#
+# <doc/wiki/MailLocation.txt>
+#
+mail_location = maildir:/var/mail/%d/%n/Maildir/:INDEX=/var/mail/%d/%n/indexes
+
+# If you need to set multiple mailbox locations or want to change default
+# namespace settings, you can do it by defining namespace sections.
+#
+# You can have private, shared and public namespaces. Private namespaces
+# are for user's personal mails. Shared namespaces are for accessing other
+# users' mailboxes that have been shared. Public namespaces are for shared
+# mailboxes that are managed by sysadmin. If you create any shared or public
+# namespaces you'll typically want to enable ACL plugin also, otherwise all
+# users can access all the shared mailboxes, assuming they have permissions
+# on filesystem level to do so.
+#
+# REMEMBER: If you add any namespaces, the default namespace must be added
+# explicitly, ie. mail_location does nothing unless you have a namespace
+# without a location setting. Default namespace is simply done by having a
+# namespace with empty prefix.
+#namespace {
+ # Namespace type: private, shared or public
+ #type = private
+
+ # Hierarchy separator to use. You should use the same separator for all
+ # namespaces or some clients get confused. '/' is usually a good one.
+ # The default however depends on the underlying mail storage format.
+ #separator =
+
+ # Prefix required to access this namespace. This needs to be different for
+ # all namespaces. For example "Public/".
+ #prefix =
+
+ # Physical location of the mailbox. This is in same format as
+ # mail_location, which is also the default for it.
+ #location =
+
+ # There can be only one INBOX, and this setting defines which namespace
+ # has it.
+ #inbox = no
+
+ # If namespace is hidden, it's not advertised to clients via NAMESPACE
+ # extension. You'll most likely also want to set list=no. This is mostly
+ # useful when converting from another server with different namespaces which
+ # you want to deprecate but still keep working. For example you can create
+ # hidden namespaces with prefixes "~/mail/", "~%u/mail/" and "mail/".
+ #hidden = no
+
+ # Show the mailboxes under this namespace with LIST command. This makes the
+ # namespace visible for clients that don't support NAMESPACE extension.
+ # "children" value lists child mailboxes, but hides the namespace prefix.
+ #list = yes
+
+ # Namespace handles its own subscriptions. If set to "no", the parent
+ # namespace handles them (empty prefix should always have this as "yes")
+ #subscriptions = yes
+#}
+
+# Example shared namespace configuration
+#namespace {
+ #type = shared
+ #separator = /
+
+ # Mailboxes are visible under "shared/user@domain/"
+ # %%n, %%d and %%u are expanded to the destination user.
+ #prefix = shared/%%u/
+
+ # Mail location for other users' mailboxes. Note that %variables and ~/
+ # expands to the logged in user's data. %%n, %%d, %%u and %%h expand to the
+ # destination user's data.
+ #location = maildir:%%h/Maildir:INDEX=~/Maildir/shared/%%u
+
+ # Use the default namespace for saving subscriptions.
+ #subscriptions = no
+
+ # List the shared/ namespace only if there are visible shared mailboxes.
+ #list = children
+#}
+
+# System user and group used to access mails. If you use multiple, userdb
+# can override these by returning uid or gid fields. You can use either numbers
+# or names. <doc/wiki/UserIds.txt>
+#mail_uid =
+#mail_gid =
+
+# Group to enable temporarily for privileged operations. Currently this is
+# used only with INBOX when either its initial creation or dotlocking fails.
+# Typically this is set to "mail" to give access to /var/mail.
+#mail_privileged_group =
+
+# Grant access to these supplementary groups for mail processes. Typically
+# these are used to set up access to shared mailboxes. Note that it may be
+# dangerous to set these if users can create symlinks (e.g. if "mail" group is
+# set here, ln -s /var/mail ~/mail/var could allow a user to delete others'
+# mailboxes, or ln -s /secret/shared/box ~/mail/mybox would allow reading it).
+#mail_access_groups =
+
+# Allow full filesystem access to clients. There's no access checks other than
+# what the operating system does for the active UID/GID. It works with both
+# maildir and mboxes, allowing you to prefix mailboxes names with eg. /path/
+# or ~user/.
+#mail_full_filesystem_access = no
+
+##
+## Mail processes
+##
+
+# Don't use mmap() at all. This is required if you store indexes to shared
+# filesystems (NFS or clustered filesystem).
+#mmap_disable = no
+
+# Rely on O_EXCL to work when creating dotlock files. NFS supports O_EXCL
+# since version 3, so this should be safe to use nowadays by default.
+#dotlock_use_excl = yes
+
+# When to use fsync() or fdatasync() calls:
+# optimized (default): Whenever necessary to avoid losing important data
+# always: Useful with e.g. NFS when write()s are delayed
+# never: Never use it (best performance, but crashes can lose data)
+#mail_fsync = optimized
+
+# Mail storage exists in NFS. Set this to yes to make Dovecot flush NFS caches
+# whenever needed. If you're using only a single mail server this isn't needed.
+#mail_nfs_storage = no
+# Mail index files also exist in NFS. Setting this to yes requires
+# mmap_disable=yes and fsync_disable=no.
+#mail_nfs_index = no
+
+# Locking method for index files. Alternatives are fcntl, flock and dotlock.
+# Dotlocking uses some tricks which may create more disk I/O than other locking
+# methods. NFS users: flock doesn't work, remember to change mmap_disable.
+#lock_method = fcntl
+
+# Directory in which LDA/LMTP temporarily stores incoming mails >128 kB.
+#mail_temp_dir = /tmp
+
+# Valid UID range for users, defaults to 500 and above. This is mostly
+# to make sure that users can't log in as daemons or other system users.
+# Note that denying root logins is hardcoded to dovecot binary and can't
+# be done even if first_valid_uid is set to 0.
+#first_valid_uid = 500
+#last_valid_uid = 0
+
+# Valid GID range for users, defaults to non-root/wheel. Users having
+# non-valid GID as primary group ID aren't allowed to log in. If user
+# belongs to supplementary groups with non-valid GIDs, those groups are
+# not set.
+#first_valid_gid = 1
+#last_valid_gid = 0
+
+# Maximum allowed length for mail keyword name. It's only forced when trying
+# to create new keywords.
+#mail_max_keyword_length = 50
+
+# ':' separated list of directories under which chrooting is allowed for mail
+# processes (ie. /var/mail will allow chrooting to /var/mail/foo/bar too).
+# This setting doesn't affect login_chroot, mail_chroot or auth chroot
+# settings. If this setting is empty, "/./" in home dirs are ignored.
+# WARNING: Never add directories here which local users can modify, that
+# may lead to root exploit. Usually this should be done only if you don't
+# allow shell access for users. <doc/wiki/Chrooting.txt>
+#valid_chroot_dirs =
+
+# Default chroot directory for mail processes. This can be overridden for
+# specific users in user database by giving /./ in user's home directory
+# (eg. /home/./user chroots into /home). Note that usually there is no real
+# need to do chrooting, Dovecot doesn't allow users to access files outside
+# their mail directory anyway. If your home directories are prefixed with
+# the chroot directory, append "/." to mail_chroot. <doc/wiki/Chrooting.txt>
+#mail_chroot =
+
+# UNIX socket path to master authentication server to find users.
+# This is used by imap (for shared users) and lda.
+#auth_socket_path = /var/run/dovecot/auth-userdb
+
+# Directory where to look up mail plugins.
+#mail_plugin_dir = /usr/lib/dovecot/modules
+
+# Space separated list of plugins to load for all services. Plugins specific to
+# IMAP, LDA, etc. are added to this list in their own .conf files.
+#mail_plugins =
+
+##
+## Mailbox handling optimizations
+##
+
+# The minimum number of mails in a mailbox before updates are done to cache
+# file. This allows optimizing Dovecot's behavior to do less disk writes at
+# the cost of more disk reads.
+#mail_cache_min_mail_count = 0
+
+# When IDLE command is running, mailbox is checked once in a while to see if
+# there are any new mails or other changes. This setting defines the minimum
+# time to wait between those checks. Dovecot can also use dnotify, inotify and
+# kqueue to find out immediately when changes occur.
+#mailbox_idle_check_interval = 30 secs
+
+# Save mails with CR+LF instead of plain LF. This makes sending those mails
+# take less CPU, especially with sendfile() syscall with Linux and FreeBSD.
+# But it also creates a bit more disk I/O which may just make it slower.
+# Also note that if other software reads the mboxes/maildirs, they may handle
+# the extra CRs wrong and cause problems.
+#mail_save_crlf = no
+
+##
+## Maildir-specific settings
+##
+
+# By default LIST command returns all entries in maildir beginning with a dot.
+# Enabling this option makes Dovecot return only entries which are directories.
+# This is done by stat()ing each entry, so it causes more disk I/O.
+# (For systems setting struct dirent->d_type, this check is free and it's
+# done always regardless of this setting)
+#maildir_stat_dirs = no
+
+# When copying a message, do it with hard links whenever possible. This makes
+# the performance much better, and it's unlikely to have any side effects.
+#maildir_copy_with_hardlinks = yes
+
+# Assume Dovecot is the only MUA accessing Maildir: Scan cur/ directory only
+# when its mtime changes unexpectedly or when we can't find the mail otherwise.
+#maildir_very_dirty_syncs = no
+
+##
+## mbox-specific settings
+##
+
+# Which locking methods to use for locking mbox. There are four available:
+# dotlock: Create <mailbox>.lock file. This is the oldest and most NFS-safe
+# solution. If you want to use /var/mail/ like directory, the users
+# will need write access to that directory.
+# dotlock_try: Same as dotlock, but if it fails because of permissions or
+# because there isn't enough disk space, just skip it.
+# fcntl : Use this if possible. Works with NFS too if lockd is used.
+# flock : May not exist in all systems. Doesn't work with NFS.
+# lockf : May not exist in all systems. Doesn't work with NFS.
+#
+# You can use multiple locking methods; if you do the order they're declared
+# in is important to avoid deadlocks if other MTAs/MUAs are using multiple
+# locking methods as well. Some operating systems don't allow using some of
+# them simultaneously.
+#mbox_read_locks = fcntl
+#mbox_write_locks = dotlock fcntl
+
+# Maximum time to wait for lock (all of them) before aborting.
+#mbox_lock_timeout = 5 mins
+
+# If dotlock exists but the mailbox isn't modified in any way, override the
+# lock file after this much time.
+#mbox_dotlock_change_timeout = 2 mins
+
+# When mbox changes unexpectedly we have to fully read it to find out what
+# changed. If the mbox is large this can take a long time. Since the change
+# is usually just a newly appended mail, it'd be faster to simply read the
+# new mails. If this setting is enabled, Dovecot does this but still safely
+# fallbacks to re-reading the whole mbox file whenever something in mbox isn't
+# how it's expected to be. The only real downside to this setting is that if
+# some other MUA changes message flags, Dovecot doesn't notice it immediately.
+# Note that a full sync is done with SELECT, EXAMINE, EXPUNGE and CHECK
+# commands.
+#mbox_dirty_syncs = yes
+
+# Like mbox_dirty_syncs, but don't do full syncs even with SELECT, EXAMINE,
+# EXPUNGE or CHECK commands. If this is set, mbox_dirty_syncs is ignored.
+#mbox_very_dirty_syncs = no
+
+# Delay writing mbox headers until doing a full write sync (EXPUNGE and CHECK
+# commands and when closing the mailbox). This is especially useful for POP3
+# where clients often delete all mails. The downside is that our changes
+# aren't immediately visible to other MUAs.
+#mbox_lazy_writes = yes
+
+# If mbox size is smaller than this (e.g. 100k), don't write index files.
+# If an index file already exists it's still read, just not updated.
+#mbox_min_index_size = 0
+
+##
+## mdbox-specific settings
+##
+
+# Maximum dbox file size until it's rotated.
+#mdbox_rotate_size = 2M
+
+# Maximum dbox file age until it's rotated. Typically in days. Day begins
+# from midnight, so 1d = today, 2d = yesterday, etc. 0 = check disabled.
+#mdbox_rotate_interval = 0
+
+# When creating new mdbox files, immediately preallocate their size to
+# mdbox_rotate_size. This setting currently works only in Linux with some
+# filesystems (ext4, xfs).
+#mdbox_preallocate_space = no
+
+##
+## Mail attachments
+##
+
+# sdbox and mdbox support saving mail attachments to external files, which
+# also allows single instance storage for them. Other backends don't support
+# this for now.
+
+# WARNING: This feature hasn't been tested much yet. Use at your own risk.
+
+# Directory root where to store mail attachments. Disabled, if empty.
+#mail_attachment_dir =
+
+# Attachments smaller than this aren't saved externally. It's also possible to
+# write a plugin to disable saving specific attachments externally.
+#mail_attachment_min_size = 128k
+
+# Filesystem backend to use for saving attachments:
+# posix : No SiS done by Dovecot (but this might help FS's own deduplication)
+# sis posix : SiS with immediate byte-by-byte comparison during saving
+# sis-queue posix : SiS with delayed comparison and deduplication
+#mail_attachment_fs = sis posix
+
+# Hash format to use in attachment filenames. You can add any text and
+# variables: %{md4}, %{md5}, %{sha1}, %{sha256}, %{sha512}, %{size}.
+# Variables can be truncated, e.g. %{sha256:80} returns only first 80 bits
+#mail_attachment_hash = %{sha1}
111 templates/default/dovecot/10-master.conf.erb
@@ -0,0 +1,111 @@
+#default_process_limit = 100
+#default_client_limit = 1000
+
+# Default VSZ (virtual memory size) limit for service processes. This is mainly
+# intended to catch and kill processes that leak memory before they eat up
+# everything.
+#default_vsz_limit = 256M
+
+# Login user is internally used by login processes. This is the most untrusted
+# user in Dovecot system. It shouldn't have access to anything at all.
+#default_login_user = dovenull
+
+# Internal user is used by unprivileged processes. It should be separate from
+# login user, so that login processes can't disturb other processes.
+#default_internal_user = dovecot
+
+service imap-login {
+ inet_listener imap {
+ #port = 143
+ }
+ inet_listener imaps {
+ #port = 993
+ #ssl = yes
+ }
+
+ # Number of connections to handle before starting a new process. Typically
+ # the only useful values are 0 (unlimited) or 1. 1 is more secure, but 0
+ # is faster. <doc/wiki/LoginProcess.txt>
+ #service_count = 1
+
+ # Number of processes to always keep waiting for more connections.
+ #process_min_avail = 0
+
+ # If you set service_count=0, you probably need to grow this.
+ #vsz_limit = 64M
+}
+
+service pop3-login {
+ inet_listener pop3 {
+ #port = 110
+ }
+ inet_listener pop3s {
+ #port = 995
+ #ssl = yes
+ }
+}
+
+service lmtp {
+ unix_listener lmtp {
+ #mode = 0666
+ }
+
+ # Create inet listener only if you can't use the above UNIX socket
+ #inet_listener lmtp {
+ # Avoid making LMTP visible for the entire internet
+ #address =
+ #port =
+ #}
+}
+
+service imap {
+ # Most of the memory goes to mmap()ing files. You may need to increase this
+ # limit if you have huge mailboxes.
+ #vsz_limit = 256M
+
+ # Max. number of IMAP processes (connections)
+ #process_limit = 1024
+}
+
+service pop3 {
+ # Max. number of POP3 processes (connections)
+ #process_limit = 1024
+}
+
+service auth {
+ # auth_socket_path points to this userdb socket by default. It's typically
+ # used by dovecot-lda, doveadm, possibly imap process, etc. Its default
+ # permissions make it readable only by root, but you may need to relax these
+ # permissions. Users that have access to this socket are able to get a list
+ # of all usernames and get results of everyone's userdb lookups.
+ unix_listener auth-userdb {
+ mode = 0600
+ user = dovenull
+ group = dovenull
+ }
+
+ # Postfix smtp-auth
+ unix_listener /var/spool/postfix/private/auth {
+ mode = 0666
+ }
+
+ # Auth process is run as this user.
+ #user = $default_internal_user
+}
+
+service auth-worker {
+ # Auth worker process is run as root by default, so that it can access
+ # /etc/shadow. If this isn't necessary, the user should be changed to
+ # $default_internal_user.
+ #user = root
+}
+
+service dict {
+ # If dict proxy is used, mail processes should have access to its socket.
+ # For example: mode=0660, group=vmail and global mail_access_groups=vmail
+ unix_listener dict {
+ #mode = 0600
+ #user =
+ #group =
+ }
+}
41 templates/default/dovecot/10-ssl.conf.erb
@@ -0,0 +1,41 @@
+##
+## SSL settings
+##
+
+# SSL/TLS support: yes, no, required. <doc/wiki/SSL.txt>
+ssl = yes
+
+# PEM encoded X.509 SSL/TLS certificate and private key. They're opened before
+# dropping root privileges, so keep the key file unreadable by anyone but
+# root. Included doc/mkcert.sh can be used to easily generate self-signed
+# certificate, just make sure to update the domains in dovecot-openssl.cnf
+ssl_cert = </etc/ssl/certs/dovecot.pem
+ssl_key = </etc/ssl/private/dovecot.pem
+
+# If key file is password protected, give the password here. Alternatively
+# give it when starting dovecot with -p parameter. Since this file is often
+# world-readable, you may want to place this setting instead to a different
+# root owned 0600 file by using ssl_key_password = <path.
+#ssl_key_password =
+
+# PEM encoded trusted certificate authority. Set this only if you intend to use
+# ssl_verify_client_cert=yes. The file should contain the CA certificate(s)
+# followed by the matching CRL(s). (e.g. ssl_ca = </etc/ssl/certs/ca.pem)
+#ssl_ca =
+
+# Request client to send a certificate. If you also want to require it, set
+# auth_ssl_require_client_cert=yes in auth section.
+#ssl_verify_client_cert = no
+
+# Which field from certificate to use for username. commonName and
+# x500UniqueIdentifier are the usual choices. You'll also need to set
+# auth_ssl_username_from_cert=yes.
+#ssl_cert_username_field = commonName
+
+# How often to regenerate the SSL parameters file. Generation is quite CPU
+# intensive operation. The value is in hours, 0 disables regeneration
+# entirely.
+#ssl_parameters_regenerate = 168
+
+# SSL ciphers to use
+#ssl_cipher_list = ALL:!LOW:!SSLv2:!EXP:!aNULL
48 templates/default/dovecot/15-lda.conf.erb
@@ -0,0 +1,48 @@
+##
+## LDA specific settings (also used by LMTP)
+##
+
+# Address to use when sending rejection mails.
+# Default is postmaster@<your domain>.
+#postmaster_address =
+
+# Hostname to use in various parts of sent mails, eg. in Message-Id.
+# Default is the system's real hostname.
+#hostname =
+
+# If user is over quota, return with temporary failure instead of
+# bouncing the mail.
+#quota_full_tempfail = no
+
+# Binary to use for sending mails.
+#sendmail_path = /usr/sbin/sendmail
+
+# If non-empty, send mails via this SMTP host[:port] instead of sendmail.
+#submission_host =
+
+# Subject: header to use for rejection mails. You can use the same variables
+# as for rejection_reason below.
+#rejection_subject = Rejected: %s
+
+# Human readable error message for rejection mails. You can use variables:
+# %n = CRLF, %r = reason, %s = original subject, %t = recipient
+#rejection_reason = Your message to <%t> was automatically rejected:%n%r
+
+# Delimiter character between local-part and detail in email address.
+#recipient_delimiter = +
+
+# Header where the original recipient address (SMTP's RCPT TO: address) is taken
+# from if not available elsewhere. With dovecot-lda -a parameter overrides this.
+# A commonly used header for this is X-Original-To.
+#lda_original_recipient_header =
+
+# Should saving a mail to a nonexistent mailbox automatically create it?
+#lda_mailbox_autocreate = no
+
+# Should automatically created mailboxes be also automatically subscribed?
+#lda_mailbox_autosubscribe = no
+
+protocol lda {
+ # Space separated list of plugins to load (default is global mail_plugins).
+ mail_plugins = sieve
+}
58 templates/default/dovecot/20-imap.conf.erb
@@ -0,0 +1,58 @@
+##
+## IMAP specific settings
+##
+
+protocol imap {
+ # Maximum IMAP command line length. Some clients generate very long command
+ # lines with huge mailboxes, so you may need to raise this if you get
+ # "Too long argument" or "IMAP command line too large" errors often.
+ #imap_max_line_length = 64k
+
+ # Maximum number of IMAP connections allowed for a user from each IP address.
+ # NOTE: The username is compared case-sensitively.
+ mail_max_userip_connections = 20
+
+ # Space separated list of plugins to load (default is global mail_plugins).
+ #mail_plugins = $mail_plugins
+
+ # IMAP logout format string:
+ # %i - total number of bytes read from client
+ # %o - total number of bytes sent to client
+ #imap_logout_format = bytes=%i/%o
+
+ # Override the IMAP CAPABILITY response. If the value begins with '+',
+ # add the given capabilities on top of the defaults (e.g. +XFOO XBAR).
+ #imap_capability =
+
+ # How long to wait between "OK Still here" notifications when client is
+ # IDLEing.
+ #imap_idle_notify_interval = 2 mins