qmail-local: Sender and environment settings in .qmail files.
authorMark Wooding <mdw@distorted.org.uk>
Wed, 29 Mar 2006 12:39:50 +0000 (13:39 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Wed, 29 Mar 2006 12:39:50 +0000 (13:39 +0100)
Support `!VAR=VALUE', and `!VAR' lines, to set and delete environment
variable VAR.  Also support `<SENDER' to set the envelope sender for
further forwardings.

dot-qmail.9
qmail-local.c

index 4fa1358..651726a 100644 (file)
@@ -39,7 +39,28 @@ A comment line begins with a number sign:
 .EE
 
 .B qmail-local
-ignores the line.
+ignores the line.  However,
+.BR qmail-valid-addresses (8)
+interprets some markers in comments.  If the first line of a
+.B .qmail
+file begins `#!' then the address (or addresses) controlled by the file
+are considered invalid, and any attempt to send to them is refused by
+.BR qmail-smtpd (8).
+(Note: This doesn't prevent local users sending mail directly.  This
+feature can therefore be used to experiment with mail rules before
+allowing the entire Internet to break them.)  If the first line of a
+.B .qmail
+file begins `#?' then 
+.BR qmail-smtpd (8)
+will consult a Userv service
+.BI addrcheck: ext
+to decide whether addresses matched by the extension
+.I ext
+are valid.  The service is passed many arguments, though the first two
+are the most interesting.  The first is the local-part tail (i.e., the
+bit that matched
+.BR default )
+and the second is the envelope sender.
 .TP 5
 (2)
 A program line begins with a vertical bar:
@@ -152,6 +173,25 @@ It reliably stores the incoming message in that directory.
 See
 .B maildir(5)
 for more details.
+.TP 5
+(6)
+An
+.I sender
+line begins with a less-than-sign `<'.  The remainder of the line is set
+as the new envelope sender for any forwarding done through this file.
+.TP 5
+(7)
+An
+.I environment
+line begins with an exclamation mark `!'.  If the remainder of the line
+has the form
+.IB var = value
+then the environment variable
+.I var
+is set to 
+.I value
+for the following program deliveries.  If there is no equals sign, the
+named environment variable is deleted.
 .PP
 If
 .B .qmail
index ec4e5e7..b6dd28c 100644 (file)
@@ -775,6 +775,12 @@ char **argv;
          strerr_die1x(111,"Uh-oh: first line of .qmail file is blank. (#4.2.1)");
        case '#':
          break;
+       case '<':
+        if (!stralloc_copys(&ueo, cmds.s + i + 1) ||
+            !stralloc_0(&ueo) ||
+            !env_put2("NEWSENDER", ueo.s))
+          temp_nomem();
+        break;
        case '.':
        case '/':
         ++count_file;
@@ -798,7 +804,20 @@ char **argv;
         break;
        case '&':
          ++i;
+        goto fwd;
+       case '!':
+        i++;
+        if (!cmds.s[i + str_chr(cmds.s + i, '=')]) {
+          if (!env_unset(cmds.s + i)) temp_nomem();
+        } else {
+        env:
+          if (!env_put(cmds.s + i)) temp_nomem();
+        }
+        break;
        default:
+        if (cmds.s[i + str_chr(cmds.s + i, '=')])
+          goto env;
+       fwd:
         ++count_forward;
          if (flagdoit) recips[numforward++] = cmds.s + i;
          else sayit("forward ",cmds.s + i,k - i);