Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

postfix.sh: add missing -E for extended regexes in smtpd_sender_restrictions #3272

Conversation

ap-wtioit
Copy link
Contributor

@ap-wtioit ap-wtioit commented Apr 18, 2023

Description

Noticed that something was wrong when in our tests i got the following additional output:

sed: -e expression #1, char 111: invalid reference \1 on `s' command's RHS

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (README.md or the documentation under docs/)
  • If necessary I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Info @wt-io-it

Copy link
Member

@georglauterbach georglauterbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, sed is one crude tool.. I thought -E is only necessary when using more sophisticated regular expressions. Oh my..

@georglauterbach georglauterbach merged commit 2f33f44 into docker-mailserver:master Apr 18, 2023
7 checks passed
@ap-wtioit
Copy link
Contributor Author

ap-wtioit commented Apr 18, 2023

For unescaped brackets you have to use -E in sed and grep:

echo "abc" | sed 's/\(b\)/d/'
echo "abc" | sed -E 's/(b)/d/'

I think both grep and sed use POSIX basic regular expressions as default and we are not used to those any more.

@georglauterbach
Copy link
Member

That explains the weirdness of the "old code" in #3271 - thanks for the info :)

@@ -77,7 +77,7 @@ function _setup_postfix_late
__postfix__log 'trace' 'Configuring user access'
if [[ -f /tmp/docker-mailserver/postfix-send-access.cf ]]
then
sed -i 's|(smtpd_sender_restrictions =)|\1 check_sender_access texthash:/tmp/docker-mailserver/postfix-send-access.cf,|' /etc/postfix/main.cf
sed -i -E 's|(smtpd_sender_restrictions =)|\1 check_sender_access texthash:/tmp/docker-mailserver/postfix-send-access.cf,|' /etc/postfix/main.cf
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sed --> sedfile to get notified in the future, if no change takes place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants