summaryrefslogtreecommitdiff
path: root/nsswitch/wins.c
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2011-03-02 10:44:14 +0100
committerVolker Lendecke <vlendec@samba.org>2011-03-02 11:33:04 +0100
commit8635a3834a50b911aab549ddb5a41952a84dccc3 (patch)
tree62ff946ef7c2b5db5ca4c696060f02502c6be1ee /nsswitch/wins.c
parent358f031ccf7e5df11416b977965dfbb184e2bd25 (diff)
downloadsamba-8635a3834a50b911aab549ddb5a41952a84dccc3.tar.gz
samba-8635a3834a50b911aab549ddb5a41952a84dccc3.tar.bz2
samba-8635a3834a50b911aab549ddb5a41952a84dccc3.zip
s3: Attempt to fix the build on IRIX
Autobuild-User: Volker Lendecke <vlendec@samba.org> Autobuild-Date: Wed Mar 2 11:33:05 CET 2011 on sn-devel-104
Diffstat (limited to 'nsswitch/wins.c')
-rw-r--r--nsswitch/wins.c65
1 files changed, 10 insertions, 55 deletions
diff --git a/nsswitch/wins.c b/nsswitch/wins.c
index 5136c94c76..e0aa2ad8f5 100644
--- a/nsswitch/wins.c
+++ b/nsswitch/wins.c
@@ -114,72 +114,27 @@ static struct in_addr *lookup_byname_backend(const char *name, int *count)
#ifdef HAVE_NS_API_H
-/* Use our own create socket code so we don't recurse.... */
-
-static int wins_lookup_open_socket_in(void)
-{
- struct sockaddr_in sock;
- int val=1;
- int res;
-
- memset((char *)&sock,'\0',sizeof(sock));
-
-#ifdef HAVE_SOCK_SIN_LEN
- sock.sin_len = sizeof(sock);
-#endif
- sock.sin_port = 0;
- sock.sin_family = AF_INET;
- sock.sin_addr.s_addr = interpret_addr("0.0.0.0");
- res = socket(AF_INET, SOCK_DGRAM, 0);
- if (res == -1)
- return -1;
-
- if (setsockopt(res,SOL_SOCKET,SO_REUSEADDR,(char *)&val,sizeof(val)) != 0) {
- close(res);
- return -1;
- }
-#ifdef SO_REUSEPORT
- if (setsockopt(res,SOL_SOCKET,SO_REUSEPORT,(char *)&val,sizeof(val)) != 0) {
- close(res);
- return -1;
- }
-#endif /* SO_REUSEPORT */
-
- /* now we've got a socket - we need to bind it */
-
- if (bind(res, (struct sockaddr * ) &sock,sizeof(sock)) < 0) {
- close(res);
- return(-1);
- }
-
- set_socket_options(res,"SO_BROADCAST");
-
- return res;
-}
-
static struct node_status *lookup_byaddr_backend(char *addr, int *count)
{
- int fd;
struct sockaddr_storage ss;
struct nmb_name nname;
- struct node_status *status;
+ struct node_status *result;
+ NTSTATUS status;
if (!initialised) {
nss_wins_init();
}
- fd = wins_lookup_open_socket_in();
- if (fd == -1)
- return NULL;
-
make_nmb_name(&nname, "*", 0);
if (!interpret_string_addr(&ss, addr, AI_NUMERICHOST)) {
return NULL;
}
- status = node_status_query(fd, &nname, &ss, count, NULL);
+ status = node_status_query(NULL, &nname, &ss, &result, count, NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ return NULL;
+ }
- close(fd);
- return status;
+ return result;
}
/* IRIX version */
@@ -229,7 +184,7 @@ int lookup(nsd_file_t *rq)
if ( status = lookup_byaddr_backend(key, &count)) {
size = strlen(key) + 1;
if (size > len) {
- free(status);
+ talloc_free(status);
return NSD_ERROR;
}
len -= size;
@@ -241,7 +196,7 @@ int lookup(nsd_file_t *rq)
if (status[i].type == 0x20) {
size = sizeof(status[i].name) + 1;
if (size > len) {
- free(status);
+ talloc_free(status);
return NSD_ERROR;
}
len -= size;
@@ -251,7 +206,7 @@ int lookup(nsd_file_t *rq)
}
}
response[strlen(response)-1] = '\n';
- free(status);
+ talloc_free(status);
}
} else if (StrCaseCmp(map,"hosts.byname") == 0) {
if (ip_list = lookup_byname_backend(key, &count)) {