Skip to content

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

Merged
georglauterbach merged 1 commit intodocker-mailserver:masterfrom
ap-wtioit:master-fix_postfix.sh_github
Apr 18, 2023
Merged

postfix.sh: add missing -E for extended regexes in smtpd_sender_restrictions#3272
georglauterbach merged 1 commit intodocker-mailserver:masterfrom
ap-wtioit:master-fix_postfix.sh_github

Conversation

@ap-wtioit
Copy link
Copy Markdown
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
Copy Markdown
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
@ap-wtioit
Copy link
Copy Markdown
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
Copy Markdown
Member

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

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
Copy Markdown
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.

3 participants