summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/postmap13
-rw-r--r--lib/postmulti14
2 files changed, 19 insertions, 8 deletions
diff --git a/lib/postmap b/lib/postmap
index 5691c48..7080b25 100644
--- a/lib/postmap
+++ b/lib/postmap
@@ -10,45 +10,50 @@
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
try:
import selinux
HAVE_SELINUX=True
except ImportError:
HAVE_SELINUX=False
# Look up for the file suffix corresponding to 'db'. If 'db' is unset,
# pick the default_detabase_type of the given instance instead.
def file_suffix(instance, db):
if not db:
- cmd = [ os.path.join(os.sep, 'usr', 'sbin', 'postconf') ]
if instance:
- config = os.path.join(os.sep, 'etc', 'postfix-%s' % instance)
- cmd.extend([ '-c', config ])
- cmd.extend([ '-h', 'default_database_type' ])
+ cmd = [ os.path.join(os.sep, 'usr', 'sbin', 'postmulti')
+ , '-x'
+ , '-i', instance
+ , '--'
+ ]
+ else:
+ cmd = []
+ cmd.extend([ os.path.join(os.sep, 'usr', 'sbin', 'postconf')
+ , '-h', 'default_database_type' ])
null = open (os.devnull, 'wb')
db = subprocess.check_output(cmd, stderr=null).rstrip()
null.closed
# See postmap(1) and postalias(1)
suffixes = { 'btree': 'db', 'cdb': 'cdb', 'hash': 'db' }
return suffixes[db]
# Compile the given (alias/lookup) table
def compile(cmd, instance, db, src):
cmd = [ os.path.join(os.sep, 'usr', 'sbin', cmd) ]
if instance:
config = os.path.join(os.sep, 'etc', 'postfix-%s' % instance)
cmd.extend([ '-c', config ])
if db:
src = "%s:%s" % (db,src)
cmd.append(src)
diff --git a/lib/postmulti b/lib/postmulti
index 6aed553..cad01f8 100644
--- a/lib/postmulti
+++ b/lib/postmulti
@@ -2,45 +2,51 @@
# Create and manage postfix instances.
# Copyright (c) 2013 Guilhem Moulin <guilhem@fripost.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Look up postfix configuration variable
def postconf(k, instance=None):
- cmd = [ os.path.join(os.sep, 'usr', 'sbin', 'postconf') ]
if instance:
- config = os.path.join(os.sep, 'etc', 'postfix-%s' % instance)
- cmd.extend([ '-c', config ])
- cmd.extend([ '-h', k ])
+ cmd = [ os.path.join(os.sep, 'usr', 'sbin', 'postmulti')
+ , '-x'
+ , '-i', instance
+ , '--'
+ ]
+ else:
+ cmd = []
+
+ cmd.extend([ os.path.join(os.sep, 'usr', 'sbin', 'postconf')
+ , '-h', k ])
return subprocess.check_output(cmd, stderr=subprocess.STDOUT).rstrip()
def main():
module = AnsibleModule(
argument_spec = dict(
instance = dict( required=True ),
group = dict( required=False )
),
supports_check_mode=True
)
params = module.params
instance = params['instance']
group = params['group']
changed=False
try:
enable = postconf('multi_instance_enable')
wrapper = postconf('multi_instance_wrapper')