Skip to content

Commit

Permalink
fb_postfix: default to lmdb maps for el10 and later (#235)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #235

Upstream dropped support for libdb in
https://src.fedoraproject.org/rpms/postfix/c/6a2621e4d73d59337dc64ba45922132286b841a1
so we need to use lmdb in RHEL 10 and later

Differential Revision: D54077466

fbshipit-source-id: 7045a9762ce0390d485c20f9ff2818ccf41fedb5
  • Loading branch information
davide125 authored and facebook-github-bot committed Feb 23, 2024
1 parent 3e25d03 commit 5433642
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
18 changes: 13 additions & 5 deletions cookbooks/fb_postfix/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# RHEL 10 and later don't support hash maps anymore
# https://src.fedoraproject.org/rpms/postfix/c/6a2621e4d73d59337dc64ba45922132286b841a1
if node.el_min_version?(10) || node.eln?
map_type = 'lmdb'
else
map_type = 'hash'
end

default['fb_postfix'] = {
'enable' => true,
'mask_service' => false,
Expand All @@ -32,21 +40,21 @@
'mail_owner' => 'postfix',
'mynetworks' => '/etc/postfix/mynetworks',
'relay_domains' => '/etc/postfix/relaydomains',
'alias_maps' => 'hash:/etc/postfix/aliases',
'alias_maps' => "#{map_type}:/etc/postfix/aliases",
'recipient_delimiter' => '+',
'smtpd_banner' => '$myhostname ESMTP',
'debug_peer_level' => 2,
'debugger_command' =>
'PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ' +
'ddd $daemon_directory/$process_name $process_id & sleep 5',
'newaliases_path' => '/usr/bin/newaliases.postfix',
'alias_database' => 'hash:/etc/postfix/aliases',
'alias_database' => "#{map_type}:/etc/postfix/aliases",
'disable_vrfy_command' => 'yes',
'smtpd_client_restrictions' =>
'hash:/etc/postfix/access, permit_mynetworks',
"#{map_type}:/etc/postfix/access, permit_mynetworks",
'smtpd_helo_required' => 'yes',
'smtpd_recipient_restrictions' =>
'check_recipient_access hash:/etc/postfix/local_access,' +
"check_recipient_access #{map_type}:/etc/postfix/local_access," +
'permit_mynetworks, reject_unauth_destination',
'biff' => 'no',
'require_home_directory' => 'no',
Expand Down Expand Up @@ -95,7 +103,7 @@
'smtpd_hard_error_limit' => '10',
'smtpd_recipient_limit' => '1000',
'smtpd_sender_restrictions' =>
'reject_unknown_sender_domain, hash:/etc/postfix/access',
"reject_unknown_sender_domain, #{map_type}:/etc/postfix/access",
'smtpd_soft_error_limit' => '5',
'smtpd_timeout' => '120s',
'smtp_sasl_auth_enable' => nil,
Expand Down
12 changes: 10 additions & 2 deletions cookbooks/fb_postfix/recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@
action :nothing
end

# RHEL 10 and later don't support hash maps anymore
# https://src.fedoraproject.org/rpms/postfix/c/6a2621e4d73d59337dc64ba45922132286b841a1
if node.el_min_version?(10) || node.eln?
map_type = 'lmdb'
else
map_type = 'hash'
end

%w{
access
canonical
Expand All @@ -115,14 +123,14 @@
else
mode '0644'
end
notifies :run, "execute[postmap #{text_map}]", :immediately
notifies :run, "execute[postmap #{map_type}:#{text_map}]", :immediately
notifies :reload, 'service[postfix]'
variables(
:db_file => text_map_rel,
)
end

execute "postmap #{text_map}" do
execute "postmap #{map_type}:#{text_map}" do
action :nothing
end
end
Expand Down

0 comments on commit 5433642

Please sign in to comment.