summaryrefslogtreecommitdiff
path: root/src/qmail-dkverify.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/qmail-dkverify.c')
-rw-r--r--src/qmail-dkverify.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/qmail-dkverify.c b/src/qmail-dkverify.c
index be73a80..8e4d51e 100644
--- a/src/qmail-dkverify.c
+++ b/src/qmail-dkverify.c
@@ -8,6 +8,7 @@
#include "buffer.h"
#include "error.h"
#include "auto_qmail.h"
+#include "auto_queue.h"
#include "str.h"
#include "exit.h"
#include "uint_t.h"
@@ -47,8 +48,8 @@ char outbuf[BUFSIZE_MESS];
buffer bo = BUFFER_INIT(write,1,outbuf,sizeof(outbuf)); // output message
void die(int e) { _exit(e); }
-void die_pipe(char *fn) { unlink(fn); die(53); };
-void die_write(char *fn) { unlink(fn); die(53); };
+void die_pipe(char *fn) { unlink(fn); die(54); };
+void die_write(char *fn) { unlink(fn); die(62); };
void die_read() { die(54); };
void out(char *s) { if (buffer_puts(&bo,s) == -1) _exit(111); }
void zero() { if (buffer_put(&bo,"\0",1) == -1) _exit(111); }
@@ -112,6 +113,8 @@ void dkim_stage()
struct stat st;
char tmpbuf[BUFSIZE_MESS + 2];
+ if (chdir(auto_queue) == -1) temp_chdir();
+
if (!stralloc_ready(&fndkin,FMTQFN)) temp_nomem();
if (!stralloc_ready(&fndkout,FMTQFN)) temp_nomem();
@@ -159,8 +162,8 @@ int mess_dkim()
buffer_init(&bi,read,fd,inbuf,sizeof(inbuf));
if (!stralloc_copys(&senddomain,"")) temp_nomem();
-
- for (;;) {
+
+ for (;;) {
if (getln(&bi,&line,&match,'\n') == -1) temp_read();
if (case_starts(line.s,"DKIM-Signature: ")) r = 1;
if (r == 1) {
@@ -170,7 +173,11 @@ int mess_dkim()
end = str_chr(line.s,'\n'); // From: user@senddomain\n
ket = str_chr(line.s,'>'); // From: User <user@senddomain>
len = (ket < end) ? ket : end;
- if (!stralloc_copyb(&senddomain,line.s + at + 1,len - at - 1)) temp_nomem();
+ len -= at - 1; // From: User <user@>
+ if (len > 0) {
+ if (!stralloc_copyb(&senddomain,line.s + at + 1,len)) temp_nomem();
+ } else
+ if (!stralloc_copys(&senddomain,"unknown")) temp_nomem();
r = 2;
}
}
@@ -326,8 +333,6 @@ int qmail_queue()
case 10: return 1;
default: return 0;
}
-
- return 0;
}
void dkim_unlink()