From 729219519f88645a4b634b04c59f1028dd7d7405 Mon Sep 17 00:00:00 2001 From: Michael Speth Date: Fri, 27 Jan 2017 13:57:19 +1300 Subject: [PATCH 1/4] Added inet_protocols parameter. The inet_protocols parameter is necessary to fix a bug with postfix when ip6 has been disabled on a server. The following blog describes the necesary changes. http://truemetal.org/universe/blog/2013/03/disable-ipv6-on-linux-centos/ --- manifests/init.pp | 1 + manifests/params.pp | 1 + templates/main.cf.erb | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 4aca743..3de5f0c 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -35,6 +35,7 @@ $relayhost_port = undef, $daemon_directory = $::postfix::params::daemon_directory, $inet_interfaces = $::postfix::params::inet_interfaces, + $inet_protocols = $::postfix::params::inet_protocols, ) inherits postfix::params { if $remove_sendmail { diff --git a/manifests/params.pp b/manifests/params.pp index c43806e..55c0298 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -48,4 +48,5 @@ $sendmailcf_package = 'sendmail-cf' $sendmail_service = 'sendmail' $inet_interfaces = 'localhost' + $inet_protocols = 'all' } diff --git a/templates/main.cf.erb b/templates/main.cf.erb index 0377e4f..88a9e45 100644 --- a/templates/main.cf.erb +++ b/templates/main.cf.erb @@ -121,7 +121,7 @@ myorigin = <%= @myorigin %> inet_interfaces = <%= @inet_interfaces %> # Enable IPv4, and IPv6 if supported -inet_protocols = all +inet_protocols = <%= @inet_protocols %> # The proxy_interfaces parameter specifies the network interface # addresses that this mail system receives mail on by way of a From 9f577e01096180fa953eb46a881e8ca65828493f Mon Sep 17 00:00:00 2001 From: Michael Speth Date: Tue, 4 Apr 2017 09:26:00 +1200 Subject: [PATCH 2/4] Disable daemon directory if set to undef. The reason is that version 3.0.0+ errors if this depricted variable is used. --- templates/main.cf.erb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/templates/main.cf.erb b/templates/main.cf.erb index 88a9e45..e2197fd 100644 --- a/templates/main.cf.erb +++ b/templates/main.cf.erb @@ -41,7 +41,9 @@ command_directory = /usr/sbin # daemon programs (i.e. programs listed in the master.cf file). This # directory must be owned by root. # +<% if @daemon_directory %> daemon_directory = <%= @daemon_directory %> +<% end %> # The data_directory parameter specifies the location of Postfix-writable # data files (caches, random numbers). This directory must be owned From cf23c0ad7279b51e6adb9b2db7a1b3dfc42f0e1d Mon Sep 17 00:00:00 2001 From: Michael Speth Date: Tue, 4 Apr 2017 10:14:43 +1200 Subject: [PATCH 3/4] Fixed daemon in line. --- manifests/init.pp | 20 ++++++++++---------- manifests/params.pp | 7 ++++++- templates/main.cf.erb | 2 +- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 3de5f0c..6991648 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -28,14 +28,15 @@ # [Remember: No empty lines between comments and class definition] class postfix ( - $remove_sendmail = undef, - $myorigin = undef, - $mydestination = undef, - $relayhost = undef, - $relayhost_port = undef, - $daemon_directory = $::postfix::params::daemon_directory, - $inet_interfaces = $::postfix::params::inet_interfaces, - $inet_protocols = $::postfix::params::inet_protocols, + $remove_sendmail = undef, + $myorigin = undef, + $mydestination = undef, + $relayhost = undef, + $relayhost_port = undef, + $daemon_directory = $::postfix::params::daemon_directory, + $inet_interfaces = $::postfix::params::inet_interfaces, + $inet_protocols = $::postfix::params::inet_protocols, + $enable_daemon_directory = $::postfix::params::enable_daemon_directory ) inherits postfix::params { if $remove_sendmail { @@ -75,5 +76,4 @@ File['postfix_config'] ] } - -} +} \ No newline at end of file diff --git a/manifests/params.pp b/manifests/params.pp index 55c0298..ce6b8fa 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -42,7 +42,12 @@ fail("The postfix module does not support the ${::osfamily} family of operating systems.") } } - + if $::lsbdistcodename == 'xenial' { + $enable_daemon_directory = false + }else{ + $enable_daemon_directory = true + } + # Set OS independent varibles here $sendmail_package = 'sendmail' $sendmailcf_package = 'sendmail-cf' diff --git a/templates/main.cf.erb b/templates/main.cf.erb index e2197fd..ced27da 100644 --- a/templates/main.cf.erb +++ b/templates/main.cf.erb @@ -41,7 +41,7 @@ command_directory = /usr/sbin # daemon programs (i.e. programs listed in the master.cf file). This # directory must be owned by root. # -<% if @daemon_directory %> +<% if @enable_daemon_directory == true %> daemon_directory = <%= @daemon_directory %> <% end %> From 3e3aec4475927f182a6d0ac9358f649e4456878a Mon Sep 17 00:00:00 2001 From: Michael Speth Date: Sat, 20 May 2017 11:48:15 +1200 Subject: [PATCH 4/4] GPCOREB-884 --- manifests/init.pp | 17 ++++++++++++++++- manifests/params.pp | 3 +++ templates/main.cf.erb | 4 ++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 6991648..6b24d2b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -4,6 +4,12 @@ # # Parameters: # +# [*header_checks*] +# If not undef, sets the header_checks field in main.cfg to +# regexp:/etc/postfix/header_checks +# It populates the header_checks file with the contents of this string. +# Default: undef +# # Actions: # # Requires: @@ -36,7 +42,8 @@ $daemon_directory = $::postfix::params::daemon_directory, $inet_interfaces = $::postfix::params::inet_interfaces, $inet_protocols = $::postfix::params::inet_protocols, - $enable_daemon_directory = $::postfix::params::enable_daemon_directory + $enable_daemon_directory = $::postfix::params::enable_daemon_directory, + $header_checks = undef, ) inherits postfix::params { if $remove_sendmail { @@ -61,6 +68,14 @@ ], } + if $header_checks { + file{$postfix::params::header_checks_file: + ensure => file, + content => $header_checks, + before => File['postfix_config'], + } + } + file{'postfix_config': ensure => 'file', path => $postfix::params::config_file, diff --git a/manifests/params.pp b/manifests/params.pp index ce6b8fa..40bd266 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -42,6 +42,9 @@ fail("The postfix module does not support the ${::osfamily} family of operating systems.") } } + + $header_checks_file = '/etc/postfix/header_checks' + if $::lsbdistcodename == 'xenial' { $enable_daemon_directory = false }else{ diff --git a/templates/main.cf.erb b/templates/main.cf.erb index ced27da..bfc9474 100644 --- a/templates/main.cf.erb +++ b/templates/main.cf.erb @@ -561,6 +561,10 @@ alias_database = hash:/etc/aliases # For details, see "man header_checks". # #header_checks = regexp:/etc/postfix/header_checks +<% if @header_checks -%> +header_checks = regexp:/etc/postfix/header_checks +local_header_rewrite_clients = static:all +<% end -%> # FAST ETRN SERVICE #