update 2025-10-06 17:39:29

This commit is contained in:
kenzok8
2025-10-06 17:39:29 +08:00
parent fdb51711b4
commit e7b7efdbf4
2776 changed files with 57544 additions and 140630 deletions

184
uwsgi/Makefile Normal file
View File

@@ -0,0 +1,184 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=uwsgi
PKG_VERSION:=2.0.26
PKG_RELEASE:=1
PYPI_NAME:=uWSGI
PYPI_SOURCE_NAME:=uwsgi
PKG_HASH:=86e6bfcd4dc20529665f5b7777193cdc48622fb2c59f0a7f1e3dc32b3882e7f9
PKG_LICENSE:=GPL-2.0-or-later
PKG_LICENSE_FILES:=LICENSE
PKG_CPE_ID:=cpe:/a:unbit:uwsgi
PKG_MAINTAINER:=Christian Marangi <ansuelsmth@gmail.com>
PKG_BUILD_DEPENDS:=python3/host
PYTHON3_PKG_BUILD:=0
PKG_CONFIG_DEPENDS:= \
CONFIG_PACKAGE_uwsgi-logfile-plugin \
CONFIG_PACKAGE_uwsgi-syslog-plugin \
CONFIG_PACKAGE_uwsgi-cgi-plugin \
CONFIG_PACKAGE_uwsgi-python3-plugin \
CONFIG_PACKAGE_uwsgi-luci-support
include $(TOPDIR)/feeds/packages/lang/python/pypi.mk
include $(INCLUDE_DIR)/package.mk
include $(TOPDIR)/feeds/packages/lang/python/python3-package.mk
#for LINUX_UNAME_VERSION:
include $(INCLUDE_DIR)/kernel.mk
define Package/uwsgi
SECTION:=net
CATEGORY:=Network
SUBMENU:=Web Servers/Proxies
TITLE:=The uWSGI server
URL:=https://uwsgi-docs.readthedocs.io/en/latest/
DEPENDS:=+libpcre2 +libcap +libuuid
endef
define Package/uwsgi-logfile-plugin
SECTION:=net
CATEGORY:=Network
SUBMENU:=Web Servers/Proxies
TITLE:=The Logfile plugin for the uWSGI server
DEPENDS:=uwsgi
endef
define Package/uwsgi-syslog-plugin
SECTION:=net
CATEGORY:=Network
SUBMENU:=Web Servers/Proxies
TITLE:=The Syslog plugin for the uWSGI server
DEPENDS:=uwsgi
endef
define Package/uwsgi-cgi-plugin
SECTION:=net
CATEGORY:=Network
SUBMENU:=Web Servers/Proxies
TITLE:=The CGI plugin for the uWSGI server
DEPENDS:=uwsgi
endef
define Package/uwsgi-python3-plugin
SECTION:=net
CATEGORY:=Network
SUBMENU:=Web Servers/Proxies
TITLE:=The Python3 plugin for the uWSGI server
DEPENDS:=uwsgi +python3-light
endef
define Package/uwsgi-luci-support
SECTION:=net
CATEGORY:=Network
SUBMENU:=Web Servers/Proxies
TITLE:=Support files for LuCI on Nginx
DEPENDS:=uwsgi +uwsgi-syslog-plugin +uwsgi-cgi-plugin
endef
define Package/uwsgi/description
The uWSGI project (to be used together with nginx or nginx-ssl).
endef
define Package/uwsgi-logfile-plugin/description
The Logfile plugin for the uWSGI project.
endef
define Package/uwsgi-syslog-plugin/description
The Syslog plugin for the uWSGI project.
endef
define Package/uwsgi-cgi-plugin/description
The CGI plugin for the uWSGI project.
endef
define Package/uwsgi-python3-plugin/description
The Python3 plugin for the uWSGI project.
endef
define Package/uwsgi-luci-support/description
Support files for LuCI on Nginx
endef
MAKE_VARS+= \
CPP=$(TARGET_CROSS)cpp \
LINUX_UNAME_VERSION=$(LINUX_UNAME_VERSION)
MAKE_FLAGS+= PROFILE=openwrt
define Build/Compile
$(call Build/Compile/Default)
ifneq ($(CONFIG_PACKAGE_uwsgi-logfile-plugin),)
$(call Build/Compile/Default,plugin.logfile)
endif
ifneq ($(CONFIG_PACKAGE_uwsgi-syslog-plugin),)
$(call Build/Compile/Default,plugin.syslog)
endif
ifneq ($(CONFIG_PACKAGE_uwsgi-cgi-plugin),)
$(call Build/Compile/Default,plugin.cgi)
endif
ifneq ($(CONFIG_PACKAGE_uwsgi-python3-plugin),)
$(call Python3/Run, \
$(PKG_BUILD_DIR), \
uwsgiconfig.py --plugin plugins/python openwrt, \
$(MAKE_VARS) \
CFLAGS="$(TARGET_CPPFLAGS) -I$(PYTHON3_INC_DIR) $(TARGET_CFLAGS)" \
)
endif
endef
define Package/uwsgi/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/uwsgi $(1)/usr/sbin/
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/uwsgi.init $(1)/etc/init.d/uwsgi
$(INSTALL_DIR) $(1)/etc/uwsgi
$(INSTALL_CONF) ./files/emperor.ini $(1)/etc/uwsgi/emperor.ini
$(INSTALL_DIR) $(1)/etc/uwsgi/vassals
endef
define Package/uwsgi/conffiles
/etc/uwsgi/emperor.ini
endef
define Package/uwsgi-logfile-plugin/install
$(INSTALL_DIR) $(1)/usr/lib/uwsgi
$(CP) $(PKG_BUILD_DIR)/logfile_plugin.so $(1)/usr/lib/uwsgi/
endef
define Package/uwsgi-syslog-plugin/install
$(INSTALL_DIR) $(1)/usr/lib/uwsgi
$(CP) $(PKG_BUILD_DIR)/syslog_plugin.so $(1)/usr/lib/uwsgi/
endef
define Package/uwsgi-cgi-plugin/install
$(INSTALL_DIR) $(1)/usr/lib/uwsgi
$(CP) $(PKG_BUILD_DIR)/cgi_plugin.so $(1)/usr/lib/uwsgi/
endef
define Package/uwsgi-python3-plugin/install
$(INSTALL_DIR) $(1)/usr/lib/uwsgi
$(INSTALL_BIN) $(PKG_BUILD_DIR)/python_plugin.so $(1)/usr/lib/uwsgi/
endef
define Package/uwsgi-luci-support/install
$(INSTALL_DIR) $(1)/etc/uwsgi/vassals
$(INSTALL_DATA) ./files-luci-support/luci-webui.ini $(1)/etc/uwsgi/vassals/luci-webui.ini
$(INSTALL_DATA) ./files-luci-support/luci-cgi_io.ini $(1)/etc/uwsgi/vassals/luci-cgi_io.ini
endef
$(eval $(call BuildPackage,uwsgi))
$(eval $(call BuildPackage,uwsgi-logfile-plugin))
$(eval $(call BuildPackage,uwsgi-syslog-plugin))
$(eval $(call BuildPackage,uwsgi-cgi-plugin))
$(eval $(call BuildPackage,uwsgi-python3-plugin))
$(eval $(call BuildPackage,uwsgi-luci-support))

View File

@@ -0,0 +1,31 @@
[uwsgi]
strict = true
if-not-env = UWSGI_EMPEROR_FD
socket = /var/run/luci-cgi_io.socket
chmod-socket = 666
cheap = true
end-if =
plugin = cgi
cgi-mode = true
cgi = /www/
chdir = /usr/lib/ucode/luci/
buffer-size = 10000
reload-mercy = 8
max-requests = 2000
limit-as = 1000
reload-on-as = 256
reload-on-rss = 192
no-orphans = true
post-buffering = 8192
socket-timeout = 120
thunder-lock = true
plugin = syslog
disable-logging = true
req-logger = syslog:uwsgi-luci-cgi_io
log-format=%(method) %(uri) => return %(status) (%(rsize) bytes in %(msecs) ms)
chmod-socket = 666
cgi-safe = /usr/libexec/cgi-io
cgi-dontresolve = true
cgi-close-stdin-on-eof = true
cheap = true
idle = 360

View File

@@ -0,0 +1,36 @@
[uwsgi]
strict = true
if-not-env = UWSGI_EMPEROR_FD
socket = /var/run/luci-webui.socket
chmod-socket = 666
cheap = true
end-if =
plugin = cgi
cgi-mode = true
cgi = /www/
chdir = /usr/lib/ucode/luci/
buffer-size = 10000
reload-mercy = 8
max-requests = 2000
limit-as = 1000
reload-on-as = 256
reload-on-rss = 192
enable-threads = true
post-buffering = 8192
socket-timeout = 120
thunder-lock = true
plugin = syslog
logger = luci syslog:uwsgi-luci
; the regular expression leaves for successful de/activation only one line each:
log-route = luci ^(?!... Starting uWSGI |compiled with version: |os: Linux|nodename: |machine: |clock source: |pcre jit |detected number of CPU cores: |current working directory: |detected binary path: |uWSGI running as root, you can use |... WARNING: you are running uWSGI as root |chdir.. to |your processes number limit is |limiting address space of processes...|your process address space limit is |your memory page size is |detected max file descriptor number: |lock engine: |thunder lock: |uwsgi socket |your server socket listen backlog is limited to |your mercy for graceful operations on workers is |mapped .* bytes |... Operational MODE: |initialized CGI path: |... no app loaded. going in full dynamic mode ...|... uWSGI is running in multiple interpreter mode ...|spawned uWSGI worker |announcing my loyalty to the Emperor...|workers have been inactive for more than |SIGINT/SIGQUIT received...killing workers...|worker .* buried |goodbye to uWSGI.|...gracefully killing workers...|Gracefully killing worker|worker .* killed successfully)
disable-logging = true
req-logger = syslog:uwsgi-luci
log-format=%(method) %(uri) => return %(status) (%(rsize) bytes in %(msecs) ms)
threads = 1
processes = 3
cheaper-algo = spare
cheaper = 1
cheaper-initial = 1
cheaper-step = 1
master = true
idle = 360

9
uwsgi/files/emperor.ini Normal file
View File

@@ -0,0 +1,9 @@
[uwsgi]
strict = true
pidfile = /var/run/uwsgi.pid
emperor = /etc/uwsgi/vassals/*.ini
early-emperor = true
vacuum = true
emperor-on-demand-directory = /var/run/
emperor-required-heartbeat = 99
vassal-set = die-on-idle=true

14
uwsgi/files/uwsgi.init Normal file
View File

@@ -0,0 +1,14 @@
#!/bin/sh /etc/rc.common
START=79
USE_PROCD=1
start_service() {
procd_open_instance
procd_set_param command /usr/sbin/uwsgi --ini /etc/uwsgi/emperor.ini
procd_set_param stderr 1
procd_set_param file /etc/uwsgi/emperor.ini
procd_set_param respawn
procd_close_instance
}

View File

@@ -0,0 +1,19 @@
--- a/uwsgiconfig.py
+++ b/uwsgiconfig.py
@@ -863,11 +863,11 @@ class uConf(object):
self.cflags.append('-DUWSGI_HAS_EXECINFO')
report['execinfo'] = True
- if self.has_include('zlib.h'):
- self.cflags.append('-DUWSGI_ZLIB')
- self.libs.append('-lz')
- self.gcc_list.append('core/zlib')
- report['zlib'] = True
+# if self.has_include('zlib.h'):
+# self.cflags.append('-DUWSGI_ZLIB')
+# self.libs.append('-lz')
+# self.gcc_list.append('core/zlib')
+ report['zlib'] = False
if uwsgi_os == 'OpenBSD':
try:

View File

@@ -0,0 +1,10 @@
--- a/uwsgiconfig.py
+++ b/uwsgiconfig.py
@@ -684,7 +684,6 @@ class uConf(object):
self.include_path += os.environ['UWSGI_INCLUDES'].split(',')
cflags = [
- '-O2',
'-I.',
'-Wall',
'-D_LARGEFILE_SOURCE',

View File

@@ -0,0 +1,15 @@
--- a/uwsgiconfig.py
+++ b/uwsgiconfig.py
@@ -5,9 +5,9 @@ uwsgi_version = '2.0.26'
import os
import re
import time
-uwsgi_os = os.uname()[0]
-uwsgi_os_k = re.split('[-+_]', os.uname()[2])[0]
-uwsgi_os_v = os.uname()[3]
+uwsgi_os = "Linux"
+uwsgi_os_k = os.environ['LINUX_UNAME_VERSION']
+uwsgi_os_v = "Linux"
uwsgi_cpu = os.uname()[4]
import sys

View File

@@ -0,0 +1,23 @@
From b55d659c2ef6fb80b3b5d70192b1271992c393fc Mon Sep 17 00:00:00 2001
From: Mathieu Lacage <mathieu.lacage@gmail.com>
Date: Tue, 30 Oct 2018 17:08:19 +0100
Subject: [PATCH] ssl-option can't be set
The ssl-option variable can't be set: it is designed to take a numeric argument but is specified as a "no_argument" option which results in an error when trying to set this option. This changeset sets the proper type.
Given the changeset which introduced this option with the ssl-enable3 option which is of type no_argument, I suspect someone copy/pasted the ssl-enable3 configuration file without testing the change.
---
core/uwsgi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/core/uwsgi.c
+++ b/core/uwsgi.c
@@ -678,7 +678,7 @@ static struct uwsgi_option uwsgi_base_op
{"ssl-enable3", no_argument, 0, "enable SSLv3 (insecure)", uwsgi_opt_true, &uwsgi.sslv3, 0},
{"ssl-enable-sslv3", no_argument, 0, "enable SSLv3 (insecure)", uwsgi_opt_true, &uwsgi.sslv3, 0},
{"ssl-enable-tlsv1", no_argument, 0, "enable TLSv1 (insecure)", uwsgi_opt_true, &uwsgi.tlsv1, 0},
- {"ssl-option", no_argument, 0, "set a raw ssl option (numeric value)", uwsgi_opt_add_string_list, &uwsgi.ssl_options, 0},
+ {"ssl-option", required_argument, 0, "set a raw ssl option (numeric value)", uwsgi_opt_add_string_list, &uwsgi.ssl_options, 0},
#if defined(UWSGI_PCRE) || defined(UWSGI_PCRE2)
{"sni-regexp", required_argument, 0, "add an SNI-governed SSL context (the key is a regexp)", uwsgi_opt_sni, NULL, 0},
#endif

View File

@@ -0,0 +1,11 @@
--- a/core/uwsgi.c
+++ b/core/uwsgi.c
@@ -1794,7 +1794,7 @@ void uwsgi_plugins_atexit(void) {
void uwsgi_backtrace(int depth) {
-#if defined(__GLIBC__) || (defined(__APPLE__) && !defined(NO_EXECINFO)) || defined(UWSGI_HAS_EXECINFO)
+#if (!defined(__UCLIBC__) && defined(__GLIBC__)) || (defined(__APPLE__) && !defined(NO_EXECINFO)) || defined(UWSGI_HAS_EXECINFO)
#include <execinfo.h>

View File

@@ -0,0 +1,63 @@
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(+)
--- 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
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
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
}
}
+ 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;

View File

@@ -0,0 +1,30 @@
[uwsgi]
xml = false
yaml = false
json = false
ssl = false
pcre = true
routing = auto
debug = false
unbit = false
malloc_implementation = libc
extras =
plugins =
bin_name = uwsgi
append_version =
plugin_dir = /usr/lib/uwsgi
plugin_build_dir = .
embedded_plugins =
as_shared_library = false
locking = auto
event = auto
timer = auto
filemonitor = auto
blacklist =
whitelist =
embed_files =
embed_config =