Commit ab1dc55f authored by ale's avatar ale
Browse files

Report lurker-index errors to client

parent 64ce65b7
Pipeline #3952 passed with stages
in 3 minutes
......@@ -25,7 +25,7 @@ var (
port = flag.Int("port", getenvInt("SMTP_PORT"), "smtp port")
hostname = flag.String("ehlo-hostname", os.Getenv("SMTP_EHLO_HOSTNAME"), "EHLO hostname")
lurkerLibDir = flag.String("lurker-lib-dir", os.Getenv("LURKER_LIB_DIR"), "lurker library dir")
addrPattern = flag.String("addr-rx", getenvDefault("LURKER_ADDR_RX", "lurker+([^@]+)@.*"), "recipient address regular expression")
addrPattern = flag.String("addr-rx", getenvDefault("LURKER_ADDR_RX", `lurker\+([^@]+)@.*`), "recipient address regular expression")
)
var addrRx *regexp.Regexp
......@@ -50,8 +50,13 @@ func isMaintenanceModeOn() bool {
func lurkerIndexMsg(listName string, data []byte) error {
cmd := exec.Command("lurker-index", "-m", "-l", listName)
cmd.Stdin = bytes.NewReader(data)
cmd.Stderr = os.Stderr
return cmd.Run()
out, err := cmd.CombinedOutput()
if err != nil {
outStr := strings.Replace(strings.TrimSpace(string(out)), "\n", "; ", -1)
log.Printf("lurker-index error: %v, %s", err, outStr)
return smtpd.Error{550, outStr}
}
return nil
}
func parseRecipientAddr(addr string) (string, error) {
......@@ -83,7 +88,7 @@ func handleMessage(peer smtpd.Peer, env smtpd.Envelope) error {
return err
}
if err := lurkerIndexMsg(listName, env.Data); err != nil {
return smtpd.Error{550, fmt.Sprintf("lurker-index error: %v", err)}
return err
}
}
return nil
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment