bug-hurd
[Top][All Lists]
Advanced

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

Re: The patch of glibc which allows the user to override the pfinet serv


From: zhengda
Subject: Re: The patch of glibc which allows the user to override the pfinet server
Date: Tue, 12 Aug 2008 20:05:49 +0200
User-agent: Thunderbird 2.0.0.16 (X11/20080707)

The new patch of glibc to override the default socket server:


Needed for glibc-2_7-branch

2008-06-30 Zheng Da <address@hidden>

   * hurd/hurdsocks.c (_hurd_socket_server): Searches environment variables
   for the socket server insteading of using the default one.
   (SOCK_SERV_%d, SOCK_SERV): The environment variables that contains
   the path of the socket server.

--- glibc-2.7-old/hurd/hurdsock.c    2008-06-21 01:38:30.660000000 +0200
+++ glibc-2.7/hurd/hurdsock.c    2008-08-11 03:33:38.690000000 +0200
@@ -45,7 +45,7 @@
socket_t
_hurd_socket_server (int domain, int dead)
{
-  socket_t server;
+  socket_t server = MACH_PORT_NULL;

  HURD_CRITICAL_BEGIN;
  __mutex_lock (&lock);
@@ -76,16 +76,37 @@

  if (domain > max_domain || servers[domain] == MACH_PORT_NULL)
    {
-      char name[sizeof (_SERVERS_SOCKET) + 100];
-      char *np = &name[sizeof (name)];
-      *--np = '\0';
-      np = _itoa (domain, np, 10, 0);
-      *--np = '/';
-      np -= sizeof (_SERVERS_SOCKET) - 1;
-      memcpy (np, _SERVERS_SOCKET, sizeof (_SERVERS_SOCKET) - 1);
-      server = __file_name_lookup (np, 0, 0);
-      if (domain <= max_domain)
-      servers[domain] = server;
+      char *name = NULL;
+      char *np = NULL;
+
+      if (__asprintf (&name, "SOCK_SERV_%d", domain) > 0)
+        {
+          np = getenv (name);
+          __free (name);
+        }
+      name = NULL;
+
+      if (np == NULL)
+        {
+          char *sock_servs = NULL;
+
+          sock_servs = getenv ("SOCK_SERV");
+          if (sock_servs == NULL)
+            sock_servs = _SERVERS_SOCKET;
+          if (__asprintf (&name, "%s/%d", sock_servs, domain) > 0)
+              np = name;
+          else
+            name = NULL;
+        }
+
+      if (np)
+        {
+          server = __file_name_lookup (np, 0, 0);
+          if (domain <= max_domain)
+            servers[domain] = server;
+        }
+
+      free (name);
    }
  else
    server = servers[domain];





reply via email to

[Prev in Thread] Current Thread [Next in Thread]