Bring in some of Paul K's fixes for ldconfig from NetBSD-current.

This solves the problem of being unable to use shared libraries with dots
in their names before the ".so.<version>" code.

This should be brought into -stable.

There are more changes from Paul that look like they should be included,
but they change the format of the hints file, so I'm not going to bring them
in now (but we should in the future).

Obtained from: pk@netbsd.org
This commit is contained in:
Paul Traina 1996-02-26 02:22:33 +00:00
parent eea817fc73
commit 0f6b2cb3f8
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=14260
2 changed files with 64 additions and 24 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1993 Paul Kranenburg
* Copyright (c) 1993,1995 Paul Kranenburg
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -27,7 +27,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: ldconfig.c,v 1.10 1995/06/24 10:08:44 asami Exp $
* $Id: ldconfig.c,v 1.13 1996/01/09 00:04:35 pk Exp $
*/
#include <sys/param.h>
@ -139,7 +139,7 @@ int silent;
{
DIR *dd;
struct dirent *dp;
char name[MAXPATHLEN], rest[MAXPATHLEN];
char name[MAXPATHLEN];
int dewey[MAXDEWEY], ndewey;
if ((dd = opendir(dir)) == NULL) {
@ -149,17 +149,38 @@ int silent;
}
while ((dp = readdir(dd)) != NULL) {
int n;
register int n;
register char *cp;
name[0] = rest[0] = '\0';
n = sscanf(dp->d_name, "lib%[^.].so.%s",
name, rest);
if (n < 2 || rest[0] == '\0')
/* Check for `lib' prefix */
if (dp->d_name[0] != 'l' ||
dp->d_name[1] != 'i' ||
dp->d_name[2] != 'b')
continue;
ndewey = getdewey(dewey, rest);
/* Copy the entry minus prefix */
(void)strcpy(name, dp->d_name + 3);
n = strlen(name);
if (n < 4)
continue;
/* Find ".so." in name */
for (cp = name + n - 4; cp > name; --cp) {
if (cp[0] == '.' &&
cp[1] == 's' &&
cp[2] == 'o' &&
cp[3] == '.')
break;
}
if (cp <= name)
continue;
*cp = '\0';
if (!isdigit(*(cp+4)))
continue;
bzero((caddr_t)dewey, sizeof(dewey));
ndewey = getdewey(dewey, cp + 4);
enter(dir, dp->d_name, name, dewey, ndewey);
}
@ -450,4 +471,3 @@ listhints()
return;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1993 Paul Kranenburg
* Copyright (c) 1993,1995 Paul Kranenburg
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -27,7 +27,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: ldconfig.c,v 1.10 1995/06/24 10:08:44 asami Exp $
* $Id: ldconfig.c,v 1.13 1996/01/09 00:04:35 pk Exp $
*/
#include <sys/param.h>
@ -139,7 +139,7 @@ int silent;
{
DIR *dd;
struct dirent *dp;
char name[MAXPATHLEN], rest[MAXPATHLEN];
char name[MAXPATHLEN];
int dewey[MAXDEWEY], ndewey;
if ((dd = opendir(dir)) == NULL) {
@ -149,17 +149,38 @@ int silent;
}
while ((dp = readdir(dd)) != NULL) {
int n;
register int n;
register char *cp;
name[0] = rest[0] = '\0';
n = sscanf(dp->d_name, "lib%[^.].so.%s",
name, rest);
if (n < 2 || rest[0] == '\0')
/* Check for `lib' prefix */
if (dp->d_name[0] != 'l' ||
dp->d_name[1] != 'i' ||
dp->d_name[2] != 'b')
continue;
ndewey = getdewey(dewey, rest);
/* Copy the entry minus prefix */
(void)strcpy(name, dp->d_name + 3);
n = strlen(name);
if (n < 4)
continue;
/* Find ".so." in name */
for (cp = name + n - 4; cp > name; --cp) {
if (cp[0] == '.' &&
cp[1] == 's' &&
cp[2] == 'o' &&
cp[3] == '.')
break;
}
if (cp <= name)
continue;
*cp = '\0';
if (!isdigit(*(cp+4)))
continue;
bzero((caddr_t)dewey, sizeof(dewey));
ndewey = getdewey(dewey, cp + 4);
enter(dir, dp->d_name, name, dewey, ndewey);
}
@ -450,4 +471,3 @@ listhints()
return;
}