Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/ldconfig Add some code to test libraries to make sure t...



details:   https://anonhg.NetBSD.org/src/rev/dddd95e50018
branches:  trunk
changeset: 486704:dddd95e50018
user:      matt <matt%NetBSD.org@localhost>
date:      Sat May 27 17:06:34 2000 +0000

description:
Add some code to test libraries to make sure they are a.out before adding
them to hints.

diffstat:

 sbin/ldconfig/ldconfig.c |  19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

diffs (47 lines):

diff -r a5ec9ae0e0c3 -r dddd95e50018 sbin/ldconfig/ldconfig.c
--- a/sbin/ldconfig/ldconfig.c  Sat May 27 16:44:41 2000 +0000
+++ b/sbin/ldconfig/ldconfig.c  Sat May 27 17:06:34 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ldconfig.c,v 1.28 2000/05/27 06:53:29 matt Exp $       */
+/*     $NetBSD: ldconfig.c,v 1.29 2000/05/27 17:06:34 matt Exp $       */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -42,6 +42,7 @@
 #include <sys/file.h>
 #include <sys/time.h>
 #include <sys/mman.h>
+#include <a.out.h>
 #include <ctype.h>
 #include <dirent.h>
 #include <err.h>
@@ -232,7 +233,9 @@
 
        while ((dp = readdir(dd)) != NULL) {
                int n;
-               char *cp;
+               char *cp, *path;
+               FILE *fp;
+               struct exec ex;
 
                /* Check for `lib' prefix */
                if (dp->d_name[0] != 'l' ||
@@ -257,6 +260,18 @@
                if (cp <= name)
                        continue;
 
+               path = concat(dir, "/", dp->d_name);
+               fp = fopen(path, "r");
+               free(path);
+               if (fp == NULL)
+                       continue;
+               n = fread(&ex, 1, sizeof(ex), fp);
+               fclose(fp);
+               if (n != sizeof(ex)
+                   || N_GETMAGIC(ex) != ZMAGIC
+                   || (N_GETFLAG(ex) & EX_DYNAMIC) == 0)
+                       continue;
+
                *cp = '\0';
                if (!isdigit(*(cp+4)))
                        continue;



Home | Main Index | Thread Index | Old Index