From 1dae0373c80217a768dd7d699e489abfea2b8f69 Mon Sep 17 00:00:00 2001
From: Deomid Ryabkov <rojer@cesanta.com>
Date: Mon, 17 Oct 2016 00:08:51 +0100
Subject: [PATCH] MG_DISABLE_POPEN -> MG_ENABLE_HTTP_SSI_EXEC

PUBLISHED_FROM=55b2b70a688234f6ebcfba37eced20ee5d5387a1
---
 docs/overview/build-options/enabling-flags.md |  3 ++-
 mongoose.c                                    |  9 ++++-----
 mongoose.h                                    | 12 ++++--------
 3 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/docs/overview/build-options/enabling-flags.md b/docs/overview/build-options/enabling-flags.md
index f3cca7c00..300beb53f 100644
--- a/docs/overview/build-options/enabling-flags.md
+++ b/docs/overview/build-options/enabling-flags.md
@@ -10,7 +10,8 @@ title: Enabling flags
 - `MG_ENABLE_COAP` enable CoAP protocol
 - `MG_ENABLE_HTTP` Enable HTTP protocol support (on by default, set to 0 to disable)
 - `MG_ENABLE_HTTP_CGI` Enable [CGI](https://docs.cesanta.com/mongoose/master/#/http/cgi.md/) support
-- `MG_ENABLE_HTTP_SSI` Enable [Server SIde Includes](https://docs.cesanta.com/mongoose/master/#/http/ssi.md/) support
+- `MG_ENABLE_HTTP_SSI` Enable [Server Side Includes](https://docs.cesanta.com/mongoose/master/#/http/ssi.md/) support
+- `MG_ENABLE_HTTP_SSI_EXEC` Enable SSI `exec` operator
 - `MG_ENABLE_HTTP_WEBDAV` enable WebDAV extensions to HTTP
 - `MG_ENABLE_HTTP_WEBSOCKET` enable WebSocket extension to HTTP (on by default, =0 to disable)
 - `MG_ENABLE_GETADDRINFO` enable `getaddrinfo()` in `mg_resolve2()`
diff --git a/mongoose.c b/mongoose.c
index 74e9b9fea..37d2db59d 100644
--- a/mongoose.c
+++ b/mongoose.c
@@ -45,7 +45,6 @@
 
 #ifdef PICOTCP
 #define NO_LIBC
-#define MG_DISABLE_POPEN
 #define MG_DISABLE_SOCKETPAIR
 #define MG_DISABLE_PFS
 #endif
@@ -6877,7 +6876,7 @@ static void mg_do_ssi_include(struct mg_connection *nc, struct http_message *hm,
   }
 }
 
-#if !MG_DISABLE_POPEN
+#if MG_ENABLE_HTTP_SSI_EXEC
 static void do_ssi_exec(struct mg_connection *nc, char *tag) {
   char cmd[BUFSIZ];
   FILE *fp;
@@ -6891,7 +6890,7 @@ static void do_ssi_exec(struct mg_connection *nc, char *tag) {
     pclose(fp);
   }
 }
-#endif /* !MG_DISABLE_POPEN */
+#endif /* MG_ENABLE_HTTP_SSI_EXEC */
 
 /*
  * SSI directive has the following format:
@@ -6903,7 +6902,7 @@ static void mg_send_ssi_file(struct mg_connection *nc, struct http_message *hm,
   static const struct mg_str btag = MG_MK_STR("<!--#");
   static const struct mg_str d_include = MG_MK_STR("include");
   static const struct mg_str d_call = MG_MK_STR("call");
-#if !MG_DISABLE_POPEN
+#if MG_ENABLE_HTTP_SSI_EXEC
   static const struct mg_str d_exec = MG_MK_STR("exec");
 #endif
   char buf[BUFSIZ], *p = buf + btag.len; /* p points to SSI directive */
@@ -6939,7 +6938,7 @@ static void mg_send_ssi_file(struct mg_connection *nc, struct http_message *hm,
         mg_call(nc, NULL, MG_EV_SSI_CALL,
                 (void *) cctx.arg.p); /* NUL added above */
         mg_call(nc, NULL, MG_EV_SSI_CALL_CTX, &cctx);
-#if !MG_DISABLE_POPEN
+#if MG_ENABLE_HTTP_SSI_EXEC
       } else if (memcmp(p, d_exec.p, d_exec.len) == 0) {
         do_ssi_exec(nc, p + d_exec.len + 1);
 #endif
diff --git a/mongoose.h b/mongoose.h
index ffc574a6a..1c0fcd811 100644
--- a/mongoose.h
+++ b/mongoose.h
@@ -464,7 +464,6 @@ void mg_lwip_set_keepalive_params(struct mg_connection *nc, int idle,
 #define MG_SOCKET_SIMPLELINK 1
 #define MG_DISABLE_SOCKETPAIR 1
 #define MG_DISABLE_SYNC_RESOLVER 1
-#define MG_DISABLE_POPEN 1
 
 /*
  * CC3100 SDK and STM32 SDK include headers w/out path, just like
@@ -520,7 +519,6 @@ int inet_pton(int af, const char *src, void *dst);
 #define MG_SOCKET_SIMPLELINK 1
 #define MG_DISABLE_SOCKETPAIR 1
 #define MG_DISABLE_SYNC_RESOLVER 1
-#define MG_DISABLE_POPEN 1
 
 /* Only SPIFFS supports directories, SLFS does not. */
 #if defined(CC3200_FS_SPIFFS) && !defined(MG_ENABLE_DIRECTORY_LISTING)
@@ -657,8 +655,6 @@ struct dirent *readdir(DIR *dir);
 #define MG_SOCKET_SIMPLELINK 1
 #define MG_DISABLE_SOCKETPAIR 1
 #define MG_DISABLE_SYNC_RESOLVER 1
-#define MG_DISABLE_POPEN 1
-#define MG_DISABLE_DAV 1
 
 /* Amalgamated: #include "common/platforms/simplelink/cs_simplelink.h" */
 
@@ -1389,10 +1385,6 @@ const char *c_strnstr(const char *s, const char *find, size_t slen);
 #define MG_DISABLE_PFS 0
 #endif
 
-#ifndef MG_DISABLE_POPEN
-#define MG_DISABLE_POPEN 0
-#endif
-
 #ifndef MG_DISABLE_RESOLVER
 #define MG_DISABLE_RESOLVER 0
 #endif
@@ -1458,6 +1450,10 @@ const char *c_strnstr(const char *s, const char *find, size_t slen);
 #define MG_ENABLE_HTTP_SSI MG_ENABLE_FILESYSTEM
 #endif
 
+#ifndef MG_ENABLE_HTTP_SSI_EXEC
+#define MG_ENABLE_HTTP_SSI_EXEC 0
+#endif
+
 #ifndef MG_ENABLE_HTTP_STREAMING_MULTIPART
 #define MG_ENABLE_HTTP_STREAMING_MULTIPART 0
 #endif
-- 
GitLab