Skip to content

Commit

Permalink
exec: Clarify what not to do with exec().
Browse files Browse the repository at this point in the history
  • Loading branch information
wdoekes authored and ionutrazvanionita committed Oct 23, 2015
1 parent f8c424d commit 7901324
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
9 changes: 5 additions & 4 deletions modules/exec/README
Expand Up @@ -160,12 +160,13 @@ modparam("exec", "time_to_kill", 20)
OSIPS_EXEC_1 the second value.

WARNING: any OpenSIPS pseudo-vars which may contain special
bash characters should be placed inside quotes, e.g.
exec("update-stats.sh '$ct'");
bourne shell (sh/bash) characters should be placed inside
quotes, e.g. exec("update-stats.sh '$(ct{re.subst,/'//g})'");

WARNING: "stdin"/"stdout"/"stderr" parameters are not designed
for a large amount of data so one should be careful when using
them because server could considerably be slowed down.
for large amounts of data, so one should be careful when using
them. Because of the basic implementation, filled up pipes
could cause a read deadlock.

This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
LOCAL_ROUTE, STARTUP_ROUTE, TIMER_ROUTE, EVENT_ROUTE,
Expand Down
11 changes: 6 additions & 5 deletions modules/exec/doc/exec_admin.xml
Expand Up @@ -200,13 +200,14 @@ modparam("exec", "time_to_kill", 20)
</listitem>
</itemizedlist>
<para>
WARNING: any OpenSIPS pseudo-vars which may contain special bash
characters should be placed inside quotes, e.g. exec("update-stats.sh '$ct'");
WARNING: any OpenSIPS pseudo-vars which may contain special bourne shell (sh/bash)
characters should be placed inside quotes, e.g.
exec("update-stats.sh '$(ct{re.subst,/'//g})'");
</para>
<para>
WARNING: "stdin"/"stdout"/"stderr" parameters are not designed for a large amount of
data so one should be careful when using them because server could considerably be
slowed down.
WARNING: "stdin"/"stdout"/"stderr" parameters are not designed for large amounts of
data, so one should be careful when using them. Because of the basic implementation,
filled up pipes could cause a read deadlock.
</para>
<para>
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
Expand Down
4 changes: 1 addition & 3 deletions modules/exec/exec.c
Expand Up @@ -428,7 +428,7 @@ int exec_sync(struct sip_msg* msg, str* command, str* input, gparam_p outvar, gp
{

pid_t pid;
int ret;
int ret = -1;
FILE *pin, *pout, *perr;

if ((input && input->len && input->s) || outvar || errvar) {
Expand Down Expand Up @@ -466,15 +466,13 @@ int exec_sync(struct sip_msg* msg, str* command, str* input, gparam_p outvar, gp
if (outvar) {
if (read_and_write2var(msg, &pout, outvar) < 0) {
LM_ERR("failed reading stdout from pipe\n");
ret = -1;
goto error;
}
}

if (errvar) {
if (read_and_write2var(msg, &perr, errvar) < 0) {
LM_ERR("failed reading stderr from pipe\n");
ret = -1;
goto error;
}
}
Expand Down

0 comments on commit 7901324

Please sign in to comment.