chiark
/
gitweb
/
~mdw
/
disorder
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
disobedience/disobedience.h: Declare variables as `extern'.
[disorder]
/
lib
/
sendmail.c
diff --git
a/lib/sendmail.c
b/lib/sendmail.c
index 5b9a82cb26eef9dfd0acd33ecd9a6e28b148dc68..0c5f4db0f7a70e9797a861169d561a5ea9fc79ab 100644
(file)
--- a/
lib/sendmail.c
+++ b/
lib/sendmail.c
@@
-57,20
+57,20
@@
static int getresponse(const char *tag, FILE *in) {
&& line[2] >= '0' && line[2] <= '9') {
const int rc = 10 * (10 * line[0] + line[1]) + line[2] - 111 * '0';
if(rc >= 400 && rc <= 599)
&& line[2] >= '0' && line[2] <= '9') {
const int rc = 10 * (10 * line[0] + line[1]) + line[2] - 111 * '0';
if(rc >= 400 && rc <= 599)
- error(0, "%s: %s", tag, line);
+
disorder_
error(0, "%s: %s", tag, line);
if(line[3] != '-') {
return rc;
}
/* else go round for further response lines */
} else {
if(line[3] != '-') {
return rc;
}
/* else go round for further response lines */
} else {
- error(0, "%s: malformed response: %s", tag, line);
+
disorder_
error(0, "%s: malformed response: %s", tag, line);
return -1;
}
}
if(ferror(in))
return -1;
}
}
if(ferror(in))
- error(errno, "%s: read error", tag);
+
disorder_
error(errno, "%s: read error", tag);
else
else
- error(0, "%s: server closed connection", tag);
+
disorder_
error(0, "%s: server closed connection", tag);
return -1;
}
return -1;
}
@@
-93,7
+93,7
@@
static int sendcommand(const char *tag, FILE *out, const char *fmt, ...) {
rc = fflush(out);
if(rc >= 0)
return 0;
rc = fflush(out);
if(rc >= 0)
return 0;
- error(errno, "%s: write error", tag);
+
disorder_
error(errno, "%s: write error", tag);
return -1;
}
return -1;
}
@@
-118,7
+118,7
@@
static int sendmailfp(const char *tag, FILE *in, FILE *out,
const char *encoding,
const char *content_type,
const char *body) {
const char *encoding,
const char *content_type,
const char *body) {
- int
rc,
sol = 1;
+ int sol = 1;
const char *ptr;
uint8_t idbuf[20];
char *id;
const char *ptr;
uint8_t idbuf[20];
char *id;
@@
-126,28
+126,28
@@
static int sendmailfp(const char *tag, FILE *in, FILE *out,
time_t now;
char date[128];
time_t now;
char date[128];
- time(&now);
+
x
time(&now);
gmtime_r(&now, &ut);
strftime(date, sizeof date, "%a, %d %b %Y %H:%M:%S +0000", &ut);
gcry_create_nonce(idbuf, sizeof idbuf);
id = mime_to_base64(idbuf, sizeof idbuf);
gmtime_r(&now, &ut);
strftime(date, sizeof date, "%a, %d %b %Y %H:%M:%S +0000", &ut);
gcry_create_nonce(idbuf, sizeof idbuf);
id = mime_to_base64(idbuf, sizeof idbuf);
- if(
(rc = getresponse(tag, in)
) / 100 != 2)
+ if(
getresponse(tag, in
) / 100 != 2)
return -1;
if(sendcommand(tag, out, "HELO %s", local_hostname()))
return -1;
return -1;
if(sendcommand(tag, out, "HELO %s", local_hostname()))
return -1;
- if(
(rc = getresponse(tag, in)
) / 100 != 2)
+ if(
getresponse(tag, in
) / 100 != 2)
return -1;
if(sendcommand(tag, out, "MAIL FROM:<%s>", sender))
return -1;
return -1;
if(sendcommand(tag, out, "MAIL FROM:<%s>", sender))
return -1;
- if(
(rc = getresponse(tag, in)
) / 100 != 2)
+ if(
getresponse(tag, in
) / 100 != 2)
return -1;
if(sendcommand(tag, out, "RCPT TO:<%s>", recipient))
return -1;
return -1;
if(sendcommand(tag, out, "RCPT TO:<%s>", recipient))
return -1;
- if(
(rc = getresponse(tag, in)
) / 100 != 2)
+ if(
getresponse(tag, in
) / 100 != 2)
return -1;
if(sendcommand(tag, out, "DATA", sender))
return -1;
return -1;
if(sendcommand(tag, out, "DATA", sender))
return -1;
- if(
(rc = getresponse(tag, in)
) / 100 != 3)
+ if(
getresponse(tag, in
) / 100 != 3)
return -1;
if(fprintf(out, "From: %s\r\n", pubsender) < 0
|| fprintf(out, "To: %s\r\n", recipient) < 0
return -1;
if(fprintf(out, "From: %s\r\n", pubsender) < 0
|| fprintf(out, "To: %s\r\n", recipient) < 0
@@
-159,7
+159,7
@@
static int sendmailfp(const char *tag, FILE *in, FILE *out,
|| fprintf(out, "Date: %s\r\n", date) < 0
|| fprintf(out, "\r\n") < 0) {
write_error:
|| fprintf(out, "Date: %s\r\n", date) < 0
|| fprintf(out, "\r\n") < 0) {
write_error:
- error(errno, "%s: write error", tag);
+
disorder_
error(errno, "%s: write error", tag);
return -1;
}
for(ptr = body; *ptr; ++ptr) {
return -1;
}
for(ptr = body; *ptr; ++ptr) {
@@
-181,7
+181,7
@@
static int sendmailfp(const char *tag, FILE *in, FILE *out,
if(fprintf(out, ".\r\n") < 0
|| fflush(out) < 0)
goto write_error;
if(fprintf(out, ".\r\n") < 0
|| fflush(out) < 0)
goto write_error;
- if(
(rc = getresponse(tag, in)
) / 100 != 2)
+ if(
getresponse(tag, in
) / 100 != 2)
return -1;
return 0;
}
return -1;
return 0;
}
@@
-237,7
+237,7
@@
int sendmail(const char *sender,
xdup2(outpipe[1], 1);
execlp(config->sendmail,
config->sendmail, "-bs", (char *)0);
xdup2(outpipe[1], 1);
execlp(config->sendmail,
config->sendmail, "-bs", (char *)0);
- fatal(errno, "executing %s", config->sendmail);
+
disorder_
fatal(errno, "executing %s", config->sendmail);
}
xclose(inpipe[0]);
xclose(outpipe[1]);
}
xclose(inpipe[0]);
xclose(outpipe[1]);
@@
-253,17
+253,17
@@
int sendmail(const char *sender,
return -1;
fdin = xsocket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
if(connect(fdin, ai->ai_addr, ai->ai_addrlen) < 0) {
return -1;
fdin = xsocket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
if(connect(fdin, ai->ai_addr, ai->ai_addrlen) < 0) {
- error(errno, "error connecting to %s", tag);
+
disorder_
error(errno, "error connecting to %s", tag);
xclose(fdin);
return -1;
}
if((fdout = dup(fdin)) < 0)
xclose(fdin);
return -1;
}
if((fdout = dup(fdin)) < 0)
- fatal(errno, "error calling dup2");
+
disorder_
fatal(errno, "error calling dup2");
}
if(!(in = fdopen(fdin, "rb")))
}
if(!(in = fdopen(fdin, "rb")))
- fatal(errno, "error calling fdopen");
+
disorder_
fatal(errno, "error calling fdopen");
if(!(out = fdopen(fdout, "wb")))
if(!(out = fdopen(fdout, "wb")))
- fatal(errno, "error calling fdopen");
+
disorder_
fatal(errno, "error calling fdopen");
rc = sendmailfp(tag, in, out, sender, pubsender, recipient, subject,
encoding, content_type, body);
fclose(in);
rc = sendmailfp(tag, in, out, sender, pubsender, recipient, subject,
encoding, content_type, body);
fclose(in);
@@
-274,9
+274,9
@@
int sendmail(const char *sender,
while(waitpid(pid, &w, 0) < 0 && errno == EINTR)
;
if(w < 0)
while(waitpid(pid, &w, 0) < 0 && errno == EINTR)
;
if(w < 0)
- fatal(errno, "error calling waitpid");
+
disorder_
fatal(errno, "error calling waitpid");
if(w)
if(w)
- info("warning: %s -bs: %s", config->sendmail, wstat(w));
+
disorder_
info("warning: %s -bs: %s", config->sendmail, wstat(w));
/* Not fatal - we determine success/failure from the SMTP conversation.
* Some MTAs exit nonzero if you don't QUIT, which is just stupidly
* picky. */
/* Not fatal - we determine success/failure from the SMTP conversation.
* Some MTAs exit nonzero if you don't QUIT, which is just stupidly
* picky. */
@@
-311,7
+311,7
@@
pid_t sendmail_subprocess(const char *sender,
_exit(0);
}
if(pid < 0)
_exit(0);
}
if(pid < 0)
- error(errno, "error calling fork");
+
disorder_
error(errno, "error calling fork");
return pid;
}
return pid;
}