[SCM] NSS Wrapper Repository - branch master updated
Andreas Schneider
asn at samba.org
Fri Nov 13 12:17:04 UTC 2015
The branch, master has been updated
via 0f089bd add me to AUTHORS
via b07f05e tests: Add test to exercise internal data structures
via 8c56086 test: add test for AI_NUMERICHOST flag.
via 72c297c nwrap: remove ai_tail argument from nwrap_files_getaddrinfo()
via 0b13b02 nwrap: rewrite the loop for duplication ai entries if socktype not given
via fbcdbed nwrap: add an explaining comment for the ai duplicating loop
via ac10582 nwrap: move setting of ai_{flags|socktype|protocol} into nwrap_convert_he_ai
via b6839a8 nwrap: use symbols IPPROTO_TCP and IPPROTO_UDP
via fb0a4cc nwrap: rename _ai -> ai_new in nwrap_files_getaddrinfo()
via 645693a nwrap: fix a memleak in nwrap_files_getaddrinfo()
via 84fb3ab nwrap: rename ai_prev -> ai_cur in nwrap_files_getaddrinfo()
via f8d4121 nwrap: Fix inventarization of IPs when loading hosts
via ce496c3 nwrap: refactor nwrap_add_hname_* into one nwrap_ed_inventarize.
via cab46be nwrap: treat AI_NUMERICHOST correctly in getaddrinfo.
via c1ce7c0 nwrap: fix treatment of EAI_ADDRINFO in nwrap_files_getaddrinfo
via deb7ea5 nwrap: correctly track EAI_ADDRINFO in nwrap_files_getaddrinfo
via 99f1ca6 nwrap: in nwrap_files_getaddrinfo, treat failure of nwrap_convert_he_ai as error
via 5b4976c nwrap: convert nwrap_files_getaddrinfo() to return EAI error codes
via 90c6576 nwrap: use the error code from nwrap_files_cache_reload() in callers
via f3f0939 nwrap: turn nwrap_files_cache_reload() into a bool function
via 4b5994b nwrap: better error propagation in nwrap_he_parse_line()
via 77fa29c nwrap: log NULL alias name at ERROR level in nwrap_add_hname()
via 25e541a nwrap: better error propagation in nwrap_add_hname()
via 1ce486b nwrap: better error propagation in nwrap_add_hname_alias
via 1363e12 nwrap: catch NULL list in nwrap_add_hname_add_to_existing
via 56a9c4f nwrap: catch null h_name in nwrap_add_hname_add_new
via 1dd94e3 nwrap: catch NULL ip in nwrap_add_ai
via d42cea9 nwrap: turn nwrap_add_hname_add_to_existing() into bool
via d3784fb tests: fix test_nwrap_gethostbyname2 - magrathea now has an IPv6 address
via 2edebd0 nwrap: simplify nwrap_file_getaddrinfo: remove a variable
via 88c70a1 nwrap: simplify nwrap_files_gethostbyname: remove a variable
via 479fa87 nwrap: log hash table full message at error level
via e284e1d nwrap: rewrite linked-list datastructures to be properly separated.
via 5df5236 nwrap: remove superfluous comments from nwrap_add_hname()
via d365a90 nwrap: remove superfluous comments from nwrap_add_hname_alias()
via dba9c6f nwrap: remove a superfluous comment from nwrap_add_hname_add_new()
via c049e77 nwrap: move var into scope in nwrap_add_hname()
via 08f3fdd nwrap: simplify nwrap_add_hname
via cec9fce nwrap: simplify nwrap_add_hname_alias
via 2bcac5e nwrap: initialize some variables in nwrap_files_getaddrinfo
via 01b9087 nwrap: slightly clean flow by removing an else branch in nwrap_getaddrinfo
via cd517c7 nwrap: in nwrap_getaddrinfo, only call libc_getaddrinfo if we need it.
via fb13b6b nwrap: slightly simplify logic in nwrap_getaddrinfo()
via ef06bed nwrap: simplify logic in nwrap_getaddrinfo, calling nwrap_files_getaddrinfo
via 3d59f93 nwrap: improve code readability in nwrap_getaddrinfo()
via a24369b nwrap: remove code duplication in nwrap_getaddrinfo
via ae1d150 tests: extend getaddrinfo_flags_ai_numericserv test to cover nwrap
via 8363415 tests: fix the getaddrinfo_service test.
via 4293eb2 nwrap: fix return code for getaddrinfo in case service is not valid
via f394978 nwrap: fix return code of getaddrinfo for AI_NUMERICSERV in error case
via 64da7b7 nwrap: fix numeric port detection in nwrap_getaddrinfo
via 969f2d4 tests: Added new test: test_nwrap_getaddrinfo_flags_ai_numericserv
from b10d23b nwrap: Better check service string sanity.
https://git.samba.org/?p=nss_wrapper.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 0f089bd55bf127db8f6a6036eba3ae27b1c9d2d5
Author: Michael Adam <obnox at samba.org>
Date: Thu Nov 12 11:55:49 2015 +0100
add me to AUTHORS
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit b07f05ebc1b60512a8adf836d7f6e76e99776bf6
Author: Robin Hack <hack.robin at gmail.com>
Date: Mon Nov 2 13:48:47 2015 +0100
tests: Add test to exercise internal data structures
This uses a big hosts file from samba to avoid regressions in Samba.
Signed-off-by: Robin Hack <hack.robin at gmail.com>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 8c5608678eaa55c7bea061f46d8b193b5f65c408
Author: Michael Adam <obnox at samba.org>
Date: Thu Nov 12 11:40:25 2015 +0100
test: add test for AI_NUMERICHOST flag.
Based on first cut at a test by Robin Hack.
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 72c297c5c384c512b6d36eca6ff0c1b56471a4a8
Author: Michael Adam <obnox at samba.org>
Date: Thu Nov 12 10:20:37 2015 +0100
nwrap: remove ai_tail argument from nwrap_files_getaddrinfo()
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 0b13b024f54c6d75ced84f83655272c89b08f327
Author: Michael Adam <obnox at samba.org>
Date: Thu Nov 12 11:35:07 2015 +0100
nwrap: rewrite the loop for duplication ai entries if socktype not given
This loop reads much more naturally now. It inserts the
duplicated entry right after the entrie that is being
duplicated. It does not need a ai_tail any more.
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit fbcdbed2cdc2e9cf49549821f45147bfc463cfa9
Author: Michael Adam <obnox at samba.org>
Date: Thu Nov 12 11:17:21 2015 +0100
nwrap: add an explaining comment for the ai duplicating loop
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit ac1058263627f66c6c59591bbda157d76f2f2b01
Author: Michael Adam <obnox at samba.org>
Date: Thu Nov 12 11:15:03 2015 +0100
nwrap: move setting of ai_{flags|socktype|protocol} into nwrap_convert_he_ai
This makes the code in nwrap_getaddrinfo() more readable
and also treats all ai stuctures in the linked list, not
just the first one!
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit b6839a8db3339564bfe6caaf008f2fa04c43c69b
Author: Michael Adam <obnox at samba.org>
Date: Thu Nov 12 11:08:47 2015 +0100
nwrap: use symbols IPPROTO_TCP and IPPROTO_UDP
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit fb0a4ccf49b8cf64781b8138798c6f70e2adae30
Author: Michael Adam <obnox at samba.org>
Date: Thu Nov 12 09:47:59 2015 +0100
nwrap: rename _ai -> ai_new in nwrap_files_getaddrinfo()
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 645693af1bf4102bb952476e085b3c0fbe5f1239
Author: Michael Adam <obnox at samba.org>
Date: Thu Nov 12 09:46:29 2015 +0100
nwrap: fix a memleak in nwrap_files_getaddrinfo()
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 84fb3ab345ae1be4e02e7e137d9045cad0cb7c88
Author: Michael Adam <obnox at samba.org>
Date: Thu Nov 12 09:45:50 2015 +0100
nwrap: rename ai_prev -> ai_cur in nwrap_files_getaddrinfo()
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit f8d412170466261a5de04e602517c92de00f6218
Author: Michael Adam <obnox at samba.org>
Date: Thu Nov 12 08:34:39 2015 +0100
nwrap: Fix inventarization of IPs when loading hosts
Use nwrap_ed_inventarize() instead of nwrap_add_ai().
This not only removes code duplication, but also
more correctly adds more than one line for a given
IP address in a list behind this address.
The original code would only have inventarized
the first line for an IP found.
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit ce496c3baf5b7d99ae8f7d8ad87493b936d56463
Author: Michael Adam <obnox at samba.org>
Date: Thu Nov 12 08:29:57 2015 +0100
nwrap: refactor nwrap_add_hname_* into one nwrap_ed_inventarize.
This reduces code duplication and abstracts the logic out.
It was not special to hname or hname_alias.
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit cab46be8c3ec713eeb9f2c7fb8aa9b984c1f5bba
Author: Michael Adam <obnox at samba.org>
Date: Mon Nov 9 00:29:23 2015 +0100
nwrap: treat AI_NUMERICHOST correctly in getaddrinfo.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11477
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit c1ce7c0d9b2d2a1f507ae05f6617ff463a7c8408
Author: Michael Adam <obnox at samba.org>
Date: Thu Nov 12 08:16:18 2015 +0100
nwrap: fix treatment of EAI_ADDRINFO in nwrap_files_getaddrinfo
Checking whether the passed in name (node) is a valid IPv6 or IPv4
address, we can do the checking for these two error conditions
properly up front.
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit deb7ea555fb3e766117075bfb8da1e41773e79a9
Author: Michael Adam <obnox at samba.org>
Date: Thu Nov 12 08:01:57 2015 +0100
nwrap: correctly track EAI_ADDRINFO in nwrap_files_getaddrinfo
When looping through the entry list and remember the
EAI_ADDRINFO case, so that we can differentiate
the cases
- no entry found at all
- an entry found buy wrong address type
Adapt return codes accordingly.
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 99f1ca607a7bf84cdfa1d214c2bb7ddfa49b3647
Author: Michael Adam <obnox at samba.org>
Date: Wed Nov 11 13:04:15 2015 +0100
nwrap: in nwrap_files_getaddrinfo, treat failure of nwrap_convert_he_ai as error
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 5b4976cf6b43eb181959327c298b25393a73b35b
Author: Michael Adam <obnox at samba.org>
Date: Wed Nov 11 13:02:59 2015 +0100
nwrap: convert nwrap_files_getaddrinfo() to return EAI error codes
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 90c657697ed5f7f784ba6fe262322cac293a7272
Author: Michael Adam <obnox at samba.org>
Date: Wed Nov 11 12:47:15 2015 +0100
nwrap: use the error code from nwrap_files_cache_reload() in callers
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit f3f093920fe80d5810b16f701ba41b885e437ca3
Author: Michael Adam <obnox at samba.org>
Date: Wed Nov 11 12:33:12 2015 +0100
nwrap: turn nwrap_files_cache_reload() into a bool function
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 4b5994b074c0deab849b75314420650b77cb7eaf
Author: Michael Adam <obnox at samba.org>
Date: Wed Nov 11 12:30:36 2015 +0100
nwrap: better error propagation in nwrap_he_parse_line()
Use the return codes of nwrap_add_hname() and nwrap_add_ai().
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 77fa29cc4ad75b9e72b2420a85753d30ad4df800
Author: Michael Adam <obnox at samba.org>
Date: Wed Nov 11 12:29:55 2015 +0100
nwrap: log NULL alias name at ERROR level in nwrap_add_hname()
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 25e541af36b10e8755d046433407838a95362f1d
Author: Michael Adam <obnox at samba.org>
Date: Wed Nov 11 12:28:58 2015 +0100
nwrap: better error propagation in nwrap_add_hname()
Use return codes from called functions.
Remove now unneeded asserts.
Make failure to add an entry for an alias an error.
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 1ce486b63506d374dd518e4e6edd6ef002621f73
Author: Michael Adam <obnox at samba.org>
Date: Wed Nov 11 12:27:33 2015 +0100
nwrap: better error propagation in nwrap_add_hname_alias
use return codes from the called function.
Remove asserts becaus the cases are caught
by the called functions.
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 1363e125d45156df1066cc41ce3008318f1c366f
Author: Michael Adam <obnox at samba.org>
Date: Wed Nov 11 12:26:02 2015 +0100
nwrap: catch NULL list in nwrap_add_hname_add_to_existing
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 56a9c4f1f24fcd4218d712f8507226db4ddb095a
Author: Michael Adam <obnox at samba.org>
Date: Wed Nov 11 12:25:30 2015 +0100
nwrap: catch null h_name in nwrap_add_hname_add_new
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 1dd94e33f51d7e716d19846762ccf87f4b36b6f1
Author: Michael Adam <obnox at samba.org>
Date: Wed Nov 11 12:24:53 2015 +0100
nwrap: catch NULL ip in nwrap_add_ai
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit d42cea9dbecd3042d2297a6e766ca3d42dea27d5
Author: Michael Adam <obnox at samba.org>
Date: Wed Nov 11 11:56:59 2015 +0100
nwrap: turn nwrap_add_hname_add_to_existing() into bool
for better error propagation.
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit d3784fb103139c9fa69d8703ba2e5c4f3e29a3d1
Author: Michael Adam <obnox at samba.org>
Date: Mon Nov 9 13:40:08 2015 +0100
tests: fix test_nwrap_gethostbyname2 - magrathea now has an IPv6 address
This should have been caught before, but the failure of this test
seems to have been uncovered by a seemingly unrelated change to
the code. (Always set ed->ed_tail = ed when initializing a new ed).
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 2edebd079be34a71d18994668b0649d346bef2a8
Author: Michael Adam <obnox at samba.org>
Date: Wed Nov 11 10:38:31 2015 +0100
nwrap: simplify nwrap_file_getaddrinfo: remove a variable
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 88c70a1c0ad9ef80dda4236a3c5c1a24f6406f0e
Author: Michael Adam <obnox at samba.org>
Date: Wed Nov 11 10:36:07 2015 +0100
nwrap: simplify nwrap_files_gethostbyname: remove a variable
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 479fa87f2c84cedf9208e46f0537104ecfa54360
Author: Michael Adam <obnox at samba.org>
Date: Wed Nov 11 11:30:13 2015 +0100
nwrap: log hash table full message at error level
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit e284e1da502c03725cfc83ecace78fb6d24b9d0b
Author: Michael Adam <obnox at samba.org>
Date: Wed Nov 11 10:27:50 2015 +0100
nwrap: rewrite linked-list datastructures to be properly separated.
The data structures were wrong:
- The nwrap_entdata structures reflects one line of the hosts
file, with ip, fqdn and aliases.
But they also had a linked list structure.
- Now the hash table was used to point each
ip address, fqdn and alias name occurring in the hosts
file to the list of lines (entdata structs) that contain
this name/address.
The problem was that these list heads were pointing to the same
entdata structures, while the list should actually be individual
for each entity (ip, fqdn, alias). This lead to wrong assiciations
of lines to IP addresse and also endless loops in the list, when
one line was put into one list twice starting from two different
points.
This patch fixes this by lifting the linked list structure to
a layer nwrap_entlist above nwrap_entdata. The entlist
entries just contain pointers to the entdata, and hence
each line can be referenced independetly by several lists.
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 5df5236e53e7a7f8151367eddfdbfe94adaf9c49
Author: Michael Adam <obnox at samba.org>
Date: Wed Nov 11 10:21:30 2015 +0100
nwrap: remove superfluous comments from nwrap_add_hname()
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit d365a90c2f07d63da39f943444479fd9f6b501eb
Author: Michael Adam <obnox at samba.org>
Date: Wed Nov 11 10:21:10 2015 +0100
nwrap: remove superfluous comments from nwrap_add_hname_alias()
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit dba9c6fa2b6f4809d2bf2b844c5995492a3eb72a
Author: Michael Adam <obnox at samba.org>
Date: Tue Nov 10 12:32:20 2015 +0100
nwrap: remove a superfluous comment from nwrap_add_hname_add_new()
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit c049e770f080a30590df7ecfce5bc45d896b3f68
Author: Michael Adam <obnox at samba.org>
Date: Mon Nov 9 17:41:43 2015 +0100
nwrap: move var into scope in nwrap_add_hname()
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 08f3fddd2cbe5bcac4d9decd6195c49aa7a91b11
Author: Michael Adam <obnox at samba.org>
Date: Mon Nov 9 17:36:37 2015 +0100
nwrap: simplify nwrap_add_hname
This is never given an alias name, so remove
the h_name_a argument.
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit cec9fce1482216508c4c09c8849bdffa288afcb6
Author: Michael Adam <obnox at samba.org>
Date: Mon Nov 9 17:36:07 2015 +0100
nwrap: simplify nwrap_add_hname_alias
This always uses the provided h_name_a alias name.
No need to fall back to the fqdn name from the entry.
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 2bcac5efa1e8017e72eebdd72d7bfa2ab7bc6bf8
Author: Michael Adam <obnox at samba.org>
Date: Mon Nov 9 17:35:29 2015 +0100
nwrap: initialize some variables in nwrap_files_getaddrinfo
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 01b9087764720ce94058531e60982baf62204f62
Author: Michael Adam <obnox at samba.org>
Date: Mon Nov 9 00:55:00 2015 +0100
nwrap: slightly clean flow by removing an else branch in nwrap_getaddrinfo
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit cd517c7b5e8437d3b5ed852083e4528c6ce1f63c
Author: Michael Adam <obnox at samba.org>
Date: Fri Nov 6 11:43:04 2015 +0100
nwrap: in nwrap_getaddrinfo, only call libc_getaddrinfo if we need it.
Instead of calling libc_getaddrinfo on spec and throwing
away the result when we are certain that we don't need it,
call libc only if we really need it.
This fixes another memleak for the libc result.
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit fb13b6be4f48ff70ee6632c8ee02a785dc869598
Author: Michael Adam <obnox at samba.org>
Date: Fri Nov 6 11:52:08 2015 +0100
nwrap: slightly simplify logic in nwrap_getaddrinfo()
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit ef06bed58bc90a62daee6b9bf10311a5ad0cad42
Author: Michael Adam <obnox at samba.org>
Date: Fri Nov 6 11:48:40 2015 +0100
nwrap: simplify logic in nwrap_getaddrinfo, calling nwrap_files_getaddrinfo
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 3d59f933d49f49222be4e0b2426e7c721cab07a4
Author: Michael Adam <obnox at samba.org>
Date: Fri Nov 6 11:31:09 2015 +0100
nwrap: improve code readability in nwrap_getaddrinfo()
Untangle a (a ? b : c) statement and add an explanatory
comment, since the intention is not immediately obvious.
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit a24369b83f94e6995e9dccc2ac7848e46f4c4586
Author: Michael Adam <obnox at samba.org>
Date: Fri Nov 6 11:28:35 2015 +0100
nwrap: remove code duplication in nwrap_getaddrinfo
The three formerly distinct cases now are all the same.
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit ae1d15038b7028acef00c38af2b8280ada325079
Author: Michael Adam <obnox at samba.org>
Date: Fri Nov 6 12:05:44 2015 +0100
tests: extend getaddrinfo_flags_ai_numericserv test to cover nwrap
If the handed in name is NULL, getaddrinfo calls are only
treated by libc even if nss_wrapper is enabled. Complement
the first tests with non-null name so that nwrap is covered.
Keep the NULL cases as they may be useful on their own.
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 83634153764c575737f8d1b3618827d5da9e24c4
Author: Michael Adam <obnox at samba.org>
Date: Fri Nov 6 11:03:40 2015 +0100
tests: fix the getaddrinfo_service test.
When the specified service is neither a number
nor a name that can be resolved as a service,
the correct return code is EAI_NONAME instead
of EAI_SERVICE.
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 4293eb298f2616e08b9edc9898f9e49212fc5d8b
Author: Michael Adam <obnox at samba.org>
Date: Fri Nov 6 11:00:54 2015 +0100
nwrap: fix return code for getaddrinfo in case service is not valid
If the specified service is not a valid service name (or port number),
EAI_NONAME should be returned.
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit f39497852851753864c031ccd73d705ccf6ea269
Author: Michael Adam <obnox at samba.org>
Date: Fri Nov 6 10:45:15 2015 +0100
nwrap: fix return code of getaddrinfo for AI_NUMERICSERV in error case
If the AI_NUMERICSERV flag is specified, the the port number
has to specified as a string representing a decimal number
or left NULL.
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 64da7b77d2efe63d3e65642e4ab7b1d2903a2983
Author: Michael Adam <obnox at samba.org>
Date: Fri Nov 6 10:22:10 2015 +0100
nwrap: fix numeric port detection in nwrap_getaddrinfo
Only a string that can be converted to a number, is
allowed as a numeric port specification. Trailing
characters are not allowed.
Signed-off-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 969f2d4b05acc5009ef5b47091497464ce961571
Author: Robin Hack <hack.robin at gmail.com>
Date: Tue Oct 13 14:42:03 2015 +0200
tests: Added new test: test_nwrap_getaddrinfo_flags_ai_numericserv
Test checks if non-valid input is handled correctly.
Signed-off-by: Robin Hack <hack.robin at gmail.com>
Reviewed-by: Andreas Schneider <asn at samba.org>
-----------------------------------------------------------------------
Summary of changes:
AUTHORS | 1 +
src/nss_wrapper.c | 547 +++++++++++++++++++++++----------------
tests/hosts.in | 88 +++++++
tests/test_getaddrinfo.c | 180 ++++++++++++-
tests/test_gethostby_name_addr.c | 2 +-
5 files changed, 588 insertions(+), 230 deletions(-)
Changeset truncated at 500 lines:
diff --git a/AUTHORS b/AUTHORS
index 335ed0a..49a2a20 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -2,3 +2,4 @@ Stefan Metzmacher <metze at samba.org>
Guenther Deschner <gd at samba.org>
Andreas Schneider <asn at samba.org>
Robin Hack <hack.robin at gmail.com>
+Michael Adam <obnox at samba.org>
diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index 21fc108..9a7fbf5 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -52,6 +52,8 @@
#include <unistd.h>
#include <ctype.h>
+#include <netinet/in.h>
+
#include <search.h>
#include <assert.h>
@@ -758,9 +760,11 @@ struct nwrap_entdata {
struct nwrap_vector nwrap_addrdata;
ssize_t aliases_count;
+};
- struct nwrap_entdata *ed_next;
- struct nwrap_entdata *ed_tail;
+struct nwrap_entlist {
+ struct nwrap_entlist *next;
+ struct nwrap_entdata *ed;
};
struct nwrap_he {
@@ -1759,7 +1763,7 @@ static void nwrap_files_cache_unload(struct nwrap_cache *nwrap)
nwrap_lines_unload(nwrap);
}
-static void nwrap_files_cache_reload(struct nwrap_cache *nwrap)
+static bool nwrap_files_cache_reload(struct nwrap_cache *nwrap)
{
struct stat st;
int ret;
@@ -1777,7 +1781,7 @@ reopen:
"Unable to open '%s' readonly %d:%s",
nwrap->path, nwrap->fd,
strerror(errno));
- return;
+ return false;
}
nwrap->fd = fileno(nwrap->fp);
@@ -1794,7 +1798,7 @@ reopen:
fclose(nwrap->fp);
nwrap->fp = NULL;
nwrap->fd = -1;
- return;
+ return false;
}
if (retried == false && st.st_nlink == 0) {
@@ -1814,7 +1818,7 @@ reopen:
NWRAP_LOG(NWRAP_LOG_TRACE,
"st_mtime[%u] hasn't changed, skip reload",
(unsigned)st.st_mtime);
- return;
+ return true;
}
NWRAP_LOG(NWRAP_LOG_TRACE,
@@ -1830,9 +1834,11 @@ reopen:
if (!ok) {
NWRAP_LOG(NWRAP_LOG_ERROR, "Failed to reload %s", nwrap->path);
nwrap_files_cache_unload(nwrap);
+ return false;
}
NWRAP_LOG(NWRAP_LOG_TRACE, "Reloaded %s", nwrap->path);
+ return true;
}
/*
@@ -2541,141 +2547,143 @@ static int nwrap_gr_copy_r(const struct group *src, struct group *dst,
return 0;
}
-static bool nwrap_add_ai(char *const ip_addr, struct nwrap_entdata *const ed)
+static struct nwrap_entlist *nwrap_entlist_init(struct nwrap_entdata *ed)
{
- ENTRY e = {
- .key = ip_addr,
- .data = (void *)ed,
- };
- ENTRY *p;
+ struct nwrap_entlist *el;
- p = hsearch(e, ENTER);
- if (p == NULL) {
- NWRAP_LOG(NWRAP_LOG_DEBUG, "Hash table is full");
- return false;
+ if (ed == NULL) {
+ NWRAP_LOG(NWRAP_LOG_ERROR,
+ "entry is NULL, can't create list item");
+ return NULL;
}
- return true;
-}
+ el = (struct nwrap_entlist *)malloc(sizeof(struct nwrap_entlist));
+ if (el == NULL) {
+ NWRAP_LOG(NWRAP_LOG_ERROR, "malloc failed");
+ return NULL;
+ }
+ el->next = NULL;
+ el->ed = ed;
-static bool nwrap_add_hname_add_new(char *const h_name,
- struct nwrap_entdata *const ed)
+ return el;
+}
+
+static bool nwrap_ed_inventarize_add_new(char *const h_name,
+ struct nwrap_entdata *const ed)
{
- /* No element found.. inventarize new item */
ENTRY e;
ENTRY *p;
+ struct nwrap_entlist *el;
+
+ if (h_name == NULL) {
+ NWRAP_LOG(NWRAP_LOG_ERROR, "h_name NULL - can't add");
+ return false;
+ }
+
+ el = nwrap_entlist_init(ed);
+ if (el == NULL) {
+ return false;
+ }
e.key = h_name;
- e.data = (void *)ed;
- ed->ed_tail = NULL;
- ed->ed_next = NULL;
+ e.data = (void *)el;
p = hsearch(e, ENTER);
if (p == NULL) {
- NWRAP_LOG(NWRAP_LOG_DEBUG, "Hash table is full!");
+ NWRAP_LOG(NWRAP_LOG_ERROR, "Hash table is full!");
return false;
}
return true;
}
-static void nwrap_add_hname_add_to_existing(struct nwrap_entdata *const ed,
- struct nwrap_entdata *const ed_dst)
+static bool nwrap_ed_inventarize_add_to_existing(struct nwrap_entdata *const ed,
+ struct nwrap_entlist *const el)
{
- if (ed_dst->ed_tail != NULL) {
- ed_dst->ed_tail->ed_next = ed;
- if (ed_dst->ed_tail != ed) {
- ed_dst->ed_tail = ed;
- ed->ed_next = NULL;
+ struct nwrap_entlist *cursor;
+ struct nwrap_entlist *el_new;
+
+ if (el == NULL) {
+ NWRAP_LOG(NWRAP_LOG_ERROR, "list is NULL, can not add");
+ return false;
+ }
+
+ el_new = nwrap_entlist_init(ed);
+ if (el_new == NULL) {
+ return false;
+ }
+
+ for (cursor = el; cursor->next != NULL; cursor = cursor->next)
+ {
+ if (cursor->ed == ed) {
+ free(el_new);
+ return false;
}
- } else {
- ed_dst->ed_tail = ed;
}
+
+ if (cursor->ed == ed) {
+ free(el_new);
+ return false;
+ }
+
+ cursor->next = el_new;
+ return true;
}
-static bool nwrap_add_hname_alias(const char *const h_name_a,
- struct nwrap_entdata *const ed)
+static bool nwrap_ed_inventarize(char *const name,
+ struct nwrap_entdata *const ed)
{
- /* One of argument 'h_hame_a' are "optional" */
- char *const h_name = (char *const) ((h_name_a == NULL) ? ed->ht.h_name : h_name_a);
ENTRY e;
ENTRY *p;
+ bool ok;
- /* Maybe it's little bit late ... */
- assert(ed != NULL);
- assert(h_name != NULL);
-
- e.key = h_name;
+ e.key = name;
e.data = NULL;
+
NWRAP_LOG(NWRAP_LOG_DEBUG, "Searching name: %s", e.key);
+
p = hsearch(e, FIND);
if (p == NULL) {
- NWRAP_LOG(NWRAP_LOG_DEBUG, "Name %s not found. Adding...", h_name);
- /* Just add alias and don't mess with metadata */
- nwrap_add_hname_add_new(h_name, ed);
+ NWRAP_LOG(NWRAP_LOG_DEBUG, "Name %s not found. Adding...", name);
+ ok = nwrap_ed_inventarize_add_new(name, ed);
} else {
- /* Element found. Add them to end of list */
- struct nwrap_entdata *ed_dst = (struct nwrap_entdata *)p->data;
+ struct nwrap_entlist *el = (struct nwrap_entlist *)p->data;
- assert(p->data != NULL);
- NWRAP_LOG(NWRAP_LOG_DEBUG, "Name %s found. Add record to list.", h_name);
- nwrap_add_hname_add_to_existing(ed, ed_dst);
+ NWRAP_LOG(NWRAP_LOG_DEBUG, "Name %s found. Add record to list.", name);
+ ok = nwrap_ed_inventarize_add_to_existing(ed, el);
}
- return true;
+ return ok;
}
-static bool nwrap_add_hname(const char *const h_name_a,
- struct nwrap_entdata *const ed)
+static bool nwrap_add_hname(struct nwrap_entdata *const ed)
{
- /* One of argument 'h_hame_a' are "optional" */
- char *const h_name = (char *const) ((h_name_a == NULL) ? ed->ht.h_name : h_name_a);
- ENTRY e;
- ENTRY *p;
- char *h_name_alias;
+ char *const h_name = (char *const)(ed->ht.h_name);
unsigned i;
+ bool ok;
- /* Maybe it's little bit late ... */
- assert(ed != NULL);
- assert(h_name != NULL);
-
- e.key = h_name;
- e.data = NULL;
- NWRAP_LOG(NWRAP_LOG_DEBUG, "Searching name: %s", e.key);
- p = hsearch(e, FIND);
- if (p == NULL) {
- NWRAP_LOG(NWRAP_LOG_DEBUG, "Name %s not found. Adding...", h_name);
- /* Just add alias and don't mess with metadata */
- nwrap_add_hname_add_new(h_name, ed);
-
- if (ed->ed_tail == NULL) {
- ed->ed_tail = ed;
- }
- } else {
- /* Element found. Add them to end of list */
- struct nwrap_entdata *ed_dst = (struct nwrap_entdata *)p->data;
-
- assert(p->data != NULL);
- NWRAP_LOG(NWRAP_LOG_DEBUG, "Name %s found. Add record to list.", h_name);
- nwrap_add_hname_add_to_existing(ed, ed_dst);
+ ok = nwrap_ed_inventarize(h_name, ed);
+ if (!ok) {
+ return false;
}
- /* Return true when list of aliases is empty */
if (ed->ht.h_aliases == NULL) {
return true;
}
/* Itemize aliases */
for (i = 0; ed->ht.h_aliases[i] != NULL; ++i) {
+ char *h_name_alias;
+
h_name_alias = ed->ht.h_aliases[i];
- assert(h_name_alias != NULL);
NWRAP_LOG(NWRAP_LOG_DEBUG, "Add alias: %s", h_name_alias);
- if (!nwrap_add_hname_alias(h_name_alias, ed)) {
- NWRAP_LOG(NWRAP_LOG_DEBUG,
+ if (!nwrap_ed_inventarize(h_name_alias, ed)) {
+ NWRAP_LOG(NWRAP_LOG_ERROR,
"Unable to add alias: %s", h_name_alias);
+ return false;
}
}
@@ -2692,6 +2700,7 @@ static bool nwrap_he_parse_line(struct nwrap_cache *nwrap, char *line)
char *n;
char *ip;
+ bool ok;
struct nwrap_entdata *ed = (struct nwrap_entdata *)
malloc(sizeof(struct nwrap_entdata));
@@ -2840,8 +2849,15 @@ static bool nwrap_he_parse_line(struct nwrap_cache *nwrap, char *line)
ed->aliases_count = aliases_count;
/* Inventarize item */
- nwrap_add_hname(NULL, ed);
- nwrap_add_ai(ip, ed);
+ ok = nwrap_add_hname(ed);
+ if (!ok) {
+ return false;
+ }
+
+ ok = nwrap_ed_inventarize(ip, ed);
+ if (!ok) {
+ return false;
+ }
nwrap_he->num++;
return true;
@@ -2873,12 +2889,17 @@ static struct passwd *nwrap_files_getpwnam(struct nwrap_backend *b,
const char *name)
{
int i;
+ bool ok;
(void) b; /* unused */
NWRAP_LOG(NWRAP_LOG_DEBUG, "Lookup user %s in files", name);
- nwrap_files_cache_reload(nwrap_pw_global.cache);
+ ok = nwrap_files_cache_reload(nwrap_pw_global.cache);
+ if (!ok) {
+ NWRAP_LOG(NWRAP_LOG_ERROR, "Error loading passwd file");
+ return NULL;
+ }
for (i=0; i<nwrap_pw_global.num; i++) {
if (strcmp(nwrap_pw_global.list[i].pw_name, name) == 0) {
@@ -2918,10 +2939,15 @@ static struct passwd *nwrap_files_getpwuid(struct nwrap_backend *b,
uid_t uid)
{
int i;
+ bool ok;
(void) b; /* unused */
- nwrap_files_cache_reload(nwrap_pw_global.cache);
+ ok = nwrap_files_cache_reload(nwrap_pw_global.cache);
+ if (!ok) {
+ NWRAP_LOG(NWRAP_LOG_ERROR, "Error loading passwd file");
+ return NULL;
+ }
for (i=0; i<nwrap_pw_global.num; i++) {
if (nwrap_pw_global.list[i].pw_uid == uid) {
@@ -2972,7 +2998,12 @@ static struct passwd *nwrap_files_getpwent(struct nwrap_backend *b)
(void) b; /* unused */
if (nwrap_pw_global.idx == 0) {
- nwrap_files_cache_reload(nwrap_pw_global.cache);
+ bool ok;
+ ok = nwrap_files_cache_reload(nwrap_pw_global.cache);
+ if (!ok) {
+ NWRAP_LOG(NWRAP_LOG_ERROR, "Error loading passwd file");
+ return NULL;
+ }
}
if (nwrap_pw_global.idx >= nwrap_pw_global.num) {
@@ -3028,7 +3059,13 @@ static struct spwd *nwrap_files_getspent(void)
struct spwd *sp;
if (nwrap_sp_global.idx == 0) {
- nwrap_files_cache_reload(nwrap_sp_global.cache);
+ bool ok;
+
+ ok = nwrap_files_cache_reload(nwrap_sp_global.cache);
+ if (!ok) {
+ NWRAP_LOG(NWRAP_LOG_ERROR, "Error loading shadow file");
+ return NULL;
+ }
}
if (nwrap_sp_global.idx >= nwrap_sp_global.num) {
@@ -3054,10 +3091,15 @@ static void nwrap_files_endspent(void)
static struct spwd *nwrap_files_getspnam(const char *name)
{
int i;
+ bool ok;
NWRAP_LOG(NWRAP_LOG_DEBUG, "Lookup user %s in files", name);
- nwrap_files_cache_reload(nwrap_sp_global.cache);
+ ok = nwrap_files_cache_reload(nwrap_sp_global.cache);
+ if (!ok) {
+ NWRAP_LOG(NWRAP_LOG_ERROR, "Error loading shadow file");
+ return NULL;
+ }
for (i=0; i<nwrap_sp_global.num; i++) {
if (strcmp(nwrap_sp_global.list[i].sp_namp, name) == 0) {
@@ -3145,10 +3187,15 @@ static struct group *nwrap_files_getgrnam(struct nwrap_backend *b,
const char *name)
{
int i;
+ bool ok;
(void) b; /* unused */
- nwrap_files_cache_reload(nwrap_gr_global.cache);
+ ok = nwrap_files_cache_reload(nwrap_gr_global.cache);
+ if (!ok) {
+ NWRAP_LOG(NWRAP_LOG_ERROR, "Error loading group file");
+ return NULL;
+ }
for (i=0; i<nwrap_gr_global.num; i++) {
if (strcmp(nwrap_gr_global.list[i].gr_name, name) == 0) {
@@ -3188,10 +3235,15 @@ static struct group *nwrap_files_getgrgid(struct nwrap_backend *b,
gid_t gid)
{
int i;
+ bool ok;
(void) b; /* unused */
- nwrap_files_cache_reload(nwrap_gr_global.cache);
+ ok = nwrap_files_cache_reload(nwrap_gr_global.cache);
+ if (!ok) {
+ NWRAP_LOG(NWRAP_LOG_ERROR, "Error loading group file");
+ return NULL;
+ }
for (i=0; i<nwrap_gr_global.num; i++) {
if (nwrap_gr_global.list[i].gr_gid == gid) {
@@ -3242,7 +3294,13 @@ static struct group *nwrap_files_getgrent(struct nwrap_backend *b)
(void) b; /* unused */
if (nwrap_gr_global.idx == 0) {
- nwrap_files_cache_reload(nwrap_gr_global.cache);
+ bool ok;
+
+ ok = nwrap_files_cache_reload(nwrap_gr_global.cache);
+ if (!ok) {
+ NWRAP_LOG(NWRAP_LOG_ERROR, "Error loading group file");
+ return NULL;
+ }
}
if (nwrap_gr_global.idx >= nwrap_gr_global.num) {
@@ -3288,8 +3346,7 @@ static int nwrap_files_gethostbyname(const char *name, int af,
struct hostent *result,
struct nwrap_vector *addr_list)
{
- struct nwrap_entdata *ed_head;
- struct nwrap_entdata *ed_cur;
+ struct nwrap_entlist *el;
struct hostent *he;
char *h_name_lower;
ENTRY e;
@@ -3297,8 +3354,13 @@ static int nwrap_files_gethostbyname(const char *name, int af,
char canon_name[DNS_NAME_MAX] = { 0 };
size_t name_len;
bool he_found = false;
+ bool ok;
- nwrap_files_cache_reload(nwrap_he_global.cache);
+ ok = nwrap_files_cache_reload(nwrap_he_global.cache);
+ if (!ok) {
+ NWRAP_LOG(NWRAP_LOG_ERROR, "error loading hosts file");
+ goto no_ent;
+ }
name_len = strlen(name);
if (name_len < sizeof(canon_name) && name[name_len - 1] == '.') {
@@ -3338,9 +3400,9 @@ static int nwrap_files_gethostbyname(const char *name, int af,
}
/* Iterate through results */
- ed_head = (struct nwrap_entdata *)e_p->data;
- for (ed_cur = ed_head; ed_cur != NULL; ed_cur = ed_cur->ed_next) {
- he = &(ed_cur->ht);
+ for (el = (struct nwrap_entlist *)e_p->data; el != NULL; el = el->next)
+ {
+ he = &(el->ed->ht);
--
NSS Wrapper Repository
More information about the samba-cvs
mailing list