From 119825e3df9b65ea24f28a7faf39b54861d62f0c Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn@samba.org>
Date: Mon, 19 Sep 2016 16:21:31 +0200
Subject: [PATCH] waf: Explicitly link libreplace against libnss_wins.so
If we do not specify replace as a depencency here, it will not link to
libreplace using an rpath.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12277
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Jim McDonough <jmcd@samba.org>
(cherry picked from commit d8a5565ae647352d11d622bd4e73ff4568678a7c)
---
nsswitch/wscript_build | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/nsswitch/wscript_build b/nsswitch/wscript_build
index f286896..ab8f8ea 100644
--- a/nsswitch/wscript_build
+++ b/nsswitch/wscript_build
@@ -42,7 +42,7 @@ if (Utils.unversioned_sys_platform() == 'linux' or (host_os.rfind('gnu') > -1)):
bld.SAMBA3_LIBRARY('nss_wins',
keep_underscore=True,
source='wins.c',
- deps='''wbclient''',
+ deps='wbclient replace',
public_headers=[],
public_headers_install=False,
pc_files=[],
--
2.10.0
From 33bc85d9060340e4ce3d2edecb3fb76dd85a5195 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn@samba.org>
Date: Mon, 19 Sep 2016 16:17:11 +0200
Subject: [PATCH 1/2] nsswitch: Add missing arguments to wins gethostbyname*
The errno pointer argument is missing.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12269
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Jim McDonough <jmcd@samba.org>
(cherry picked from commit 124ae4e861f048fe015bff32ace4abff4d3e6c62)
---
nsswitch/wins.c | 51 +++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 41 insertions(+), 10 deletions(-)
diff --git a/nsswitch/wins.c b/nsswitch/wins.c
index fc65c03..be84f2e 100644
--- a/nsswitch/wins.c
+++ b/nsswitch/wins.c
@@ -39,10 +39,19 @@ static pthread_mutex_t wins_nss_mutex = PTHREAD_MUTEX_INITIALIZER;
#define INADDRSZ 4
#endif
-NSS_STATUS _nss_wins_gethostbyname_r(const char *hostname, struct hostent *he,
- char *buffer, size_t buflen, int *h_errnop);
-NSS_STATUS _nss_wins_gethostbyname2_r(const char *name, int af, struct hostent *he,
- char *buffer, size_t buflen, int *h_errnop);
+NSS_STATUS _nss_wins_gethostbyname_r(const char *hostname,
+ struct hostent *he,
+ char *buffer,
+ size_t buflen,
+ int *errnop,
+ int *h_errnop);
+NSS_STATUS _nss_wins_gethostbyname2_r(const char *name,
+ int af,
+ struct hostent *he,
+ char *buffer,
+ size_t buflen,
+ int *errnop,
+ int *h_errnop);
static char *lookup_byname_backend(const char *name)
{
@@ -225,8 +234,12 @@ gethostbyname() - we ignore any domain portion of the name and only
handle names that are at most 15 characters long
**************************************************************************/
NSS_STATUS
-_nss_wins_gethostbyname_r(const char *hostname, struct hostent *he,
- char *buffer, size_t buflen, int *h_errnop)
+_nss_wins_gethostbyname_r(const char *hostname,
+ struct hostent *he,
+ char *buffer,
+ size_t buflen,
+ int *errnop,
+ int *h_errnop)
{
NSS_STATUS nss_status = NSS_STATUS_SUCCESS;
char *ip;
@@ -247,6 +260,7 @@ _nss_wins_gethostbyname_r(const char *hostname, struct hostent *he,
ip = lookup_byname_backend(name);
if (ip == NULL) {
+ *errnop = EINVAL;
nss_status = NSS_STATUS_NOTFOUND;
goto out;
}
@@ -254,6 +268,7 @@ _nss_wins_gethostbyname_r(const char *hostname, struct hostent *he,
rc = inet_pton(AF_INET, ip, &in);
wbcFreeMemory(ip);
if (rc == 0) {
+ *errnop = errno;
nss_status = NSS_STATUS_TRYAGAIN;
goto out;
}
@@ -263,6 +278,7 @@ _nss_wins_gethostbyname_r(const char *hostname, struct hostent *he,
namelen = strlen(name) + 1;
if ((he->h_name = get_static(&buffer, &buflen, namelen)) == NULL) {
+ *errnop = EAGAIN;
nss_status = NSS_STATUS_TRYAGAIN;
goto out;
}
@@ -275,18 +291,21 @@ _nss_wins_gethostbyname_r(const char *hostname, struct hostent *he,
i = sizeof(char*) - i;
if (get_static(&buffer, &buflen, i) == NULL) {
+ *errnop = EAGAIN;
nss_status = NSS_STATUS_TRYAGAIN;
goto out;
}
if ((he->h_addr_list = (char **)get_static(
&buffer, &buflen, 2 * sizeof(char *))) == NULL) {
+ *errnop = EAGAIN;
nss_status = NSS_STATUS_TRYAGAIN;
goto out;
}
if ((he->h_addr_list[0] = get_static(&buffer, &buflen,
INADDRSZ)) == NULL) {
+ *errnop = EAGAIN;
nss_status = NSS_STATUS_TRYAGAIN;
goto out;
}
@@ -306,12 +325,14 @@ _nss_wins_gethostbyname_r(const char *hostname, struct hostent *he,
i = sizeof(char*) - i;
if (get_static(&buffer, &buflen, i) == NULL) {
+ *errnop = EAGAIN;
nss_status = NSS_STATUS_TRYAGAIN;
goto out;
}
if ((he->h_aliases = (char **)get_static(
&buffer, &buflen, sizeof(char *))) == NULL) {
+ *errnop = EAGAIN;
nss_status = NSS_STATUS_TRYAGAIN;
goto out;
}
@@ -330,17 +351,27 @@ _nss_wins_gethostbyname_r(const char *hostname, struct hostent *he,
NSS_STATUS
-_nss_wins_gethostbyname2_r(const char *name, int af, struct hostent *he,
- char *buffer, size_t buflen, int *h_errnop)
+_nss_wins_gethostbyname2_r(const char *name,
+ int af,
+ struct hostent *he,
+ char *buffer,
+ size_t buflen,
+ int *errnop,
+ int *h_errnop)
{
NSS_STATUS nss_status;
if(af!=AF_INET) {
+ *errnop = EAFNOSUPPORT;
*h_errnop = NO_DATA;
nss_status = NSS_STATUS_UNAVAIL;
} else {
- nss_status = _nss_wins_gethostbyname_r(
- name, he, buffer, buflen, h_errnop);
+ nss_status = _nss_wins_gethostbyname_r(name,
+ he,
+ buffer,
+ buflen,
+ errnop,
+ h_errnop);
}
return nss_status;
}
--
2.10.0
From b8d9c7b69509555f40335a0dd7b93ef032354b0d Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn@samba.org>
Date: Tue, 20 Sep 2016 13:26:52 +0200
Subject: [PATCH 2/2] nsswitch: Also set h_errnop for nss_wins functions
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12269
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jim McDonough <jmcd@samba.org>
(cherry picked from commit 382345126c56e26d3dbc319f1c7c1dae3c4fafc9)
---
nsswitch/wins.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/nsswitch/wins.c b/nsswitch/wins.c
index be84f2e..dccb6dd 100644
--- a/nsswitch/wins.c
+++ b/nsswitch/wins.c
@@ -261,6 +261,7 @@ _nss_wins_gethostbyname_r(const char *hostname,
ip = lookup_byname_backend(name);
if (ip == NULL) {
*errnop = EINVAL;
+ *h_errnop = NETDB_INTERNAL;
nss_status = NSS_STATUS_NOTFOUND;
goto out;
}
@@ -269,6 +270,7 @@ _nss_wins_gethostbyname_r(const char *hostname,
wbcFreeMemory(ip);
if (rc == 0) {
*errnop = errno;
+ *h_errnop = NETDB_INTERNAL;
nss_status = NSS_STATUS_TRYAGAIN;
goto out;
}
@@ -279,6 +281,7 @@ _nss_wins_gethostbyname_r(const char *hostname,
if ((he->h_name = get_static(&buffer, &buflen, namelen)) == NULL) {
*errnop = EAGAIN;
+ *h_errnop = NETDB_INTERNAL;
nss_status = NSS_STATUS_TRYAGAIN;
goto out;
}
@@ -292,6 +295,7 @@ _nss_wins_gethostbyname_r(const char *hostname,
if (get_static(&buffer, &buflen, i) == NULL) {
*errnop = EAGAIN;
+ *h_errnop = NETDB_INTERNAL;
nss_status = NSS_STATUS_TRYAGAIN;
goto out;
}
@@ -299,6 +303,7 @@ _nss_wins_gethostbyname_r(const char *hostname,
if ((he->h_addr_list = (char **)get_static(
&buffer, &buflen, 2 * sizeof(char *))) == NULL) {
*errnop = EAGAIN;
+ *h_errnop = NETDB_INTERNAL;
nss_status = NSS_STATUS_TRYAGAIN;
goto out;
}
@@ -306,6 +311,7 @@ _nss_wins_gethostbyname_r(const char *hostname,
if ((he->h_addr_list[0] = get_static(&buffer, &buflen,
INADDRSZ)) == NULL) {
*errnop = EAGAIN;
+ *h_errnop = NETDB_INTERNAL;
nss_status = NSS_STATUS_TRYAGAIN;
goto out;
}
@@ -326,6 +332,7 @@ _nss_wins_gethostbyname_r(const char *hostname,
if (get_static(&buffer, &buflen, i) == NULL) {
*errnop = EAGAIN;
+ *h_errnop = NETDB_INTERNAL;
nss_status = NSS_STATUS_TRYAGAIN;
goto out;
}
@@ -333,12 +340,14 @@ _nss_wins_gethostbyname_r(const char *hostname,
if ((he->h_aliases = (char **)get_static(
&buffer, &buflen, sizeof(char *))) == NULL) {
*errnop = EAGAIN;
+ *h_errnop = NETDB_INTERNAL;
nss_status = NSS_STATUS_TRYAGAIN;
goto out;
}
he->h_aliases[0] = NULL;
+ *h_errnop = NETDB_SUCCESS;
nss_status = NSS_STATUS_SUCCESS;
out:
--
2.10.0
From c91544eb234af9a13ab08f2b1e31d2915965985b Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn@samba.org>
Date: Sun, 13 Nov 2016 17:40:21 +0100
Subject: [PATCH] nss_wins: Fix errno values for HOST_NOT_FOUND
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12269
Signed-off-by: Andreas Schneider <asn@samba.org>
---
nsswitch/wins.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/nsswitch/wins.c b/nsswitch/wins.c
index dccb6dd..19d3c5b 100644
--- a/nsswitch/wins.c
+++ b/nsswitch/wins.c
@@ -260,8 +260,7 @@ _nss_wins_gethostbyname_r(const char *hostname,
ip = lookup_byname_backend(name);
if (ip == NULL) {
- *errnop = EINVAL;
- *h_errnop = NETDB_INTERNAL;
+ *h_errnop = HOST_NOT_FOUND;
nss_status = NSS_STATUS_NOTFOUND;
goto out;
}
--
2.10.2