update on postsuper manual page

2016-09-17 Thread Geert Stappers

Hi,

My goal is to have

  mailq | tail -n +2 | grep -v '^ *(' | awk 'BEGIN { RS = "" }
  # $7=sender, $8=recipient1, $9=recipient2
  { if ($8 == "u...@example.com" && $9 == "")
print $1 }
  ' | tr -d '*!' | postsuper -d -

in the manaul page of postsuper. Current text in manual page has errors.

Patches are prepared.

This message is to find out if I can post to this mailinglist.
 

Groeten
Geert Stappers
-- 
Leven en laten leven


[PATCH 1/2] man/man1/postsuper.1: regular single quote for AWK

2016-09-17 Thread Geert Stappers
For some reason were the single quotes at the AWK command
made special. The strange single quote breaks copy-and-paste
the "filtered postsuper delete example".

Having regular single quotes makes the example usable again.
---
 man/man1/postsuper.1 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/man/man1/postsuper.1 b/man/man1/postsuper.1
index 9b292a9..bfe8dd1 100644
--- a/man/man1/postsuper.1
+++ b/man/man1/postsuper.1
@@ -43,11 +43,11 @@ queue IDs from standard input. For example, to delete all 
mail
 with exactly one recipient \fbu...@example.com\fR:
 .sp
 .nf
-mailq | tail +2 | grep -v '^ *(' | awk  \'BEGIN { RS = "" }
+mailq | tail +2 | grep -v '^ *(' | awk 'BEGIN { RS = "" }
 # $7=sender, $8=recipient1, $9=recipient2
 { if ($8 == "u...@example.com" && $9 == "")
   print $1 }
-\' | tr -d '*!' | postsuper -d -
+' | tr -d '*!' | postsuper -d -
 .fi
 .sp
 Specify "\fB-d ALL\fR" to remove all messages; for example, specify
-- 
2.8.0.rc3



[PATCH 2/2] man/man1/postsuper.1: tail needs -n for +2

2016-09-17 Thread Geert Stappers
It is very long ago that `tail -5 foo` would show
the last five lines of foo. These days you need to say

  tail -n 5 foo

The "filtered postsuper delete example" also misses the -n.

This patch adds the  -n

When in doubt about "compatiblity", check
 * http://www.unix.com/man-page/posix/1p/tail/
 * http://www.unix.com/man-page/freebsd/1/tail/
 * http://man7.org/linux/man-pages/man1/tail.1p.html
and the manual page on your local system
---
 man/man1/postsuper.1 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/man/man1/postsuper.1 b/man/man1/postsuper.1
index bfe8dd1..f507416 100644
--- a/man/man1/postsuper.1
+++ b/man/man1/postsuper.1
@@ -43,7 +43,7 @@ queue IDs from standard input. For example, to delete all mail
 with exactly one recipient \fbu...@example.com\fR:
 .sp
 .nf
-mailq | tail +2 | grep -v '^ *(' | awk 'BEGIN { RS = "" }
+mailq | tail -n +2 | grep -v '^ *(' | awk 'BEGIN { RS = "" }
 # $7=sender, $8=recipient1, $9=recipient2
 { if ($8 == "u...@example.com" && $9 == "")
   print $1 }
-- 
2.8.0.rc3



Re: update on postsuper manual page

2016-09-17 Thread Wietse Venema
Geert Stappers:
> 
> Hi,
> 
> My goal is to have
> 
>   mailq | tail -n +2 | grep -v '^ *(' | awk 'BEGIN { RS = "" }
>   # $7=sender, $8=recipient1, $9=recipient2
>   { if ($8 == "u...@example.com" && $9 == "")
> print $1 }
>   ' | tr -d '*!' | postsuper -d -
> 
> in the manaul page of postsuper. Current text in manual page has errors.
> 
> Patches are prepared.

Thanks for spotting the bitrot.

Wietse


Rough postscreen policy design

2016-09-17 Thread Wietse Venema
This is a rough design for the postscreen policy callout.

Wietse

High-level description
==

After checking the postscreen_access_list, postscreen will call out
to an optional policy service before making DNS queries or sending
the PREGREET banner to the client.

The policy test is just another test that the client must pass
before it can talk to a real Postfix SMTP server.  Just like all
other postscreen tests, a successful policy test is remembered for
some amount of time so that a good client does not have to be tested
with every connection that it makes.

Configuration parameters:

postscreen_policy_service = inet:host:port | unix:pathname
postscreen_policy_timeout = time in seconds
postscreen_policy_default_ttl = time in seconds
postscreen_policy_default_action = pass | ignore | enforce | drop

The host and port may be numeric or symbolic. If the policy server
is local, specify 127.0.0.1 or ::1 for maximal robustness.

Actions:

pass: Skip this test for this client, for the amount of time
specified with postscreen_policy_default_ttl.

ignore, enforce, drop: These actions have the exact same meaning
as with other postscreen tests (specifically, "enforce" allows
other tests to complete, rejects attempts to deliver mail with
a 550 SMTP reply, and logs the helo/sender/recipient information).
The postscreen_policy_default_ttl value is ignored.

Protocol


postscreen sends a request over a policy service connection and
expects a reply over that same connection. Once the reply is received,
that connection may be reused for another policy request. It is an
error for a policy server to close a connection after sending a
response.

postscreen will use parallel connections when multiple policy queries
are in progress.

Each policy request contains name=value attributes with the local
and remote address and port.

Request format:
client_address "="  |  
server_address "="  |  
client_port "="  
server_port "="  


The order of the attributes is unspecified; the order shown above
is just an example for readability. A policy server must ignore
attribute names that it does not know.

Each policy response must contain an action and may contain a ttl
value that indicates how long postscreen will skip a policy test
that returns a "pass" result.

Reply format:
action "=" "pass" | "ignore" | "enforce" | "drop" 
ttl "="  


See "Configuration parameters" above for a description of actions.
With actions other than "pass", postscreen ignores the ttl attribute.

If a "pass" action specifies no ttl, postscreen_policy_default_ttl
is used instead.

Error handling
==

When postscreen cannot complete a policy service request, it will
use the postscreen_policy_default_action and postscreen_policy_default_ttl.

Examples of errors:

- The policy server connection is not ready to write (write would block).

- The policy server does not respond to a connection request or
  policy request within the postscreen_policy_timeout.

- The policy server response is malformed.

Alternatives considered
===

Instead of doing the policy check before DNSBL and PREGREET checks,
they could be done in parallel, at least some of the time. Then, 
the policy timeouts could be more relaxed. Unfortunately that
requires that the PREGREET or DNSBL checks expire at the same time 
as the policy check ttl, which is hard to guarantee.