Browse Source

lua-openssl: update to 0.7.8-0

Swith to building with CMake to avoid huge patching of the stock
Makefile.

Reorganize Makefile for consistency between packages.

Add patch to fix deprecated OpenSSL functions.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
lilik-openwrt-22.03
Rosen Penev 4 years ago
parent
commit
38f01ad2c9
4 changed files with 164 additions and 156 deletions
  1. +10
    -10
      lang/lua-openssl/Makefile
  2. +0
    -146
      lang/lua-openssl/patches/0001-Revise-Makefile.patch
  3. +11
    -0
      lang/lua-openssl/patches/010-cmake.patch
  4. +143
    -0
      lang/lua-openssl/patches/020-openssl-deprecated.patch

+ 10
- 10
lang/lua-openssl/Makefile View File

@ -8,19 +8,19 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=lua-openssl PKG_NAME:=lua-openssl
PKG_VERSION:=0.7.4
PKG_RELEASE:=1
PKG_MAINTAINER:=Amnon Paz <pazamnon@gmail.com>
PKG_LICENSE:=MIT
PKG_RELEASE:=$(AUTORELEASE)
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_MIRROR_HASH:=c27cedee438de95877823b1ae0607556564d82c8692be40f43743ca9cc5a029a
PKG_SOURCE_URL:=https://github.com/zhaozg/lua-openssl.git
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=96effbaf477ca205f1787aaf1cce643bd208066b
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_URL:=https://github.com/zhaozg/lua-openssl.git
PKG_SOURCE_VERSION:=0.7.8-0
PKG_MIRROR_HASH:=890dda7b23ff303e70ca8aa0d729836de347c0e58057282f55c6abf87e39c602
PKG_MAINTAINER:=Amnon Paz <pazamnon@gmail.com>
PKG_LICENSE:=MIT
PKG_LICENSE_FILES:=LICENSE
include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/package.mk
include ../../devel/ninja/ninja-cmake.mk
define Package/lua-openssl define Package/lua-openssl
SUBMENU:=Lua SUBMENU:=Lua
@ -37,7 +37,7 @@ endef
define Package/lua-openssl/install define Package/lua-openssl/install
$(INSTALL_DIR) $(1)/usr/lib/lua $(INSTALL_DIR) $(1)/usr/lib/lua
$(INSTALL_BIN) $(PKG_BUILD_DIR)/openssl.so $(1)/usr/lib/lua/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/lua/5.1/openssl.so $(1)/usr/lib/lua/
endef endef
$(eval $(call BuildPackage,lua-openssl)) $(eval $(call BuildPackage,lua-openssl))

+ 0
- 146
lang/lua-openssl/patches/0001-Revise-Makefile.patch View File

@ -1,146 +0,0 @@
--- a/Makefile
+++ b/Makefile
@@ -1,121 +1,52 @@
T=openssl
+.PHONY: install clean
-PREFIX ?=/usr/local
-CC := $(CROSS)$(CC)
-AR := $(CROSS)$(AR)
-LD := $(CROSS)$(LD)
-
-#OS auto detect
-ifneq (,$(TARGET_SYS))
- SYS := $(TARGET_SYS)
-else
- SYS := $(shell gcc -dumpmachine)
-endif
-
-#Lua auto detect
-LUA_VERSION := $(shell pkg-config luajit --print-provides)
-ifeq ($(LUA_VERSION),)
- # Not found luajit package, try lua
- LUA_VERSION := $(shell pkg-config lua --print-provides)
- ifeq ($(LUA_VERSION),)
- # Not found lua package, try from prefix
- LUA_VERSION := $(shell lua -e "_,_,v=string.find(_VERSION,'Lua (.+)');print(v)")
- LUA_CFLAGS ?= -I$(PREFIX)/include/lua$(LUA_VERSION)
- LUA_LIBS ?= -L$(PREFIX)/lib -llua
- LUA_LIBDIR ?= $(PREFIX)/lib/lua/$(LUA_VERSION)
- else
- # Found lua package
- LUA_VERSION := $(shell lua -e "_,_,v=string.find(_VERSION,'Lua (.+)');print(v)")
- LUA_CFLAGS ?= $(shell pkg-config lua --cflags)
- LUA_LIBS ?= $(shell pkg-config lua --libs)
- LUA_LIBDIR ?= $(PREFIX)/lib/lua/$(LUA_VERSION)
- endif
-else
- # Found luajit package
- LUA_VERSION := $(shell luajit -e "_,_,v=string.find(_VERSION,'Lua (.+)');print(v)")
- LUA_CFLAGS ?= $(shell pkg-config luajit --cflags)
- LUA_LIBS ?= $(shell pkg-config luajit --libs)
- LUA_LIBDIR ?= $(PREFIX)/lib/lua/$(LUA_VERSION)
-endif
-
-#OpenSSL auto detect
-OPENSSL_CFLAGS ?= $(shell pkg-config openssl --cflags)
-OPENSSL_LIBS ?= $(shell pkg-config openssl --static --libs)
-
-ifneq (, $(findstring linux, $(SYS)))
- # Do linux things
- CFLAGS = -fpic
- LDFLAGS = -Wl,--no-undefined -fpic -lrt -ldl -lm
-endif
-
-ifneq (, $(findstring apple, $(SYS)))
- # Do darwin things
- CFLAGS = -fPIC
- LDFLAGS = -fPIC -undefined dynamic_lookup -ldl
- #MACOSX_DEPLOYMENT_TARGET="10.3"
- CC := MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET} $(CC)
-endif
+PKGC ?= pkg-config
-ifneq (, $(findstring mingw, $(SYS)))
- # Do mingw things
- CFLAGS = -DLUA_LIB -DLUA_BUILD_AS_DLL -DWIN32_LEAN_AND_MEAN
-endif
+LIB_OPTION = -shared
+LUAPKGC = lua
-ifneq (, $(findstring cygwin, $(SYS)))
- # Do cygwin things
- CFLAGS = -fPIC
-endif
+# LUA include/libraries build flags
+LUA_CFLAGS := $(shell $(PKGC) --cflags $(LUAPKGC))
+LUA_LIBS_DIR := $(shell $(PKGC) --libs $(LUAPKGC))
-ifneq (, $(findstring iOS, $(SYS)))
- # Do iOS things
- CFLAGS = -fPIC
- LDFLAGS = -fPIC -ldl
-endif
+# openssl include/libraries build flags
+OPENSSL_CFLAGS ?= $(shell $(PKGC) openssl --cflags)
+OPENSSL_LIBS_DIR ?= $(shell $(PKGC) openssl --libs)
-#custom config
+LDFLAGS = -Wl,--no-undefined -fpic -lrt -ldl -lm $(OPENSSL_LIBS_DIR) $(LUA_LIBS_DIR)
+CFLAGS += -fPIC -DPTHREADS $(OPENSSL_CFLAGS) $(LUA_CFLAGS)
ifeq (.config, $(wildcard .config))
- include .config
+include .config
endif
-LIBNAME= $T.so.$V
+LIBNAME= $T.so
-CFLAGS += $(OPENSSL_CFLAGS) $(LUA_CFLAGS) $(TARGET_FLAGS)
-LDFLAGS += -shared $(OPENSSL_LIBS) $(LUA_LIBS)
# Compilation directives
WARN_MIN = -Wall -Wno-unused-value
WARN = -Wall
WARN_MOST = $(WARN) -W -Waggregate-return -Wcast-align -Wmissing-prototypes -Wnested-externs -Wshadow -Wwrite-strings -pedantic
CFLAGS += -g $(WARN_MIN) -DPTHREADS -Ideps -Ideps/lua-compat -Ideps/auxiliar
-
OBJS=src/asn1.o deps/auxiliar/auxiliar.o src/bio.o src/cipher.o src/cms.o src/compat.o src/crl.o src/csr.o src/dh.o src/digest.o src/dsa.o \
src/ec.o src/engine.o src/hmac.o src/lbn.o src/lhash.o src/misc.o src/ocsp.o src/openssl.o src/ots.o src/pkcs12.o src/pkcs7.o \
src/pkey.o src/rsa.o src/ssl.o src/th-lock.o src/util.o src/x509.o src/xattrs.o src/xexts.o src/xname.o src/xstore.o \
src/xalgor.o src/callback.o src/srp.o deps/auxiliar/subsidiar.o
-.c.o:
- $(CC) $(CFLAGS) -c -o $@ $?
+%.o: %.c
+ $(CC) $(CFLAGS) -c $< -o $@
all: $T.so
- @echo "Target system: "$(SYS)
+ echo $(SYS)
+ $(CC) $(LDFLAGS) $(LIB_OPTION) $(OBJS) -o $@
-$T.so: lib$T.a
- $(CC) -o $@ src/openssl.o -L. -l$T $(LDFLAGS)
-
-lib$T.a: $(OBJS)
- $(AR) rcs $@ $?
+$T.so: $(OBJS)
+ echo "LUA LIBS_DIR: " $(LUA_LIBS_DIR)
+ $(CC) $(CFLAGS) $(LIB_OPTION) -o $T.so $(OBJS) $(LDFLAGS)
install: all
mkdir -p $(LUA_LIBDIR)
cp $T.so $(LUA_LIBDIR)
-info:
- @echo "Target system: "$(SYS)
- @echo "CC:" $(CC)
- @echo "AR:" $(AR)
- @echo "PREFIX:" $(PREFIX)
-
clean:
- rm -f $T.so lib$T.a $(OBJS)
-
-# vim: ts=8 sw=8 noet
+ rm -f $T.so $(OBJS)

+ 11
- 0
lang/lua-openssl/patches/010-cmake.patch View File

@ -0,0 +1,11 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -21,8 +21,6 @@ add_definitions(-DPTHREADS)
if(BUILD_SHARED_LUA_OPENSSL)
set(LUA_OPENSSL_LIBTYPE SHARED)
- add_definitions(-DLUA_BUILD_AS_DLL -DLUA_LIB)
- set(EXTRA_LIBS "ws2_32.lib" "crypt32.lib")
else()
set(LUA_OPENSSL_LIBTYPE STATIC)
endif()

+ 143
- 0
lang/lua-openssl/patches/020-openssl-deprecated.patch View File

@ -0,0 +1,143 @@
--- a/src/cipher.c
+++ b/src/cipher.c
@@ -8,6 +8,10 @@ cipher module for lua-openssl binding
#include "openssl.h"
#include "private.h"
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
+#define EVP_CIPHER_CTX_reset EVP_CIPHER_CTX_init
+#endif
+
/***
list all support cipher algs
@@ -109,7 +113,7 @@ static LUA_FUNCTION(openssl_evp_encrypt)
memcpy(evp_iv, iv, iv_len);
}
- EVP_CIPHER_CTX_init(c);
+ EVP_CIPHER_CTX_reset(c);
ret = EVP_EncryptInit_ex(c, cipher, e, (const byte*)evp_key, iv_len > 0 ? (const byte*)evp_iv : NULL);
if (ret == 1)
{
@@ -131,8 +135,12 @@ static LUA_FUNCTION(openssl_evp_encrypt)
OPENSSL_free(buffer);
}
}
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
+ EVP_CIPHER_CTX_reset(c);
+#else
EVP_CIPHER_CTX_cleanup(c);
EVP_CIPHER_CTX_free(c);
+#endif
return (ret == 1) ? ret : openssl_pushresult(L, ret);
}
else
@@ -196,7 +204,7 @@ static LUA_FUNCTION(openssl_evp_decrypt)
memcpy(evp_iv, iv, iv_len);
}
- EVP_CIPHER_CTX_init(c);
+ EVP_CIPHER_CTX_reset(c);
ret = EVP_DecryptInit_ex(c, cipher, e, key ? (const byte*)evp_key : NULL, iv_len > 0 ? (const byte*)evp_iv : NULL);
if (ret == 1)
{
@@ -220,8 +228,12 @@ static LUA_FUNCTION(openssl_evp_decrypt)
OPENSSL_free(buffer);
}
}
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
+ EVP_CIPHER_CTX_reset(c);
+#else
EVP_CIPHER_CTX_cleanup(c);
EVP_CIPHER_CTX_free(c);
+#endif
return (ret == 1) ? ret : openssl_pushresult(L, ret);
}
else
@@ -292,7 +304,7 @@ static LUA_FUNCTION(openssl_evp_cipher)
memcpy(evp_iv, iv, iv_len);
}
- EVP_CIPHER_CTX_init(c);
+ EVP_CIPHER_CTX_reset(c);
ret = EVP_CipherInit_ex(c, cipher, e, (const byte*)evp_key, iv_len > 0 ? (const byte*)evp_iv : NULL, enc);
if (ret == 1)
{
@@ -317,8 +329,12 @@ static LUA_FUNCTION(openssl_evp_cipher)
OPENSSL_free(buffer);
}
}
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
+ EVP_CIPHER_CTX_reset(c);
+#else
EVP_CIPHER_CTX_cleanup(c);
EVP_CIPHER_CTX_free(c);
+#endif
return (ret == 1) ? ret : openssl_pushresult(L, ret);
}
else
@@ -376,7 +392,7 @@ static LUA_FUNCTION(openssl_cipher_new)
memcpy(evp_iv, iv, iv_len);
}
c = EVP_CIPHER_CTX_new();
- EVP_CIPHER_CTX_init(c);
+ EVP_CIPHER_CTX_reset(c);
if (!EVP_CipherInit_ex(c, cipher, e, key ? (const byte*)evp_key : NULL, iv_len > 0 ? (const byte*)evp_iv : NULL, enc))
{
luaL_error(L, "EVP_CipherInit_ex failed, please check openssl error");
@@ -431,7 +447,7 @@ static LUA_FUNCTION(openssl_cipher_encry
memcpy(evp_iv, iv, iv_len);
}
c = EVP_CIPHER_CTX_new();
- EVP_CIPHER_CTX_init(c);
+ EVP_CIPHER_CTX_reset(c);
ret = EVP_EncryptInit_ex(c, cipher, e,
key ? (const byte*)evp_key : NULL,
iv_len > 0 ? (const byte*)evp_iv : NULL);
@@ -491,7 +507,7 @@ static LUA_FUNCTION(openssl_cipher_decry
memcpy(evp_iv, iv, iv_len);
}
c = EVP_CIPHER_CTX_new();
- EVP_CIPHER_CTX_init(c);
+ EVP_CIPHER_CTX_reset(c);
ret = EVP_DecryptInit_ex(c, cipher, e,
key ? (const byte*)evp_key : NULL,
iv_len > 0 ? (const byte*)evp_iv : NULL);
@@ -937,8 +953,12 @@ static LUA_FUNCTION(openssl_cipher_ctx_f
return 0;
lua_pushnil(L);
lua_rawsetp(L, LUA_REGISTRYINDEX, ctx);
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
+ EVP_CIPHER_CTX_reset(ctx);
+#else
EVP_CIPHER_CTX_cleanup(ctx);
EVP_CIPHER_CTX_free(ctx);
+#endif
FREE_OBJECT(1);
return 0;
}
--- a/src/openssl.c
+++ b/src/openssl.c
@@ -523,9 +523,7 @@ LUALIB_API int luaopen_openssl(lua_State
#endif
#ifndef OPENSSL_NO_ENGINE
- ENGINE_load_dynamic();
- ENGINE_load_openssl();
- ENGINE_load_builtin_engines();
+ ENGINE_register_all_complete();
#endif
#ifdef LOAD_ENGINE_CUSTOM
LOAD_ENGINE_CUSTOM
--- a/src/th-lock.c
+++ b/src/th-lock.c
@@ -310,7 +310,7 @@ unsigned long irix_thread_id(void)
/* Linux and a few others */
#ifdef PTHREADS
-#ifndef OPENSSL_SYS_WIN32
+#if !defined(OPENSSL_SYS_WIN32) && (OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER))
static pthread_mutex_t *lock_cs;
static long *lock_count;

Loading…
Cancel
Save