MM4_Forward.RES fix
This commit is contained in:
parent
0d2974bd27
commit
5cd58210fe
|
@ -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>
|
2011-09-08 P. A. Bagyenda <bagyenda@dsmagic.com>
|
||||||
* Exposed more functions in lib (get_stripped_param_value)
|
* Exposed more functions in lib (get_stripped_param_value)
|
||||||
* Minor changes to mms_msg module
|
* Minor changes to mms_msg module
|
||||||
|
|
|
@ -2641,3 +2641,39 @@ Octstr *get_keyword_from_mime(MIMEEntity *me)
|
||||||
|
|
||||||
return keyword;
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -264,6 +264,9 @@ Octstr *parse_rfc2047_text(Octstr *in, int *mibenum);
|
||||||
/* Utility func */
|
/* Utility func */
|
||||||
void mygw_free(void *);
|
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 */
|
/* Get (copy of) keyword from mime thingie */
|
||||||
Octstr *get_keyword_from_mime(MIMEEntity *me);
|
Octstr *get_keyword_from_mime(MIMEEntity *me);
|
||||||
#define US_ASCII_MIB_VAL 3
|
#define US_ASCII_MIB_VAL 3
|
||||||
|
|
|
@ -40,41 +40,6 @@
|
||||||
} while(0)
|
} 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,
|
static Octstr *get_dlr_notify_url(Octstr *msgid, char *report_type, Octstr *mmc_gid, Octstr *mmc_id,
|
||||||
Octstr *status,
|
Octstr *status,
|
||||||
|
@ -1027,10 +992,12 @@ static void dispatch_mm7_recv(List *rl)
|
||||||
/* hmon->register_thread( "dispatch_mm7" ); */
|
/* hmon->register_thread( "dispatch_mm7" ); */
|
||||||
while ((h = gwlist_consume(rl)) != NULL) {
|
while ((h = gwlist_consume(rl)) != NULL) {
|
||||||
MmscGrp *m = h->m;
|
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? */
|
int ret = -1, has_auth = (m->type != MM1_MMSC); /* We dont authenticate mm1. right? */
|
||||||
|
|
||||||
if (!has_auth && auth_check(m->incoming.user,
|
if (!has_auth && http_auth_check(user,
|
||||||
m->incoming.pass,
|
pass,
|
||||||
h->headers, &has_auth) != 0) { /* Ask it to authenticate... */
|
h->headers, &has_auth) != 0) { /* Ask it to authenticate... */
|
||||||
List *hh = http_create_empty_headers();
|
List *hh = http_create_empty_headers();
|
||||||
http_header_add(hh, "WWW-Authenticate",
|
http_header_add(hh, "WWW-Authenticate",
|
||||||
|
|
|
@ -274,7 +274,8 @@ int main(int argc, char *argv[])
|
||||||
mm4_type ? "MM4" : "MM3",
|
mm4_type ? "MM4" : "MM3",
|
||||||
settings->host_alias);
|
settings->host_alias);
|
||||||
if (qf) {
|
if (qf) {
|
||||||
newmsgid = mms_make_msgid(octstr_get_cstr(qf),
|
newmsgid = msgid ? octstr_duplicate(msgid) :
|
||||||
|
mms_make_msgid(octstr_get_cstr(qf),
|
||||||
settings->host_alias);
|
settings->host_alias);
|
||||||
mms_info(0, "mmsfromemail", NULL, "%s Queued message to %s from %s (via %s) => %s",
|
mms_info(0, "mmsfromemail", NULL, "%s Queued message to %s from %s (via %s) => %s",
|
||||||
mm4_type ? "MM4 Incoming" : "Email2MMS",
|
mm4_type ? "MM4 Incoming" : "Email2MMS",
|
||||||
|
|
Loading…
Reference in New Issue