set ORIGINAL_RECIPIENT in the environment of mda scripts
authorop <op@openbsd.org>
Fri, 15 Mar 2024 21:52:20 +0000 (21:52 +0000)
committerop <op@openbsd.org>
Fri, 15 Mar 2024 21:52:20 +0000 (21:52 +0000)
mostly for compatibility with postfix since some mdas (like
public-inbox) make use of it.

diff from Philipp (philipp+openbsd [at] bureaucracy [dot] de)
ok gilles@

usr.sbin/smtpd/mda_unpriv.c

index 1d59550..2c097fc 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: mda_unpriv.c,v 1.8 2021/06/14 17:58:15 eric Exp $     */
+/*     $OpenBSD: mda_unpriv.c,v 1.9 2024/03/15 21:52:20 op Exp $       */
 
 /*
  * Copyright (c) 2018 Gilles Chehade <gilles@poolp.org>
@@ -28,7 +28,7 @@ mda_unpriv(struct dispatcher *dsp, struct deliver *deliver,
     const char *pw_name, const char *pw_dir)
 {
        int             idx;
-       char           *mda_environ[11];
+       char           *mda_environ[12];
        char            mda_exec[LINE_MAX];
        char            mda_wrapper[LINE_MAX];
        const char     *mda_command;
@@ -54,6 +54,7 @@ mda_unpriv(struct dispatcher *dsp, struct deliver *deliver,
        xasprintf(&mda_environ[idx++], "PATH=%s", _PATH_DEFPATH);
        xasprintf(&mda_environ[idx++], "DOMAIN=%s", deliver->rcpt.domain);
        xasprintf(&mda_environ[idx++], "HOME=%s", pw_dir);
+       xasprintf(&mda_environ[idx++], "ORIGINAL_RECIPIENT=%s@%s", deliver->rcpt.user, deliver->rcpt.domain);
        xasprintf(&mda_environ[idx++], "RECIPIENT=%s@%s", deliver->dest.user, deliver->dest.domain);
        xasprintf(&mda_environ[idx++], "SHELL=/bin/sh");
        xasprintf(&mda_environ[idx++], "LOCAL=%s", deliver->rcpt.user);