Postfix MX backup doesn't send to primary server

2017-08-27 Thread Davide Marchi

Hi friends,
I'm wondering about an Postfix MX backup server correct configuration.
I'm working on Debian Jessie and Postfix 2.11.x.

If I shut down the primary server, the MX backup receive the mail 
correctly and mail goes into mailbox 'INBOX'.
The problem is that if I try to look into the postfix queue this is 
empty:


Code:
postqueue -p
Mail queue is empty

and of course the message is not delivered to the main server!

I have recently approached Postfix and I would need help debugging this 
problem.


These are the setups of the two different servers:

SERVER1: https://pastebin.com/wVaqxj2i

SERVER2: https://pastebin.com/2mYBGvCN


many many thanks


Davide


Re: Postfix MX backup doesn't send to primary server

2017-08-27 Thread Wietse Venema
Davide Marchi:
> If I shut down the primary server, the MX backup receive the mail 
> correctly and mail goes into mailbox 'INBOX'.

Well that is the mistake. This server should not deliver to mailbox.

Have a look at Postfix documentation:
"Configuring Postfix as primary or backup MX host for a remote site"
http://www.postfix.org/STANDARD_CONFIGURATION_README.html#backup

Wietse


Re: Postfix MX backup doesn't send to primary server

2017-08-27 Thread Davide Marchi

Il 2017-08-27 14:49 wie...@porcupine.org ha scritto:

Davide Marchi:

If I shut down the primary server, the MX backup receive the mail
correctly and mail goes into mailbox 'INBOX'.


Well that is the mistake. This server should not deliver to mailbox.


Good, this is interesting, but a little bit more suggestion? :-)



Have a look at Postfix documentation:
"Configuring Postfix as primary or backup MX host for a remote site"
http://www.postfix.org/STANDARD_CONFIGURATION_README.html#backup

Wietse


I followed these documentation but surely something I must have 
missed..
Is there a command to check where the queue is headed and possibly its 
relative parameter?


Mamy thanks again

Davide


Re: Postfix MX backup doesn't send to primary server

2017-08-27 Thread Viktor Dukhovni
On Sun, Aug 27, 2017 at 01:01:58PM +0200, Davide Marchi wrote:

> If I shut down the primary server, the MX backup receive the mail correctly
> and mail goes into mailbox 'INBOX'.
> The problem is that if I try to look into the postfix queue this is empty:

Do not list the mx-backup domain in "mydestination".  Do list the
mx-backup domain in "relay_domains".  Set either:

parent_domain_matches_subdomains = smtpd_access_maps

  or, better yet:

parent_domain_matches_subdomains = 

if you're not relying on "example.com" matching "foo.example.com"
in access(5) tables and are willing to add ".example.com" keys as
necessary.

If you're behind a NAT device, make sure to list the external
address(es) in "proxy_interfaces".

For more help:  http://www.postfix.org/DEBUG_README.html#mail

-- 
Viktor.


antispam gateway rejecting unknown mailbox

2017-08-27 Thread joao reis

Hi,

I have a postfix server with antispam milter and policy daemons 
forwarding messages to various distinct remote servers. It works very 
well, all messages for the configured domains are forwarded using smtp / 
lmtp transport to each server.


My ideia is keep the minimal configuration for each domain: domain 
settings and the transport maps. Today I have this:


virtual_mailbox_domains = /etc/postfix/virtual_domains # with the valid 
domains
transport_maps = hash:/etc/postfix/transport # with the domains and 
destination


The problem is that when I send a message to an inexistent mailbox and 
existent configured domain, the message is forwarded to destination 
server and then the destination server rejects it.


Is it possible to reject in rcpt to command in the antispam gateway 
without copying all the mailbox table in to it?



Thanks in advance.

João Reis.



Re: postfix/postqueue[5742]: panic: vbuf_print: output for \%s\ exceeds space 0

2017-08-27 Thread Wietse Venema
A. Schulze:
> postqueue: panic: vbuf_print: output for '%s' exceeds space 0

Unfortunately, there is no way that I can reproduce this in
postfix-3.2.0, given the preconditions in this code.  Does this
machine have ECC meory? Does it have a history of programs crashing?

Wietse

Message-ID: <20170826122446.horde.wtusryfdzjjo1nij3m0g...@andreasschulze.de>
postfix 3.2.0
postqueue: panic: vbuf_print: output for '%s' exceeds space 0

This msg_panic() call is made from VBUF_SNPRINTF():
#define VBUF_SNPRINTF(bp, sz, fmt, arg) do { \
ssize_t _ret; \
VBUF_SPACE((bp), (sz)); \
_ret = snprintf((char *) (bp)->ptr, (bp)->cnt, (fmt), (arg)); \
if (_ret < 0) \
msg_panic("%s: output error for '%s'", myname, (fmt)); \
if (_ret >= (bp)->cnt) \
msg_panic("%s: output for '%s' exceeds space %ld", \
  myname, fmt, (long) (bp)->cnt); \

According to the panic message, (bp)->cnt is zero, meaning the
output buffer has no free space, which can't happen because
VBUF_SNPRINTF() is called with sz > 0, as will be argued below.
Therefore, VBUF_SPACE() is called with a value sz > 0, and the
output buffer must have free space.

The panic message says "%s" therefore this VBUF_SNPRINTF() call is
made while formatting a string with an fmt value of "%s".

This VBUF_SNPRINTF() call is made from vbuf_print():
s = va_arg(ap, char *);
if (prec >= 0 || (width > 0 && width > strlen(s))) {
VBUF_SNPRINTF(bp, (width > prec ? width : prec) + INT_SPACE,
  vstring_str(fmt), s);
} else {
VBUF_STRCAT(bp, s); /* noop for empty string */
}

This is the only VBUF_SNPRINTF() call with an fmt value of "%s".

Note that this VBUF_SNPRINTF() call happens only when prec >= 0
(VBUF_SNPRINTF called with sz >= INT_SPACE) or when width > 0
(VBUF_SNPRINTF called with sz > INT_SPACE).

The fmt argument for VBUF_SNPRINTF() contains "%s". Therefore:

There was no '-' for left-adjusted field. This info is copied literally.

There was no '+' for signed field. This info is copied literally.

There was no '0' for numeric left-padding. This info is copied literally.

There was no '*' for dynamic field width. This info is converted to
decimal string and added to the format string.

There was no hard-coded field width. This info is copied literally.

Therefore width == 0 (see vbuf_print source code).

There was no '.' for precision. This info is copied literally.

Therefore there was no '*' for dynamic precision.

Therefore there was no hard-coded precision.

Therefore prec == -1 (see vbuf_print source code).

In order to invoke VBUF_SNPRINTF() for %s, at least one of the
following predicates must be true:

prec >= 0, falsified by the above analysis.

width > 0 && width > strlen(s), falsified by the above analysis.

If VBUF_SNPRINTF() is invoked anyway, then some memory was corrupted
either dynamically during program execution, or some bit got flipped
in the file system page cache with some part of the executable file
or Postfix library, so that a constant or instruction was clobbered.

There is no point speculating which memory might be affected, without
making this panic independently reproducible.


Re: postfix/postqueue[5742]: panic: vbuf_print: output for \%s\ exceeds space 0

2017-08-27 Thread Larry Kuenning

Pardon an amateur for jumping in here, but I think I see something:

On 8/26/2017 6:24 AM, A. Schulze wrote:


Now my script called pfqgrep -r "+truncated-domain" which trigger the
panic message sometimes

# pfqgrep -r '+12345678901'
Quantifier follows nothing in regex; marked by <-- HERE in m/+ <-- HERE
12345678901/ at /usr/sbin/pfqgrep line 158,  chunk 1.


Doesn't that error message "Quantifier follows nothing" mean that the 
regexp parser pfqgrep is choking on a quoted expression because it 
begins with a "+" sign?  It seems to expect the "+" to mean "one or more 
of what precedes" and finds nothing to apply this to.


Since A. Schulze is trying to find a literal "+" sign, isn't "\+" the 
way to represent it?


--
Larry Kuenning
la...@qhpress.org



postfix log in mysql

2017-08-27 Thread Kev
Hi postfixers,

We have spam filter servers for our down, 5 of them to be exact. we use
amavisd, bitdefender & clamav for spam and virus filter. 

we have a self help portal done in php/mysql for users to manage
whitelist/blacklist etc, now i want to allow users to check there email
logs to they can find if any wanted email is blocked,

so the question is, how can i log postfix to a mysql db where i can write
an interface for users to search for email and see what did the
blocking, such as rbl, amavis etc ? 

ive seen some solutions to use syslog in to mysql but i was thinking
something much simpler where i will still have logs in place even if
mysql fails.

rgds




Re: postfix log in mysql

2017-08-27 Thread Christian Kivalo


Am 28. August 2017 05:51:10 MESZ schrieb Kev :
>Hi postfixers,
>
>We have spam filter servers for our down, 5 of them to be exact. we use
>amavisd, bitdefender & clamav for spam and virus filter. 
>
>we have a self help portal done in php/mysql for users to manage
>whitelist/blacklist etc, now i want to allow users to check there email
>logs to they can find if any wanted email is blocked,
>
>so the question is, how can i log postfix to a mysql db where i can
>write
>an interface for users to search for email and see what did the
>blocking, such as rbl, amavis etc ? 
>
>ive seen some solutions to use syslog in to mysql but i was thinking
>something much simpler where i will still have logs in place even if
>mysql fails.
Most syslog daemons can write to more than one output stream so besides 
absorbing your logs with mysql additionally you could keep logging to file and 
have your logs as normal. 
>rgds

-- 
Christian Kivalo


Re: postfix/postqueue[5742]: panic: vbuf_print: output for \%s\ exceeds space 0

2017-08-27 Thread A. Schulze


wietse:


A. Schulze:

postqueue: panic: vbuf_print: output for '%s' exceeds space 0




this is pfqgrep:

  $mailq = "/usr/sbin/postqueue -p |"; # added 'strace -f' here
  open(MAILQ, $mailq) or die;
  while () {
# read from STDIN
  }

execve("/usr/sbin/postqueue", ["/usr/sbin/postqueue", "-p"], [/* 52  
vars */]) = 0

...
chdir("/var/spool/postfix") = 0
rt_sigaction(SIGPIPE, {0x1, [PIPE], SA_RESTORER|SA_RESTART,  
0x7f4c8e917910}, {SIG_DFL, [], 0}, 8) = 0

getuid()= 0
socket(PF_FILE, SOCK_STREAM, 0) = 4
fcntl(4, F_GETFL)   = 0x2 (flags O_RDWR)
fcntl(4, F_SETFL, O_RDWR)   = 0
connect(4, {sa_family=AF_FILE, path="public/showq"}, 110) = 0
poll([{fd=4, events=POLLIN}], 1, 360) = 1 ([{fd=4, revents=POLLIN}])
read(4, "queue_name\0active\0queue_id\0003xdsD"..., 4096) = 149
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
write(1, "Queue ID- --Size-- ---Ar"..., 218) = 218
poll([{fd=4, events=POLLIN}], 1, 360) = 1 ([{fd=4, revents=POLLIN}])
read(4, "queue_name\0active\0queue_id\0003xgg0"..., 4096) = 1453
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
write(1, "\n3xgg0L0F7Lz4FLj* 30013 Mon "..., 257) = 257
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
Quantifier follows nothing in regex; marked by <-- HERE in m/+ <--  
HERE 1234567890123/ at /usr/sbin/pfqgrep line 158,  chunk 1.

write(1, "\n3xgfY21WScz4FLZ* 32602 Mon "..., 241) = 241
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
write(1, "\n3xgWSk0qGbz4FKf* 42628 Mon "..., 257) = 257
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
write(1, "\n3xgh1z1cT1z4FLr* 76609 Mon "..., 184) = -1 EPIPE (Broken pipe)
--- SIGPIPE (Broken pipe) @ 0 (0) ---
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
poll([{fd=4, events=POLLIN}], 1, 360) = 1 ([{fd=4, revents=POLLIN}])
read(4, "queue_name\0active\0queue_id\0003xgKR"..., 4096) = 4096
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
poll([{fd=4, events=POLLIN}], 1, 360) = 1 ([{fd=4, revents=POLLIN}])
read(4, "3xdqXK4q4lz4FLK\0time\0001503639089\0"..., 4096) = 4096
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
write(2, "postqueue: panic: vbuf_print: ou"..., 62postqueue: panic:  
vbuf_print: output for '%s' exceeds space 0

) = 62
sendto(3, "<18>Aug 28 08:09:02 postfix/post"..., 95, MSG_NOSIGNAL,  
NULL, 0) = 95

rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigaction(SIGCHLD, NULL, {SIG_DFL, [], 0}, 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
nanosl