Apply patch from Stefan Esser to close PR #7941: add code to handle

dynamic loading of libdes on ELF systems. The patch looks correct to
me.
This commit is contained in:
Bill Paul 1998-09-16 01:50:04 +00:00
parent 8b95823257
commit 4b692ba7f9
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=39319
2 changed files with 17 additions and 2 deletions

View File

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.2 1997/12/16 17:43:23 bde Exp $
# $Id: Makefile,v 1.3 1998/05/09 13:32:37 bde Exp $
PROG= keyserv
SRCS= keyserv.c setkey.c keyserv_uid.c crypt_svc.c crypt_server.c crypt.h
@ -6,6 +6,9 @@ SRCS= keyserv.c setkey.c keyserv_uid.c crypt_svc.c crypt_server.c crypt.h
MAN8= keyserv.8
CFLAGS+= -DKEYSERV_RANDOM -DBROKEN_DES -I.
.if $(OBJFORMAT) == elf
CFLAGS+= -DOBJFORMAT_ELF
.endif
DPADD= ${LIBMP} ${LIBRPCSVC}
LDADD= -lmp -lrpcsvc

View File

@ -44,7 +44,7 @@
#ifndef lint
static const char rcsid[] =
"$Id$";
"$Id: crypt_server.c,v 1.3 1997/09/23 06:36:26 charnier Exp $";
#endif /* not lint */
/*
@ -171,7 +171,11 @@ static void *dlhandle;
#endif
#ifndef LIBDES
#ifdef OBJFORMAT_ELF
#define LIBDES "libdes.so.3"
#else
#define LIBDES "libdes.so.3."
#endif /* OBJFORMAT_ELF */
#endif
void load_des(warn, libpath)
@ -185,6 +189,9 @@ void load_des(warn, libpath)
int len;
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)
err(1, "opendir(/usr/lib) failed");
@ -203,11 +210,16 @@ void load_des(warn, libpath)
}
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) {
if (dlhandle != NULL)