FreeBSD Bugzilla – Attachment 118126 Details for
Bug 160295
[patch] ypserv(8): ypserv -P [bin/109494] breaks tcp
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
yp_main.c.diff
yp_main.c.diff (text/plain; charset=us-ascii), 3.26 KB, created by
Dylan Simon
on 2011-08-30 17:15:19 UTC
(
hide
)
Description:
yp_main.c.diff
Filename:
MIME Type:
Creator:
Dylan Simon
Created:
2011-08-30 17:15:19 UTC
Size:
3.26 KB
patch
obsolete
>--- yp_main.c.orig 2011-08-30 11:15:33.595224119 -0400 >+++ yp_main.c 2011-08-30 11:15:21.375092957 -0400 >@@ -84,16 +84,6 @@ > int do_dns = 0; > int resfd; > >-struct socktype { >- const char *st_name; >- int st_type; >-}; >-static struct socktype stlist[] = { >- { "tcp", SOCK_STREAM }, >- { "udp", SOCK_DGRAM }, >- { NULL, 0 } >-}; >- > static > void _msgout(char* msg) > { >@@ -235,14 +225,13 @@ > main(int argc, char *argv[]) > { > register SVCXPRT *transp = NULL; >- int sock; >+ int sock_udp = -1, sock_tcp = -1; > int proto = 0; > struct sockaddr_in saddr; > socklen_t asize = sizeof (saddr); > int ch; > in_port_t yp_port = 0; > char *errstr; >- struct socktype *st; > > while ((ch = getopt(argc, argv, "hdnp:P:")) != -1) { > switch (ch) { >@@ -282,7 +271,10 @@ > if (getsockopt(0, SOL_SOCKET, SO_TYPE, > (char *)&_rpcfdtype, &ssize) == -1) > exit(1); >- sock = 0; >+ if (_rpcfdtype == SOCK_DGRAM) >+ sock_udp = 0; >+ else if (_rpcfdtype == SOCK_STREAM) >+ sock_tcp = 0; > _rpcpmstart = 1; > proto = 0; > openlog("ypserv", LOG_PID, LOG_DAEMON); >@@ -293,46 +285,49 @@ > } > openlog("ypserv", LOG_PID, LOG_DAEMON); > } >- sock = RPC_ANYSOCK; >+ sock_udp = sock_tcp = RPC_ANYSOCK; > (void) pmap_unset(YPPROG, YPVERS); > (void) pmap_unset(YPPROG, 1); > } > > /* > * Initialize TCP/UDP sockets. >+ * Really should only do this if !_rpcpmstart. > */ >- memset((char *)&saddr, 0, sizeof(saddr)); >- saddr.sin_family = AF_INET; >- saddr.sin_addr.s_addr = htonl(INADDR_ANY); >- saddr.sin_port = htons(yp_port); >- for (st = stlist; st->st_name != NULL; st++) { >- /* Do not bind the socket if the user didn't specify a port */ >- if (yp_port == 0) >- break; >+ if (yp_port) >+ { >+ memset((char *)&saddr, 0, sizeof(saddr)); >+ saddr.sin_family = AF_INET; >+ saddr.sin_addr.s_addr = htonl(INADDR_ANY); >+ saddr.sin_port = htons(yp_port); >+ >+ sock_udp = socket(AF_INET, SOCK_DGRAM, 0); >+ if (sock_udp == -1) { >+ _msgout("cannot create a udp socket"); >+ exit(1); >+ } > >- sock = socket(AF_INET, st->st_type, 0); >- if (sock == -1) { >- if ((asprintf(&errstr, "cannot create a %s socket", >- st->st_name)) == -1) >- err(1, "unexpected failure in asprintf()"); >- _msgout(errstr); >- free((void *)errstr); >+ if (bind(sock_udp, (struct sockaddr *) &saddr, sizeof(saddr)) >+ == -1) { >+ _msgout("cannot bind udp socket"); > exit(1); > } >- if (bind(sock, (struct sockaddr *) &saddr, sizeof(saddr)) >+ >+ sock_tcp = socket(AF_INET, SOCK_STREAM, 0); >+ if (sock_tcp == -1) { >+ _msgout("cannot create a tcp socket"); >+ exit(1); >+ } >+ >+ if (bind(sock_tcp, (struct sockaddr *) &saddr, sizeof(saddr)) > == -1) { >- if ((asprintf(&errstr, "cannot bind %s socket", >- st->st_name)) == -1) >- err(1, "unexpected failure in asprintf()"); >- _msgout(errstr); >- free((void *)errstr); >+ _msgout("cannot bind tcp socket"); > exit(1); > } >- errstr = NULL; > } > > if ((_rpcfdtype == 0) || (_rpcfdtype == SOCK_DGRAM)) { >- transp = svcudp_create(sock); >+ transp = svcudp_create(sock_udp); > if (transp == NULL) { > _msgout("cannot create udp service"); > exit(1); >@@ -350,7 +345,7 @@ > } > > if ((_rpcfdtype == 0) || (_rpcfdtype == SOCK_STREAM)) { >- transp = svctcp_create(sock, 0, 0); >+ transp = svctcp_create(sock_tcp, 0, 0); > if (transp == NULL) { > _msgout("cannot create tcp service"); > exit(1);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 160295
: 118126