<?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>Configuration</title><revhistory><revision><revnumber>1</revnumber><date>2014-08-27 10:01:44</date><authorinitials>vic</authorinitials></revision></revhistory></articleinfo><section><title>Configuration</title><section><title>Syntax</title><para>The configuration file is very simple and intuitive. The file is located in /etc/apolicy/main.conf by default and follows this syntax: </para><screen><![CDATA[[section]
parameter = value
other-parameter = other-value]]></screen><para>Leading whitespace is removed from values and lines beginning with &quot;#&quot; or &quot;;&quot;  are ignored and may be used to provide comments. </para></section><section><title>/etc/apolicy/main.conf</title><para>The <emphasis>main.conf</emphasis> file contains the configuration for the main process,  log level, listen address, etc. The file is well commented and self explanatory. </para></section><section><title>/etc/apolicy/policy.conf</title><para>The <emphasis>policy.conf</emphasis> file contains the ACLs, Actions and Access statements.  It's in this file that you put your rules. </para><para>You define an ACL, an ACTION and finally you combine one or more ACL with an ACTION, using the ACCESS statement. If all ACLs matched, then apolicy will return the defined ACTION to Postfix. If not all ACLs matched, then DUNNO is returned.  </para><section><title>An ACL line</title><para>An ACL line should follow this syntax: </para><screen><![CDATA[acl name type value]]></screen><para>Where <emphasis>acl</emphasis> sets the line as an ACL statement, <emphasis>name</emphasis> is an identifier, for <emphasis>type</emphasis> look at the supported <ulink url="http://www.apolicy.org/Configuration/AclList#">ACLs</ulink> and <emphasis>value</emphasis> is the value that will be used by the ACL. You can set the value to a path to another text file that contains one value per line. It must be a full path to the file. </para></section><section><title>An ACTION line</title><para>An ACTION line should follow this syntax: </para><screen><![CDATA[action name type text]]></screen><para>Where <emphasis>action</emphasis> sets the line as an ACTION statement, <emphasis>name</emphasis> is an identifier, <emphasis>type</emphasis> is any of the actions listed in the  <ulink url="http://www.postfix.org/access.5.html">Postfix Access(5)</ulink> table, and <emphasis>text</emphasis> is the optional text returned by the action. </para><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> There is an special action named <emphasis role="strong">default</emphasis>. The <emphasis role="strong">default</emphasis> action is used when there is nothing left to do, and <emphasis>apolicy</emphasis> has always to return something to Postfix. The standard value of the <emphasis role="strong">default</emphasis> action is <emphasis role="strong">DUNNO</emphasis>, but you can change this. Setting the <emphasis role="strong">default</emphasis> action to REJECT, you can have the same behavior as a firewall, denying everything and allowing just what is necessary. </para></section><section><title>An ACCESS line</title><para>An ACCESS line should follow this syntax: </para><screen><![CDATA[access acl action]]></screen><para>Where <emphasis>access</emphasis> sets the line as an ACCESS statement, <emphasis>acl</emphasis> is an identifier of any previous defined ACL (you can use more than one) and <emphasis>action</emphasis> is an identifier of any previous defined ACTION. </para><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> You can use the operator <emphasis role="strong">!</emphasis> to negate an ACL and invert the response. </para><screen><![CDATA[acl foo sender foo@domain.com
action not_foo REJECT You are not foo!
access !foo not_foo]]></screen><para>The example above says: <emphasis>if the sender is different of <ulink url="mailto:foo@domain.com">foo@domain.com</ulink>, execute the action not_foo</emphasis> </para><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> Available in apolicy 0.72 and latter </para><para>In an access statement the action is now optional. If there is no action specified, the <emphasis role="strong">default</emphasis> action is used. </para></section></section></section></article>