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: Wed, 25 Jun 2008 16:44:51 +0200
User-agent: Thunderbird 2.0.0.14 (X11/20080421)

Neal H. Walfield wrote:
This works in the case where you want to override all pf servers.
This case is important.  Also important is the ability to override a
single pf server in a similar manner.

A couple comments on the code: please follow the GNU coding standards.
Second, I assume that you left the #if 0 in because you are requesting
review.  Make sure that you remove this when you really intend to
submit the patch.  Finally, when that happens, make sure to include a
change log entry.

Neal
I wonder if it's really necessary to override a single pf server.
If more network protocols are implemented, we have to provide more environment variables for the servers. On the other hand, if we override the path of all socket servers, we can create a symbolic link to the default server which we don't want to override. Anyway, I provide two more environment variables SOCK_INET_SERV_PATH and SOCK_LOCAL_SERV_PATH for the pfinet server and pflocal server, respectively. I try to make my code meet the GNU coding standard. If it doesn't, could you point it out. The GNU coding standard is a bit long, so I'm not sure if my code meets all GNU standards.

Here is the patch of the second version

--- glibc-2.7-old/hurd/hurdsock.c    2008-06-21 01:38:30.000000000 +0200
+++ /glibc-2.7/hurd/hurdsock.c    2008-06-24 12:55:23.000000000 +0200
@@ -76,16 +76,39 @@

  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);
+      char *sock_serv_path = NULL;
+      int len;
+      char *name = NULL;
+      char *np = NULL;
+      if ((domain == AF_INET
+            && (sock_serv_path = getenv ("SOCK_INET_SERV_PATH")))
+          || (domain == AF_LOCAL
+              && (sock_serv_path = getenv ("SOCK_LOCAL_SERV_PATH"))))
+        {
+          np = sock_serv_path;
+        }
+      else
+        {
+          sock_serv_path = getenv ("SOCK_SERV_PATH");
+          if (sock_serv_path == NULL)
+            sock_serv_path = _SERVERS_SOCKET;
+          len = strlen (sock_serv_path);
+          name = (char *)malloc (len + 100);
+          if (name == NULL)
+            __libc_fatal ("hurd: Can't allocate the socket server path\n");
+          np = &name[len + 100];
+          *--np = '\0';
+          np = _itoa (domain, np, 10, 0);
+          *--np = '/';
+          np -= len;
+          memcpy (np, sock_serv_path , len);
+        }
+
      server = __file_name_lookup (np, 0, 0);
      if (domain <= max_domain)
-      servers[domain] = server;
+        servers[domain] = server;
+      if (name)
+        free(name);
    }
  else
    server = servers[domain];

Best,
Zheng Da




reply via email to

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