Bug 1398910 - Default example postfix chroot-update does not work on Fedora
Summary: Default example postfix chroot-update does not work on Fedora
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: postfix
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Jaroslav Škarvada
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-11-27 09:23 UTC by Scott Shambarger
Modified: 2019-03-26 15:24 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-03-26 15:24:44 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Patch to fix errors in LINUX2 example script (965 bytes, patch)
2016-11-27 09:23 UTC, Scott Shambarger
no flags Details | Diff
new chroot-update script (879 bytes, application/x-shellscript)
2019-01-10 10:37 UTC, Jaroslav Petráš
no flags Details
chroot-update simplified a bit (604 bytes, application/x-shellscript)
2019-01-10 18:20 UTC, Jaroslav Petráš
no flags Details
chroot-update script using regexp patterns to find and copy requires libs and cfg files (611 bytes, application/x-shellscript)
2019-01-10 18:30 UTC, Jaroslav Petráš
no flags Details

Description Scott Shambarger 2016-11-27 09:23:06 UTC
Created attachment 1224771 [details]
Patch to fix errors in LINUX2 example script

Description of problem:
doc/postfix/README_FILES/BASIC_CONFIGURATION_README describes setting up the chroot environment by copying the example scripts in doc/postfix/examples/chroot-setup/(LINUX2) to /etc/postfix/chroot-update.  However, without several modifications, the script fails to work when postfix is started.

Version-Release number of selected component (if applicable):
postfix-3.1.3-1.fc24.x86_64

How reproducible:
Script fails to work correctly whenever postfix is started. (error is ignored)

Steps to Reproduce:
1. Copy /usr/share/doc/postfix/examples/chroot-setup/LINUX2 to /etc/postfix/chroot-update (chmod +x and restorecon file, see related bug 1398907 for missing SELinux label however; chcon -t postfix_exec_t to work around that bug).
2. Start postfix with systemctl

Actual results:
/var/spool/postfix/lib(64)/ directories not populated, labels on /var/spool/postfix/etc/ files are incorrect.

Expected results:
chroot environment should be correctly setup and functional allowing postfix chroot daemons to resolve DNS entries.

Additional info:
There are several problems with the LINUX2 script that should be fixed by default so people following the README don't struggle with these issues:

The cond_copy function in the script uses 'find "$dir"...' rather than 'find "$dir/"...' for the /lib(64) directories, which does not find any files because /lib(64) are symlinks into /usr.

The $CP variable is missing the -Z flag to "cp" so that the SELinux labels are created correctly.

The "mkdir" command is also missing the -Z flag.

The final line is "postfix reload", which fails because the script is run by systemd on postfix startup (before postfix is running).

NOTE: the mkdir -p -Z usr/lib/zoneinfo shows an error which appears to be a bug with mkdir (but leads to extra errors in the log on startup):
 "mkdir: failed to set default creation context for 'usr/lib':..."

I've attached a patch which should fix the above in the LINUX2 script.

Comment 1 Scott Shambarger 2016-11-27 09:43:50 UTC
Created bug 1398913 for the mkdir SELinux bug

Comment 2 Fedora End Of Life 2017-07-26 00:00:13 UTC
This message is a reminder that Fedora 24 is nearing its end of life.
Approximately 2 (two) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 24. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '24'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 24 is end of life. If you would still like
to see this bug fixed and are able to reproduce it against a later version
of Fedora, you are encouraged  change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.

Comment 3 Fedora End Of Life 2017-08-08 19:21:42 UTC
Fedora 24 changed to end-of-life (EOL) status on 2017-08-08. Fedora 24 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.

Comment 4 Scott Shambarger 2017-08-22 11:14:33 UTC
Still present in F26

Comment 5 Fedora End Of Life 2018-05-03 08:18:26 UTC
This message is a reminder that Fedora 26 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 26. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '26'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 26 is end of life. If you would still like
to see this bug fixed and are able to reproduce it against a later version
of Fedora, you are encouraged  change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.

Comment 6 Scott Shambarger 2018-05-06 19:00:49 UTC
Bug still present in F27 3.2.5-2

Comment 7 Ben Cotton 2018-11-27 15:48:09 UTC
This message is a reminder that Fedora 27 is nearing its end of life.
On 2018-Nov-30  Fedora will stop maintaining and issuing updates for
Fedora 27. It is Fedora's policy to close all bug reports from releases
that are no longer maintained. At that time this bug will be closed as
EOL if it remains open with a Fedora  'version' of '27'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 27 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 8 Scott Shambarger 2018-11-28 02:11:46 UTC
Bug still present in postfix-3.3.1-5.fc29, updating to F29

Comment 9 Jaroslav Petráš 2019-01-10 10:37:13 UTC
Created attachment 1519728 [details]
new chroot-update script

To fix issue with resolving A and PTR records by smtpd I wrote a little script you can find in attachment. It's working on my CentOS 7.6 system and with paths patterns generalization it could be usable by more GNU/Linux distributions. It also utilizes restorecon (with recursive option set) to restore SELinux contexts over /var/spool/postfix if SELinux is in enforcing state.

Comment 10 Scott Shambarger 2019-01-10 16:36:26 UTC
You could probably simplify the script by adding '-Z' to the cp command, then restorecon wouldn't be necessary (not to mention you'd still get AVC errors if SELinux was in passive mode... -Z or restorecon should always be used :)

Also, the 'postfix reload' will fail when the script is called at ExecStartPre in the postfix.service file...

Comment 11 Jaroslav Petráš 2019-01-10 18:20:00 UTC
Created attachment 1519887 [details]
chroot-update simplified a bit

Yeah you are right. I replaced restorecon with 'cp -Z' and improved regexps a bit. Also I removed that reload which I forgot there by mistake. Thanks :)

Comment 12 Jaroslav Petráš 2019-01-10 18:28:55 UTC
Comment on attachment 1519887 [details]
chroot-update simplified a bit

COPY left commented by mistake. Also in next version find is sanitized by '-type f' and '-L' options.

Comment 13 Jaroslav Petráš 2019-01-10 18:30:57 UTC
Created attachment 1519889 [details]
chroot-update script using regexp patterns to find and copy requires libs and cfg files

Comment 14 Jaroslav Škarvada 2019-03-08 17:01:42 UTC
(In reply to Jaroslav Petráš from comment #9)
> Created attachment 1519728 [details]
> new chroot-update script
> 
> To fix issue with resolving A and PTR records by smtpd I wrote a little
> script you can find in attachment. It's working on my CentOS 7.6 system and
> with paths patterns generalization it could be usable by more GNU/Linux
> distributions. It also utilizes restorecon (with recursive option set) to
> restore SELinux contexts over /var/spool/postfix if SELinux is in enforcing
> state.

Please, could you be more specific what's the source of the problem? I would prefer patching the original script instead of writing new one. Is it lack of mdns4_minimal support in the chroot? Current /etc/nsswitch.conf has (f29):
hosts:      files mdns4_minimal [NOTFOUND=return] dns myhostname mymachines

IMHO the default action for UNAVAIL is continue, so it should work even without the mdns4_minimal libraries. Or is there different problem?

Comment 15 Jaroslav Škarvada 2019-03-26 15:15:45 UTC
I am going to fix the root causes described in the comment 0 by applying the provided patch - thanks for it. In case it's not enough or if you encounter more related problems, please reopen this bug or file a new one (preferred).

Also to simplify things I am moving this bug to rawhide (according to the bug history it shouldn't be a problem). If you need the fix in previous Fedora versions, please let me know.


Note You need to log in before you can comment on or make changes to this bug.