scan a hostname through disallowed host list if any (doesn't do b32 checking)
Signed-off-by: AGentooCat <agentoocat@mail.i2p>
This commit is contained in:
@ -382,6 +382,7 @@ int sam_disconnect(struct lineconn_t *hand) {
|
||||
struct smtp_conn_state *state = (struct smtp_conn_state*)hand->data;
|
||||
log(DEBUG, "Closing SAM connection at FD %d", hand->fd);
|
||||
xfree(state->_from);
|
||||
freemail(&state->mail);
|
||||
for (long i = 0; i < state->_tol; i++)
|
||||
xfree(state->_tos[i]);
|
||||
if (state->tos) free(state->tos);
|
||||
|
13
src/smtp.c
13
src/smtp.c
@ -158,6 +158,14 @@ int is_user_allowed(char *user) {
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
int is_host_allowed(char *host) {
|
||||
if (gloconf->disallowed_hosts) {
|
||||
for (long i = 0; gloconf->disallowed_hosts[i]; i++)
|
||||
if (!strcmp(host, gloconf->disallowed_hosts[i]))
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char *postmen[] = {
|
||||
"pop.postman.i2p",
|
||||
@ -266,10 +274,12 @@ int smtp_line(struct lineconn_t *hand) {
|
||||
msg = "550 MAIL FROM was already given";
|
||||
break;
|
||||
}
|
||||
char *hostname = strchr(com->argv[0], '@') + 1;
|
||||
if (state->is_incoming) {
|
||||
if (!is_host_allowed(hostname))
|
||||
goto smtplinefail;
|
||||
char *b32peer = b64to32(hand->edata);
|
||||
if (!b32peer) goto smtplinefail;
|
||||
char *hostname = strchr(com->argv[0], '@') + 1;
|
||||
struct I2Host *host = lookup_host(NULL, hostname);
|
||||
int host_good = 1;
|
||||
if (!host || host->mailsrvl == 0) {
|
||||
@ -306,7 +316,6 @@ int smtp_line(struct lineconn_t *hand) {
|
||||
log(DEBUG, "MAIL FROM (%s) = [%s(%s) -> %s]", host_good ? "verified" : "BAD but allowed", com->argv[0], state->mail.from, b32peer);
|
||||
xfree(b32peer);
|
||||
} else {
|
||||
char *hostname = strchr(com->argv[0], '@');
|
||||
*hostname = 0;
|
||||
asprintf(&state->mail.from, "%s@%s", com->argv[0], mehost->b32addr);
|
||||
*hostname = '@';
|
||||
|
Reference in New Issue
Block a user