Added shell based CGI
This commit is contained in:
@@ -5,5 +5,8 @@
|
|||||||
#define AUTOESCAPE_CHAR '\\'
|
#define AUTOESCAPE_CHAR '\\'
|
||||||
#define NOMINIFY_CHAR '&'
|
#define NOMINIFY_CHAR '&'
|
||||||
#define SEPARATOR_CHAR ','
|
#define SEPARATOR_CHAR ','
|
||||||
|
#define SHELL_CHAR '$'
|
||||||
|
|
||||||
|
#define ALLOW_SHELL
|
||||||
|
|
||||||
#define MAX_INCLUDE_DEPTH 10
|
#define MAX_INCLUDE_DEPTH 10
|
||||||
|
|||||||
29
src/parse.c
29
src/parse.c
@@ -1,3 +1,9 @@
|
|||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#ifdef ALLOW_SHELL
|
||||||
|
#define _POSIX_C_SOURCE 2
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -6,8 +12,6 @@
|
|||||||
#include <vector.h>
|
#include <vector.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
|
|
||||||
#include <config.h>
|
|
||||||
|
|
||||||
struct var {
|
struct var {
|
||||||
struct string *var;
|
struct string *var;
|
||||||
struct string *value;
|
struct string *value;
|
||||||
@@ -128,6 +132,26 @@ autoescapeend:
|
|||||||
fputc(data->data[i], out);
|
fputc(data->data[i], out);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#ifdef ALLOW_SHELL
|
||||||
|
case SHELL_CHAR: {
|
||||||
|
FILE *process;
|
||||||
|
long start;
|
||||||
|
start = ++i;
|
||||||
|
while (data->data[i] != ESCAPE_CHAR)
|
||||||
|
++i;
|
||||||
|
data->data[i] = '\0';
|
||||||
|
process = popen(data->data + start, "r");
|
||||||
|
for (;;) {
|
||||||
|
int c;
|
||||||
|
c = fgetc(process);
|
||||||
|
if (c == EOF)
|
||||||
|
break;
|
||||||
|
mputc(&s, c, out);
|
||||||
|
}
|
||||||
|
pclose(process);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -165,6 +189,7 @@ static int expandfile(struct expandfile *ret, char *filename, int level) {
|
|||||||
goto error;
|
goto error;
|
||||||
break;
|
break;
|
||||||
case VAR_CHAR: case AUTOESCAPE_CHAR: case NOMINIFY_CHAR:
|
case VAR_CHAR: case AUTOESCAPE_CHAR: case NOMINIFY_CHAR:
|
||||||
|
case SHELL_CHAR:
|
||||||
if (appendchar(ret->data, ESCAPE_CHAR))
|
if (appendchar(ret->data, ESCAPE_CHAR))
|
||||||
goto error;
|
goto error;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
|||||||
Reference in New Issue
Block a user