The attached patch adds 2 control files to qmail-ldap 20020501a:
-- control/replyaddfrom: defines the string attached to the from line in
mails generated by qmail-reply
example: echo " (Auto-Reply)" > control/replyaddfrom
-- control/replyaddsub: defines the subject prefix in mails generated by
qmail-reply
exmaple: echo "[This is an auto-reply] " > control/replyaddfrom
This also includes Claudio Jeker's patch to fix the "Return-Path".
I find this useful.
--
Jose Celestino <[EMAIL PROTECTED]> SAPO.pt::Systems http://www.sapo.pt
---------------------------------------------------------------------
Our bugs run faster.
*** qmail-1.03/qmail-reply.c Fri Jul 5 13:23:52 2002
--- qmail-1.03.ok/qmail-reply.c Fri Jul 5 13:22:16 2002
***************
*** 16,21 ****
--- 16,24 ----
#include "byte.h"
#include "fd.h"
#include "qmail-ldap.h"
+ #include "control.h"
+ #include "subfd.h"
+ #include "qldap-debug.h"
/* some error-handling funktions */
void temp_nomem() { strerr_die1x(111,"Out of memory. (LDAP-ERR #4.5.0)"); }
***************
*** 23,28 ****
--- 26,34 ----
void temp_childcrashed() { strerr_die1x(111,"Aack, child crashed. (LDAP-ERR
#4.5.0)"); }
void temp_fork() { strerr_die3x(111,"Unable to fork: ",error_str(errno),". (LDAP-ERR
#4.5.0)"); }
void temp_read() { strerr_die3x(111,"Unable to read message: ",error_str(errno),".
(LDAP-ERR #4.5.0)"); }
+ void die_temp() { _exit(111); }
+ void die_nomem() { substdio_putsflush(subfderr,"qreceipt: fatal: out of memory\n");
+die_temp(); }
+ void log_control() { log ("qmail-reply unable to read controls"); }
/* function prototypes */
void check_header_and_get_subject(void);
***************
*** 46,51 ****
--- 52,58 ----
stralloc dtline={0};
stralloc prog={0};
stralloc line = {0};
+ stralloc foo = {0};
/* a match function */
static int wild_matchb(register char* pattern, register unsigned int pat_len, \
***************
*** 101,106 ****
--- 108,127 ----
strerr_die1x(111,"RECIPIENT not present (LDAP-ERR #4.1.4)");
}
+ i = byte_chr(from.s, from.len, '@');
+ if ( i == 0 || i >= from.len )
+ strerr_die1x(111,"Bad RECIPIENT address (LDAP-ERR #4.1.5)");
+
+ if (!stralloc_copys(&foo,"QMAILSUSER=")) temp_nomem();
+ if (!stralloc_catb(&foo,from.s, i)) temp_nomem();
+ if (!stralloc_0(&foo)) temp_nomem();
+ if (!env_put(foo.s)) temp_nomem();
+
+ if (!stralloc_copys(&foo,"QMAILSHOST=")) temp_nomem();
+ if (!stralloc_catb(&foo,from.s+i+1, from.len - i - 1)) temp_nomem();
+ if (!stralloc_0(&foo)) temp_nomem();
+ if (!env_put(foo.s)) temp_nomem();
+
check_header_and_get_subject();
send_reply();
***************
*** 168,173 ****
--- 189,196 ----
int child;
int pi[2];
int wstat;
+ stralloc replyaddfrom = {0};
+ stralloc replyaddsub = {0};
if (!stralloc_copys(&prog, auto_qmail)) temp_nomem();
if (!stralloc_cats(&prog, "/bin/datemail")) temp_nomem();
***************
*** 187,192 ****
--- 210,225 ----
strerr_die5x(111,"Unable to run ",prog.s,":
",error_str(errno),". (LDAP-ERR #4.4.0)");
}
+ if (chdir(auto_qmail) == -1) log_control();
+
+ if (control_readline(&replyaddfrom,"control/replyaddfrom") != 1) {
+ if (!stralloc_copys(&replyaddfrom," (via the qmail-reply program)"))
+die_nomem();
+ }
+
+ if (control_readline(&replyaddsub,"control/replyaddsub") != 1) {
+ if (!stralloc_copys(&replyaddsub,"[Auto-Reply] ")) die_nomem();
+ }
+
close(pi[0]);
write(pi[1],dtline.s,dtline.len);
write(pi[1],"Precedence: junk\n", 17);
***************
*** 194,202 ****
write(pi[1],to.s, to.len);
write(pi[1], "\nFrom: ", 7);
write(pi[1], from.s, from.len);
! write(pi[1], " (via the qmail-reply program)", 30);
write(pi[1], "\nSubject: ", 10);
! write(pi[1], "[Auto-Reply] ", 13);
write(pi[1], subject.s, subject.len);
write(pi[1], "\n", 1);
write(pi[1],replytext.s,replytext.len);
--- 227,235 ----
write(pi[1],to.s, to.len);
write(pi[1], "\nFrom: ", 7);
write(pi[1], from.s, from.len);
! write(pi[1], replyaddfrom.s, replyaddfrom.len);
write(pi[1], "\nSubject: ", 10);
! write(pi[1], replyaddsub.s, replyaddsub.len);
write(pi[1], subject.s, subject.len);
write(pi[1], "\n", 1);
write(pi[1],replytext.s,replytext.len);