saltstack-formulas / postfix-formula

http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html
Other
25 stars 130 forks source link

master.cf does not support custom arguments with custom services #87

Open leonhedding opened 5 years ago

leonhedding commented 5 years ago

I made a change to postfix/files/master.cf. I don't know how to make a pull request here.

I replaced lines 139 - 149 of the current version with the below. It allows me to setup amivisd on port 10025 with all the arguments that I need.

{%-   if wrap %}
{{      parameter_str | wordwrap(width=wrap, break_long_words=False, wrapstring='\n%s  ' | format(comment)) }}
{%-   else %}
{{      parameter_str }}
{%-   endif -%}
{%-   elif 'user' in service or 'argv' in postfix_master_services.defaults[service_name] -%}
{%-      set parameter_str = "%s  user=%s argv=%s %s" | format(comment,
                                            service_param(service, service_name, 'user'),
                                            service_param(service, service_name, 'argv'),
                                            service_param(service, service_name, 'extras', '')) -%}
{%-   if wrap %}
{{      parameter_str | wordwrap(width=wrap, break_long_words=False, wrapstring='\n%s  ' | format(comment)) }}
{%-   else %}
{{      parameter_str }}
{%-   endif -%}
{%-   endif -%}
{%-   if service.args is not none -%}
{%-     for option in service.get('args', postfix_master_services.defaults[
                                            service_name].get('args', [])) -%}
{%-       if option.startswith('#') %}
{{ option }}
{%-       else %}
{{ comment }}  {{ option }}
{%-       endif %}
{%-     endfor %}
{%-   endif %}
roskens commented 5 years ago

Creating a PR is super easy.

  1. Fork the repository
  2. Edit the file in your forked repository, (The pencil icon next to the trash can)
  3. Add a commit message, and then select the "Create a new branch for this commit and start a pull request." option.
  4. Click "Propose file change button".

I take it you want to add the if service.args ... block to the extra_service macro?

leonhedding commented 5 years ago

Yes, that would be about correct.

ixs commented 5 years ago

@leonhedding I'd like a bit of clarification of your initial problem. I believe I have a fix for your problem, but wanna make sure I understand your underlying issue.

You would like to add a custom service to the master.cf config. You are trying to do that via the postfix:master_config:services pillar. Your service should be something like one of the existing postfix services, such as smtpd, smtp etc.? But instead you end up with a dovecot-deliver or mailman styled service at the bottom of the file where argv and user is defined but empty? And you actually do not want that, right?

leonhedding commented 5 years ago

It has been a while since I reviewed this, but I am pretty certain that is the issue I was having is what you describe. It was putting in text that I can't have for the amavisd setup. It should be setup like smtpd, but have a different name and port.

gojufhv commented 4 years ago

I've had the same problem - as workaround i used the extras variable:

mymailfilter:
        enable: true
        extras: |
          -o content_filter=
           -o local_recipient_maps=
           -o relay_recipient_maps=
           -o myhostname=localhost
           -o smtpd_helo_restrictions=
           -o smtpd_client_restrictions=
           -o smtpd_sender_restrictions=
           -o smtpd_recipient_restrictions=permit_mynetworks,reject
           -o mynetworks=127.0.0.0/8
        no_args: true