[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, 02 Jul 2008 20:42:43 +0200 |
User-agent: |
Thunderbird 2.0.0.14 (X11/20080421) |
Neal H. Walfield wrote:
If more network protocols are implemented, we have to provide more
environment variables for the servers.
Or you use an environment variable that is based on a stem and the
protocol number. So instead of SOCK_INET_SERV_PATH,
SOCK_SERV_%d_PATH. Perhaps it is best to support both. The number of
protocol is not increasing at a terribly fast rate.
The new version of the patch is below.
I wonder if I can use __snprintf(). The code in the original glibc
doesn't use it.
Needed for glibc-2_7-branch
2008-06-30 Zheng Da <zhengda1936@gmail.com>
* hurd/hurdsocks.c: _hurd_socket_server() searches in environment
variables
for the socket server insteading of using the default one.
--- glibc-2.7-old/hurd/hurdsock.c 2008-06-21 01:38:30.300000000 +0200
+++ glibc-2.7/hurd/hurdsock.c 2008-07-02 08:33:49.570000000 +0200
@@ -76,16 +76,30 @@
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_env_name[30];
+ int len;
+ char *name = NULL;
+ char *np = NULL;
+ __snprintf (sock_serv_env_name, 30, "SOCK_SERV_%d_PATH", domain);
+ if ((np = getenv (sock_serv_env_name)) == NULL)
+ {
+ char *sock_serv_path = NULL;
+ 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;
+ __snprintf (np, len + 100, "%s/%d", sock_serv_path, domain);
+ }
+
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
- Re: The patch of glibc which allows the user to override the pfinet server,
zhengda <=