diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-06 01:46:31 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-06 01:46:31 +0000 |
commit | 32afea41ba8b7328e252ae97ca32c56f98d42a90 (patch) | |
tree | 11b25ffd59d9190c8316cd48ace4e198531d0e7d /debian/postfix-add-policy | |
parent | Adding upstream version 3.4.23. (diff) | |
download | postfix-debian.tar.xz postfix-debian.zip |
Adding debian version 3.4.23-0+deb10u1.debian/3.4.23-0+deb10u1debian
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | debian/postfix-add-policy | 99 | ||||
-rw-r--r-- | debian/postfix-add-policy.8 | 67 |
2 files changed, 166 insertions, 0 deletions
diff --git a/debian/postfix-add-policy b/debian/postfix-add-policy new file mode 100644 index 0000000..dec5ad6 --- /dev/null +++ b/debian/postfix-add-policy @@ -0,0 +1,99 @@ +#!/usr/bin/python3 +''' +postfix-add-filter - A script to append new services to Postfix master.cf to +simplify integration of content filters. + +Copyright (c) 2008 Scott Kitterman <scott@kitterman.com> +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__ = "Scott Kitterman" +__email__ = "scott@kitterman.com" +__version__ = "0.1: August 3, 2008" + +import sys +import shutil +import os +import time + +def makepolicy(name, 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 spawn + user=%s argv=%s +""" % (name, 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', 'nobody', '/usr/bin/policyd') + """ +To output this usage message: + % postfix-add-policy +""" + + +if __name__ == '__main__': + import sys + if len(sys.argv) < 4: + print(USAGE + "\n") + elif len(sys.argv) == 4: + policyname = sys.argv[1] + user = sys.argv[2] + argv = sys.argv[3] + # 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, 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 + "\n") + diff --git a/debian/postfix-add-policy.8 b/debian/postfix-add-policy.8 new file mode 100644 index 0000000..bb03ea3 --- /dev/null +++ b/debian/postfix-add-policy.8 @@ -0,0 +1,67 @@ +.TH POSTFIX-ADD-POLICY 8 +.ad +.fi +.SH NAME +postfix-add-policy +\- +add policy service to Postfix master.cf +.SH "SYNOPSIS" +.na +.nf +\fBpostfix-add-policy\fR [\fIpolicy name\fR...] [\fIusername\fR...] [\fIargv\fR...] +.SH DESCRIPTION +.ad +.fi +The \fBpostfix-add-policy\fR(8) command adds an smtp policy server named +\fIpolicy name\fR running using \fIusername\fR and called as \fIargv\fR to +\/etc/postfix/master.cf to facilitate integration of SMTP policy servers such as +postgrey or postfix-policyd-spf-perl. The configuration is based on the Postfix +SMTPD_POLICY_README. Adminstrators should verify it is appropriate for their +requirements. + +The original file is copied prior to modification and left in /etc/postfix to +make it possible to revert changes easily. + +Available in the Debian package for Postfix version 2.5.3 and later. + +.SH DIAGNOSTICS +.ad +.fi +If the given \fIpolicy name\fR already appears in the master.cf, a message will +be printed to standard out and master.cf will not be modified. + +.SH "ENVIRONMENT" +.na +.nf +.ad +.fi +.IP \fBMAIL_CONFIG\fR +Directory with Postfix configuration files. + +The \fBpostfix-add-policy\fR(8) command should use this, but it currently +doesn't. It is hard coded to /etc/postfix. This should be changed. +.SH "CONFIGURATION PARAMETERS" +.na +.nf +.ad +.fi +None +.SH "FILES" +.na +.nf +/etc/postfix/master.cf +.SH "SEE ALSO" +.na +.nf +postconf(5), Postfix configuration +.SH "LICENSE" +.na +.nf +.ad +.fi +This software is licensed under the MIT open source license. +.SH "AUTHOR(S)" +.na +.nf +Scott Kitterman +<scott@kitterman.com> |