From se@dialup124.zpr.uni-koeln.de  Tue Sep 15 15:50:42 1998
Received: from Sisyphos.MI.Uni-Koeln.DE (Sisyphos.MI.Uni-Koeln.DE [134.95.212.10])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id PAA28608
          for <FreeBSD-gnats-submit@freebsd.org>; Tue, 15 Sep 1998 15:50:30 -0700 (PDT)
          (envelope-from se@dialup124.zpr.uni-koeln.de)
Received: from dialup124.zpr.Uni-Koeln.DE (dialup124.zpr.Uni-Koeln.DE [134.95.219.124])
	by Sisyphos.MI.Uni-Koeln.DE (8.8.7/8.8.7) with ESMTP id AAA06049
	for <FreeBSD-gnats-submit@FreeBSD.ORG>; Wed, 16 Sep 1998 00:49:44 +0200 (MET DST)
Received: (from se@localhost) by dialup124.zpr.Uni-Koeln.DE (8.8.8/8.6.9) id AAA01952; Wed, 16 Sep 1998 00:03:57 +0200 (CEST)
Message-Id: <199809152203.AAA01952@dialup124.zpr.Uni-Koeln.DE>
Date: Wed, 16 Sep 1998 00:03:57 +0200 (CEST)
From: Stefan Esser <se@dialup124.zpr.uni-koeln.de>
Reply-To: se@dialup124.zpr.uni-koeln.de
To: FreeBSD-gnats-submit@freebsd.org
Subject: FIX: keyserv with DES not ready for ELF
X-Send-Pr-Version: 3.2

>Number:         7941
>Category:       bin
>Synopsis:       FIX: keyserv with DES not ready for ELF
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Sep 15 16:00:01 PDT 1998
>Closed-Date:    Tue Sep 15 18:50:17 PDT 1998
>Last-Modified:  Tue Sep 15 18:51:03 PDT 1998
>Originator:     Stefan Esser
>Release:        FreeBSD 3.0-CURRENT i386
>Organization:
>Environment:
FreeBSD 3.0-current (ELF)
>Description:
There are no compilation errors if you build "keyserv" on an ELF system,
but because of differences in the library names and symbol names, the 
resulting binary can't attach _des_crypt() from libdes.so and falls back
to ARCFOUR.
>How-To-Repeat:
On a system with DES sources and ELF do:

$ keyserv -v

Watch the output of that command, it indicates that no DES support is
available.

>Fix:

The following patch should not cause any trouble under -stable
or under -current/aout, but fixes the ELF case.

I was not sure, whether dlopen() should be called with "libdes.so"
or with "libdes.so.3". I chose the latter ...
	
Index: Makefile
===================================================================
RCS file: /usr/cvs/src/usr.sbin/keyserv/Makefile,v
retrieving revision 1.3
diff -C2 -r1.3 Makefile
*** Makefile	1998/05/09 13:32:37	1.3
--- Makefile	1998/09/15 21:51:46
***************
*** 7,10 ****
--- 7,13 ----
  
  CFLAGS+= -DKEYSERV_RANDOM -DBROKEN_DES -I.
+ .if $(OBJFORMAT) == elf
+ CFLAGS+= -DOBJFORMAT_ELF
+ .endif
  
  DPADD=	${LIBMP} ${LIBRPCSVC}
Index: crypt_server.c
===================================================================
RCS file: /usr/cvs/src/usr.sbin/keyserv/crypt_server.c,v
retrieving revision 1.3
diff -C2 -r1.3 crypt_server.c
*** crypt_server.c	1997/09/23 06:36:26	1.3
--- crypt_server.c	1998/09/15 21:50:35
***************
*** 172,176 ****
--- 172,180 ----
  
  #ifndef LIBDES
+ #ifdef OBJFORMAT_ELF
+ #define LIBDES "libdes.so.3"
+ #else
  #define LIBDES "libdes.so.3."
+ #endif /* OBJFORMAT_ELF */
  #endif
  
***************
*** 186,189 ****
--- 190,196 ----
  
  	if (libpath == NULL) {
+ #ifdef OBJFORMAT_ELF
+ 		snprintf(dlpath, sizeof(dlpath), "%s/%s", _PATH_USRLIB, LIBDES);
+ #else
  		len = strlen(LIBDES);
  		if ((dird = opendir(_PATH_USRLIB)) == NULL)
***************
*** 204,212 ****
--- 211,224 ----
  
  		closedir(dird);
+ #endif /* OBJFORMAT_ELF */
  	} else
  		snprintf(dlpath, sizeof(dlpath), "%s", libpath);
  
  	if (dlpath != NULL && (dlhandle = dlopen(dlpath, 0444)) != NULL)
+ #ifdef OBJFORMAT_ELF
+ 		_my_crypt = (int (*)())dlsym(dlhandle, "_des_crypt");
+ #else
  		_my_crypt = (int (*)())dlsym(dlhandle, "__des_crypt");
+ #endif /* OBJFORMAT_ELF */
  
  	if (_my_crypt == NULL) {
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: wpaul 
State-Changed-When: Tue Sep 15 18:50:17 PDT 1998 
State-Changed-Why:  
Patch applied, thanks! 

-Bill 
>Unformatted:
