<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE article
  PUBLIC '-//OASIS//DTD DocBook XML V4.4//EN'
  'http://www.docbook.org/xml/4.4/docbookx.dtd'>
<article><articleinfo><title>Installation</title><revhistory><revision><revnumber>3</revnumber><date>2021-11-18 10:56:16</date><authorinitials>jcrey</authorinitials></revision><revision><revnumber>2</revnumber><date>2021-11-18 10:46:46</date><authorinitials>jcrey</authorinitials></revision><revision><revnumber>1</revnumber><date>2014-08-27 10:00:40</date><authorinitials>vic</authorinitials></revision></revhistory></articleinfo><section><title>Installation</title><section><title>Debian Etch 4.0 dependencies</title><screen><![CDATA[# aptitude install python python-ipy python-dns python-twisted-core python-twisted-bin python-ldap
# wget http://ufpr.dl.sourceforge.net/sourceforge/pymilter/python-spf_2.0.3-0_all.deb
# dpkg -i python-spf_2.0.3-0_all.deb ]]></screen><para><inlinemediaobject><imageobject><imagedata depth="16" fileref="http://www.apolicy.org/moin_static1910/moniker/img/icon-info.png" width="16"/></imageobject><textobject><phrase>{i}</phrase></textobject></inlinemediaobject> For all Ubuntu releases, make sure that the <emphasis>Universe</emphasis> repository is in your sources.list. </para></section><section><title>Ubuntu 6.06 dependencies</title><para>Add Dapper backports in sources.list. </para><screen><![CDATA[deb http://archive.ubuntu.com/ubuntu dapper-backports main universe]]></screen><screen><![CDATA[aptitude install python python-ipy python-dns python-twisted-core python-twisted-bin python-ldap
aptitude install -t dapper-backports python-spf]]></screen></section><section><title>Ubuntu 6.10, 7.04, 7.10, 8.04 dependencies</title><screen><![CDATA[aptitude install python-ipy python-dns python-twisted-core python-twisted-bin python-spf python-ldap]]></screen></section><section><title>Fedora 7, 8, 9 dependencies</title><screen><![CDATA[yum install python-twisted-core python-pyspf python-pydns python-IPy python-devel python-ldap]]></screen></section><section><title>Other distributions</title><para>apolicy depends on the following Python modules: </para><itemizedlist><listitem><para>twisted &gt;= 2.4: <ulink url="http://twistedmatrix.com/"/> </para></listitem><listitem><para>ipy &gt;= 0.50: <ulink url="http://software.inl.fr/trac/wiki/IPy"/> </para></listitem><listitem><para>pydns &gt;= 2.3: <ulink url="http://pydns.sourceforge.net/"/> </para></listitem><listitem><para>pyspf &gt;= 2.0: <ulink url="http://www.bmsi.com/python/milter.html"/> </para></listitem><listitem><para>ldap: <ulink url="http://python-ldap.sourceforge.net/"/> </para></listitem></itemizedlist><para>Your distribution might have most of them already packaged. </para></section><section><title>Installing apolicy from source</title><para>The following commands should do just fine, you must be root: </para><screen><![CDATA[# wget ftp://ftp.uma.es/pub/apolicy/apolicy-0.74-1.tar.gz
# tar zxf apolicy-0.74-1.tar.gz
# cd apolicy-0.74-1
# python setup.py install]]></screen><para><inlinemediaobject><imageobject><imagedata depth="16" fileref="http://www.apolicy.org/moin_static1910/moniker/img/attention.png" width="16"/></imageobject><textobject><phrase>&lt;!&gt;</phrase></textobject></inlinemediaobject> If you are updating a previous installation, <emphasis role="strong">don't run python setup.py install</emphasis>, instead run this one: </para><screen><![CDATA[# python setup.py install_lib]]></screen><para>The command above will preserve your configuration files. </para><para>Take a look at /etc/apolicy/main.conf for additional settings, and  /etc/apolicy/policy.conf for the ACLs, actions and access configuration. </para><section><title>Verify integrity and authenticity &lt;= 0.73</title><screen><![CDATA[# wget http://www.apolicy.org/gpg/miguelfilho.gpg -O- -q | gpg --import
# wget http://download.gna.org/apolicy/apolicy-0.73.tar.gz.sig
# gpg --verify apolicy-0.73.tar.gz.sig]]></screen></section></section><section><title>init scripts</title><para>To start the daemon </para><screen><![CDATA[systemctl daemon-reload
systemctl enable apolicy
systemctl start apolicy]]></screen><para>Note that the supplied default cofiguration comes with a complex example that makes apolicy fail to start. This is because the example need datasource configuration. Adapt the configuraton with trivial stuff and make apolicy starts. </para><para>apolicy will listen by default on 127.0.0.1:10001. </para><para>By now the proccess must be running, check with <code>ps</code> and <code>netstat</code>. In case of any problem, check /var/log/syslog and /var/log/maillog. </para></section><section><title>Configuring Postfix</title><para>Just add <emphasis role="strong">check_policy_service inet:127.0.0.1:10001</emphasis> to  <emphasis role="strong">smtpd_client_restrictions</emphasis>, <emphasis role="strong">smtpd_recipient_restrictions</emphasis> etc,  and you are good to go. </para><para>For the <emphasis>size</emphasis> acl works properly, apolicy must to be called from  <emphasis role="strong">smtpd_end_of_data_restrictions</emphasis>. </para><para>Restart Postfix. </para></section><section><title>Logging</title><para>There is two log sources to get information, first is the log sent to syslog, using the mail facility. The other is the file <emphasis>/var/log/twistd.log</emphasis>. This file contains critical errors from the <emphasis role="strong">twisted</emphasis> daemon, keep an eye on this file too. </para></section><section><title>Debugging</title><para>You can turn debug on editing the configuration file /etc/apolicy/main.conf. Go to the bottom of the file and change this: </para><screen><![CDATA[[logger_apolicy]
level=INFO]]></screen><para>To this: </para><screen><![CDATA[[logger_apolicy]
level=DEBUG]]></screen><para>Then restart apolicy. </para></section></section></article>