Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 01 Jun 1998 07:23:39 -0700
From:      "Jordan K. Hubbard" <jkh@time.cdrom.com>
To:        ben@stuyts.nl
Cc:        current@FreeBSD.ORG, brian@awfulhak.org
Subject:   Re: ppp cannot find libalias 
Message-ID:  <20865.896711019@time.cdrom.com>
In-Reply-To: Your message of "Mon, 01 Jun 1998 15:05:39 %2B0200." <199806011305.PAA10258@daneel.stuyts.nl> 

next in thread | previous in thread | raw e-mail | index | archive | help
> /usr/lib, as they are now in /usr/lib/aout. The new ppp does not look in the 
> correct place for libalias yet. It still looks in /usr/lib:

Hmmm.  What do you guys think of this?  The ELF path may be wrong
since I'm not sure if my understanding of how ELF names its shared
libs is entirely sound, but that's easily fixed if so.

Index: loadalias.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/ppp/loadalias.c,v
retrieving revision 1.16
diff -u -r1.16 loadalias.c
--- loadalias.c	1998/05/21 21:46:19	1.16
+++ loadalias.c	1998/06/01 14:21:54
@@ -40,7 +40,12 @@
 #include "id.h"
 #include "loadalias.h"
 
-#define _PATH_ALIAS_PREFIX "/usr/lib/libalias.so.2."
+static char *_PathAliasPrefixes[] = {
+	"/usr/lib/aout/libalias.so.2.",
+	"/usr/lib/elf/libalias.so",
+	"/usr/lib/libalias.so.2.",
+	NULL
+};
 
 #define off(item) ((int)&(((struct aliasHandlers *)0)->item))
 #define entry(a) { off(a), "_PacketAlias" #a }
@@ -68,29 +73,17 @@
 
 struct aliasHandlers PacketAlias;
 
-int 
-alias_Load()
+static int 
+_alias_Load(char *path)
 {
-  const char *path;
-  const char *env;
   int i;
-
-  if (PacketAlias.dl)
-    return 0;
 
-  path = _PATH_ALIAS_PREFIX;
-  env = getenv("_PATH_ALIAS_PREFIX");
-  if (env) {
-    if (ID0realuid() == 0)
-      path = env;
-    else
-      log_Printf(LogALERT, "Ignoring environment _PATH_ALIAS_PREFIX"
-                " value (%s)\n", env);
-  }
+  if (!*path)
+      return -1;
 
   PacketAlias.dl = dlopen(path, RTLD_NOW);
   if (PacketAlias.dl == (void *) 0) {
-    /* Look for _PATH_ALIAS_PREFIX with any number appended */
+    /* Look for prefix with any number appended */
     int plen;
 
     plen = strlen(path);
@@ -135,11 +128,8 @@
         }
       }
     }
-    if (PacketAlias.dl == (void *) 0) {
-      log_Printf(LogWARN, "_PATH_ALIAS_PREFIX (%s*): Invalid lib: %s\n",
-	        path, dlerror());
+    if (PacketAlias.dl == (void *) 0)
       return -1;
-    }
   }
   for (i = 0; map[i].name; i++) {
     *(void **)((char *)&PacketAlias + map[i].offset) =
@@ -155,6 +145,35 @@
   (*PacketAlias.Init)();
 
   return 0;
+}
+
+int
+alias_Load()
+{
+  char *env, *paths[2];
+  char **p = NULL;
+  int i = -1;
+
+  if (PacketAlias.dl)
+    return 0;
+
+  if ((env = getenv("_PATH_ALIAS_PREFIX")) != NULL) {
+      if (ID0realuid() == 0) {
+	  paths[0] = env;
+	  paths[1] = NULL;
+	  p = paths;
+      }
+      else
+	  log_Printf(LogALERT, "Ignoring environment _PATH_ALIAS_PREFIX"
+			       " value (%s)\n", env);
+  }
+  if (!p)
+      p = _PathAliasPrefixes;
+  while (*p && (i = _alias_Load(*p)))
+	++p;
+  if (i)
+      log_Printf(LogWARN, "No valid alias libraries found in search path.\n");
+  return i;
 }
 
 void 



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20865.896711019>