Skip to content

Commit 6c902a4

Browse files
committed
Fixes #32827 - Add sendmail config options
As part of CVE-2021-3584 the option email_sendmail_location was limited to just 4 choices. This allows admins to set it via settings.yaml. The idea is that if you can edit settings.yaml, you're already compromised while UI could be less protected. When a setting is present in settings.yaml, the option becomes read-only in the UI. If the options are not set, they don't show up in settings.yaml.
1 parent 8bfb8ce commit 6c902a4

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

manifests/init.pp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
#
2121
# $email_delivery_method:: Email delivery method
2222
#
23+
# $email_sendmail_location:: The location of the binary to call when sendmail is the delivery method. Unused when SMTP delivery is used.
24+
#
25+
# $email_sendmail_arguments:: The arguments to pass to the sendmail binary. Unused when SMTP delivery is used.
26+
#
2327
# $email_smtp_address:: SMTP server hostname, when delivery method is SMTP
2428
#
2529
# $email_smtp_port:: SMTP port
@@ -264,6 +268,8 @@
264268
Enum['pattern', 'multiline_pattern', 'multiline_request_pattern', 'json'] $logging_layout = $foreman::params::logging_layout,
265269
Hash[String, Boolean] $loggers = $foreman::params::loggers,
266270
Optional[Enum['sendmail', 'smtp']] $email_delivery_method = $foreman::params::email_delivery_method,
271+
Optional[Stdlib::Absolutepath] $email_sendmail_location = $foreman::params::email_sendmail_location,
272+
Optional[String[1]] $email_sendmail_arguments = $foreman::params::email_sendmail_arguments,
267273
Optional[Stdlib::Host] $email_smtp_address = $foreman::params::email_smtp_address,
268274
Stdlib::Port $email_smtp_port = $foreman::params::email_smtp_port,
269275
Optional[Stdlib::Fqdn] $email_smtp_domain = $foreman::params::email_smtp_domain,

manifests/params.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545

4646
# Configure foreman email settings (database or email.yaml)
4747
$email_delivery_method = undef
48+
$email_sendmail_location = undef
49+
$email_sendmail_arguments = undef
4850
$email_smtp_address = undef
4951
$email_smtp_port = 25
5052
$email_smtp_domain = undef

spec/classes/foreman_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@
225225
logging_level: 'info',
226226
loggers: {},
227227
email_delivery_method: 'sendmail',
228+
email_sendmail_location: '/usr/bin/mysendmail',
229+
email_sendmail_arguments: '--myargument',
228230
email_smtp_address: 'smtp.example.com',
229231
email_smtp_port: 25,
230232
email_smtp_domain: 'example.com',
@@ -247,6 +249,8 @@
247249

248250
it 'should configure certificates in settings.yaml' do
249251
is_expected.to contain_concat__fragment('foreman_settings+01-header.yaml')
252+
.with_content(%r{^:email_sendmail_location: "/usr/bin/mysendmail"$})
253+
.with_content(%r{^:email_sendmail_arguments: "--myargument"$})
250254
.with_content(%r{^:websockets_ssl_key: /etc/ssl/private/snakeoil-ws\.pem$})
251255
.with_content(%r{^:websockets_ssl_cert: /etc/ssl/certs/snakeoil-ws\.pem$})
252256
end

templates/settings.yaml.erb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@
7171
:enabled: <%= scope.lookupvar("foreman::telemetry_logger_enabled") %>
7272
# logging level as in Logger::LEVEL
7373
:level: '<%= scope.lookupvar("foreman::telemetry_logger_level") %>'
74+
<% if scope.lookupvar("foreman::email_sendmail_location") || scope.lookupvar("foreman::email_sendmail_arguments") -%>
75+
76+
# Email settings
77+
<% if scope.lookupvar("foreman::email_sendmail_location") -%>
78+
:email_sendmail_location: "<%= scope.lookupvar("foreman::email_sendmail_location") %>"
79+
<% end -%>
80+
<% if scope.lookupvar("foreman::email_sendmail_arguments") -%>
81+
:email_sendmail_arguments: "<%= scope.lookupvar("foreman::email_sendmail_arguments") %>"
82+
<% end -%>
83+
<% end -%>
7484

7585
<% if scope.lookupvar("foreman::dynflow_manage_services") -%>
7686
:dynflow:

0 commit comments

Comments
 (0)