From owner-freebsd-ports-bugs@FreeBSD.ORG Sat Oct 6 22:00:31 2012 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 68F111065678 for ; Sat, 6 Oct 2012 22:00:31 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 40E838FC3B for ; Sat, 6 Oct 2012 22:00:29 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q96M0ScQ014324 for ; Sat, 6 Oct 2012 22:00:29 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q96M0SuV014320; Sat, 6 Oct 2012 22:00:28 GMT (envelope-from gnats) Resent-Date: Sat, 6 Oct 2012 22:00:28 GMT Resent-Message-Id: <201210062200.q96M0SuV014320@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Piotr Florczyk Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id BB5F91065673 for ; Sat, 6 Oct 2012 21:59:36 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id 9B5818FC14 for ; Sat, 6 Oct 2012 21:59:36 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.5/8.14.5) with ESMTP id q96Lxain014510 for ; Sat, 6 Oct 2012 21:59:36 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.5/8.14.5/Submit) id q96LxaAG014509; Sat, 6 Oct 2012 21:59:36 GMT (envelope-from nobody) Message-Id: <201210062159.q96LxaAG014509@red.freebsd.org> Date: Sat, 6 Oct 2012 21:59:36 GMT From: Piotr Florczyk To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: ports/172415: New port: net/lualdap X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Oct 2012 22:00:31 -0000 >Number: 172415 >Category: ports >Synopsis: New port: net/lualdap >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sat Oct 06 22:00:27 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Piotr Florczyk >Release: 9.0 >Organization: >Environment: >Description: New port for lualdap. It looks like it's unmaintained but there is no other ldap library for lua. I have used patches from: https://github.com/devurandom/lualdap/ to make it compatible with current openldap release (and added couple of lines from myself). Port tested @redports >How-To-Repeat: >Fix: Patch attached with submission follows: # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # lualdap # lualdap/files # lualdap/files/patch-src-lualdap.c # lualdap/pkg-plist # lualdap/pkg-descr # lualdap/Makefile # lualdap/distinfo # echo c - lualdap mkdir -p lualdap > /dev/null 2>&1 echo c - lualdap/files mkdir -p lualdap/files > /dev/null 2>&1 echo x - lualdap/files/patch-src-lualdap.c sed 's/^X//' >lualdap/files/patch-src-lualdap.c << '7522ff50a0ea8b7f49ea0323984a7f75' X--- src/lualdap.c.orig 2012-10-05 12:14:01.029124386 +0000 X+++ src/lualdap.c 2012-10-05 12:14:49.482549262 +0000 X@@ -1,11 +1,12 @@ X /* X ** LuaLDAP X ** See Copyright Notice in license.html X-** $Id: lualdap.c,v 1.48 2007/12/14 15:11:22 carregal Exp $ X+** $Id: lualdap.c,v 1.48 2007-12-14 15:11:22 carregal Exp $ X */ X X #include X #include X+#include X X #ifdef WIN32 X #include X@@ -19,10 +20,14 @@ X #include "ldap.h" X #endif X X-#include "lua.h" X-#include "lauxlib.h" X-#if ! defined (LUA_VERSION_NUM) || LUA_VERSION_NUM < 501 X-#include "compat-5.1.h" X+#include X+#include X+ X+#if LUA_VERSION_NUM < 502 X+/* lua_rawlen: Not entirely correct, but should work anyway */ X+# define lua_rawlen lua_objlen X+# define luaL_newlib(L,l) (lua_newtable(L), luaL_register(L,NULL,l)) X+# define luaL_setfuncs(L,l,n) (assert(n==0), luaL_register(L,NULL,l)) X #endif X X #ifdef WINLDAPAPI X@@ -141,9 +146,9 @@ X /* X ** Get the field called name of the table at position 2. X */ X-static void strgettable (lua_State *L, const char *name) { X+static void strgettable (lua_State *L, int idx, const char *name) { X lua_pushstring (L, name); X- lua_gettable (L, 2); X+ lua_gettable (L, idx); X } X X X@@ -151,8 +156,8 @@ X ** Get the field named name as a string. X ** The table MUST be at position 2. X */ X-static const char *strtabparam (lua_State *L, const char *name, char *def) { X- strgettable (L, name); X+static const char *strtabparam (lua_State *L, int idx, const char *name, char *def) { X+ strgettable (L, idx, name); X if (lua_isnil (L, -1)) X return def; X else if (lua_isstring (L, -1)) X@@ -168,8 +173,8 @@ X ** Get the field named name as an integer. X ** The table MUST be at position 2. X */ X-static long longtabparam (lua_State *L, const char *name, int def) { X- strgettable (L, name); X+static long longtabparam (lua_State *L, int idx, const char *name, int def) { X+ strgettable (L, idx, name); X if (lua_isnil (L, -1)) X return def; X else if (lua_isnumber (L, -1)) X@@ -183,8 +188,8 @@ X ** Get the field named name as a double. X ** The table MUST be at position 2. X */ X-static double numbertabparam (lua_State *L, const char *name, double def) { X- strgettable (L, name); X+static double numbertabparam (lua_State *L, int idx, const char *name, double def) { X+ strgettable (L, idx, name); X if (lua_isnil (L, -1)) X return def; X else if (lua_isnumber (L, -1)) X@@ -199,7 +204,7 @@ X ** The table MUST be at position 2. X */ X static int booltabparam (lua_State *L, const char *name, int def) { X- strgettable (L, name); X+ strgettable (L, 2, name); X if (lua_isnil (L, -1)) X return def; X else if (lua_isboolean (L, -1)) X@@ -243,7 +248,7 @@ X value_error (L, n); X return NULL; X } X- a->bvals[a->bi].bv_len = lua_strlen (L, -1); X+ a->bvals[a->bi].bv_len = lua_rawlen (L, -1); X a->bvals[a->bi].bv_val = (char *)lua_tostring (L, -1); X a->bi++; X return ret; X@@ -296,7 +301,7 @@ X A_setval (L, a, name); X else if (lua_istable (L, tab)) { /* list of strings */ X int i; X- int n = luaL_getn (L, tab); X+ int n = lua_rawlen (L, tab); X for (i = 1; i <= n; i++) { X lua_rawgeti (L, tab, i); /* push table element */ X A_setval (L, a, name); X@@ -368,7 +373,7 @@ X array[1] = NULL; X } else if (lua_istable (L, tab)) { X int i; X- int n = luaL_getn (L, tab); X+ int n = lua_rawlen (L, tab); X if (limit < (n+1)) X return luaL_error (L, LUALDAP_PREFIX"too many arguments"); X for (i = 0; i < n; i++) { X@@ -387,13 +392,25 @@ X X X /* X+** Fill in the struct timeval, according to the timeout parameter. X+*/ X+static struct timeval *get_timeout_param (lua_State *L, int idx, struct timeval *st) { X+ double t = numbertabparam (L, idx, "timeout", -1); X+ if(t < 0) X+ return NULL; /* No timeout, block */ X+ st->tv_sec = (long)t; X+ st->tv_usec = (long)(1000000 * (t - st->tv_sec)); X+ return st; X+} X+ X+/* X ** Get the result message of an operation. X ** #1 upvalue == connection X ** #2 upvalue == msgid X ** #3 upvalue == result code of the message (ADD, DEL etc.) to be received. X */ X static int result_message (lua_State *L) { X- struct timeval *timeout = NULL; /* ??? function parameter ??? */ X+ struct timeval timeout; X LDAPMessage *res; X int rc; X conn_data *conn = (conn_data *)lua_touserdata (L, lua_upvalueindex (1)); X@@ -401,7 +418,7 @@ X /*int res_code = (int)lua_tonumber (L, lua_upvalueindex (3));*/ X X luaL_argcheck (L, conn->ld, 1, LUALDAP_PREFIX"LDAP connection is closed"); X- rc = ldap_result (conn->ld, msgid, LDAP_MSG_ONE, timeout, &res); X+ rc = ldap_result (conn->ld, msgid, LDAP_MSG_ONE, get_timeout_param (L, 1, &timeout), &res); X if (rc == 0) X return faildirect (L, LUALDAP_PREFIX"result timeout expired"); X else if (rc < 0) { X@@ -424,10 +441,14 @@ X default: X lua_pushnil (L); X lua_pushliteral (L, LUALDAP_PREFIX); X- lua_pushstring (L, msg); X- lua_pushliteral (L, " "); X lua_pushstring (L, ldap_err2string(err)); X- lua_concat (L, 4); X+ lua_concat (L, 2); X+ if (msg != NULL) { X+ lua_pushliteral (L, " ("); X+ lua_pushstring (L, msg); X+ lua_pushliteral (L, ")"); X+ lua_concat (L, 4); X+ } X ret = 2; X } X ldap_memfree (mdn); X@@ -461,7 +482,11 @@ X luaL_argcheck(L, conn!=NULL, 1, LUALDAP_PREFIX"LDAP connection expected"); X if (conn->ld == NULL) /* already closed */ X return 0; X+#if defined(LDAP_API_FEATURE_X_OPENLDAP) && LDAP_API_FEATURE_X_OPENLDAP >= 20300 X+ ldap_unbind_ext (conn->ld, NULL, NULL); X+#else X ldap_unbind (conn->ld); X+#endif X conn->ld = NULL; X lua_pushnumber (L, 1); X return 1; X@@ -504,7 +529,7 @@ X BerValue bvalue; X ldap_int_t rc, msgid; X bvalue.bv_val = (char *)luaL_checkstring (L, 4); X- bvalue.bv_len = lua_strlen (L, 4); X+ bvalue.bv_len = lua_rawlen (L, 4); X rc = ldap_compare_ext (conn->ld, dn, attr, &bvalue, NULL, NULL, &msgid); X return create_future (L, rc, 1, msgid, LDAP_RES_COMPARE); X } X@@ -666,15 +691,17 @@ X static int next_message (lua_State *L) { X search_data *search = getsearch (L); X conn_data *conn; X- struct timeval *timeout = NULL; /* ??? function parameter ??? */ X+ struct timeval timeout; X LDAPMessage *res; X int rc; X int ret; X X+ luaL_checktype(L, 1, LUA_TTABLE); X+ X lua_rawgeti (L, LUA_REGISTRYINDEX, search->conn); X conn = (conn_data *)lua_touserdata (L, -1); /* get connection */ X X- rc = ldap_result (conn->ld, search->msgid, LDAP_MSG_ONE, timeout, &res); X+ rc = ldap_result (conn->ld, search->msgid, LDAP_MSG_ONE, get_timeout_param (L, 1, &timeout), &res); X if (rc == 0) X return faildirect (L, LUALDAP_PREFIX"result timeout expired"); X else if (rc == -1) X@@ -724,8 +751,10 @@ X */ X static int string2scope (lua_State *L, const char *s) { X if ((s == NULL) || (*s == '\0')) X- return LDAP_SCOPE_DEFAULT; X+ return LDAP_SCOPE_SUBTREE; X switch (*s) { X+ case 'd': X+ return LDAP_SCOPE_DEFAULT; X case 'b': X return LDAP_SCOPE_BASE; X case 'o': X@@ -784,20 +813,6 @@ X X X /* X-** Fill in the struct timeval, according to the timeout parameter. X-*/ X-static struct timeval *get_timeout_param (lua_State *L, struct timeval *st) { X- double t = numbertabparam (L, "timeout", 0); X- st->tv_sec = (long)t; X- st->tv_usec = (long)(1000000 * (t - st->tv_sec)); X- if (st->tv_sec == 0 && st->tv_usec == 0) X- return NULL; X- else X- return st; X-} X- X- X-/* X ** Perform a search operation. X ** @return #1 Function to iterate over the result entries. X ** @return #2 nil. X@@ -818,11 +833,11 @@ X return 2; X /* get other parameters */ X attrsonly = booltabparam (L, "attrsonly", 0); X- base = (ldap_pchar_t) strtabparam (L, "base", NULL); X- filter = (ldap_pchar_t) strtabparam (L, "filter", NULL); X- scope = string2scope (L, strtabparam (L, "scope", NULL)); X- sizelimit = longtabparam (L, "sizelimit", LDAP_NO_LIMIT); X- timeout = get_timeout_param (L, &st); X+ base = (ldap_pchar_t) strtabparam (L, 2, "base", NULL); X+ filter = (ldap_pchar_t) strtabparam (L, 2, "filter", NULL); X+ scope = string2scope (L, strtabparam (L, 2, "scope", NULL)); X+ sizelimit = longtabparam (L, 2, "sizelimit", LDAP_NO_LIMIT); X+ timeout = get_timeout_param (L, 2, &st); X X rc = ldap_search_ext (conn->ld, base, scope, filter, attrs, attrsonly, X NULL, NULL, timeout, sizelimit, &msgid); X@@ -831,7 +846,8 @@ X X create_search (L, 1, msgid); X lua_pushcclosure (L, next_message, 1); X- return 1; X+ lua_pushvalue(L, 2); X+ return 2; X } X X X@@ -872,7 +888,7 @@ X ** Create a metatable. X */ X static int lualdap_createmeta (lua_State *L) { X- const luaL_reg methods[] = { X+ const luaL_Reg methods[] = { X {"close", lualdap_close}, X {"add", lualdap_add}, X {"compare", lualdap_compare}, X@@ -887,7 +903,7 @@ X return 0; X X /* define methods */ X- luaL_openlib (L, NULL, methods, 0); X+ luaL_setfuncs(L, methods, 0); X X /* define metamethods */ X lua_pushliteral (L, "__gc"); X@@ -939,13 +955,27 @@ X const char *password = luaL_optstring (L, 3, NULL); X int use_tls = lua_toboolean (L, 4); X conn_data *conn = (conn_data *)lua_newuserdata (L, sizeof(conn_data)); X+#if defined(LDAP_API_FEATURE_X_OPENLDAP) && LDAP_API_FEATURE_X_OPENLDAP >= 20300 X+ struct berval cred = { 0, NULL }; X+ char *host_with_schema = NULL; X+#endif X int err; X X /* Initialize */ X lualdap_setmeta (L, LUALDAP_CONNECTION_METATABLE); X conn->version = 0; X+#if defined(LDAP_API_FEATURE_X_OPENLDAP) && LDAP_API_FEATURE_X_OPENLDAP >= 20300 X+ host_with_schema = malloc(strlen(host) + 8); X+ strcpy(host_with_schema, "ldap://"); X+ strcat(host_with_schema, host); X+ err = ldap_initialize(&conn->ld, host_with_schema); X+ free(host_with_schema); X+ host_with_schema = NULL; X+ if (err != LDAP_SUCCESS) X+#else X conn->ld = ldap_init (host, LDAP_PORT); X if (conn->ld == NULL) X+#endif X return faildirect(L,LUALDAP_PREFIX"Error connecting to server"); X /* Set protocol version */ X conn->version = LDAP_VERSION3; X@@ -959,7 +989,16 @@ X return faildirect (L, ldap_err2string (rc)); X } X /* Bind to a server */ X+#if defined(LDAP_API_FEATURE_X_OPENLDAP) && LDAP_API_FEATURE_X_OPENLDAP >= 20300 X+ cred.bv_len = strlen(password); X+ cred.bv_val = malloc(cred.bv_len+1); X+ strcpy(cred.bv_val, password); X+ err = ldap_sasl_bind_s (conn->ld, who, LDAP_SASL_SIMPLE, &cred, NULL, NULL, NULL); X+ free(cred.bv_val); X+ memset(&cred, 0, sizeof(cred)); X+#else X err = ldap_bind_s (conn->ld, who, password, LDAP_AUTH_SIMPLE); X+#endif X if (err != LDAP_SUCCESS) X return faildirect (L, ldap_err2string (err)); X X@@ -987,13 +1026,15 @@ X ** Create ldap table and register the open method. X */ X int luaopen_lualdap (lua_State *L) { X- struct luaL_reg lualdap[] = { X+ struct luaL_Reg lualdap[] = { X {"open_simple", lualdap_open_simple}, X {NULL, NULL}, X }; X X lualdap_createmeta (L); X- luaL_openlib (L, LUALDAP_TABLENAME, lualdap, 0); X+ luaL_newlib(L, lualdap); X+ lua_pushvalue(L, -1); X+ lua_setglobal(L, LUALDAP_TABLENAME); X set_info (L); X X return 1; 7522ff50a0ea8b7f49ea0323984a7f75 echo x - lualdap/pkg-plist sed 's/^X//' >lualdap/pkg-plist << '413db716190360393f6c1a30a26007c2' X%%LUA_MODLIBDIR%%/lualdap.so X%%PORTDOCS%%%%DOCSDIR%%/index.html X%%PORTDOCS%%%%DOCSDIR%%/license.html X%%PORTDOCS%%%%DOCSDIR%%/lualdap.png X%%PORTDOCS%%%%DOCSDIR%%/manual.html X%%PORTDOCS%%@dirrm %%DOCSDIR%% 413db716190360393f6c1a30a26007c2 echo x - lualdap/pkg-descr sed 's/^X//' >lualdap/pkg-descr << '7e928cf87fe9ce4b0be56e914aa16c6d' XLuaLDAP is a simple interface from Lua to an LDAP client. XIn fact it is a bind to OpenLDAP or to ADSI. It enables a Lua program to: X X- connect to an LDAP server; X- execute any operation (search, add, compare, delete, modify and rename); X- retrieve entries and references of the search result. X XWWW: http://www.keplerproject.org/lualdap/ 7e928cf87fe9ce4b0be56e914aa16c6d echo x - lualdap/Makefile sed 's/^X//' >lualdap/Makefile << '94fae91482b7d07aa8ffa7609dc1f85a' X# New ports collection makefile for: lualdap X# Date created: 5 Oct 2012 X# Whom: Piotr Florczyk X# $FreeBSD$ X XPORTNAME= lualdap XPORTVERSION= 1.1.0 XCATEGORIES= net XMASTER_SITES= http://files.luaforge.net/releases/${PORTNAME}/${PORTNAME}/LuaLDAP${PORTVERSION}/ XPKGNAMEPREFIX= ${LUA_PKGNAMEPREFIX} X XMAINTAINER= pf@itwf.pl XCOMMENT= LDAP support for the Lua language X XUSE_GMAKE= yes XUSE_LUA?= 5.1+ XLUA_COMPS= lua XUSE_OPENLDAP= yes X XMAKE_ARGS+= LUA_LIBDIR="${LUA_LIBDIR}" \ X LUA_INC="${LUA_INCDIR}" \ X OPENLDAP_LIB="-L ${PREFIX}/lib -lldap" \ X LUA_VERSION_NUM="${LUA_VER_STR}0" X XALL_TARGET= X Xdo-install: X ${INSTALL_PROGRAM} ${WRKSRC}/src/lualdap.so.${PORTVERSION} ${LUA_MODLIBDIR}/${PORTNAME}.so X. if !defined(NOPORTDOCS) X @${MKDIR} ${DOCSDIR} X @${INSTALL_DATA} ${WRKSRC}/doc/us/* ${DOCSDIR} X. endif X X.include 94fae91482b7d07aa8ffa7609dc1f85a echo x - lualdap/distinfo sed 's/^X//' >lualdap/distinfo << 'bf03d21f8715b6dd063d1da72be90fcb' XSHA256 (lualdap-1.1.0.tar.gz) = c2875704b8cdc6398c2f1cf25199a16d217ded2c696d134ae591935ab3c98d33 XSIZE (lualdap-1.1.0.tar.gz) = 30087 bf03d21f8715b6dd063d1da72be90fcb exit >Release-Note: >Audit-Trail: >Unformatted: