1
0
Fork 0

MM4_Forward.RES fix

This commit is contained in:
bagyenda 2011-09-20 03:59:02 +00:00
parent 0d2974bd27
commit 5cd58210fe
5 changed files with 48 additions and 39 deletions

View File

@ -1,3 +1,5 @@
2011-09-20 P. A. Bagyenda <bagyenda@dsmagic.com>
* Fix: MM4_Forward.RES should include original msg ID (thanks to Franz Schwartau (franz@eletromail.org)
2011-09-08 P. A. Bagyenda <bagyenda@dsmagic.com>
* Exposed more functions in lib (get_stripped_param_value)
* Minor changes to mms_msg module

View File

@ -2641,3 +2641,39 @@ Octstr *get_keyword_from_mime(MIMEEntity *me)
return keyword;
}
int http_auth_check(char *user, char *pass, List *headers, int *has_auth_hdr)
{
int i, res = -1;
Octstr *v = http_header_value(headers, octstr_imm("Authorization"));
Octstr *p = NULL, *q = NULL;
*has_auth_hdr = (v != NULL);
if (user == NULL || user[0] == 0) {
res = 0;
goto done;
}
if (!v ||
octstr_search(v, octstr_imm("Basic "), 0) != 0)
goto done;
p = octstr_copy(v, sizeof "Basic", octstr_len(v));
octstr_base64_to_binary(p);
i = octstr_search_char(p, ':', 0);
q = octstr_copy(p, i+1, octstr_len(p));
octstr_delete(p, i, octstr_len(p));
/* p = user, q = pass. */
if (octstr_str_compare(p,user) != 0 ||
octstr_str_compare(q,pass) != 0)
res = -1;
else
res = 0;
done:
octstr_destroy(v);
octstr_destroy(p);
octstr_destroy(q);
return res;
}

View File

@ -264,6 +264,9 @@ Octstr *parse_rfc2047_text(Octstr *in, int *mibenum);
/* Utility func */
void mygw_free(void *);
/* Authenticate using HTTP Basic auth */
int http_auth_check(char *user, char *pass, List *headers, int *has_auth_hdr);
/* Get (copy of) keyword from mime thingie */
Octstr *get_keyword_from_mime(MIMEEntity *me);
#define US_ASCII_MIB_VAL 3

View File

@ -40,41 +40,6 @@
} while(0)
static int auth_check(Octstr *user, Octstr *pass, List *headers, int *has_auth_hdr)
{
int i, res = -1;
Octstr *v = http_header_value(headers, octstr_imm("Authorization"));
Octstr *p = NULL, *q = NULL;
*has_auth_hdr = (v != NULL);
if (octstr_len(user) == 0) {
res = 0;
goto done;
}
if (!v ||
octstr_search(v, octstr_imm("Basic "), 0) != 0)
goto done;
p = octstr_copy(v, sizeof "Basic", octstr_len(v));
octstr_base64_to_binary(p);
i = octstr_search_char(p, ':', 0);
q = octstr_copy(p, i+1, octstr_len(p));
octstr_delete(p, i, octstr_len(p));
/* p = user, q = pass. */
if (octstr_compare(user, p) != 0 ||
octstr_compare(pass, q) != 0)
res = -1;
else
res = 0;
done:
octstr_destroy(v);
octstr_destroy(p);
octstr_destroy(q);
return res;
}
static Octstr *get_dlr_notify_url(Octstr *msgid, char *report_type, Octstr *mmc_gid, Octstr *mmc_id,
Octstr *status,
@ -1027,10 +992,12 @@ static void dispatch_mm7_recv(List *rl)
/* hmon->register_thread( "dispatch_mm7" ); */
while ((h = gwlist_consume(rl)) != NULL) {
MmscGrp *m = h->m;
char *user = m->incoming.user ? octstr_get_cstr(m->incoming.user) : NULL;
char *pass = m->incoming.pass ? octstr_get_cstr(m->incoming.pass) : NULL;
int ret = -1, has_auth = (m->type != MM1_MMSC); /* We dont authenticate mm1. right? */
if (!has_auth && auth_check(m->incoming.user,
m->incoming.pass,
if (!has_auth && http_auth_check(user,
pass,
h->headers, &has_auth) != 0) { /* Ask it to authenticate... */
List *hh = http_create_empty_headers();
http_header_add(hh, "WWW-Authenticate",

View File

@ -274,8 +274,9 @@ int main(int argc, char *argv[])
mm4_type ? "MM4" : "MM3",
settings->host_alias);
if (qf) {
newmsgid = mms_make_msgid(octstr_get_cstr(qf),
settings->host_alias);
newmsgid = msgid ? octstr_duplicate(msgid) :
mms_make_msgid(octstr_get_cstr(qf),
settings->host_alias);
mms_info(0, "mmsfromemail", NULL, "%s Queued message to %s from %s (via %s) => %s",
mm4_type ? "MM4 Incoming" : "Email2MMS",
octstr_get_cstr(xto), octstr_get_cstr(xfrom),