diff options
author | Jakub Jirutka <jakub@jirutka.cz> | 2017-03-10 00:32:24 +0100 |
---|---|---|
committer | Jakub Jirutka <jakub@jirutka.cz> | 2017-03-10 00:33:18 +0100 |
commit | 066b35bd070d22f59e5f3fd5be29614d34517721 (patch) | |
tree | 26a2e5056b484382130074ce02d8c83288da42da /main/lua-ldap | |
parent | 23980ddbd76a735adb0f6f8f66b4a80d72df363a (diff) | |
download | aports-066b35bd070d22f59e5f3fd5be29614d34517721.tar.bz2 aports-066b35bd070d22f59e5f3fd5be29614d34517721.tar.xz |
main/lua-ldap: fix segfault, iteration error and run tests
Diffstat (limited to 'main/lua-ldap')
-rw-r--r-- | main/lua-ldap/APKBUILD | 28 | ||||
-rw-r--r-- | main/lua-ldap/fix-open_simple-segfault.patch | 31 | ||||
-rw-r--r-- | main/lua-ldap/fix-search-iter.patch | 18 | ||||
-rw-r--r-- | main/lua-ldap/script-to-run-test.lua-against-a-dummy-slapd.patch | 101 | ||||
-rw-r--r-- | main/lua-ldap/update-test.lua-for-5.2.patch | 58 |
5 files changed, 230 insertions, 6 deletions
diff --git a/main/lua-ldap/APKBUILD b/main/lua-ldap/APKBUILD index 57b50e820e..9e3b937005 100644 --- a/main/lua-ldap/APKBUILD +++ b/main/lua-ldap/APKBUILD @@ -4,15 +4,20 @@ pkgname=lua-ldap _pkgname=lualdap pkgver=1.2.3 -pkgrel=2 +pkgrel=3 pkgdesc="Lua binding to LDAP" url="https://github.com/bdellegrazie/lualdap" arch="all" license="MIT" depends="" makedepends="openldap-dev" +checkdepends="bash openldap openldap-back-bdb" subpackages="" -source="$_pkgname-$pkgver.tar.gz::https://github.com/bdellegrazie/$_pkgname/archive/v$pkgver.tar.gz" +source="$_pkgname-$pkgver.tar.gz::https://github.com/bdellegrazie/$_pkgname/archive/v$pkgver.tar.gz + fix-open_simple-segfault.patch + fix-search-iter.patch + script-to-run-test.lua-against-a-dummy-slapd.patch + update-test.lua-for-5.2.patch" builddir="$srcdir/$_pkgname-$pkgver" _luaversions="5.1 5.2 5.3" @@ -37,11 +42,20 @@ build() { msg "Building for Lua $lver..." cd "$builddir-$lver" - make CFLAGS="-DLDAP_DEPRECATED -fPIC -ansi $(pkg-config --cflags lua$lver)" \ + make CFLAGS="-fPIC -ansi -Wall $(pkg-config --cflags lua$lver)" \ OPENLDAP_LIB="-lldap -llber" || return 1 done } +check() { + local lver; for lver in $_luaversions; do + msg "Testing with Lua $lver..." + + cd "$builddir-$lver" + make LUA=lua$lver check || return 1 + done +} + package() { mkdir -p "$pkgdir" } @@ -60,6 +74,8 @@ _package() { install } -md5sums="a9eda2f55640a8c816b4d4c6c3d7ef1b lualdap-1.2.3.tar.gz" -sha256sums="efde10853429fe1c1c208604a352bee395ac897d407f9d7bf9efca62cff02f67 lualdap-1.2.3.tar.gz" -sha512sums="51934d18d1ee97a0130545e657497e51542eef97c338df14e7171f94a2d6395fceb00313e1e64e46e6cdeedf85a17c63284595fdf6fbce8b7abce29d28f1b4a7 lualdap-1.2.3.tar.gz" +sha512sums="51934d18d1ee97a0130545e657497e51542eef97c338df14e7171f94a2d6395fceb00313e1e64e46e6cdeedf85a17c63284595fdf6fbce8b7abce29d28f1b4a7 lualdap-1.2.3.tar.gz +6f71ec19be58e21778cdce0a28d52c2629df736a8cbd119e6b98a306f20df193c0a646449b40104490f992750d1fbcef4519238aca4b9706f7460a6238009769 fix-open_simple-segfault.patch +f1ba8e85421498abab814c20d2e410c5b13a6b63d0d56463ad38434405c5ae1cc694f168edfb37a0a727597f68dd67d511d234947b9df55d6322751275d4df61 fix-search-iter.patch +62d1fb82529ea2d5302a84d163c8cfb5f5681d2927ecb5699a486a2aaf6f6a45f9c36e18d167ed120620615db2693abed1881621e4bb0d7b992445696072989a script-to-run-test.lua-against-a-dummy-slapd.patch +970da7a53d050210298712742decdf2b617450e78ebaed993c73b5300870f2b1979661c83a82d316b37f26f373c2c86d6a024ab82c1b628c73f0ca6e9c61b0ac update-test.lua-for-5.2.patch" diff --git a/main/lua-ldap/fix-open_simple-segfault.patch b/main/lua-ldap/fix-open_simple-segfault.patch new file mode 100644 index 0000000000..ecd9d629d9 --- /dev/null +++ b/main/lua-ldap/fix-open_simple-segfault.patch @@ -0,0 +1,31 @@ +From: Jakub Jirutka <jakub@jirutka.cz> +Date: Fri, 10 Mar 2017 00:28:52 +0100 +Subject: [PATCH] Fix segfault in lualdap_open_simple() + +--- a/src/lualdap.c ++++ b/src/lualdap.c +@@ -1011,7 +1011,7 @@ + int use_tls = lua_toboolean (L, 4); + conn_data *conn = (conn_data *)lua_newuserdata (L, sizeof(conn_data)); + #if defined(LDAP_API_FEATURE_X_OPENLDAP) && LDAP_API_FEATURE_X_OPENLDAP >= 20300 +- struct berval cred = { 0, NULL }; ++ struct berval *cred = NULL; + char *host_with_schema = NULL; + #endif + int err; +@@ -1045,12 +1045,9 @@ + } + /* Bind to a server */ + #if defined(LDAP_API_FEATURE_X_OPENLDAP) && LDAP_API_FEATURE_X_OPENLDAP >= 20300 +- cred.bv_len = strlen(password); +- cred.bv_val = malloc(cred.bv_len+1); +- strcpy(cred.bv_val, password); +- err = ldap_sasl_bind_s (conn->ld, who, LDAP_SASL_SIMPLE, &cred, NULL, NULL, NULL); +- free(cred.bv_val); +- memset(&cred, 0, sizeof(cred)); ++ cred = ber_bvstrdup(password); ++ err = ldap_sasl_bind_s (conn->ld, who, LDAP_SASL_SIMPLE, cred, NULL, NULL, NULL); ++ ber_bvfree(cred); + #else + err = ldap_bind_s (conn->ld, who, password, LDAP_AUTH_SIMPLE); + #endif diff --git a/main/lua-ldap/fix-search-iter.patch b/main/lua-ldap/fix-search-iter.patch new file mode 100644 index 0000000000..6060534171 --- /dev/null +++ b/main/lua-ldap/fix-search-iter.patch @@ -0,0 +1,18 @@ +From: Jakub Jirutka <jakub@jirutka.cz> +Date: Fri, 10 Mar 2017 00:29:30 +0100 +Subject: [PATCH] Fix error when calling search result iterator + +This patch fixes error: + + tests/test.lua:175: bad argument #1 to 'iter' (table expected, got no value) +--- a/src/lualdap.c ++++ b/src/lualdap.c +@@ -726,8 +726,6 @@ + int rc; + int ret; + +- luaL_checktype(L, 1, LUA_TTABLE); +- + lua_rawgeti (L, LUA_REGISTRYINDEX, search->conn); + conn = (conn_data *)lua_touserdata (L, -1); /* get connection */ + diff --git a/main/lua-ldap/script-to-run-test.lua-against-a-dummy-slapd.patch b/main/lua-ldap/script-to-run-test.lua-against-a-dummy-slapd.patch new file mode 100644 index 0000000000..36c70180de --- /dev/null +++ b/main/lua-ldap/script-to-run-test.lua-against-a-dummy-slapd.patch @@ -0,0 +1,101 @@ +From 847bbf5dbd8053ce21c90dd808ed98ff4b6e742a Mon Sep 17 00:00:00 2001 +From: Dan Callaghan <dcallagh@redhat.com> +Date: Mon, 30 Jun 2014 11:27:56 +1000 +Subject: [PATCH] script to run test.lua against a dummy slapd + +Source: https://src.fedoraproject.org/cgit/rpms/lua-ldap.git/tree/0002-script-to-run-test.lua-against-a-dummy-slapd.patch +--- a/Makefile ++++ b/Makefile +@@ -26,3 +26,6 @@ install: src/$(LIBNAME) + + clean: + rm -f $(OBJS) src/$(LIBNAME) ++ ++check: ++ LUA_CPATH="src/?.so.$V" bash tests/run-tests.sh +new file mode 100755 +--- /dev/null ++++ b/tests/run-tests.sh +@@ -0,0 +1,79 @@ ++#!/bin/bash ++set -ex ++ ++d=$(readlink -f "$(dirname $0)") ++password=thepassword ++ ++rm -rf "$d/slapd-config" "$d/slapd-data" ++mkdir "$d/slapd-config" "$d/slapd-data" ++ ++# populate slapd config ++slapadd -F "$d/slapd-config" -n0 <<EOF ++dn: cn=config ++objectClass: olcGlobal ++cn: config ++olcPidFile: $d/slapd.pid ++ ++dn: cn=schema,cn=config ++objectClass: olcSchemaConfig ++cn: schema ++ ++dn: cn=module,cn=config ++objectClass: olcModuleList ++cn: module ++olcModulepath: /usr/lib/openldap ++olcModuleload: back_bdb.so ++ ++include: file:///etc/openldap/schema/core.ldif ++include: file:///etc/openldap/schema/cosine.ldif ++include: file:///etc/openldap/schema/inetorgperson.ldif ++include: file:///etc/openldap/schema/nis.ldif ++ ++dn: olcDatabase=config,cn=config ++objectClass: olcDatabaseConfig ++olcDatabase: config ++olcAccess: to * by * none ++ ++dn: olcDatabase=bdb,cn=config ++objectClass: olcDatabaseConfig ++objectClass: olcBdbConfig ++olcDatabase: bdb ++olcSuffix: dc=example,dc=invalid ++olcDbDirectory: $d/slapd-data ++olcDbIndex: objectClass eq ++olcAccess: to * by * write ++#olcAccess: to * by users write ++EOF ++ ++# populate slapd data ++slapadd -F "$d/slapd-config" -n1 <<EOF ++dn: dc=example,dc=invalid ++objectClass: top ++objectClass: domain ++ ++#dn: ou=users,dc=example,dc=invalid ++#objectClass: top ++#objectClass: organizationalUnit ++#ou: users ++ ++dn: uid=ldapuser,dc=example,dc=invalid ++objectClass: top ++objectClass: person ++objectClass: organizationalperson ++objectClass: inetorgperson ++objectClass: posixAccount ++cn: My LDAP User ++givenName: My ++sn: LDAP User ++uid: ldapuser ++uidNumber: 15549 ++gidNumber: 15549 ++homeDirectory: /home/lol ++mail: ldapuser@example.invalid ++userPassword: $(slappasswd -s "$password") ++EOF ++ ++slapd -F "$d/slapd-config" -h ldap://localhost:3899/ ++trap 'kill -TERM $(cat "$d/slapd.pid")' EXIT ++ ++${LUA:-lua} tests/test.lua localhost:3899 dc=example,dc=invalid uid=ldapuser,dc=example,dc=invalid "$password" +-- +1.9.3 + diff --git a/main/lua-ldap/update-test.lua-for-5.2.patch b/main/lua-ldap/update-test.lua-for-5.2.patch new file mode 100644 index 0000000000..1035273b93 --- /dev/null +++ b/main/lua-ldap/update-test.lua-for-5.2.patch @@ -0,0 +1,58 @@ +From 85891948cd7b6e9eed2c0e4b199de2a8d19a0824 Mon Sep 17 00:00:00 2001 +From: Dan Callaghan <dcallagh@redhat.com> +Date: Mon, 30 Jun 2014 11:18:04 +1000 +Subject: [PATCH] update test.lua for 5.2 + +Source: https://src.fedoraproject.org/cgit/rpms/lua-ldap.git/tree/0001-update-test.lua-for-5.2.patch +diff --git a/lualdap/tests/test.lua b/lualdap/tests/test.lua +index 2dce95b..76c8640 100755 +--- a/tests/test.lua ++++ b/tests/test.lua +@@ -27,7 +27,7 @@ function print_attrs (dn, attrs) + if tv == "string" then + io.write (values) + elseif tv == "table" then +- local n = table.getn (values) ++ local n = #values + for i = 1, n-1 do + io.write (values[i]..",") + end +@@ -77,7 +77,7 @@ function test_object (obj, objmethods) + -- trying to set metatable. + assert2 (false, pcall (setmetatable, ENV, {})) + -- checking existence of object's methods. +- for i = 1, table.getn (objmethods) do ++ for i = 1, #objmethods do + local method = obj[objmethods[i]] + assert2 ("function", type(method)) + assert2 (false, pcall (method), "no 'self' parameter accepted") +@@ -128,7 +128,7 @@ end + -- checks return value which should be a function AND also its return value. + --------------------------------------------------------------------- + function check_future (ret, method, ...) +- local ok, f = pcall (method, unpack (arg)) ++ local ok, f = pcall (method, ...) + assert (ok, f) + assert2 ("function", type(f)) + assert2 (ret, f()) +@@ -377,7 +377,7 @@ tests = { + -- Main + --------------------------------------------------------------------- + +-if table.getn(arg) < 1 then ++if #arg < 1 then + print (string.format ("Usage %s host[:port] base [who [password]]", arg[0])) + os.exit() + end +@@ -390,7 +390,7 @@ PASSWORD = arg[4] + require"lualdap" + assert (type(lualdap)=="table", "couldn't load LDAP library") + +-for i = 1, table.getn (tests) do ++for i = 1, #tests do + local t = tests[i] + io.write (t[1].." ...") + t[2] () +-- +1.9.3 + |