Changing Postfix policy script to bash to remove python dep warning
This commit is contained in:
parent
39c45d06e3
commit
fd3f4cef8b
|
@ -556,6 +556,7 @@ src/Makefile -text
|
|||
src/alternc-check -text
|
||||
src/alternc-dboptimize -text
|
||||
src/alternc-passwd -text
|
||||
src/alternc_add_policy_dovecot -text
|
||||
src/alternc_reload -text
|
||||
src/compress_logs.sh -text
|
||||
src/cron_users.sh -text
|
||||
|
@ -569,7 +570,6 @@ src/functions_dns.sh -text
|
|||
src/functions_hosting.sh -text
|
||||
src/mem_add -text
|
||||
src/mem_del -text
|
||||
src/postfix-add-policy -text
|
||||
src/quota-warning.sh -text
|
||||
src/quota_delete -text
|
||||
src/quota_edit -text
|
||||
|
|
|
@ -329,7 +329,7 @@ grep -v '^\ *#' $postfix_conf |while read line ; do
|
|||
done
|
||||
|
||||
# Conviguring delivery used by Postfix
|
||||
echo `/usr/lib/alternc/postfix-add-policy dovecot vmail:vmail DRhu pipe '/usr/bin/sudo /usr/lib/dovecot/deliver -f ${sender} -d ${recipient} '`
|
||||
. ./alternc_add_policy_dovecot
|
||||
|
||||
# Bug #1215: configure mydestination when $FQDN is not in
|
||||
OLDDESTINATION=`postconf mydestination | awk -F '=' '{print $2}'`
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
# Purpose of file: Makefile des binaires de /usr/lib/alternc
|
||||
# ----------------------------------------------------------------------
|
||||
SETUID=quota_edit quota_get mem_add mem_del du.pl
|
||||
SCRIPTS=sqlbackup.sh quota_init quota_delete update_domains.sh slave_dns sendmail spoolsize.php fixperms.sh alternc-dboptimize export_account.php cron_users_doit.sh cron_users.sh compress_logs.sh delete_logs.sh quota-warning.sh update_mails.sh postfix-add-policy
|
||||
SCRIPTS=sqlbackup.sh quota_init quota_delete update_domains.sh slave_dns sendmail spoolsize.php fixperms.sh alternc-dboptimize export_account.php cron_users_doit.sh cron_users.sh compress_logs.sh delete_logs.sh quota-warning.sh update_mails.sh alternc_add_policy_dovecot
|
||||
LIBS=functions.sh functions_hosting.sh functions_dns.sh
|
||||
BIN=$(DESTDIR)/usr/lib/alternc/
|
||||
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
#! /bin/bash
|
||||
|
||||
#script used to update Postfix Master.cf file, to use dovecot delivery service.
|
||||
#launch from alternc.install
|
||||
|
||||
|
||||
name="/etc/postfix/master.cf"
|
||||
|
||||
if grep -q dovecot $name ; then
|
||||
echo "Policy already active, not updated"
|
||||
else
|
||||
echo -e "dovecot unix - n n - 0 pipe\n\tflags=DRhu user=vmail:vmail argv=/usr/bin/sudo /usr/lib/dovecot/deliver -f \${sender} -d \${recipient}" >> $name
|
||||
echo "Policy updated"
|
||||
fi
|
||||
|
|
@ -1,107 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
'''
|
||||
postfix-add-filter - A script to append new services to Postfix master.cf to
|
||||
simplify integration of content filters.
|
||||
|
||||
Modified version for Alternc. Original author: Scott Kitterman <scott@kitterman.com>
|
||||
|
||||
For the need of AlternC, we add the feature to specify policy name.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
'''
|
||||
__author__ = "AlternC"
|
||||
__email__ = "equipe@alternc.org"
|
||||
__version__ = "0.1~alternc: August 26, 2012"
|
||||
|
||||
import sys
|
||||
import shutil
|
||||
import os
|
||||
import time
|
||||
import fileinput
|
||||
|
||||
def makepolicy(name, method, flags, user, argv):
|
||||
# Recommendations from the Postfix SMTPD_POLICY_README.
|
||||
header = """# ==========================================================================
|
||||
# service type private unpriv chroot wakeup maxproc command + args
|
||||
# (yes) (yes) (yes) (never) (100)
|
||||
# ==========================================================================
|
||||
# Added using postfix-add-policy script:
|
||||
"""
|
||||
policy = ("""%s unix - n n - 0 %s
|
||||
flags=%s user=%s argv=%s
|
||||
""" % (name, method, flags, user, argv))
|
||||
additions = header + policy
|
||||
return (additions)
|
||||
|
||||
|
||||
USAGE = """To add a new policy service to your master.cf:
|
||||
% sudo postfix-policy-add {policy service name} {user} {file (full path)}
|
||||
|
||||
Example:
|
||||
% sudo postfix-policy-add policyd noboby /usr/bin/policyd
|
||||
|
||||
Adds the following to master.cf:
|
||||
""" + makepolicy('policyd','method','flags', 'user', '/usr/bin/policyd') + """
|
||||
To output this usage message:
|
||||
% postfix-add-policy
|
||||
"""
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
if len(sys.argv) < 6:
|
||||
print USAGE
|
||||
elif len(sys.argv) == 6:
|
||||
policyname = sys.argv[1]
|
||||
user = sys.argv[2]
|
||||
flags = sys.argv[3]
|
||||
method = sys.argv[4]
|
||||
argv = sys.argv[5]
|
||||
# Read in master.cf and check to make sure specified name isn't
|
||||
# already used
|
||||
masterfile = open('/etc/postfix/master.cf', mode='r')
|
||||
master = masterfile.readlines()
|
||||
masterfile.close()
|
||||
bailout = False
|
||||
for line in master:
|
||||
if policyname in line:
|
||||
# Policy name already used, print error and bail
|
||||
print ('Selected policy name, %s, already in master.cf. \
|
||||
Master.cf not updated.' % (policyname))
|
||||
bailout = True
|
||||
break
|
||||
if not bailout:
|
||||
# Make backup copy
|
||||
backupname = '/etc/postfix/master.cf.' + str(int(time.time()))
|
||||
shutil.copy2('/etc/postfix/master.cf', backupname)
|
||||
# Make working copy
|
||||
shutil.copy2('/etc/postfix/master.cf', \
|
||||
'/etc/postfix/master.cf.working')
|
||||
# Add stuff in
|
||||
stuff = makepolicy(policyname, method, flags, user, argv)
|
||||
# Append stuff to the working copy:
|
||||
|
||||
newmaster = open('/etc/postfix/master.cf.working', mode='a')
|
||||
newmaster.writelines(stuff)
|
||||
|
||||
newmaster.close()
|
||||
# Put working copy in place.
|
||||
shutil.move('/etc/postfix/master.cf.working', \
|
||||
'/etc/postfix/master.cf')
|
||||
else:
|
||||
print USAGE
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
# 1. On lit les en-têtes et on mémorise l'état.
|
||||
|
||||
$fr="";
|
||||
|
||||
$rt="";
|
||||
|
||||
open(SM,"|/usr/sbin/sendmail -t -i");
|
||||
|
|
Loading…
Reference in New Issue