Make PL/pgSQL function feed back identity for mailboxes/relocated when there
are catchall destinations.
Without catchall aliases, if no virtual_alias matches, the query can just
return NULL and Postfix will later check mailboxes/relocated for the address
to rewrite.
However, since virtual aliases are handled long before mailboxes/relocated,
a catchall alias would also catch mail to mailboxes and relocated addresses,
which we do not want.
The way to tell postfix to keep delivering is for the virtual alias map to
return the search key itself (identity function).
This patch changes the postfix_virtual_alias_maps Pl/pgSQL function to do
exactly that, but only if there are catchall destinations defined for the
domain in question — otherwise it returns NULL when no match is found.
# -*- coding: UTF-8 -*-# Copyright (c) 2010 - 2011, Pascal Volk# See COPYING for distribution information.""" VirtualMailManager.cli ~~~~~~~~~~~~~~~~~~~~~~ VirtualMailManager's command line interface."""importosfromarrayimportarrayfromfcntlimportioctlfromgetpassimportgetpassfromtermiosimportTIOCGWINSZfromVirtualMailManagerimportENCODINGfromVirtualMailManager.constantsimportVMM_TOO_MANY_FAILURESfromVirtualMailManager.errorsimportVMMError__all__=('prog','get_winsize','read_pass','w_err','w_std')_=lambdamsg:msg_std_write=os.sys.stdout.write_err_write=os.sys.stderr.writeprog=os.path.basename(os.sys.argv[0])defw_std(*args):"""Writes a line for each arg of *args*, encoded in the current ENCODING, to stdout. """_std_write('\n'.join(a.encode(ENCODING,'replace')forainargs)+'\n')defw_err(code,*args):"""Writes a line for each arg of *args*, encoded in the current ENCODING, to stderr. This function optionally interrupts the program execution if *code* does not equal to 0. *code* will be used as the system exit status. """_err_write('\n'.join(a.encode(ENCODING,'replace')forainargs)+'\n')ifcode:os.sys.exit(code)defget_winsize():"""Returns a tuple of integers ``(ws_row, ws_col)`` with the height and width of the terminal."""fd=Nonefordevin(os.sys.stdout,os.sys.stderr,os.sys.stdin):ifhasattr(dev,'fileno')andos.isatty(dev.fileno()):fd=dev.fileno()breakiffdisNone:# everything seems to be redirected# fall back to environment or assume some common defaultsws_row,ws_col=24,80try:ws_col=int(os.environ.get('COLUMNS',80))ws_row=int(os.environ.get('LINES',24))exceptValueError:passreturnws_row,ws_col#"struct winsize" with the ``unsigned short int``s ws_{row,col,{x,y}pixel}ws=array('H',(0,0,0,0))ioctl(fd,TIOCGWINSZ,ws,True)ws_row,ws_col=ws[:2]returnws_row,ws_coldefread_pass():"""Interactive 'password chat', returns the password in plain format. Throws a VMMError after the third failure. """# TP: Please preserve the trailing space.readp_msg0=_(u'Enter new password: ').encode(ENCODING,'replace')# TP: Please preserve the trailing space.readp_msg1=_(u'Retype new password: ').encode(ENCODING,'replace')mismatched=Truefailures=0whilemismatched:iffailures>2:raiseVMMError(_(u'Too many failures - try again later.'),VMM_TOO_MANY_FAILURES)clear0=getpass(prompt=readp_msg0)clear1=getpass(prompt=readp_msg1)ifclear0!=clear1:failures+=1w_err(0,_(u'Sorry, passwords do not match.'))continueifnotclear0:failures+=1w_err(0,_(u'Sorry, empty passwords are not permitted.'))continuemismatched=Falsereturnclear0del_