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.
Created bug 1398913 for the mkdir SELinux bug
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.
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.
Still present in F26
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.
Bug still present in F27 3.2.5-2
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.
Bug still present in postfix-3.3.1-5.fc29, updating to F29
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.
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...
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 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.
Created attachment 1519889 [details] chroot-update script using regexp patterns to find and copy requires libs and cfg files
(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?
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.