diff --git a/.gitignore b/.gitignore index f583b53..5c61624 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,4 @@ _ReSharper*/ .vagrant/ pkg/ *~ +/.idea/ 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..7f04de7 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -35,6 +35,9 @@ $relayhost_port = undef, $daemon_directory = $::postfix::params::daemon_directory, $inet_interfaces = $::postfix::params::inet_interfaces, + $inet_protocols = $::postfix::params::inet_protocols, + $masquerade_domains = $facts['networking']['fqdn'], + $virtual_root = false, ) inherits postfix::params { if $remove_sendmail { @@ -75,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'] + } + } } diff --git a/manifests/params.pp b/manifests/params.pp index c43806e..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,13 +39,14 @@ $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' $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..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 =} @@ -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..4a56003 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 @@ -166,14 +166,14 @@ inet_protocols = all # # 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,8 +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 %> + 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