From: Alex Moskalenko <mav@elserv.msk.su>
To: sysadmins@lists.altlinux.org
Subject: Re: [Sysadmins] Postfix multi-instance
Date: Sun, 10 Nov 2019 11:29:13 +0300
Message-ID: <be1b5a62-5563-1808-947a-789b741f8133@elserv.msk.su> (raw)
In-Reply-To: <e6f5197f-3685-12c4-95ff-cb523392346a@elserv.msk.su>
[-- Attachment #1: Type: text/plain, Size: 1179 bytes --]
Быстрый хак на предмет поддержки Postfix Multi-instance в chroot.d-скриптах.
Хак со следующими условностями: дополнительные экземпляры должны иметь
spool_directory там же, где и основной экземпляр, и их имена должны
начинаться с postfix (так и происходит при создание дополнительных
экземпляров с помощью postmulti с параметрами по умолчанию). Сделано для
того, чтобы какой-нибудь экземпляр с queue_directory=/ не спровоцировал
удаление системных /{etc,lib,lib64} при работе скриптов из chroot.d.
Есть смысл на эту тему баг заводить или это дикая экзотика?
09.11.2019 18:28, Alex Moskalenko пишет:
> Здравствуйте.
>
> Я правильно понимаю, что какая-либо поддержка Multi-instance в
> chroot.d-скриптах postfix'а у нас отсутствует совсем?
>
> Понадобилось поднять несколько экземпляров Postfix'а на одной машине.
> Создал их с помощью postmulti, настроил, и понял, что без ручного
> копирования в их каталоги нужных файлов и библиотек ничего не работает.
>
> Нет ли каких-нибудь наработок в этой области?
>
> _______________________________________________
> Sysadmins mailing list
> Sysadmins@lists.altlinux.org
> https://lists.altlinux.org/mailman/listinfo/sysadmins
[-- Attachment #2: postmulti.patch --]
[-- Type: text/x-patch, Size: 4137 bytes --]
diff -uNr old/postfix.conf new/postfix.conf
--- old/postfix.conf 2016-03-02 17:52:33.000000000 +0300
+++ new/postfix.conf 2019-11-09 23:32:07.173447039 +0300
@@ -5,33 +5,35 @@
[ -n "$verbose" ] && err_null= || err_null='2>/dev/null'
postconf='/usr/sbin/postconf -E'
-eval $postconf >/dev/null $err_null || exit
-cd /var/spool/postfix
-
-incompatible_maps="alias_database alias_maps"
-force_alias=
-force_alias_maps=
-force_map=
-if [ -n "$force" ]; then
+for pinst in /etc/postfix $($postconf -h multi_instance_directories); do
+ eval $postconf -c $pinst >/dev/null $err_null || continue
+ cd "$($postconf -c $pinst -h queue_directory)"
+ pwd | grep -q "^/var/spool/postfix.*" || continue
+
+ incompatible_maps="alias_database alias_maps"
+ force_alias=
+ force_alias_maps=
+ force_map=
+ if [ -n "$force" ]; then
force_alias=1
force_alias_maps=1
force_map=1
# Purge all configs from chroot
rm -f etc/*
-fi
+ fi
-copy_resolv_conf
+ copy_resolv_conf
-suffix_hash=db
-suffix_cdb=cdb
+ suffix_hash=db
+ suffix_cdb=cdb
-# alias_database
-if [ -z "$force_alias" ]; then
+ # alias_database
+ if [ -z "$force_alias" ]; then
for type in hash cdb; do
update_alias=
eval suffix=\$suffix_$type
- for src in `$postconf -h alias_database |
+ for src in `$postconf -c $pinst -h alias_database |
tr -s ', ' '\n' |
sort -u |
sed -n 's,^'$type':\(/.*\),\1,p'`; do
@@ -42,16 +44,16 @@
break 2
done
done
-fi
-if [ -n "$force_alias" -o -n "$update_alias" ]; then
- /usr/bin/newaliases $verbose ||
- Fatal "failed to update alias database"
-fi
+ fi
+ if [ -n "$force_alias" -o -n "$update_alias" ]; then
+ /usr/bin/newaliases -C $pinst $verbose ||
+ Info "failed to update alias database for $pinst"
+ fi
# alias_maps
-for type in hash cdb; do
+ for type in hash cdb; do
eval suffix=\$suffix_$type
- for src in `$postconf -h alias_maps |
+ for src in `$postconf -c $pinst -h alias_maps |
tr -s ', ' '\n' |
sort -u |
sed -n 's,^'$type':\(/.*\),\1,p'`; do
@@ -63,22 +65,22 @@
update_alias_map=1
fi
if [ -n "$force_alias_map" -o -n "$update_alias_map" ]; then
- postalias $verbose "$src" ||
- Fatal "failed to update alias map $src database"
+ postalias -c $pinst $verbose "$src" ||
+ Info "failed to update alias map $src database for $pinst"
fi
done
-done
+ done
# other maps
-for type in hash cdb; do
+ for type in hash cdb; do
eval suffix=\$suffix_$type
- for src in `$postconf |
+ for src in `$postconf -c $pinst |
tr -s ', ' '\n' |
sort -u |
sed -n 's,^'$type':\(/.*\),\1,p'`; do
# Filter out incompatible maps
for map in $incompatible_maps; do
- test "`$postconf -h $map`" = "$type:$src" && src="" && break || :
+ test "`$postconf -c $pinst -h $map`" = "$type:$src" && src="" && break || :
done
[ -f "$src" ] || continue
update_map=
@@ -88,14 +90,15 @@
update_map=1
fi
if [ -n "$force_map" -o -n "$update_map" ]; then
- postmap $verbose "$type:$src" ||
- Fatal "failed to update $src database"
+ postmap -c $pinst $verbose "$type:$src" ||
+ Info "failed to update $src database for $pinst"
fi
done
-done
+ done
-nono='no
+ nono='no
no'
-if [ "`$postconf -h smtp_use_tls smtpd_use_tls`" != "$nono" ]; then
+ if [ "`$postconf -c $pinst -h smtp_use_tls smtpd_use_tls`" != "$nono" ]; then
: # Consider updating files specified in smtp{,d}_tls_CA{file,path}
-fi
+ fi
+done
diff -uNr old/postfix.lib new/postfix.lib
--- old/postfix.lib 2016-03-02 17:52:33.000000000 +0300
+++ new/postfix.lib 2019-11-09 23:24:43.272914416 +0300
@@ -5,11 +5,16 @@
# Source functions library
. /etc/chroot.d/functions
-cd /var/spool/postfix
+postconf='/usr/sbin/postconf -E'
-if [ -n "$force" ]; then
+for pinst in /etc/postfix $($postconf -h multi_instance_directories); do
+ cd "$($postconf -c $pinst -h queue_directory)"
+ pwd | grep -q "^/var/spool/postfix.*" || continue
+
+ if [ -n "$force" ]; then
# Purge all libs from chroot
rm -f ${chrooted_slib}/*
-fi
+ fi
-copy_resolv_lib
+ copy_resolv_lib
+done
next prev parent reply other threads:[~2019-11-10 8:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-09 15:28 Alex Moskalenko
2019-11-10 8:29 ` Alex Moskalenko [this message]
2019-11-10 21:49 ` Konstantin Lepikhov
2019-11-12 8:44 ` Michael Shigorin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=be1b5a62-5563-1808-947a-789b741f8133@elserv.msk.su \
--to=mav@elserv.msk.su \
--cc=sysadmins@lists.altlinux.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
ALT Linux sysadmins discussion
This inbox may be cloned and mirrored by anyone:
git clone --mirror http://lore.altlinux.org/sysadmins/0 sysadmins/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 sysadmins sysadmins/ http://lore.altlinux.org/sysadmins \
sysadmins@lists.altlinux.org sysadmins@lists.altlinux.ru sysadmins@lists.altlinux.com
public-inbox-index sysadmins
Example config snippet for mirrors.
Newsgroup available over NNTP:
nntp://lore.altlinux.org/org.altlinux.lists.sysadmins
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git