Merge ~kstenerud/ubuntu/+source/postfix:cosmic-postfix-mysql-config-1791139 into ubuntu/+source/postfix:ubuntu/cosmic-devel

Proposed by Karl Stenerud
Status: Merged
Approved by: Andreas Hasenack
Approved revision: 535f0b89fa9fd2264b82f5c4ea7737f1e109be5c
Merged at revision: 535f0b89fa9fd2264b82f5c4ea7737f1e109be5c
Proposed branch: ~kstenerud/ubuntu/+source/postfix:cosmic-postfix-mysql-config-1791139
Merge into: ubuntu/+source/postfix:ubuntu/cosmic-devel
Diff against target: 113 lines (+14/-14)
8 files modified
debian/changelog (+7/-0)
debian/postfix-cdb.postinst (+1/-2)
debian/postfix-ldap.postinst (+1/-2)
debian/postfix-lmdb.postinst (+1/-2)
debian/postfix-mysql.postinst (+1/-2)
debian/postfix-pcre.postinst (+1/-2)
debian/postfix-pgsql.postinst (+1/-2)
debian/postfix.postinst (+1/-2)
Reviewer Review Type Date Requested Status
Andreas Hasenack Approve
Canonical Server Pending
Canonical Server Core Reviewers Pending
Review via email: mp+354654@code.launchpad.net

Description of the change

Handle empty alias fields in /etc/postfix/main.cf

PPA: https://launchpad.net/~kstenerud/+archive/ubuntu/cosmic-postfix-mysql-config-1791139

Steps to test (broken path):

# lxc launch ubuntu-daily:cosmic testing
# lxc exec testing bash
# dhclient
# apt update
# apt dist-upgrade -y
# apt install -y postfix postfix-mysql
# sed -i 's/\(alias_.* =\).*/\1/g' /etc/postfix/main.cf
# service postfix reload
# apt install --reinstall postfix-mysql

You'll get the following error:
    Adding mysql map entry to /etc/postfix/dynamicmaps.cf
    /var/lib/dpkg/info/postfix-mysql.postinst: 33: [: =: unexpected operator

Steps to test (fixed path):

# lxc launch ubuntu-daily:cosmic testing
# lxc exec testing bash
# dhclient
# sudo add-apt-repository -y ppa:kstenerud/cosmic-postfix-mysql-config-1791139
# apt update
# apt dist-upgrade -y
# apt install -y postfix postfix-mysql
# sed -i 's/\(alias_.* =\).*/\1/g' /etc/postfix/main.cf
# service postfix reload
# apt install --reinstall postfix-mysql

The reinstall process should complete successfully.

To post a comment you must log in.
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Please see the other debian/*.postinst scripts, all (most?) of them have the same problem. Short list in https://bugs.launchpad.net/ubuntu/+source/postfix/+bug/1791139/comments/7

review: Needs Fixing
Revision history for this message
Andreas Hasenack (ahasenack) :
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Thanks for the changes, I'll check again tomorrow morning before you start your day.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

I see "Thanks for the changes", but I don't see the extended changelog entry like:
 * d/postfix-cdb.postinst, d/postfix-ldap.postinst, d/postfix-lmdb.postinst, d/postfix-mysql.postinst, d/postfix-pcre.postinst, d/postfix-pgsql.postinst, d/postfix.postinst:

If you prefer a rather short entry I think you could get away with a readable but more correct:
 * d/postfix-{cdb,ldap,lmdb,mysql,pcre,pgsql}.postinst, d/postfix.postinst:

And in my personal (might need a second) opinion, even this would be sort of ok indicating that more than one file were changed without flooding the changelog entry:
 * d/postfix*.postinst:

Further since in those cases changing in debian/* (no patch file with dep3 header) we have no nice place to put the Debian bug reference I sometimes add it to the changelog entry.
Would be #908221

And finally I think both bugs will be fixed, so list both LP Bugs (1791139).

So overall maybe:
 * d/postfix-{cdb,ldap,lmdb,mysql,pcre,pgsql}.postinst, d/postfix.postinst: Handle
   empty alias fields in main.cf (LP: #908221 LP: #1791139 Closes: #908221)

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

The "changes" I meant were the other postinst fixes. I'll give them a run now, but since I cannot upload this package, the formal review and upload should be done by a core dev.

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Suggestion for the testing procedure: there is no need for an intermediary ppa. You can trigger the failure by just reinstalling postfix-mysql, like this, after the first sed:

sudo apt install --reinstall postfix-mysql

root@cosmic-postfix:~# apt install postfix-mysql --reinstall
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
  libfreetype6
Use 'apt autoremove' to remove it.
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
Need to get 21.4 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://br.archive.ubuntu.com/ubuntu cosmic/main amd64 postfix-mysql amd64 3.3.0-1ubuntu1 [21.4 kB]
Fetched 21.4 kB in 213503982334601d 7h 0min 15s (0 B/s)
(Reading database ... 28802 files and directories currently installed.)
Preparing to unpack .../postfix-mysql_3.3.0-1ubuntu1_amd64.deb ...
Removing mysql map entry from /etc/postfix/dynamicmaps.cf
Unpacking postfix-mysql (3.3.0-1ubuntu1) over (3.3.0-1ubuntu1) ...
Setting up postfix-mysql (3.3.0-1ubuntu1) ...
Adding mysql map entry to /etc/postfix/dynamicmaps.cf
/var/lib/dpkg/info/postfix-mysql.postinst: 33: [: =: unexpected operator
Processing triggers for man-db (2.8.4-2) ...

Revision history for this message
Karl Stenerud (kstenerud) wrote :

OK, I've changed the description to:

 * d/postfix-{cdb,ldap,lmdb,mysql,pcre,pgsql}.postinst, d/postfix.postinst:
   Handle empty alias_database field in main.cf (LP: #908221 LP: #1791139
   Closes: #908221)

Since only the alias_database field was breaking.

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

I verified the fix for postfix-mysql, but the ppas don't have a newer build which includes the same fix for the other packages that are also affected.

I don't think a DEP8 run is needed here, since the fix is in a postinst script and that is tested just by installing the package, and upgrading it, something you (and I) did manually.

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

#908221 is a debian bug, don't prefix it with LP, or else this upload will close a nautilus bug (!) :)

Revision history for this message
Karl Stenerud (kstenerud) wrote :

OK, new build uploaded, description and instructions updated.

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

+1

review: Approve
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

tagged and uploaded

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index b5f577c..cd5d73a 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,10 @@
6+postfix (3.3.0-1ubuntu2) cosmic; urgency=medium
7+
8+ * d/postfix-{cdb,ldap,lmdb,mysql,pcre,pgsql}.postinst, d/postfix.postinst:
9+ Handle empty alias_database field in main.cf (LP: #1791139 Closes: #908221)
10+
11+ -- Karl Stenerud <karl.stenerud@canonical.com> Wed, 12 Sep 2018 06:06:30 +0000
12+
13 postfix (3.3.0-1ubuntu1) cosmic; urgency=medium
14
15 * debian/patches/fix-postconf-segfault.diff: Fix a postconf segfault
16diff --git a/debian/postfix-cdb.postinst b/debian/postfix-cdb.postinst
17index 2f37e39..674c0bd 100644
18--- a/debian/postfix-cdb.postinst
19+++ b/debian/postfix-cdb.postinst
20@@ -30,8 +30,7 @@ set -e
21 case "$1" in
22 configure)
23 addmap cdb mkmap_cdb_open
24- if [ $(postconf |grep alias_database | awk '{print $3}'|awk -F \: \
25- '{print $1}') = 'cdb' ]; then
26+ if [ "$(postconf -h alias_database | cut -f1 -d:)" = "cdb" ]; then
27 runnewaliases
28 fi
29 ;;
30diff --git a/debian/postfix-ldap.postinst b/debian/postfix-ldap.postinst
31index 7c23dd9..7248187 100644
32--- a/debian/postfix-ldap.postinst
33+++ b/debian/postfix-ldap.postinst
34@@ -30,8 +30,7 @@ set -e
35 case "$1" in
36 configure)
37 addmap ldap
38- if [ $(postconf |grep alias_database | awk '{print $3}'|awk -F \: \
39- '{print $1}') = 'ldap' ]; then
40+ if [ "$(postconf -h alias_database | cut -f1 -d:)" = "ldap" ]; then
41 runnewaliases
42 fi
43 ;;
44diff --git a/debian/postfix-lmdb.postinst b/debian/postfix-lmdb.postinst
45index 5cab441..d7f3a96 100644
46--- a/debian/postfix-lmdb.postinst
47+++ b/debian/postfix-lmdb.postinst
48@@ -31,8 +31,7 @@ set -e
49 case "$1" in
50 configure)
51 addmap lmdb mkmap_lmdb_open
52- if [ $(postconf |grep alias_database | awk '{print $3}'|awk -F \: \
53- '{print $1}') = 'lmdb' ]; then
54+ if [ "$(postconf -h alias_database | cut -f1 -d:)" = "lmdb" ]; then
55 runnewaliases
56 fi
57 ;;
58diff --git a/debian/postfix-mysql.postinst b/debian/postfix-mysql.postinst
59index 3b66fe7..d247c5d 100644
60--- a/debian/postfix-mysql.postinst
61+++ b/debian/postfix-mysql.postinst
62@@ -30,8 +30,7 @@ set -e
63 case "$1" in
64 configure)
65 addmap mysql
66- if [ $(postconf |grep alias_database | awk '{print $3}'|awk -F \: \
67- '{print $1}') = 'mysql' ]; then
68+ if [ "$(postconf -h alias_database | cut -f1 -d:)" = "mysql" ]; then
69 runnewaliases
70 fi
71 ;;
72diff --git a/debian/postfix-pcre.postinst b/debian/postfix-pcre.postinst
73index fd58c2e..43b4f12 100644
74--- a/debian/postfix-pcre.postinst
75+++ b/debian/postfix-pcre.postinst
76@@ -30,8 +30,7 @@ set -e
77 case "$1" in
78 configure)
79 addmap pcre
80- if [ $(postconf |grep alias_database | awk '{print $3}'|awk -F \: \
81- '{print $1}') = 'pcre' ]; then
82+ if [ "$(postconf -h alias_database | cut -f1 -d:)" = "pcre" ]; then
83 runnewaliases
84 fi
85 ;;
86diff --git a/debian/postfix-pgsql.postinst b/debian/postfix-pgsql.postinst
87index cae480e..dd9ea14 100644
88--- a/debian/postfix-pgsql.postinst
89+++ b/debian/postfix-pgsql.postinst
90@@ -30,8 +30,7 @@ set -e
91 case "$1" in
92 configure)
93 addmap pgsql
94- if [ $(postconf |grep alias_database | awk '{print $3}'|awk -F \: \
95- '{print $1}') = 'pgsql' ]; then
96+ if [ "$(postconf -h alias_database | cut -f1 -d:)" = "pgsql" ]; then
97 runnewaliases
98 fi
99 ;;
100diff --git a/debian/postfix.postinst b/debian/postfix.postinst
101index b42a983..7c04187 100644
102--- a/debian/postfix.postinst
103+++ b/debian/postfix.postinst
104@@ -614,8 +614,7 @@ if [ ! -f /etc/postfix/master.cf.proto ]; then
105 fi
106
107 if [ "$mailer" != "No configuration" ] || [ -f /etc/postfix/main.cf ]; then
108- aliastype=$(postconf |grep alias_database | awk '{print $3}' | \
109- awk -F \: '{print $1}')
110+ aliastype=$(postconf -h alias_database | cut -f1 -d:)
111 if ( [ "$aliastype" != "ldap" ] && [ "$aliastype" != "lmdb" ] && \
112 [ "$aliastype" != "cdb" ] && [ "$aliastype" != "pcre" ] && \
113 [ "$aliastype" != "mysql" ] && [ "$aliastype" != "pgsql" ] && \

Subscribers

People subscribed via source and target branches