improved detokenizer_shell module: Script now receives 2nd argument as request-ip
This commit is contained in:
parent
bc4ef69c40
commit
50fd9b03aa
|
@ -35,16 +35,28 @@ static int mms_detokenizer_fini(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Octstr *mms_detokenize(Octstr * token, Octstr *request_ip)
|
static Octstr *mms_detokenize(Octstr *token, Octstr *request_ip)
|
||||||
{
|
{
|
||||||
Octstr *cmd = NULL, *msisdn = NULL;
|
Octstr *cmd = NULL, *msisdn = NULL;
|
||||||
|
Octstr *tmp1, *tmp2;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
|
|
||||||
if (script == NULL || octstr_len(script) == 0)
|
if (script == NULL || octstr_len(script) == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
cmd = octstr_format("%s '%s'", octstr_get_cstr(script), octstr_get_cstr(token));
|
tmp1 = octstr_duplicate(token ? token : octstr_imm(""));
|
||||||
|
tmp2 = octstr_duplicate(request_ip ? request_ip : octstr_imm(""));
|
||||||
|
|
||||||
|
escape_shell_chars(tmp1);
|
||||||
|
escape_shell_chars(tmp2);
|
||||||
|
|
||||||
|
cmd = octstr_format("%s %s %s",
|
||||||
|
octstr_get_cstr(script),
|
||||||
|
octstr_get_cstr(tmp1),
|
||||||
|
octstr_get_cstr(tmp2));
|
||||||
|
octstr_destroy(tmp1);
|
||||||
|
octstr_destroy(tmp2);
|
||||||
info(0, "Calling \"%s\"", octstr_get_cstr(cmd));
|
info(0, "Calling \"%s\"", octstr_get_cstr(cmd));
|
||||||
if ((fp = popen(octstr_get_cstr(cmd), "r"))) {
|
if ((fp = popen(octstr_get_cstr(cmd), "r"))) {
|
||||||
if (fgets(buf, sizeof buf, fp) != NULL) {
|
if (fgets(buf, sizeof buf, fp) != NULL) {
|
||||||
|
|
Loading…
Reference in New Issue