Commit c7b2e9ad authored by J0WI's avatar J0WI Committed by Leo

main/lua-ldap: upgrade to 1.2.5

parent e53386cf
......@@ -3,22 +3,16 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=lua-ldap
_pkgname=lualdap
pkgver=1.2.3
pkgrel=6
pkgver=1.2.5
pkgrel=0
pkgdesc="Lua binding to LDAP"
url="https://github.com/bdellegrazie/lualdap"
url="https://github.com/lualdap/lualdap"
arch="all"
license="MIT"
depends=""
options="!check" # fails to detect correct builddir
makedepends="openldap-dev"
checkdepends="openldap openldap-back-bdb"
subpackages=""
source="$_pkgname-$pkgver.tar.gz::https://github.com/bdellegrazie/$_pkgname/archive/v$pkgver.tar.gz
fix-open_simple-segfault.patch
fix-anonymous-bind.patch
fix-search-iter.patch
script-to-run-test.lua-against-a-dummy-slapd.patch
update-test.lua-for-5.2.patch"
checkdepends="openldap openldap-back-bdb lua-busted"
source="$_pkgname-$pkgver.tar.gz::https://github.com/lualdap/lualdap/archive/v$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"
_luaversions="5.1 5.2 5.3"
......@@ -28,13 +22,12 @@ for _v in $_luaversions; do
done
prepare() {
default_prepare || return 1
default_prepare
cd "$builddir"
sed -i -e '/LUA_VERSION_NUM/d' config
local lver; for lver in $_luaversions; do
cp -r "$builddir" "$builddir-$lver" || return 1
cp -r "$builddir" "$builddir-$lver"
done
}
......@@ -43,8 +36,8 @@ build() {
msg "Building for Lua $lver..."
cd "$builddir-$lver"
make CFLAGS="-fPIC -ansi -Wall $(pkg-config --cflags lua$lver)" \
OPENLDAP_LIB="-lldap -llber" || return 1
make CFLAGS="$CFLAGS -fPIC -ansi -Wall $(pkg-config --cflags lua$lver)" \
OPENLDAP_LIB="-lldap -llber"
done
}
......@@ -53,7 +46,7 @@ check() {
msg "Testing with Lua $lver..."
cd "$builddir-$lver"
make LUA=lua$lver check || return 1
make LUA_CPATH="src/?.so.$V" LUA=lua$lver check
done
}
......@@ -70,6 +63,7 @@ _package() {
replaces="lua$lver-lualdap" # for backward compatibility (v3.5)
[ "$lver" = "5.1" ] && replaces="${replaces:-} $pkgname" # for backward compatibility (<v3.4)
mkdir -p "$subpkgdir/usr/lib/lua/$lver"
cd "$builddir-$lver"
make DESTDIR="$subpkgdir" \
LUA_LIBDIR="$(pkg-config --variable=INSTALL_CMOD lua$lver)" \
......@@ -79,9 +73,4 @@ _package() {
echo 'rock_manifest = {}' > "$rockdir"/rock_manifest
}
sha512sums="51934d18d1ee97a0130545e657497e51542eef97c338df14e7171f94a2d6395fceb00313e1e64e46e6cdeedf85a17c63284595fdf6fbce8b7abce29d28f1b4a7 lualdap-1.2.3.tar.gz
f9f88ef13c8dd13064ca338720d461355cc4d32c03a7e597d7d7a0d9a8a20802bafe0dd479f8c341926fc714fb91489f0649c76675609b84d61ee0327fba8a56 fix-open_simple-segfault.patch
733bbe09edba98f7a549d1e4083a45bf05e1ce9aeffea0416b42e22f1a9f3072a4b36dd56bfde78586edcaafeffcd4880cb72953aeb2952121c92afadd0c8816 fix-anonymous-bind.patch
45170c06fe71bc61565fbdb960d74e59745dc91cbf52c760b8495890d9b02d8fa9361dc4c747d1257db8cb0dac16d97415db6fe69d6d17bb0b37b507aa60627e fix-search-iter.patch
59622fabc03dd669c554cd8a58a934b5990f482da59bd5b7c243e53a41fbaaa55933ebd345d0d5911c48665fa18f6fcb08e0d9d74a61602f80afe6cb0b20dc4a script-to-run-test.lua-against-a-dummy-slapd.patch
ffc0f08a141667db402b4b523f0de9893035bdbee5f8e68e48792cd7a29d549931ec4be0715b9f872992f492c1ac2e62c0e05552159571ffa05e5f507a1baf85 update-test.lua-for-5.2.patch"
sha512sums="4fbd7bcea2e55a3b165a7316e4f6c45aee22506915c4cc204d1b5006adbf95611ebf4558c1ef1511f90d7142571cff37ea24952072dc7ecb13bbbe06aef32e72 lualdap-1.2.5.tar.gz"
From: Jakub Jirutka <jakub@jirutka.cz>
Date: Sun, 12 Mar 2017 15:16:19 +0100
Subject: [PATCH] Fix anonymous bind
Empty string should work for both ancient and the current OpenLDAP API
(but I've tested only the current).
Upstream-Issue: https://github.com/bdellegrazie/lualdap/pull/1
---
src/lualdap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/lualdap.c b/src/lualdap.c
index 5bc1bb9..6063a97 100644
--- a/src/lualdap.c
+++ b/src/lualdap.c
@@ -1003,7 +1003,7 @@ static int lualdap_initialize (lua_State *L) {
static int lualdap_open_simple (lua_State *L) {
ldap_pchar_t host = (ldap_pchar_t) luaL_checkstring (L, 1);
ldap_pchar_t who = (ldap_pchar_t) luaL_optstring (L, 2, NULL);
- const char *password = luaL_optstring (L, 3, NULL);
+ const char *password = luaL_optstring (L, 3, "");
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
From: Jakub Jirutka <jakub@jirutka.cz>
Date: Fri, 10 Mar 2017 00:28:52 +0100
Subject: [PATCH] Fix segfault in lualdap_open_simple()
Upstream-Issue: https://github.com/bdellegrazie/lualdap/pull/1
--- 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
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)
Upstream-Issue: https://github.com/bdellegrazie/lualdap/pull/1
--- 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 */
From d69b83f1464a6326c426f0228bb98c626c7f64bd Mon Sep 17 00:00:00 2001
From: Dan Callaghan <dcallagh@redhat.com>
Date: Mon, 30 Jun 2014 11:27:56 +1000
Subject: [PATCH] Add script to run test.lua against a dummy slapd
Ported from https://src.fedoraproject.org/cgit/rpms/lua-ldap.git/tree/0002-script-to-run-test.lua-against-a-dummy-slapd.patch
Upstream-Issue: https://github.com/bdellegrazie/lualdap/pull/2
---
Makefile | 3 ++
tests/run-tests.sh | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 86 insertions(+)
create mode 100755 tests/run-tests.sh
diff --git a/Makefile b/Makefile
index 72ee348..9bfa542 100644
--- a/Makefile
+++ b/Makefile
@@ -26,3 +26,6 @@ install: src/$(LIBNAME)
clean:
rm -f $(OBJS) src/$(LIBNAME)
+
+check:
+ LUA_CPATH="src/?.so.$V" sh tests/run-tests.sh
diff --git a/tests/run-tests.sh b/tests/run-tests.sh
new file mode 100755
index 0000000..33949c1
--- /dev/null
+++ b/tests/run-tests.sh
@@ -0,0 +1,83 @@
+#!/bin/sh
+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"
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
Upstream-Issue: https://github.com/bdellegrazie/lualdap/pull/2
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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment