From 9934edfe88f0e394b5e9f092cbf8be4cadd35bf8 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Tue, 22 Aug 2017 01:11:14 +0200 Subject: [PATCH 1/9] Add support for inet_protocols parameter --- README.markdown | 1 + manifests/init.pp | 1 + manifests/params.pp | 1 + spec/classes/postfix_spec.rb | 9 +++++++++ spec/spec_helper.rb | 3 ++- templates/main.cf.erb | 2 +- 6 files changed, 15 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index dbe53bc..e7565b3 100644 --- a/README.markdown +++ b/README.markdown @@ -43,6 +43,7 @@ class {'postfix': * `relayhost_port` This sets the port for the relay host specified with the `relayhost` parameter. The default is `undef` which leaves the port specifier off the end of the relayhost setting. This parameter does nothing if the `relayhost` parameter is not set. * `daemon_directory` Sets the directory with Postfix support programs and daemon programs are installed. The default is specific for each operating system. It's _not_ recommended that this parameter be changed. * `inet_interfaces` Sets the network interface for postfix to bind do. The default value is `localhost` +* `inet_protocols` The Internet protocols Postfix will attempt to use when making or accepting connections. Specify one or more of "ipv4" or "ipv6", separated by whitespace or commas. The default value is `all` # Attribution 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/spec/classes/postfix_spec.rb b/spec/classes/postfix_spec.rb index 6cc0d49..db6e7ec 100644 --- a/spec/classes/postfix_spec.rb +++ b/spec/classes/postfix_spec.rb @@ -98,6 +98,15 @@ ) } end + describe 'when setting inet_protocols' do + let :params do + { :inet_protocols => 'all' } + end + it { should contain_file('postfix_config').with_content( + %r{^inet_protocols = all$} + ) } + end + end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 639ac04..13cc1e6 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -33,7 +33,8 @@ 'sendmail_package' => 'sendmail', 'sendmailcf_package' => 'sendmail-cf', 'sendmail_service' => 'sendmail', - 'inet_interfaces' => 'localhost' + 'inet_interfaces' => 'localhost', + 'inet_protocols' => 'all' } case os['osfamily'] when 'Debian' 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 5b57ab23b246b6d83993ca19cd19c984219ac7d2 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Wed, 22 Nov 2017 14:12:29 +0100 Subject: [PATCH 2/9] Set hostname as masquerade_domains --- manifests/init.pp | 1 + templates/main.cf.erb | 2 ++ 2 files changed, 3 insertions(+) diff --git a/manifests/init.pp b/manifests/init.pp index 3de5f0c..1b33958 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -36,6 +36,7 @@ $daemon_directory = $::postfix::params::daemon_directory, $inet_interfaces = $::postfix::params::inet_interfaces, $inet_protocols = $::postfix::params::inet_protocols, + $masquerade_domains = $hostname, ) inherits postfix::params { if $remove_sendmail { diff --git a/templates/main.cf.erb b/templates/main.cf.erb index 88a9e45..8600a2e 100644 --- a/templates/main.cf.erb +++ b/templates/main.cf.erb @@ -690,3 +690,5 @@ sample_directory = /usr/share/doc/postfix-2.6.6/samples # readme_directory: The location of the Postfix README files. # readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES + +masquerade_domains = <%= @masquerade_domains %> From 73fe721e83702fcc4c3fb1d5de6911ba3e1c9092 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Wed, 22 Nov 2017 14:40:37 +0100 Subject: [PATCH 3/9] Add option for root@localhost for relay servers From 70fda05bec7f5c1edb0ac4d392fe3592c3a7df6a Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Wed, 22 Nov 2017 16:20:48 +0100 Subject: [PATCH 4/9] Bug. --- spec/classes/postfix_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/classes/postfix_spec.rb b/spec/classes/postfix_spec.rb index db6e7ec..67b0d08 100644 --- a/spec/classes/postfix_spec.rb +++ b/spec/classes/postfix_spec.rb @@ -24,7 +24,7 @@ %r{^myorigin = } ) } it { should contain_file('postfix_config').with_content( - %r{^mydestination = \$myhostname, localhost.\$mydomain, localhost$} + %r{^mydestination = $myhostname, localhost.$mydomain, localhost$} ) } it { should contain_file('postfix_config').without_content( %r{^relayhost =} From 3c7834c56b769126f06757c50b670c7c3b4d22c5 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Tue, 28 Nov 2017 10:12:33 +0100 Subject: [PATCH 5/9] Add /etc/postfix/virtual feature for root@localhost --- manifests/init.pp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/manifests/init.pp b/manifests/init.pp index 1b33958..82fe216 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -37,6 +37,7 @@ $inet_interfaces = $::postfix::params::inet_interfaces, $inet_protocols = $::postfix::params::inet_protocols, $masquerade_domains = $hostname, + $virtual_root = false, ) inherits postfix::params { if $remove_sendmail { @@ -77,4 +78,18 @@ ] } + if $virtual_root { + file { '/etc/postfix/virtual': + ensure => present, + content => 'root root@localhost', + require => Package['postfix'] + } + + exec { 'rebuild.virtual.db': + command => '/sbin/postmap /etc/postfix/virtual', + subscribe => File['/etc/postfix/virtual'], + refreshonly => true, + notify => Service['postfix'] + } + } } From ddcb0d3708f74499479efb0aaa01891a4b0fcb55 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Wed, 17 Jan 2024 16:10:49 +0100 Subject: [PATCH 6/9] Add .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index f583b53..5c61624 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,4 @@ _ReSharper*/ .vagrant/ pkg/ *~ +/.idea/ From 9176c62178a4e094a6cdcd2c3dfdaa9ff8b27126 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Wed, 17 Jan 2024 16:11:20 +0100 Subject: [PATCH 7/9] puppet-lint -f --- manifests/params.pp | 6 +++--- tests/set_relayport.pp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index 55c0298..3fa4b8b 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -23,7 +23,7 @@ # [Remember: No empty lines between comments and class definition] class postfix::params{ # Set OS family specific variables here, and test for supported OS families. - case $::osfamily{ + case $facts['os']['family']{ /Debian/: { $sendmail_ensure = 'purged' $package = 'postfix' @@ -39,10 +39,10 @@ $daemon_directory = '/usr/libexec/postfix' } default: { - fail("The postfix module does not support the ${::osfamily} family of operating systems.") + fail("The postfix module does not support the ${facts['os']['family']} family of operating systems.") } } - + # Set OS independent varibles here $sendmail_package = 'sendmail' $sendmailcf_package = 'sendmail-cf' diff --git a/tests/set_relayport.pp b/tests/set_relayport.pp index 2713237..506fa96 100644 --- a/tests/set_relayport.pp +++ b/tests/set_relayport.pp @@ -1,4 +1,4 @@ class{'postfix': - relayhost => 'smtp.example.org', - relayhost_port => '999', + relayhost => 'smtp.example.org', + relayhost_port => '999', } \ No newline at end of file From baf261f920a64615ae676cf519431fb69d9245b7 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Wed, 17 Jan 2024 16:15:05 +0100 Subject: [PATCH 8/9] Use $facts['networking']['fqdn'] instead of $hostname --- manifests/init.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 82fe216..7f04de7 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -36,7 +36,7 @@ $daemon_directory = $::postfix::params::daemon_directory, $inet_interfaces = $::postfix::params::inet_interfaces, $inet_protocols = $::postfix::params::inet_protocols, - $masquerade_domains = $hostname, + $masquerade_domains = $facts['networking']['fqdn'], $virtual_root = false, ) inherits postfix::params { From c327c60199b6636dcd438e361b41ba4fab63d774 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Tue, 23 Jan 2024 09:27:21 +0100 Subject: [PATCH 9/9] Update main.cf template to version 2.10.1 --- templates/main.cf.erb | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/templates/main.cf.erb b/templates/main.cf.erb index 8600a2e..4a56003 100644 --- a/templates/main.cf.erb +++ b/templates/main.cf.erb @@ -166,14 +166,14 @@ inet_protocols = <%= @inet_protocols %> # # See also below, section "REJECTING MAIL FOR UNKNOWN LOCAL USERS". # -#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain -#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain, -# mail.$mydomain, www.$mydomain, ftp.$mydomain <%- if @mydestination -%> mydestination = <%= @mydestination %> <%- else -%> mydestination = $myhostname, localhost.$mydomain, localhost <%- end -%> +#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain +#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain, +# mail.$mydomain, www.$mydomain, ftp.$mydomain # REJECTING MAIL FOR UNKNOWN LOCAL USERS # @@ -478,6 +478,8 @@ alias_database = hash:/etc/aliases # the main.cf file, otherwise the SMTP server will reject mail for # non-UNIX accounts with "User unknown in local recipient table". # +# Cyrus IMAP over LMTP. Specify ``lmtpunix cmd="lmtpd" +# listen="/var/imap/socket/lmtp" prefork=0'' in cyrus.conf. #mailbox_transport = lmtp:unix:/var/lib/imap/socket/lmtp # If using the cyrus-imapd IMAP server deliver local mail to the IMAP @@ -500,7 +502,8 @@ alias_database = hash:/etc/aliases # how many simultaneous LMTP sessions will be permitted to the Cyrus # message store. # -# To use the old cyrus deliver program you have to set: +# Cyrus IMAP via command line. Uncomment the "cyrus...pipe" and +# subsequent line in master.cf. #mailbox_transport = cyrus # The fallback_transport specifies the optional transport in master.cf @@ -685,10 +688,16 @@ manpage_directory = /usr/share/man # sample_directory: The location of the Postfix sample configuration files. # This parameter is obsolete as of Postfix 2.1. # -sample_directory = /usr/share/doc/postfix-2.6.6/samples +sample_directory = /usr/share/doc/postfix-2.10.1/samples # readme_directory: The location of the Postfix README files. # -readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES +readme_directory = /usr/share/doc/postfix-2.10.1/README_FILES + +# smtpd_forbid_bare_newline: disallow bare newline +# +#smtpd_forbid_bare_newline = yes +#smtpd_forbid_bare_newline_exclusions = $mynetworks masquerade_domains = <%= @masquerade_domains %> +