Subject: pkg/13469: security/curys-sasl patches for non-ELF NetBSD systems
To: None <gnats-bugs@gnats.netbsd.org>
From: Stoned Elipot <seb@pbox.org>
List: netbsd-bugs
Date: 07/15/2001 12:28:41
>Number: 13469
>Category: pkg
>Synopsis: cyrus-sasl plugings shared libraries not found on non-ELF NetBSD systems
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: pkg-manager
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Sun Jul 15 03:26:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: Stoned Elipot
>Release: pkgsrc-current
>Organization:
SCRIPT, Paris VII University, France
>Environment:
System: NetBSD nef 1.4.1 NetBSD 1.4.1 (GENERIC_SCSI3) #1: Mon Aug 9 02:34:40 PDT 1999 mrg@sun4690:/work/tmp/mrg/src/sys/arch/sparc/compile/GENERIC_SCSI3 sparc
>Description:
On non-ELF NetBSD system cyrus-sasl doest not find auth mechanisms shared
libraries because only files matching *.so are considered.
>How-To-Repeat:
Build and install curys-sasl on a non-ELF NetBSD system and then with a
pwcheck_method of sasldb try with the saslpasswd command to create a user/passwd
in sasldb: only a PLAIN mechanism password will be created because the
mechs lib cannot be found.
>Fix:
The following patches correct this problem. They need futher work like
replacing the configure's definition of UNDERSCORE_SYMBOL_HACK by the usage
of AC_LTDL_DLSYM_USCORE macro from libtool's ltdl.m4, I'm working on this as
well as on Solaris package portability fixes...
With these patches cyrus-sasl's lib/dlopen.c try to read libtool's
.la files to get the name of the shared lib objects.
Hoping theses can help people with old netbsd boxes...
New pkg patch file, patch/patch-aj:
$NetBSD$
--- lib/dlopen.c.orig Thu Mar 9 21:53:47 2000
+++ lib/dlopen.c
@@ -47,6 +47,8 @@
#include <dlfcn.h>
#endif /* !__hpux */
#include <stdlib.h>
+#include <errno.h>
+#include <stdio.h>
#include <limits.h>
#include <sys/param.h>
#include <sasl.h>
@@ -146,7 +148,11 @@
#else /* __hpux */
#define SO_SUFFIX ".so"
#endif /* __hpux */
+#define LA_SUFFIX ".la"
+#define _LA_LIB 0x1
+#define _SO_LIB 0x2
+#define _XX_LIB 0x4
/* gets the list of mechanisms */
int _sasl_get_mech_list(const char *entryname,
@@ -159,7 +165,7 @@
* checks appropriately. */
int result;
char str[PATH_MAX], tmp[PATH_MAX+2], c, prefix[PATH_MAX+2]; /* 1 for '/' 1 for trailing '\0' */
-#if __OpenBSD__
+#if defined(__OpenBSD__) || defined(UNDERSCORE_SYMBOL_HACK)
char adj_entryname[1024];
#else
#define adj_entryname entryname
@@ -180,7 +186,7 @@
|| ! add_plugin)
return SASL_BADPARAM;
-#if __OpenBSD__
+#if defined(__OpenBSD__) || defined(UNDERSCORE_SYMBOL_HACK)
snprintf(adj_entryname, sizeof adj_entryname, "_%s", entryname);
#endif
@@ -213,6 +219,7 @@
{
while ((dir=readdir(dp)) != NULL)
{
+ int _lib_type;
size_t length;
void *library;
void *entry_point;
@@ -225,13 +232,91 @@
if (length + pos>=PATH_MAX) continue; /* too big */
- if (strcmp(dir->d_name + (length - 3), SO_SUFFIX)) continue;
+ _lib_type = _XX_LIB;
+
+ if (strcmp(dir->d_name + (length - 3), SO_SUFFIX)) {
+ if (strcmp(dir->d_name + (length - 3), LA_SUFFIX)) {
+ continue;
+ } else {
+ _lib_type=_LA_LIB;
+ }
+ } else
+ _lib_type=_SO_LIB;
memcpy(name,dir->d_name,length);
name[length]='\0';
strcpy(tmp,prefix);
strcat(tmp,name);
+
+ if (_lib_type == _LA_LIB) {
+#define _LINE_LEN 1024
+ FILE* file;
+ char* line;
+ char* rline;
+ char* ntmp;
+ int got_dlname;
+ size_t line_len;
+ file = fopen(tmp, "r");
+ if (!file) {
+ _sasl_log(NULL, SASL_LOG_WARNING, NULL, SASL_FAIL, errno, "unable to get library name from %s: %z: %m", tmp);
+ continue;
+ }
+ line_len = _LINE_LEN;
+ line = (char*)malloc(sizeof(char) * line_len);
+ if (!line) {
+ _sasl_log(NULL, SASL_LOG_WARNING, NULL, SASL_NOMEM, errno, "unable to get library name from %s: %z: %m", tmp);
+ fclose(file);
+
+ continue;
+ }
+ ntmp = NULL;
+ got_dlname = 0;
+ while (!feof(file)) {
+ if (!fgets (line, line_len, file))
+ break;
+ while (line[strlen(line) -1] != '\n') {
+ rline = (char*)realloc(line, sizeof(char)* line_len *2);
+ if (!rline) {
+ _sasl_log(NULL, SASL_LOG_WARNING, NULL, SASL_NOMEM, errno, "unable to get library name from %s: %z: %m", tmp);
+ free(line);
+ line = NULL;
+ break;
+ }
+ if (!fgets (&line[line_len -1], line_len +1, file))
+ break;
+ line_len *=2;
+ }
+ if (!line)
+ break;
+ if (line[0] == '\n' || line[0] == '#')
+ continue;
+ if (strncmp(line, "dlname=", sizeof("dlname=") - 1) == 0) {
+ char* end;
+ char* start;
+ int len;
+ end = strrchr (line, '\'');
+ start = &line[sizeof("dlname=") - 1];
+ len = strlen (start);
+ if (len > 3 && start[0] == '\'') {
+ ntmp = &start[1];
+ *end = '\0';
+ strcpy(tmp,prefix);
+ strcat(tmp,ntmp);
+ got_dlname++;
+ }
+ break;
+ }
+ }
+ if (ferror(file) || feof(file)) {
+ _sasl_log(NULL, SASL_LOG_WARNING, NULL, SASL_FAIL, 0, "unable to get library name from %s: %z", tmp);
+ }
+ fclose(file);
+ if (line)
+ free(line);
+ if (!got_dlname)
+ continue;
+ }
VL(("entry is = [%s]\n",tmp));
Diffs on current pkg files:
Index: Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/security/cyrus-sasl/Makefile,v
retrieving revision 1.14
diff -u -r1.14 Makefile
--- Makefile 2001/03/27 03:20:15 1.14
+++ Makefile 2001/07/15 10:08:38
@@ -124,4 +124,5 @@
cd ${WRKSRC}/doc; ${INSTALL_DATA} *.html *.txt ${HTMLDIR}
PKG_PREFIX=${PREFIX} ${SH} ${INSTALL_FILE} ${PKGNAME} POST-INSTALL
+.include "../../security/openssl/buildlink.mk"
.include "../../mk/bsd.pkg.mk"
Index: distinfo
===================================================================
RCS file: /cvsroot/pkgsrc/security/cyrus-sasl/distinfo,v
retrieving revision 1.2
diff -u -r1.2 distinfo
--- distinfo 2001/04/19 15:40:30 1.2
+++ distinfo 2001/07/15 10:08:38
@@ -2,7 +2,7 @@
SHA1 (cyrus-sasl-1.5.24.tar.gz) = 6e8cbc8f1ee5269c4f3aad1f501b422be7117168
Size (cyrus-sasl-1.5.24.tar.gz) = 494457 bytes
-SHA1 (patch-aa) = 4e6d027a6d4d66d54f7a565a0e5c48b34f05bb08
+SHA1 (patch-aa) = 01066f89a513927960387abd681f9a100ea66e96
SHA1 (patch-ab) = 82359390958c020348e7e7ebc39315da552d34c7
SHA1 (patch-ac) = b5f99dd4789c19e36c29bbc3fbf47c556e32876e
SHA1 (patch-ad) = faa888873c16c3c322e110a6f90380748b138942
@@ -11,3 +11,4 @@
SHA1 (patch-ag) = acfc55182396a96d3fccdb93ba3c6207eb7c154f
SHA1 (patch-ah) = 66ce42b201558c959be0a584e7d4121a283ae3db
SHA1 (patch-ai) = 55ade1200d2c5b8f20b4c1775d6c3b7d3b8ef278
+SHA1 (patch-aj) = 3374b91f2d806a4bc7c65bf3a98781e26e9f25af
Index: patches/patch-aa
===================================================================
RCS file: /cvsroot/pkgsrc/security/cyrus-sasl/patches/patch-aa,v
retrieving revision 1.3
diff -u -r1.3 patch-aa
--- patch-aa 2001/01/31 22:47:53 1.3
+++ patch-aa 2001/07/15 10:08:38
@@ -1,6 +1,6 @@
-$NetBSD: patch-aa,v 1.3 2001/01/31 22:47:53 jlam Exp $
+$NetBSD$
---- configure.in.orig Thu Jul 20 22:35:01 2000
+--- configure.in.orig Fri Jul 21 04:35:01 2000
+++ configure.in
@@ -65,9 +65,12 @@
@@ -32,13 +32,25 @@
if test "$with_des" = no; then
dnl if openssl is around, we might be able to use that for des
-@@ -694,6 +700,9 @@
-
+@@ -695,6 +701,9 @@
LTLIBOBJS=`echo "$LIBOBJS" | sed 's/\.o/.lo/g'`
AC_SUBST(LTLIBOBJS)
-+
+
+dnl Check for /dev/urandom
+AC_CHECK_FILE(/dev/urandom, AC_DEFINE_UNQUOTED(SASL_DEV_RANDOM, "/dev/urandom"))
-
++
AC_CHECK_HEADERS(getopt.h unistd.h crypt.h pwd.h shadow.h paths.h)
AC_C_CONST
+ AC_C_INLINE
+@@ -706,6 +715,11 @@
+ SASL_UTIL_HEADERS_EXTRA="")
+ AC_SUBST(SASL_UTIL_LIBS_EXTRA)
+ AC_SUBST(SASL_UTIL_HEADERS_EXTRA)
++
++case "$host" in
++ *-*-netbsdelf*) true ;;
++ *-*-netbsd*) AC_DEFINE(UNDERSCORE_SYMBOL_HACK,1,[Define if symbol in a shared object are prefixed with an underscore]) ;;
++esac
+
+ AC_CHECK_FUNCS(getdomainname getpassphrase getpid)
+
>Release-Note:
>Audit-Trail:
>Unformatted: