Commit 5f72f723 authored by Alberto Bertogli's avatar Alberto Bertogli

smtpsrv: Clean up post-data hook tracing output

This patch does some cleanups on the tracing output for the post-data
hook, to quote the output better and more consistently.
parent 5782a770
......@@ -741,7 +741,6 @@ func (c *Conn) runPostDataHook(data []byte) ([]byte, bool, error) {
tr := trace.New("Hook.Post-DATA", c.conn.RemoteAddr().String())
defer tr.Finish()
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute)
defer cancel()
......@@ -769,14 +768,14 @@ func (c *Conn) runPostDataHook(data []byte) ([]byte, bool, error) {
cmd.Env = append(cmd.Env, "SPF_PASS="+boolToStr(c.spfResult == spf.Pass))
out, err := cmd.Output()
tr.Debugf("stdout: %q", out)
if err != nil {
hookResults.Add("post-data:fail", 1)
tr.Debugf("stdout: %s", out)
permanent := false
if ee, ok := err.(*exec.ExitError); ok {
tr.Printf("stderr: %s", string(ee.Stderr))
tr.Printf("stderr: %q", string(ee.Stderr))
if status, ok := ee.Sys().(syscall.WaitStatus); ok {
permanent = status.ExitStatus() == 20
......@@ -792,12 +791,11 @@ func (c *Conn) runPostDataHook(data []byte) ([]byte, bool, error) {
// contents. If it does not, just skip it.
if !isHeader(out) {
hookResults.Add("post-data:badoutput", 1)
tr.Errorf("error parsing post-data output: '%s'", out)
tr.Errorf("error parsing post-data output: %q", out)
return nil, false, nil
tr.Debugf("stdout: %s", out)
hookResults.Add("post-data:success", 1)
return out, false, nil
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment