uwsgi-cgi: add patch to fix #10134
authorAnsuel Smith <ansuelsmth@gmail.com>
Wed, 9 Oct 2019 18:11:51 +0000 (20:11 +0200)
committerAnsuel Smith <ansuelsmth@gmail.com>
Thu, 10 Oct 2019 23:26:18 +0000 (01:26 +0200)
- add uwsgi patch to add option to don't follow simbolic link but call it directly (waiting to be approved)

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
net/uwsgi-cgi/Makefile
net/uwsgi-cgi/patches/030-plugins-cgi_adds_dontresolve_option.patch [new file with mode: 0644]

index 933ce885ea12b615c9eb1b3d4502aff716790ec6..72f2ef720b6284d9c35cab5ce62c22557e0da0b7 100644 (file)
@@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=uwsgi-cgi
 PKG_VERSION:=2.0.18
-PKG_RELEASE:=2
+PKG_RELEASE:=3
 
 PKG_SOURCE_URL= \
        https://projects.unbit.it/downloads \
diff --git a/net/uwsgi-cgi/patches/030-plugins-cgi_adds_dontresolve_option.patch b/net/uwsgi-cgi/patches/030-plugins-cgi_adds_dontresolve_option.patch
new file mode 100644 (file)
index 0000000..7acdfc7
--- /dev/null
@@ -0,0 +1,65 @@
+From f259999d824b921a8a443e73d8c2b9e2d2170413 Mon Sep 17 00:00:00 2001
+From: Ansuel Smith <ansuelsmth@gmail.com>
+Date: Tue, 8 Oct 2019 02:10:43 +0200
+Subject: [PATCH] plugins/cgi: adds dontresolve option
+
+This option permit to call the simbolic link instead of the file the simbolic link points.
+All the security check are still done as the simbolic path is passed at the end after all the checks are passed. This is useful if some cgi app are used for multiple function based on the name they are called by.
+
+Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
+---
+ plugins/cgi/cgi_plugin.c | 13 +++++++++++++
+ 1 file changed, 13 insertions(+)
+
+diff --git a/plugins/cgi/cgi_plugin.c b/plugins/cgi/cgi_plugin.c
+index d032db17c..30e1cc528 100644
+--- a/plugins/cgi/cgi_plugin.c
++++ b/plugins/cgi/cgi_plugin.c
+@@ -15,6 +15,7 @@ struct uwsgi_cgi {
+       struct uwsgi_string_list *loadlib;
+       struct uwsgi_string_list *cgi_safe;
+       int optimize;
++      int dontresolve;
+       int from_docroot;
+       int has_mountpoints;
+       struct uwsgi_dyn_dict *default_cgi;
+@@ -75,6 +76,8 @@ struct uwsgi_option uwsgi_cgi_options[] = {
+         {"cgi-safe", required_argument, 0, "skip security checks if the cgi file is under the specified path", uwsgi_opt_add_string_list, &uc.cgi_safe, 0},
++        {"cgi-dontresolve", no_argument, 0 , "call symbolic link directly instead of the real path", uwsgi_opt_true,&uc.dontresolve, 0},
++
+         {0, 0, 0, 0, 0, 0, 0},
+ };
+@@ -475,6 +478,7 @@ static int uwsgi_cgi_request(struct wsgi_request *wsgi_req) {
+       char full_path[PATH_MAX];
+       char tmp_path[PATH_MAX];
++      char symbolic_path[PATH_MAX];
+       struct stat cgi_stat;
+       int need_free = 0;
+       int is_a_file = 0;
+@@ -533,6 +537,10 @@ static int uwsgi_cgi_request(struct wsgi_request *wsgi_req) {
+                       uwsgi_404(wsgi_req);
+                       return UWSGI_OK;
+               }
++              if (uc.dontresolve) {
++                      full_path_len = strlen(full_path);
++                      memcpy(symbolic_path, full_path, full_path_len+1);
++              }
+               full_path_len = strlen(tmp_path);
+               // add +1 to copy the null byte
+@@ -639,6 +647,11 @@ static int uwsgi_cgi_request(struct wsgi_request *wsgi_req) {
+               }
+       }
++      if (uc.dontresolve) {
++              full_path_len = strlen(symbolic_path);
++              memcpy(full_path, symbolic_path, full_path_len+1);
++      }
++
+       int ret = uwsgi_cgi_run(wsgi_req, docroot, docroot_len, full_path, helper, path_info, script_name, is_a_file, discard_base);
+       if (need_free) free(docroot);
+       return ret;