Files
labca/notify-mailer_main.patch
2021-07-16 11:54:06 +02:00

63 lines
1.7 KiB
Diff

diff --git a/cmd/notify-mailer/main.go b/cmd/notify-mailer/main.go
index fa2aac74e..08430ee10 100644
--- a/cmd/notify-mailer/main.go
+++ b/cmd/notify-mailer/main.go
@@ -37,6 +37,7 @@ type mailer struct {
recipients []recipient
targetRange interval
sleepInterval time.Duration
+ pa *policy.AuthorityImpl
}
// interval defines a range of email addresses to send to in alphabetical order.
@@ -151,7 +152,7 @@ func (m *mailer) run() error {
continue
}
- if err := policy.ValidEmail(address); err != nil {
+ if err := m.pa.ValidEmail(address); err != nil {
m.log.Infof("Skipping %q due to policy violation: %s", address, err)
continue
}
@@ -477,7 +478,9 @@ func main() {
NotifyMailer struct {
DB cmd.DBConfig
cmd.SMTPConfig
+ cmd.HostnamePolicyConfig
}
+ PA cmd.PAConfig
Syslog cmd.SyslogConfig
}
@@ -531,6 +534,14 @@ func main() {
log.Infof("While reading the recipient list file %s", probs)
}
+ // Validate PA config and set defaults if needed
+ cmd.FailOnError(cfg.PA.CheckChallenges(), "Invalid PA configuration")
+
+ pa, err := policy.New(cfg.PA.Challenges)
+ cmd.FailOnError(err, "Failed to create PA")
+ err = pa.SetHostnamePolicyFile(cfg.NotifyMailer.HostnamePolicyFile)
+ cmd.FailOnError(err, "Failed to load HostnamePolicyFile")
+
var mailClient bmail.Mailer
if *dryRun {
log.Infof("Starting %s in dry-run mode", cmd.VersionString())
@@ -546,6 +557,7 @@ func main() {
cfg.NotifyMailer.Username,
smtpPassword,
nil,
+ nil,
*address,
log,
metrics.NoopRegisterer,
@@ -566,6 +578,7 @@ func main() {
end: *end,
},
sleepInterval: *sleep,
+ pa: pa,
}
err = m.run()