@ -0,0 +1,16 @@ | |||
# | |||
# Copyright (C) 2006-2015 OpenWrt.org | |||
# | |||
# This is free software, licensed under the GNU General Public License v2. | |||
# See /LICENSE for more information. | |||
# | |||
define Package/python3-asyncio | |||
$(call Package/python3/Default) | |||
TITLE:=Python $(PYTHON3_VERSION) asyncio module | |||
DEPENDS:=+python3-light | |||
endef | |||
$(eval $(call Py3BasePackage,python3-asyncio, \ | |||
/usr/lib/python$(PYTHON3_VERSION)/asyncio \ | |||
)) |
@ -0,0 +1,22 @@ | |||
# | |||
# Copyright (C) 2006-2015 OpenWrt.org | |||
# | |||
# This is free software, licensed under the GNU General Public License v2. | |||
# See /LICENSE for more information. | |||
# | |||
define Package/python3-codecs | |||
$(call Package/python3/Default) | |||
TITLE:=Python $(PYTHON3_VERSION) codecs + unicode support | |||
DEPENDS:=+python3-light | |||
endef | |||
$(eval $(call Py3BasePackage,python3-codecs, \ | |||
/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/_codecs_cn.$(PYTHON3_SO_SUFFIX) \ | |||
/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/_codecs_hk.$(PYTHON3_SO_SUFFIX) \ | |||
/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/_codecs_iso2022.$(PYTHON3_SO_SUFFIX) \ | |||
/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/_codecs_jp.$(PYTHON3_SO_SUFFIX) \ | |||
/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/_codecs_kr.$(PYTHON3_SO_SUFFIX) \ | |||
/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/_codecs_tw.$(PYTHON3_SO_SUFFIX) \ | |||
/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/unicodedata.$(PYTHON3_SO_SUFFIX) \ | |||
)) |
@ -0,0 +1,18 @@ | |||
# | |||
# Copyright (C) 2006-2015 OpenWrt.org | |||
# | |||
# This is free software, licensed under the GNU General Public License v2. | |||
# See /LICENSE for more information. | |||
# | |||
define Package/python3-ctypes | |||
$(call Package/python3/Default) | |||
TITLE:=Python $(PYTHON3_VERSION) ctypes module | |||
DEPENDS:=+python3-light | |||
endef | |||
$(eval $(call Py3BasePackage,python3-ctypes, \ | |||
/usr/lib/python$(PYTHON3_VERSION)/ctypes \ | |||
/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/_ctypes.$(PYTHON3_SO_SUFFIX) \ | |||
/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/_ctypes_test.$(PYTHON3_SO_SUFFIX) \ | |||
)) |
@ -0,0 +1,17 @@ | |||
# | |||
# Copyright (C) 2006-2015 OpenWrt.org | |||
# | |||
# This is free software, licensed under the GNU General Public License v2. | |||
# See /LICENSE for more information. | |||
# | |||
define Package/python3-dbm | |||
$(call Package/python3/Default) | |||
TITLE:=Python $(PYTHON3_VERSION) dbm module | |||
DEPENDS:=+python3-light +libdb47 | |||
endef | |||
$(eval $(call Py3BasePackage,python3-dbm, \ | |||
/usr/lib/python$(PYTHON3_VERSION)/dbm \ | |||
/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/_dbm.$(PYTHON3_SO_SUFFIX) \ | |||
)) |
@ -0,0 +1,17 @@ | |||
# | |||
# Copyright (C) 2006-2015 OpenWrt.org | |||
# | |||
# This is free software, licensed under the GNU General Public License v2. | |||
# See /LICENSE for more information. | |||
# | |||
define Package/python3-decimal | |||
$(call Package/python3/Default) | |||
TITLE:=Python $(PYTHON3_VERSION) decimal module | |||
DEPENDS:=+python3-light | |||
endef | |||
$(eval $(call Py3BasePackage,python3-decimal, \ | |||
/usr/lib/python$(PYTHON3_VERSION)/decimal.py \ | |||
/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/_decimal.$(PYTHON3_SO_SUFFIX) \ | |||
)) |
@ -0,0 +1,16 @@ | |||
# | |||
# Copyright (C) 2006-2015 OpenWrt.org | |||
# | |||
# This is free software, licensed under the GNU General Public License v2. | |||
# See /LICENSE for more information. | |||
# | |||
define Package/python3-distutils | |||
$(call Package/python3/Default) | |||
TITLE:=Python $(PYTHON3_VERSION) distutils module | |||
DEPENDS:=+python3-light | |||
endef | |||
$(eval $(call Py3BasePackage,python3-distutils, \ | |||
/usr/lib/python$(PYTHON3_VERSION)/distutils \ | |||
)) |
@ -0,0 +1,16 @@ | |||
# | |||
# Copyright (C) 2006-2015 OpenWrt.org | |||
# | |||
# This is free software, licensed under the GNU General Public License v2. | |||
# See /LICENSE for more information. | |||
# | |||
define Package/python3-email | |||
$(call Package/python3/Default) | |||
TITLE:=Python $(PYTHON3_VERSION) email module | |||
DEPENDS:=+python3-light | |||
endef | |||
$(eval $(call Py3BasePackage,python3-email, \ | |||
/usr/lib/python$(PYTHON3_VERSION)/email \ | |||
)) |
@ -0,0 +1,16 @@ | |||
# | |||
# Copyright (C) 2006-2015 OpenWrt.org | |||
# | |||
# This is free software, licensed under the GNU General Public License v2. | |||
# See /LICENSE for more information. | |||
# | |||
define Package/python3-gdbm | |||
$(call Package/python3/Default) | |||
TITLE:=Python $(PYTHON3_VERSION) gdbm module | |||
DEPENDS:=+python3-light +libgdbm | |||
endef | |||
$(eval $(call Py3BasePackage,python3-gdbm, \ | |||
/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/_gdbm.$(PYTHON3_SO_SUFFIX) \ | |||
)) |
@ -0,0 +1,16 @@ | |||
# | |||
# Copyright (C) 2006-2015 OpenWrt.org | |||
# | |||
# This is free software, licensed under the GNU General Public License v2. | |||
# See /LICENSE for more information. | |||
# | |||
define Package/python3-logging | |||
$(call Package/python3/Default) | |||
TITLE:=Python $(PYTHON3_VERSION) logging module | |||
DEPENDS:=+python3-light | |||
endef | |||
$(eval $(call Py3BasePackage,python3-logging, \ | |||
/usr/lib/python$(PYTHON3_VERSION)/logging \ | |||
)) |
@ -0,0 +1,17 @@ | |||
# | |||
# Copyright (C) 2006-2015 OpenWrt.org | |||
# | |||
# This is free software, licensed under the GNU General Public License v2. | |||
# See /LICENSE for more information. | |||
# | |||
define Package/python3-multiprocessing | |||
$(call Package/python3/Default) | |||
TITLE:=Python $(PYTHON3_VERSION) multiprocessing | |||
DEPENDS:=+python3-light | |||
endef | |||
$(eval $(call Py3BasePackage,python3-multiprocessing, \ | |||
/usr/lib/python$(PYTHON3_VERSION)/multiprocessing \ | |||
/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/_multiprocessing.$(PYTHON3_SO_SUFFIX) \ | |||
)) |
@ -0,0 +1,18 @@ | |||
# | |||
# Copyright (C) 2006-2015 OpenWrt.org | |||
# | |||
# This is free software, licensed under the GNU General Public License v2. | |||
# See /LICENSE for more information. | |||
# | |||
define Package/python3-ncurses | |||
$(call Package/python3/Default) | |||
TITLE:=Python $(PYTHON3_VERSION) ncurses module | |||
DEPENDS:=+python3-light +libncursesw | |||
endef | |||
$(eval $(call Py3BasePackage,python3-ncurses, \ | |||
/usr/lib/python$(PYTHON3_VERSION)/curses \ | |||
/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/_curses.$(PYTHON3_SO_SUFFIX) \ | |||
/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/_curses_panel.$(PYTHON3_SO_SUFFIX) \ | |||
)) |
@ -0,0 +1,17 @@ | |||
# | |||
# Copyright (C) 2006-2015 OpenWrt.org | |||
# | |||
# This is free software, licensed under the GNU General Public License v2. | |||
# See /LICENSE for more information. | |||
# | |||
define Package/python3-openssl | |||
$(call Package/python3/Default) | |||
TITLE:=Python $(PYTHON3_VERSION) SSL module | |||
DEPENDS:=+python3-light +libopenssl | |||
endef | |||
$(eval $(call Py3BasePackage,python3-openssl, \ | |||
/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/_hashlib.$(PYTHON3_SO_SUFFIX) \ | |||
/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/_ssl.$(PYTHON3_SO_SUFFIX) \ | |||
)) |
@ -0,0 +1,18 @@ | |||
# | |||
# Copyright (C) 2006-2015 OpenWrt.org | |||
# | |||
# This is free software, licensed under the GNU General Public License v2. | |||
# See /LICENSE for more information. | |||
# | |||
define Package/python3-pydoc | |||
$(call Package/python3/Default) | |||
TITLE:=Python $(PYTHON3_VERSION) pydoc module | |||
DEPENDS:=+python3-light | |||
endef | |||
$(eval $(call Py3BasePackage,python3-pydoc, \ | |||
/usr/lib/python$(PYTHON3_VERSION)/doctest.py \ | |||
/usr/lib/python$(PYTHON3_VERSION)/pydoc.py \ | |||
/usr/lib/python$(PYTHON3_VERSION)/pydoc_data \ | |||
)) |
@ -0,0 +1,17 @@ | |||
# | |||
# Copyright (C) 2006-2015 OpenWrt.org | |||
# | |||
# This is free software, licensed under the GNU General Public License v2. | |||
# See /LICENSE for more information. | |||
# | |||
define Package/python3-sqlite3 | |||
$(call Package/python3/Default) | |||
TITLE:=Python $(PYTHON3_VERSION) sqlite3 module | |||
DEPENDS:=+python3-light +libsqlite3 | |||
endef | |||
$(eval $(call Py3BasePackage,python3-sqlite3, \ | |||
/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/_sqlite3.$(PYTHON3_SO_SUFFIX) \ | |||
/usr/lib/python$(PYTHON3_VERSION)/sqlite3 \ | |||
)) |
@ -0,0 +1,16 @@ | |||
# | |||
# Copyright (C) 2006-2015 OpenWrt.org | |||
# | |||
# This is free software, licensed under the GNU General Public License v2. | |||
# See /LICENSE for more information. | |||
# | |||
define Package/python3-unittest | |||
$(call Package/python3/Default) | |||
TITLE:=Python $(PYTHON3_VERSION) unittest module | |||
DEPENDS:=+python3-light | |||
endef | |||
$(eval $(call Py3BasePackage,python3-unittest, \ | |||
/usr/lib/python$(PYTHON3_VERSION)/unittest \ | |||
)) |
@ -0,0 +1,19 @@ | |||
# | |||
# Copyright (C) 2006-2015 OpenWrt.org | |||
# | |||
# This is free software, licensed under the GNU General Public License v2. | |||
# See /LICENSE for more information. | |||
# | |||
define Package/python3-xml | |||
$(call Package/python3/Default) | |||
TITLE:=Python $(PYTHON3_VERSION) xml libs | |||
DEPENDS:=+python3-light | |||
endef | |||
$(eval $(call Py3BasePackage,python3-xml, \ | |||
/usr/lib/python$(PYTHON3_VERSION)/xml \ | |||
/usr/lib/python$(PYTHON3_VERSION)/xmlrpc \ | |||
/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/_elementtree.$(PYTHON3_SO_SUFFIX) \ | |||
/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/pyexpat.$(PYTHON3_SO_SUFFIX) \ | |||
)) |
@ -0,0 +1,31 @@ | |||
diff --git a/Modules/_ctypes/libffi/configure b/Modules/_ctypes/libffi/configure | |||
index 75f62a7..4d6c9f2 100755 | |||
--- a/Modules/_ctypes/libffi/configure | |||
+++ b/Modules/_ctypes/libffi/configure | |||
@@ -17257,20 +17257,12 @@ case "$host" in | |||
fi | |||
;; | |||
- i?86-*-* | x86_64-*-*) | |||
- TARGETDIR=x86 | |||
- if test $ac_cv_sizeof_size_t = 4; then | |||
- case "$host" in | |||
- *-gnux32) | |||
- TARGET=X86_64 | |||
- ;; | |||
- *) | |||
- TARGET=X86 | |||
- ;; | |||
- esac | |||
- else | |||
- TARGET=X86_64; | |||
- fi | |||
+ i?86-*-*) | |||
+ TARGET=X86; TARGETDIR=x86 | |||
+ ;; | |||
+ | |||
+ x86_64-*-*) | |||
+ TARGET=X86_64; TARGETDIR=x86 | |||
;; | |||
ia64*-*-*) |
@ -0,0 +1,12 @@ | |||
diff --git a/setup.py b/setup.py | |||
index 7868b7b..9ae0ef2 100644 | |||
--- a/setup.py | |||
+++ b/setup.py | |||
@@ -444,7 +444,6 @@ class PyBuildExt(build_ext): | |||
add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') | |||
if cross_compiling: | |||
self.add_gcc_paths() | |||
- self.add_multiarch_paths() | |||
# Add paths specified in the environment variables LDFLAGS and | |||
# CPPFLAGS for header and library files. |
@ -0,0 +1,10 @@ | |||
--- a/Lib/distutils/command/build_scripts.py | |||
+++ b/Lib/distutils/command/build_scripts.py | |||
@@ -89,6 +89,7 @@ class build_scripts (Command): | |||
adjust = 1 | |||
post_interp = match.group(1) or '' | |||
+ adjust = 0 | |||
if adjust: | |||
log.info("copying and adjusting %s -> %s", script, | |||
self.build_dir) |
@ -0,0 +1,15 @@ | |||
diff --git a/setup.py b/setup.py | |||
index 7868b7b..544fa7e 100644 | |||
--- a/setup.py | |||
+++ b/setup.py | |||
@@ -452,8 +452,9 @@ class PyBuildExt(build_ext): | |||
# directly since an inconsistently reproducible issue comes up where | |||
# the environment variable is not set even though the value were passed | |||
# into configure and stored in the Makefile (issue found on OS X 10.3). | |||
+ rt_lib_dirs = [] if cross_compiling else self.compiler.runtime_library_dirs | |||
for env_var, arg_name, dir_list in ( | |||
- ('LDFLAGS', '-R', self.compiler.runtime_library_dirs), | |||
+ ('LDFLAGS', '-R', rt_lib_dirs), | |||
('LDFLAGS', '-L', self.compiler.library_dirs), | |||
('CPPFLAGS', '-I', self.compiler.include_dirs)): | |||
env_val = sysconfig.get_config_var(env_var) |
@ -0,0 +1,32 @@ | |||
--- a/configure.ac | |||
+++ b/configure.ac | |||
@@ -844,7 +844,8 @@ AC_RUN_IFELSE( | |||
FILE *f = fopen(".", "r"); | |||
return f && fread(&c, 1, 1, f)]])], | |||
[ac_cv_fread_reads_directories=no], | |||
- [ac_cv_fread_reads_directories=yes]) | |||
+ [ac_cv_fread_reads_directories=yes], | |||
+ [ac_cv_fread_reads_directories=no]) | |||
]) | |||
if test $ac_cv_fread_reads_directories = yes; then | |||
FREAD_READS_DIRECTORIES=UnfortunatelyYes | |||
@@ -878,7 +879,8 @@ AC_RUN_IFELSE( | |||
if (snprintf(buf, 3, "%s", "12345") != 5 | |||
|| strcmp(buf, "12")) return 1]])], | |||
[ac_cv_snprintf_returns_bogus=no], | |||
- [ac_cv_snprintf_returns_bogus=yes]) | |||
+ [ac_cv_snprintf_returns_bogus=yes], | |||
+ [ac_cv_snprintf_returns_bogus=no]) | |||
]) | |||
if test $ac_cv_snprintf_returns_bogus = yes; then | |||
SNPRINTF_RETURNS_BOGUS=UnfortunatelyYes | |||
@@ -901,7 +903,8 @@ yippeeyeswehaveit | |||
#endif | |||
]), | |||
[ac_cv_sane_mode_bits=yes], | |||
- [ac_cv_sane_mode_bits=no]) | |||
+ [ac_cv_sane_mode_bits=no], | |||
+ [ac_cv_sane_mode_bits=yes]) | |||
]) | |||
if test $ac_cv_sane_mode_bits = yes; then | |||
NEEDS_MODE_TRANSLATION= |
@ -0,0 +1,11 @@ | |||
--- a/Makefile | |||
+++ b/Makefile | |||
@@ -1039,7 +1039,7 @@ else | |||
endif | |||
curl_check := $(shell (echo 072200; curl-config --vernum | sed -e '/^70[BC]/s/^/0/') 2>/dev/null | sort -r | sed -ne 2p) | |||
ifeq "$(curl_check)" "072200" | |||
- USE_CURL_FOR_IMAP_SEND = YesPlease | |||
+# USE_CURL_FOR_IMAP_SEND = YesPlease | |||
endif | |||
ifdef USE_CURL_FOR_IMAP_SEND | |||
BASIC_CFLAGS += -DUSE_CURL_FOR_IMAP_SEND |
@ -1 +0,0 @@ | |||
OPTIONS="-Lf /dev/null -p /var/run/snmpd.pid" |
@ -0,0 +1,77 @@ | |||
# | |||
# Copyright (C) 2006-2014 OpenWrt.org | |||
# | |||
# This is free software, licensed under the GNU General Public License v2. | |||
# See /LICENSE for more information. | |||
# | |||
include $(TOPDIR)/rules.mk | |||
PKG_NAME:=stunnel | |||
PKG_VERSION:=5.10 | |||
PKG_RELEASE:=1 | |||
PKG_LICENSE:=GPL-2.0+ | |||
PKG_MAINTAINER:=Michael Haas <haas@computerlinguist.org> | |||
PKG_LICENSE_FILES:=COPYING COPYRIGHT.GPL | |||
PKG_SOURCE_URL:=http://stunnel.cybermirror.org/archive/5.x/ | |||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz | |||
PKG_MD5SUM:=a0edda805eb7d6ea600a230fb0979ea1 | |||
PKG_FIXUP:=autoreconf | |||
PKG_INSTALL:=1 | |||
include $(INCLUDE_DIR)/package.mk | |||
define Package/stunnel | |||
SECTION:=net | |||
CATEGORY:=Network | |||
DEPENDS:=+libopenssl | |||
TITLE:=SSL TCP Wrapper | |||
URL:=http://www.stunnel.org/ | |||
endef | |||
define Package/stunnel/description | |||
Stunnel is a program that allows you to encrypt arbitrary TCP | |||
connections inside SSL (Secure Sockets Layer) available on both Unix | |||
and Windows. Stunnel can allow you to secure non-SSL aware daemons and | |||
protocols (like POP, IMAP, LDAP, etc) by having Stunnel provide the | |||
encryption, requiring no changes to the daemon's code. | |||
endef | |||
define Package/stunnel/conffiles | |||
/etc/stunnel/stunnel.conf | |||
endef | |||
CONFIGURE_ARGS+= \ | |||
--with-random=/dev/urandom \ | |||
--with-threads=fork \ | |||
--with-ssl=$(STAGING_DIR)/usr \ | |||
--disable-libwrap \ | |||
--disable-systemd | |||
ifeq ($(CONFIG_IPV6),n) | |||
CONFIGURE_ARGS+= \ | |||
--disable-ipv6 | |||
endif | |||
define Build/Compile | |||
mkdir -p $(PKG_INSTALL_DIR)/etc/stunnel | |||
echo '#dummy' > $(PKG_INSTALL_DIR)/etc/stunnel/stunnel.pem | |||
$(call Build/Compile/Default) | |||
endef | |||
define Package/stunnel/install | |||
$(INSTALL_DIR) $(1)/usr/bin | |||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/stunnel $(1)/usr/bin/ | |||
$(INSTALL_DIR) $(1)/usr/lib/stunnel | |||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/stunnel/libstunnel.so $(1)/usr/lib/stunnel/ | |||
$(INSTALL_DIR) $(1)/etc/stunnel | |||
$(INSTALL_CONF) ./files/stunnel.conf $(1)/etc/stunnel/stunnel.conf | |||
$(INSTALL_DIR) $(1)/etc/init.d | |||
$(INSTALL_BIN) ./files/stunnel.init $(1)/etc/init.d/stunnel | |||
endef | |||
$(eval $(call BuildPackage,stunnel)) |
@ -0,0 +1,45 @@ | |||
; Drop privileges | |||
setuid = nobody | |||
setgid = nogroup | |||
; When running under procd, stay in foreground | |||
foreground = yes | |||
; Don't log to stderr, use syslog | |||
syslog = yes | |||
; 1-7. Use 7 for greatest verbosity | |||
;debug = 5 | |||
; Starting here, enter your services or uncomment the examples | |||
; Example: | |||
; If your local httpd does not support HTTPS, use stunnel in remote | |||
; mode to forward TLS connections coming in on port 443 to non-TLS | |||
; on port 80. | |||
; Make sure that the cert is available. | |||
;[httpd] | |||
;accept = 443 | |||
;connect = 127.0.0.1:80 | |||
;cert = /etc/stunnel/stunnel.pem | |||
; Example: | |||
; If your local email client does not support TLS, | |||
; use stunnel in client mode to forward non-TLS connections on | |||
; port 143 to TLS-enabled servername:993. | |||
;[imap] | |||
;client = yes | |||
;accept = 143 | |||
;connect = servername:993 | |||
; Disable peer verification - be sure to understand the limitations of peer | |||
; verification in stunnel when enabling. | |||
;verify = 0 | |||
; Default client section: | |||
; stunnel requires at least one section to start successfully. | |||
; You can safely remove this section once you have configured | |||
; your own. We use client mode here as server requires a certificate. | |||
[dummy] | |||
client = yes | |||
accept = localhost:6000 | |||
connect = localhost:6001 |
@ -0,0 +1,12 @@ | |||
#!/bin/sh /etc/rc.common | |||
# Copyright (C) 2006-2008 OpenWrt.org | |||
START=90 | |||
USE_PROCD=1 | |||
start_service() { | |||
procd_open_instance | |||
procd_set_param command /usr/bin/stunnel /etc/stunnel/stunnel.conf | |||
procd_set_param respawn # respawn automatically if something died | |||
procd_close_instance | |||
} |
@ -0,0 +1,25 @@ | |||
--- a/src/prototypes.h | |||
+++ b/src/prototypes.h | |||
@@ -559,7 +559,7 @@ extern GETNAMEINFO s_getnameinfo; | |||
#endif /* USE_WIN32 */ | |||
-int getnameinfo(const struct sockaddr *, int, char *, int, char *, int, int); | |||
+int getnameinfo(const struct sockaddr *, socklen_t, char *, socklen_t, char *, socklen_t, unsigned int); | |||
#endif /* !defined HAVE_GETNAMEINFO */ | |||
--- a/src/resolver.c | |||
+++ b/src/resolver.c | |||
@@ -535,8 +535,9 @@ const char *s_gai_strerror(int err) { | |||
/* implementation is limited to functionality needed by stunnel */ | |||
#ifndef HAVE_GETNAMEINFO | |||
-int getnameinfo(const struct sockaddr *sa, int salen, | |||
- char *host, int hostlen, char *serv, int servlen, int flags) { | |||
+int getnameinfo(const struct sockaddr *sa, socklen_t salen, | |||
+ char *host, socklen_t hostlen, char *serv, socklen_t servlen, | |||
+ unsigned int flags) { | |||
#if defined(USE_WIN32) && !defined(_WIN32_WCE) | |||
if(s_getnameinfo) |
@ -0,0 +1,140 @@ | |||
--- a/configure | |||
+++ b/configure | |||
@@ -5646,66 +5646,66 @@ done | |||
-for flag in -fstack-protector; do | |||
- as_CACHEVAR=`$as_echo "ax_cv_check_cflags__$flag" | $as_tr_sh` | |||
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 | |||
-$as_echo_n "checking whether C compiler accepts $flag... " >&6; } | |||
-if eval \${$as_CACHEVAR+:} false; then : | |||
- $as_echo_n "(cached) " >&6 | |||
-else | |||
- | |||
- ax_check_save_flags=$CFLAGS | |||
- CFLAGS="$CFLAGS $flag" | |||
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext | |||
-/* end confdefs.h. */ | |||
- | |||
-int | |||
-main () | |||
-{ | |||
- | |||
- ; | |||
- return 0; | |||
-} | |||
-_ACEOF | |||
-if ac_fn_c_try_compile "$LINENO"; then : | |||
- eval "$as_CACHEVAR=yes" | |||
-else | |||
- eval "$as_CACHEVAR=no" | |||
-fi | |||
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext | |||
- CFLAGS=$ax_check_save_flags | |||
-fi | |||
-eval ac_res=\$$as_CACHEVAR | |||
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 | |||
-$as_echo "$ac_res" >&6; } | |||
-if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : | |||
- if ${CFLAGS+:} false; then : | |||
- case " $CFLAGS " in | |||
- *" $flag "*) | |||
- { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 | |||
- (: CFLAGS already contains $flag) 2>&5 | |||
- ac_status=$? | |||
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 | |||
- test $ac_status = 0; } | |||
- ;; | |||
- *) | |||
- { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 | |||
- (: CFLAGS="$CFLAGS $flag") 2>&5 | |||
- ac_status=$? | |||
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 | |||
- test $ac_status = 0; } | |||
- CFLAGS="$CFLAGS $flag" | |||
- ;; | |||
- esac | |||
-else | |||
- CFLAGS="$flag" | |||
-fi | |||
- | |||
-else | |||
- : | |||
-fi | |||
- | |||
-done | |||
+#for flag in -fstack-protector; do | |||
+# as_CACHEVAR=`$as_echo "ax_cv_check_cflags__$flag" | $as_tr_sh` | |||
+#{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 | |||
+#$as_echo_n "checking whether C compiler accepts $flag... " >&6; } | |||
+#if eval \${$as_CACHEVAR+:} false; then : | |||
+# $as_echo_n "(cached) " >&6 | |||
+#else | |||
+# | |||
+# ax_check_save_flags=$CFLAGS | |||
+# CFLAGS="$CFLAGS $flag" | |||
+# cat confdefs.h - <<_ACEOF >conftest.$ac_ext | |||
+#/* end confdefs.h. */ | |||
+ | |||
+#int | |||
+#main () | |||
+#{ | |||
+# | |||
+# ; | |||
+# return 0; | |||
+#} | |||
+#_ACEOF | |||
+#if ac_fn_c_try_compile "$LINENO"; then : | |||
+# eval "$as_CACHEVAR=yes" | |||
+#else | |||
+# eval "$as_CACHEVAR=no" | |||
+#fi | |||
+#rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext | |||
+# CFLAGS=$ax_check_save_flags | |||
+#fi | |||
+#eval ac_res=\$$as_CACHEVAR | |||
+# { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 | |||
+#$as_echo "$ac_res" >&6; } | |||
+#if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : | |||
+# if ${CFLAGS+:} false; then : | |||
+# case " $CFLAGS " in | |||
+# *" $flag "*) | |||
+# { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$flag"; } >&5 | |||
+# (: CFLAGS already contains $flag) 2>&5 | |||
+# ac_status=$? | |||
+# $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 | |||
+# test $ac_status = 0; } | |||
+# ;; | |||
+# *) | |||
+# { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$flag\""; } >&5 | |||
+# (: CFLAGS="$CFLAGS $flag") 2>&5 | |||
+# ac_status=$? | |||
+# $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 | |||
+# test $ac_status = 0; } | |||
+# CFLAGS="$CFLAGS $flag" | |||
+# ;; | |||
+# esac | |||
+#else | |||
+# CFLAGS="$flag" | |||
+#fi | |||
+# | |||
+#else | |||
+# : | |||
+#fi | |||
+# | |||
+#done | |||
--- a/configure.ac | |||
+++ b/configure.ac | |||
@@ -71,7 +71,7 @@ AX_APPEND_COMPILE_FLAGS([-Wformat=2]) | |||
AX_APPEND_COMPILE_FLAGS([-Wconversion]) | |||
AX_APPEND_COMPILE_FLAGS([-Wno-long-long]) | |||
AX_APPEND_COMPILE_FLAGS([-Wno-deprecated-declarations]) | |||
-AX_APPEND_COMPILE_FLAGS([-fstack-protector]) | |||
+#AX_APPEND_COMPILE_FLAGS([-fstack-protector]) | |||
AX_APPEND_COMPILE_FLAGS([-fPIE]) | |||
AX_APPEND_COMPILE_FLAGS([-D_FORTIFY_SOURCE=2]) | |||
AX_APPEND_LINK_FLAGS([-fPIE -pie]) |
@ -0,0 +1,110 @@ | |||
# | |||
# Copyright (C) 2015 OpenWrt.org | |||
# | |||
# This is free software, licensed under the GNU General Public License v2. | |||
# See /LICENSE for more information. | |||
# | |||
include $(TOPDIR)/rules.mk | |||
PKG_NAME:=pianod | |||
PKG_VERSION:=173 | |||
PKG_RELEASE:=2 | |||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz | |||
PKG_SOURCE_URL:=http://deviousfish.com/Downloads/pianod/ | |||
PKG_MD5SUM:=be0cec19ea6df1c4bc6c1cac8e253445 | |||
PKG_MAINTAINER:=Ted Hess <thess@kitschensync.net> | |||
PKG_LICENSE:=MIT VARIOUS | |||
PKG_LICENSE_FILES:=COPYING | |||
PKG_FIXUP:=autoreconf | |||
PKG_INSTALL:=1 | |||
include $(INCLUDE_DIR)/package.mk | |||
define Package/pianod | |||
SECTION:=sound | |||
CATEGORY:=Sound | |||
DEPENDS:=+libao +libfaad2 +libmad +libpolarssl +libjson-c +libgcrypt +libpthread | |||
TITLE:=Pandora radio daemon | |||
USERID:=pianod=88:pianod=88 | |||
URL:=http://deviousfish.com/pianod/ | |||
endef | |||
define Package/pianod/description | |||
pianod is a Pandora music player client with line-oriented and Websocket control interfaces. | |||
A simple protocol makes for easy clients, mix scripting, integration with a | |||
home automation system, use as multiple-user music system for home or office. | |||
Documentation and configuration information can be found at: | |||
http://deviousfish.com/pianod/ | |||
endef | |||
define Package/pianod-client | |||
SECTION:=sound | |||
CATEGORY:=Sound | |||
DEPENDS:=+pianod | |||
TITLE:=Pandora radio daemon WebUI | |||
URL:=http://deviousfish.com/pianod/ | |||
endef | |||
define Package/pianod-client/description | |||
Web client UI and remote player viewer for pianod | |||
Examples --- (Note: The viewer.* files need not be on the pianod host) | |||
Main interface: http://pianod-host:4446/pianod | |||
Remote viewer: file:///<path>/viewer.html?server=pianod-host:4446 --or-- | |||
http://pianod-host:4446/pianod/viewer.html?server=pianod-host:4446 | |||
endef | |||
CONFIGURE_ARGS+= --with-polarssl | |||
PIANOD_CLIENT:=pianod-client-compiled-51.tar.gz | |||
define Download/pianod-client | |||
URL:=$(PKG_SOURCE_URL)/Devel | |||
FILE:=$(PIANOD_CLIENT) | |||
MD5SUM:=abbdee5627bcee6a00c8304da8b4e2e7 | |||
endef | |||
define Package/pianod/conffiles | |||
/etc/pianod/startscript | |||
/etc/pianod/users | |||
endef | |||
define Build/Prepare | |||
$(call Build/Prepare/Default) | |||
ifeq ($(CONFIG_PACKAGE_pianod-client),y) | |||
$(eval $(call Download,pianod-client)) | |||
mkdir -p $(PKG_BUILD_DIR)/pianod-client | |||
$(TAR) -xf $(DL_DIR)/$(PIANOD_CLIENT) --strip=1 -C $(PKG_BUILD_DIR)/pianod-client | |||
endif | |||
endef | |||
define Package/pianod-client/Configure | |||
endef | |||
define Package/pianod-client/Compile | |||
endef | |||
define Package/pianod/install | |||
$(INSTALL_DIR) $(1)/usr/bin | |||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/pianod $(1)/usr/bin/ | |||
# These scripts need ksh (install mksh and link) | |||
# $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/piano $(1)/usr/bin/ | |||
# $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/runmix $(1)/usr/bin/ | |||
$(INSTALL_DIR) $(1)/etc/pianod | |||
$(INSTALL_DATA) $(PKG_BUILD_DIR)/contrib/startscript-example $(1)/etc/pianod/startscript | |||
$(INSTALL_DIR) $(1)/etc/init.d | |||
$(INSTALL_BIN) ./files/pianod.init $(1)/etc/init.d/pianod | |||
endef | |||
define Package/pianod-client/install | |||
$(INSTALL_DIR) $(1)/www/pianod | |||
$(INSTALL_DATA) $(PKG_BUILD_DIR)/pianod-client/*.{html,js,gif,jpeg,css} $(1)/www/pianod/ | |||
endef | |||
$(eval $(call BuildPackage,pianod)) | |||
$(eval $(call BuildPackage,pianod-client)) |
@ -0,0 +1,42 @@ | |||
#!/bin/sh /etc/rc.common | |||
# Copyright (C) 2015 OpenWrt.org | |||
NAME=pianod | |||
START=95 | |||
USE_PROCD=1 | |||
PD_USER=$NAME | |||
PD_STARTSCRIPT=/etc/$NAME/startscript | |||
PD_PASSWDFILE=/etc/$NAME/users | |||
PD_WEBUI=/www/$NAME | |||
start_service() { | |||
# Take group ownership of audio devices | |||
chown root:$NAME /dev/snd/* /dev/mixer /dev/dsp | |||
chmod 664 /dev/snd/* /dev/mixer /dev/dsp | |||
procd_open_instance | |||
procd_set_param command "/usr/bin/$NAME" | |||
procd_append_param command -n $PD_USER | |||
procd_append_param command -i "$PD_STARTSCRIPT" | |||
procd_append_param command -u "$PD_PASSWDFILE" | |||
[ -d "$PD_WEBUI" ] && procd_append_param command -c "$PD_WEBUI" | |||
# No HTTPS support without certificates | |||
procd_append_param command -s 0 | |||
procd_close_instance | |||
} | |||
# Wait for service to exit and release sockets | |||
reload_service() { | |||
stop | |||
sleep 2 | |||
start | |||
} | |||
restart() { | |||
reload_service | |||
} |
@ -0,0 +1,29 @@ | |||
--- a/src/libwaitress/waitress.c | |||
+++ b/src/libwaitress/waitress.c | |||
@@ -813,7 +813,14 @@ static WaitressReturn_t WaitressConnect | |||
sizeof (sockopt)); | |||
/* non-blocking connect will return immediately */ | |||
- connect (sock, gacurr->ai_addr, gacurr->ai_addrlen); | |||
+ if (connect (sock, gacurr->ai_addr, gacurr->ai_addrlen) == -1) { | |||
+ // Error if not in-progress or immediate success | |||
+ if (errno != EINPROGRESS) { | |||
+ // Close socket and try alternatives | |||
+ close (sock); | |||
+ continue; | |||
+ } | |||
+ } | |||
pollres = WaitressPollLoop (sock, POLLOUT, waith->timeout); | |||
if (pollres == 0) { | |||
--- a/src/libfootball/fb_service.c | |||
+++ b/src/libfootball/fb_service.c | |||
@@ -111,6 +111,8 @@ static bool fb_setup_socket (FB_SERVICE | |||
service->socket [which] = 0; | |||
} else { | |||
fb_perror ("socket"); | |||
+ // Element must be zero (not -1) | |||
+ service->socket [which] = 0; | |||
}; | |||
return false; | |||
} |
@ -0,0 +1,42 @@ | |||
--- a/configure.ac | |||
+++ b/configure.ac | |||
@@ -31,8 +31,6 @@ AC_CHECK_LIB([pthread], [pthread_create] | |||
# with it, but don't consider it an error. | |||
# PKG_CHECK_MODULES only validates that pkg-config returns stuff; it doesn't | |||
# validate that these are correct, so check lib to make sure they're right. | |||
-PKG_CHECK_MODULES([gnutls], [gnutls],, | |||
- [AC_MSG_WARN([No pkg-config for libgnutls])]) | |||
PKG_CHECK_MODULES([ao], [ao],, | |||
[AC_MSG_WARN([No pkg-config for libao])]) | |||
PKG_CHECK_MODULES([mad], [mad],, | |||
@@ -42,12 +40,28 @@ PKG_CHECK_MODULES([json], [json-c],, | |||
[PKG_CHECK_MODULES([json], [json0],, | |||
[AC_MSG_WARN([No pkg-config for json-c (aka libjson0, libjson)])])])]) | |||
+ | |||
# Network communication stuff: | |||
AC_CHECK_LIB([gcrypt], [gcry_cipher_open],, | |||
[AC_MSG_ERROR([Cannot find required library: libgcrypt],1)]) | |||
-AC_CHECK_LIB([gnutls], [gnutls_record_recv],, | |||
+# Check for SSL option | |||
+AC_ARG_WITH(polarssl, [ --with-polarssl Build waitress with PolarSSL (default GNUTLS)], [ | |||
+ AC_MSG_RESULT(>>Using PolarSSL) | |||
+ HAS_POLARSSL=1 | |||
+ AC_DEFINE([USE_POLARSSL], 1, [Build for PolarSSL]) | |||
+ PKG_CHECK_MODULES([polarssl], [polarssl],, | |||
+ [AC_MSG_WARN([No pkg-config for libpolarssl])]) | |||
+ AC_CHECK_LIB([polarssl], [ssl_set_session],, | |||
+ [AC_MSG_ERROR([Cannot find required library: libpolarssl (aka polarssl)],1)])] ) | |||
+AM_CONDITIONAL([USE_POLARSSL],[test "x$HAS_POLARSSL" = "x1"]) | |||
+ | |||
+if test "x$HAS_POLARSSL" != x1 ; then | |||
+ PKG_CHECK_MODULES([gnutls], [gnutls],, | |||
+ [AC_MSG_WARN([No pkg-config for libgnutls])]) | |||
+ AC_CHECK_LIB([gnutls], [gnutls_record_recv],, | |||
[AC_MSG_ERROR([Cannot find required library: libgnutls (aka gnutls)],1)]) | |||
-AC_CHECK_FUNCS(gnutls_transport_set_int2 gnutls_sec_param_to_pk_bits) | |||
+ AC_CHECK_FUNCS(gnutls_transport_set_int2 gnutls_sec_param_to_pk_bits) | |||
+fi | |||
# Bloody json library may be linked via -ljson, or -ljson-c depending on | |||
# the platform. Try both. |
@ -0,0 +1,59 @@ | |||
--- a/src/libpiano/config.h | |||
+++ /dev/null | |||
@@ -1 +0,0 @@ | |||
-#define PACKAGE "libpiano" | |||
--- a/src/libwaitress/config.h | |||
+++ /dev/null | |||
@@ -1 +0,0 @@ | |||
-#define PACKAGE "libwaitress" | |||
--- a/src/libpiano/piano.h | |||
+++ b/src/libpiano/piano.h | |||
@@ -39,6 +39,8 @@ THE SOFTWARE. | |||
* http://pan-do-ra-api.wikia.com | |||
*/ | |||
+#define LIBPIANO_NAME "libpiano" | |||
+ | |||
#define PIANO_RPC_HOST "tuner.pandora.com" | |||
#define PIANO_RPC_PATH "/services/json/?" | |||
--- a/src/libwaitress/waitress.c | |||
+++ b/src/libwaitress/waitress.c | |||
@@ -922,14 +922,14 @@ static WaitressReturn_t WaitressSendRequ | |||
if (WaitressProxyEnabled (waith) && !waith->url.tls) { | |||
snprintf (buf, WAITRESS_BUFFER_SIZE, | |||
"%s http://%s:%s/%s HTTP/" WAITRESS_HTTP_VERSION "\r\n" | |||
- "Host: %s\r\nUser-Agent: " PACKAGE "\r\nConnection: Close\r\n", | |||
+ "Host: %s\r\nUser-Agent: " LIBWAITRESS_NAME "\r\nConnection: Close\r\n", | |||
(waith->method == WAITRESS_METHOD_GET ? "GET" : "POST"), | |||
waith->url.host, | |||
WaitressDefaultPort (&waith->url), path, waith->url.host); | |||
} else { | |||
snprintf (buf, WAITRESS_BUFFER_SIZE, | |||
"%s /%s HTTP/" WAITRESS_HTTP_VERSION "\r\n" | |||
- "Host: %s\r\nUser-Agent: " PACKAGE "\r\nConnection: Close\r\n", | |||
+ "Host: %s\r\nUser-Agent: " LIBWAITRESS_NAME "\r\nConnection: Close\r\n", | |||
(waith->method == WAITRESS_METHOD_GET ? "GET" : "POST"), | |||
path, waith->url.host); | |||
} | |||
--- a/src/libwaitress/waitress.h | |||
+++ b/src/libwaitress/waitress.h | |||
@@ -29,6 +29,8 @@ THE SOFTWARE. | |||
#include <stdbool.h> | |||
#include <gnutls/gnutls.h> | |||
+#define LIBWAITRESS_NAME "libwaitress" | |||
+ | |||
#define WAITRESS_BUFFER_SIZE 10*1024 | |||
typedef enum { | |||
--- a/src/libpiano/request.c | |||
+++ b/src/libpiano/request.c | |||
@@ -40,6 +40,7 @@ THE SOFTWARE. | |||
#include <stdio.h> | |||
#include <string.h> | |||
/* needed for urlencode */ | |||
+#include <config.h> | |||
#include <waitress.h> | |||
#include "piano.h" |
@ -0,0 +1,344 @@ | |||
--- a/src/libwaitress/waitress.h | |||
+++ b/src/libwaitress/waitress.h | |||
@@ -27,7 +27,12 @@ THE SOFTWARE. | |||
#include <stdlib.h> | |||
#include <unistd.h> | |||
#include <stdbool.h> | |||
+ | |||
+#if defined(USE_POLARSSL) | |||
+typedef struct _polarssl_ctx polarssl_ctx; | |||
+#else | |||
#include <gnutls/gnutls.h> | |||
+#endif | |||
#define LIBWAITRESS_NAME "libwaitress" | |||
@@ -102,8 +107,9 @@ typedef struct { | |||
WaitressUrl_t url; | |||
WaitressUrl_t proxy; | |||
+#if !defined(USE_POLARSSL) | |||
gnutls_certificate_credentials_t tlsCred; | |||
- | |||
+#endif | |||
/* per-request data */ | |||
struct { | |||
int sockfd; | |||
@@ -121,7 +127,11 @@ typedef struct { | |||
WaitressReturn_t (*read) (void *, char *, const size_t, size_t *); | |||
WaitressReturn_t (*write) (void *, const char *, const size_t); | |||
+#if defined(USE_POLARSSL) | |||
+ polarssl_ctx* sslCtx; | |||
+#else | |||
gnutls_session_t tlsSession; | |||
+#endif | |||
} request; | |||
} WaitressHandle_t; | |||
--- a/src/pianod.c | |||
+++ b/src/pianod.c | |||
@@ -531,8 +531,11 @@ static bool initialize_libraries (APPSTA | |||
gcry_check_version (NULL); | |||
gcry_control (GCRYCTL_DISABLE_SECMEM, 0); | |||
gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); | |||
+ | |||
+#if !defined(USE_POLARSSL) | |||
int crystatus = gnutls_global_init (); | |||
if (crystatus == GNUTLS_E_SUCCESS) { | |||
+#endif | |||
PianoReturn_t status = PianoInit (&app->ph, app->settings.partnerUser, app->settings.partnerPassword, | |||
app->settings.device, app->settings.inkey, app->settings.outkey); | |||
if (status == PIANO_RET_OK) { | |||
@@ -545,11 +548,13 @@ static bool initialize_libraries (APPSTA | |||
} else { | |||
flog (LOG_ERROR, "initialize_libraries: PianoInit: %s", PianoErrorToStr (status)); | |||
} | |||
+#if !defined(USE_POLARSSL) | |||
gnutls_global_deinit (); | |||
} else { | |||
flog (LOG_ERROR, "initialize_libraries: gnutls_global_init: %s", gcry_strerror (crystatus)); | |||
} | |||
+#endif | |||
return false; | |||
} | |||
@@ -728,7 +733,9 @@ int main (int argc, char **argv) { | |||
PianoDestroyPlaylist (app.song_history); | |||
PianoDestroyPlaylist (app.playlist); | |||
WaitressFree (&app.waith); | |||
+#if !defined(USE_POLARSSL) | |||
gnutls_global_deinit (); | |||
+#endif | |||
settings_destroy (&app.settings); | |||
} | |||
--- a/src/libwaitress/waitress.c | |||
+++ b/src/libwaitress/waitress.c | |||
@@ -41,11 +41,33 @@ THE SOFTWARE. | |||
#include <assert.h> | |||
#include <stdint.h> | |||
-#include <gnutls/x509.h> | |||
#include "config.h" | |||
#include "waitress.h" | |||
+#if defined(USE_POLARSSL) | |||
+ | |||
+#include <polarssl/ssl.h> | |||
+#include <polarssl/entropy.h> | |||
+#include <polarssl/ctr_drbg.h> | |||
+#include <polarssl/x509.h> | |||
+#include <polarssl/sha1.h> | |||
+ | |||
+struct _polarssl_ctx | |||
+{ | |||
+ ssl_context ssl; | |||
+ ssl_session session; | |||
+ entropy_context entrophy; | |||
+ ctr_drbg_context rnd; | |||
+}; | |||
+ | |||
+#else | |||
+ | |||
+// Use gnutls by default (USE_POLARSSL not defined) | |||
+#include <gnutls/x509.h> | |||
+ | |||
+#endif | |||
+ | |||
#define strcaseeq(a,b) (strcasecmp(a,b) == 0) | |||
#define WAITRESS_HTTP_VERSION "1.1" | |||
@@ -56,6 +78,13 @@ typedef struct { | |||
static WaitressReturn_t WaitressReceiveHeaders (WaitressHandle_t *, size_t *); | |||
+// gnutls wants (void *) and polarssl want (unsigned char *) | |||
+#if defined(USE_POLARSSL) | |||
+#define BUFFER_CAST unsigned char | |||
+#else | |||
+#define BUFFER_CAST void | |||
+#endif | |||
+ | |||
#define READ_RET(buf, count, size) \ | |||
if ((wRet = waith->request.read (waith, buf, count, size)) != \ | |||
WAITRESS_RET_OK) { \ | |||
@@ -444,7 +473,7 @@ static int WaitressPollLoop (int fd, sho | |||
* @param write count bytes | |||
* @return number of written bytes or -1 on error | |||
*/ | |||
-static ssize_t WaitressPollWrite (void *data, const void *buf, size_t count) { | |||
+static ssize_t WaitressPollWrite (void *data, const BUFFER_CAST *buf, size_t count) { | |||
int pollres = -1; | |||
ssize_t retSize; | |||
WaitressHandle_t *waith = data; | |||
@@ -478,13 +507,20 @@ static WaitressReturn_t WaitressOrdinary | |||
return waith->request.readWriteRet; | |||
} | |||
-static WaitressReturn_t WaitressGnutlsWrite (void *data, const char *buf, | |||
+static WaitressReturn_t WaitressTlsWrite (void *data, const char *buf, | |||
const size_t size) { | |||
WaitressHandle_t *waith = data; | |||
+#if defined(USE_POLARSSL) | |||
+ | |||
+ if (ssl_write (&waith->request.sslCtx->ssl, buf, size) < 0) { | |||
+ return WAITRESS_RET_TLS_WRITE_ERR; | |||
+ } | |||
+#else | |||
if (gnutls_record_send (waith->request.tlsSession, buf, size) < 0) { | |||
return WAITRESS_RET_TLS_WRITE_ERR; | |||
} | |||
+#endif | |||
return waith->request.readWriteRet; | |||
} | |||
@@ -494,7 +530,7 @@ static WaitressReturn_t WaitressGnutlsWr | |||
* @param buffer size | |||
* @return number of read bytes or -1 on error | |||
*/ | |||
-static ssize_t WaitressPollRead (void *data, void *buf, size_t count) { | |||
+static ssize_t WaitressPollRead (void *data, BUFFER_CAST *buf, size_t count) { | |||
int pollres = -1; | |||
ssize_t retSize; | |||
WaitressHandle_t *waith = data; | |||
@@ -531,16 +567,34 @@ static WaitressReturn_t WaitressOrdinary | |||
return waith->request.readWriteRet; | |||
} | |||
-static WaitressReturn_t WaitressGnutlsRead (void *data, char *buf, | |||
+static WaitressReturn_t WaitressTlsRead (void *data, char *buf, | |||
const size_t size, size_t *retSize) { | |||
WaitressHandle_t *waith = data; | |||
+#if defined(USE_POLARSSL) | |||
+ int ret; | |||
+ | |||
+ *retSize = 0; | |||
+ waith->request.readWriteRet = WAITRESS_RET_OK; | |||
+ ret = ssl_read (&waith->request.sslCtx->ssl, buf, size); | |||
+ | |||
+ if (ret < 0) { | |||
+ if (ret != POLARSSL_ERR_SSL_PEER_CLOSE_NOTIFY) { | |||
+ waith->request.readWriteRet = WAITRESS_RET_TLS_READ_ERR; | |||
+ } | |||
+ | |||
+ return waith->request.readWriteRet; | |||
+ } | |||
+ | |||
+ *retSize = ret; | |||
+#else | |||
ssize_t ret = gnutls_record_recv (waith->request.tlsSession, buf, size); | |||
if (ret < 0) { | |||
return WAITRESS_RET_TLS_READ_ERR; | |||
} else { | |||
*retSize = ret; | |||
} | |||
+#endif | |||
return waith->request.readWriteRet; | |||
} | |||
@@ -727,10 +781,28 @@ static int WaitressParseStatusline (cons | |||
/* verify server certificate | |||
*/ | |||
static WaitressReturn_t WaitressTlsVerify (const WaitressHandle_t *waith) { | |||
+ | |||
+#if defined(USE_POLARSSL) | |||
+ unsigned char fingerprint[20]; | |||
+ | |||
+ const x509_crt* cert = ssl_get_peer_cert (&waith->request.sslCtx->ssl); | |||
+ | |||
+ if (NULL == cert) { | |||
+ return WAITRESS_RET_TLS_HANDSHAKE_ERR; | |||
+ } | |||
+ | |||
+ sha1 (cert->raw.p, cert->raw.len, fingerprint); | |||
+ | |||
+ if (memcmp (fingerprint, waith->tlsFingerprint, sizeof (fingerprint)) != 0) { | |||
+ return WAITRESS_RET_TLS_FINGERPRINT_MISMATCH; | |||
+ } | |||
+ | |||
+#else | |||
gnutls_session_t session = waith->request.tlsSession; | |||
unsigned int certListSize; | |||
const gnutls_datum_t *certList; | |||
gnutls_x509_crt_t cert; | |||
+ char fingerprint[20]; | |||
if (gnutls_certificate_type_get (session) != GNUTLS_CRT_X509) { | |||
return WAITRESS_RET_TLS_HANDSHAKE_ERR; | |||
@@ -750,7 +822,6 @@ static WaitressReturn_t WaitressTlsVerif | |||
return WAITRESS_RET_TLS_HANDSHAKE_ERR; | |||
} | |||
- char fingerprint[20]; | |||
size_t fingerprintSize = sizeof (fingerprint); | |||
if (gnutls_x509_crt_get_fingerprint (cert, GNUTLS_DIG_SHA1, fingerprint, | |||
&fingerprintSize) != 0) { | |||
@@ -763,7 +834,7 @@ static WaitressReturn_t WaitressTlsVerif | |||
} | |||
gnutls_x509_crt_deinit (cert); | |||
- | |||
+#endif | |||
return WAITRESS_RET_OK; | |||
} | |||
@@ -807,11 +878,6 @@ static WaitressReturn_t WaitressConnect | |||
/* we need shorter timeouts for connect() */ | |||
fcntl (sock, F_SETFL, O_NONBLOCK); | |||
- /* increase socket receive buffer */ | |||
- const int sockopt = 256*1024; | |||
- setsockopt (sock, SOL_SOCKET, SO_RCVBUF, &sockopt, | |||
- sizeof (sockopt)); | |||
- | |||
/* non-blocking connect will return immediately */ | |||
if (connect (sock, gacurr->ai_addr, gacurr->ai_addrlen) == -1) { | |||
// Error if not in-progress or immediate success | |||
@@ -880,6 +946,11 @@ static WaitressReturn_t WaitressConnect | |||
} | |||
} | |||
+#if defined(USE_POLARSSL) | |||
+ if (ssl_handshake (&waith->request.sslCtx->ssl) != 0) { | |||
+ return WAITRESS_RET_TLS_HANDSHAKE_ERR; | |||
+ } | |||
+#else | |||
/* Ignore return code as connection will likely still succeed */ | |||
gnutls_server_name_set (waith->request.tlsSession, GNUTLS_NAME_DNS, | |||
waith->url.host, strlen (waith->url.host)); | |||
@@ -887,14 +958,15 @@ static WaitressReturn_t WaitressConnect | |||
if (gnutls_handshake (waith->request.tlsSession) != GNUTLS_E_SUCCESS) { | |||
return WAITRESS_RET_TLS_HANDSHAKE_ERR; | |||
} | |||
+#endif | |||
if ((wRet = WaitressTlsVerify (waith)) != WAITRESS_RET_OK) { | |||
return wRet; | |||
} | |||
/* now we can talk encrypted */ | |||
- waith->request.read = WaitressGnutlsRead; | |||
- waith->request.write = WaitressGnutlsWrite; | |||
+ waith->request.read = WaitressTlsRead; | |||
+ waith->request.write = WaitressTlsWrite; | |||
} | |||
return WAITRESS_RET_OK; | |||
@@ -1120,6 +1192,21 @@ WaitressReturn_t WaitressFetchCall (Wait | |||
waith->request.contentLengthKnown = false; | |||
if (waith->url.tls) { | |||
+#if defined(USE_POLARSSL) | |||
+ waith->request.sslCtx = calloc (1, sizeof(polarssl_ctx)); | |||
+ | |||
+ entropy_init (&waith->request.sslCtx->entrophy); | |||
+ ctr_drbg_init (&waith->request.sslCtx->rnd, entropy_func, &waith->request.sslCtx->entrophy, "libwaitress", 11); | |||
+ ssl_init (&waith->request.sslCtx->ssl); | |||
+ | |||
+ ssl_set_endpoint (&waith->request.sslCtx->ssl, SSL_IS_CLIENT); | |||
+ ssl_set_authmode (&waith->request.sslCtx->ssl, SSL_VERIFY_NONE); | |||
+ ssl_set_rng (&waith->request.sslCtx->ssl, ctr_drbg_random, &waith->request.sslCtx->rnd); | |||
+ ssl_set_session (&waith->request.sslCtx->ssl, &waith->request.sslCtx->session); | |||
+ ssl_set_bio (&waith->request.sslCtx->ssl, | |||
+ WaitressPollRead, waith, | |||
+ WaitressPollWrite, waith); | |||
+#else | |||
gnutls_init (&waith->request.tlsSession, GNUTLS_CLIENT); | |||
gnutls_set_default_priority (waith->request.tlsSession); | |||
@@ -1137,6 +1224,7 @@ WaitressReturn_t WaitressFetchCall (Wait | |||
WaitressPollRead); | |||
gnutls_transport_set_push_function (waith->request.tlsSession, | |||
WaitressPollWrite); | |||
+#endif | |||
} | |||
/* buffer is required for connect already */ | |||
@@ -1148,15 +1236,22 @@ WaitressReturn_t WaitressFetchCall (Wait | |||
if ((wRet = WaitressSendRequest (waith)) == WAITRESS_RET_OK) { | |||
wRet = WaitressReceiveResponse (waith); | |||
} | |||
+#if !defined(USE_POLARSSL) | |||
if (waith->url.tls) { | |||
gnutls_bye (waith->request.tlsSession, GNUTLS_SHUT_RDWR); | |||
} | |||
+#endif | |||
} | |||
/* cleanup */ | |||
if (waith->url.tls) { | |||
+#if defined(USE_POLARSSL) | |||
+ ssl_free (&waith->request.sslCtx->ssl); | |||
+ free (waith->request.sslCtx); | |||
+#else | |||
gnutls_deinit (waith->request.tlsSession); | |||
gnutls_certificate_free_credentials (waith->tlsCred); | |||
+#endif | |||
} | |||
if (waith->request.sockfd != -1) { | |||
close (waith->request.sockfd); |
@ -0,0 +1,11 @@ | |||
Index: mmc-utils-f4eb241519f8d500ce6068a70d2389be39ac5189/Makefile | |||
=================================================================== | |||
--- mmc-utils-f4eb241519f8d500ce6068a70d2389be39ac5189.orig/Makefile | |||
+++ mmc-utils-f4eb241519f8d500ce6068a70d2389be39ac5189/Makefile | |||
@@ -1,5 +1,5 @@ | |||
CC ?= gcc | |||
-AM_CFLAGS = -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 | |||
+AM_CFLAGS = -D_FILE_OFFSET_BITS=64 | |||
CFLAGS ?= -g -O2 | |||
objects = \ | |||
mmc.o \ |