[SCM] Samba Shared Repository - branch master updated

Michael Adam obnox at samba.org
Mon Jan 11 14:31:03 UTC 2016


The branch, master has been updated
       via  7cec309 nss_wrapper: bump version to 1.1.2
       via  da292b6 nwrap: Fix segfaults while reloading hosts file
       via  19b2dcb nwrap: Don't fail if we want to add an existing entry
       via  9b79020 nwrap: Fix the build on Solaris
       via  5f62197 nwrap: Don't leak memory from gethostbyname*() functions
       via  b54bbb2 nwrap: Fix the build on FreeBSD
       via  766e795 nwrap: fix a copy and paste error in the destructor.
       via  554963d nwrap: Cleanup shadow getspnam() memory
       via  159fdb0 nwrap: fix leaking the entlists
       via  bf49615 nwrap: catch error to add item to vector in nwrap_he_parse_line()
       via  736fa61 nwrap: rename nwrap_he.entdata to nwrap_he.entries
       via  e94a7c5 nwrap: remove unused member list from struct nwrap_he
       via  16b71ae nwrap: Small code shift in nwrap_ed_inventarize_add_to_existing()
       via  db0ef5c nwrap: Cast max_hostents to avoid warnings
       via  8fad97b nwrap: Fix initialization of e entry
       via  f1acb0e nwrap: remove ai_tail argument from nwrap_files_getaddrinfo()
       via  d198cda nwrap: rewrite the loop for duplication ai entries if socktype not given
       via  ab2f41b nwrap: add an explaining comment for the ai duplicating loop
       via  062c97b nwrap: move setting of ai_{flags|socktype|protocol} into nwrap_convert_he_ai
       via  a66606c nwrap: use symbols IPPROTO_TCP and IPPROTO_UDP
       via  bf65160 nwrap: rename _ai -> ai_new in nwrap_files_getaddrinfo()
       via  a42f658 nwrap: fix a memleak in nwrap_files_getaddrinfo()
       via  07b6925 nwrap: rename ai_prev -> ai_cur in nwrap_files_getaddrinfo()
       via  b996f0a nwrap: Fix inventarization of IPs when loading hosts
       via  07f1bef nwrap: refactor nwrap_add_hname_* into one nwrap_ed_inventarize.
       via  55e9606 nwrap: treat AI_NUMERICHOST correctly in getaddrinfo.
       via  34cff9e nwrap: fix treatment of EAI_ADDRINFO in nwrap_files_getaddrinfo
       via  154080c nwrap: correctly track EAI_ADDRINFO in nwrap_files_getaddrinfo
       via  0dc34ea nwrap: in nwrap_files_getaddrinfo, treat failure of nwrap_convert_he_ai as error
       via  18be46d nwrap: convert nwrap_files_getaddrinfo() to return EAI error codes
       via  6078126 nwrap: use the error code from nwrap_files_cache_reload() in callers
       via  fe7e163 nwrap: turn nwrap_files_cache_reload() into a bool function
       via  4919f1c nwrap: better error propagation in nwrap_he_parse_line()
       via  ccb4076 nwrap: log NULL alias name at ERROR level in nwrap_add_hname()
       via  f6e4c58 nwrap: better error propagation in nwrap_add_hname()
       via  ddd0ca8 nwrap: better error propagation in nwrap_add_hname_alias
       via  7ec5aae nwrap: catch NULL list in nwrap_add_hname_add_to_existing
       via  2974cef nwrap: catch null h_name in nwrap_add_hname_add_new
       via  be8c7dc nwrap: catch NULL ip in nwrap_add_ai
       via  a725bd7 nwrap: turn nwrap_add_hname_add_to_existing() into bool
       via  d681a08 nwrap: simplify nwrap_file_getaddrinfo: remove a variable
       via  28f0a8b nwrap: simplify nwrap_files_gethostbyname: remove a variable
       via  54c825b nwrap: log hash table full message at error level
       via  9502535 nwrap: rewrite linked-list datastructures to be properly separated.
       via  19d5415 nwrap: remove superfluous comments from nwrap_add_hname()
       via  4ec47e7 nwrap: remove superfluous comments from nwrap_add_hname_alias()
       via  69af963 nwrap: remove a superfluous comment from nwrap_add_hname_add_new()
       via  3cc12ec nwrap: move var into scope in nwrap_add_hname()
       via  f7b28bd nwrap: simplify nwrap_add_hname
       via  8f62cda nwrap: simplify nwrap_add_hname_alias
       via  067978d nwrap: initialize some variables in nwrap_files_getaddrinfo
       via  be182ba nwrap: slightly clean flow by removing an else branch in nwrap_getaddrinfo
       via  559ed74 nwrap: in nwrap_getaddrinfo, only call libc_getaddrinfo if we need it.
       via  9927e49 nwrap: slightly simplify logic in nwrap_getaddrinfo()
       via  b0569d4 nwrap: simplify logic in nwrap_getaddrinfo, calling nwrap_files_getaddrinfo
       via  53e633e nwrap: improve code readability in nwrap_getaddrinfo()
       via  8da2110 nwrap: remove code duplication in nwrap_getaddrinfo
       via  5bea2dc nwrap: fix return code for getaddrinfo in case service is not valid
       via  40f9bf7 nwrap: fix return code of getaddrinfo for AI_NUMERICSERV in error case
       via  522631b nwrap: fix numeric port detection in nwrap_getaddrinfo
       via  72764a6 nwrap: Better check service string sanity.
       via  200f5bf nwrap: Fix memory leak in nwrap_gethostbyname_r()
       via  43d470a nwrap: Fix memory leak in nwrap_files_gethostbyname()
       via  853b2ff nwrap: Fix memory leak in nwrap_he_unload()
       via  3cae3e5 nwrap: Rename cont to vector in nwrap_vector_add_item()
       via  e1bb009 nwrap: Fix memory leak inside nwrap_getaddrinfo()
       via  0f1ffb9 nwrap: Use nwrap_vector_foreach instead of for loop
       via  9d71542 nwrap: Fix memory leak when getline() is used.
       via  4505dcd nwrap: Add basic locking for support multithreaded applications
       via  1017031 nwrap: Add BSD libc support for gethost*_r functios.
       via  960345e nwrap: Use nwrap vectors as memory backend for getaddrinfo() and gethostbyname()
       via  090dec2 nwrap: Add string manipulation functions.
       via  270d6f9 nwrap: Add nwrap_add_hname() and nwrap_add_hname_alias().
       via  442fc3f nwrap: Add function nwrap_add_ai
       via  15c1453 nwrap: Add a hash table to the nwrap structure
       via  f3da6e4 nwrap: Simplify file loading.
       via  ff65d01 nwrap: Add nwrap vector memory management functions
       via  6706ee4 nwrap: Check for setspent and getspnam functions
       via  22f159f src: Add configure check for shadow.h
       via  088887b nwrap: Add support for getspnam()
       via  608fa20 nwrap: Add (set|get|end)spent functions
       via  e971a44 nwrap: Add nss_wrapper_shadow_enabled() function
       via  4be5853 nwrap: Add shadow file parser
       via  2a53352 nwrap: Remove unused struct member in nwrap_main
       via  90585c4 nwrap: Implement nwrap_files_initgroups()
       via  80abc70 nwrap: Remove unneeded memcpy in getgrouplist()
       via  a104389 nwrap: Avoid a string comparsion in getgrouplist()
       via  1c346a0 nwrap: Use ssize_t for aliases_count
       via  02b5410 nwrap: Prevent compilation failure on machine without IPv4
       via  90dbe7b nwrap: Replace free() calls by SAFE_FREE macro where possible.
       via  ea741de nwrap: Fix the handle loops for older gcc versions.
       via  77d0fce torture: add torture comment output of name/ip to WinsBy{Ip,Name} tests
       via  71ffd3b torture: Fix winbind.wbclient.ResolveWinsByIp test
       via  fcb1ca8 torture: fix check_pw_with_krb5 in the rpc:lsa test
       via  688590f torture: fix check_dom_trust_pw in the rpc:lsa test
       via  38c2305 torture: fix the ldap.netlogon-udp test
       via  9b443d2 torture: fix the ldap.cldap test
      from  2e2d4be s3:wscript: fix spaces

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 7cec3092ffd8fa6f0f14194be7856ab087ac75a9
Author: Michael Adam <obnox at samba.org>
Date:   Wed Dec 16 17:47:04 2015 +0100

    nss_wrapper: bump version to 1.1.2
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    
    Autobuild-User(master): Michael Adam <obnox at samba.org>
    Autobuild-Date(master): Mon Jan 11 15:30:49 CET 2016 on sn-devel-144

commit da292b606230190e65f7ef17d23f8c7a65135ecb
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Dec 17 08:46:33 2015 +0100

    nwrap: Fix segfaults while reloading hosts file
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 19b2dcbeb230adc956d023dfea0d1aad9bb2a1ca
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Nov 24 17:32:47 2015 +0100

    nwrap: Don't fail if we want to add an existing entry
    
    Pair-Programmed-With: Michael Adam <obnox at samba.org>
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Signed-off-by: Michael Adam <obnox at samba.org>

commit 9b7902090d2d594d25d517759dba78ced0f9124b
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Nov 23 08:33:02 2015 +0100

    nwrap: Fix the build on Solaris
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 5f621977fd52b6da94707733bc273636a7ba2fde
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Nov 20 09:38:16 2015 +0100

    nwrap: Don't leak memory from gethostbyname*() functions
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit b54bbb2b832570070c1310b22792d0c6586cde85
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Nov 20 08:51:49 2015 +0100

    nwrap: Fix the build on FreeBSD
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 766e795518127bf0febd3c0da436adb1a376771d
Author: Michael Adam <obnox at samba.org>
Date:   Fri Nov 20 09:01:01 2015 +0100

    nwrap: fix a copy and paste error in the destructor.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 554963d8877d2260ec36ff4bc097499606386d11
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Nov 19 09:02:46 2015 +0100

    nwrap: Cleanup shadow getspnam() memory
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Signed-off-by: Michael Adam <obnox at samba.org>

commit 159fdb01856d26d118e7862cd30175571c973682
Author: Michael Adam <obnox at samba.org>
Date:   Thu Nov 19 01:00:16 2015 +0100

    nwrap: fix leaking the entlists
    
    Track the list heads in a vector in the newrap_he_global
    struct and free the structures upon nwrap_he_unload.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit bf496153bc280ed58ee25de599b08446bebf738e
Author: Michael Adam <obnox at samba.org>
Date:   Thu Nov 19 00:34:54 2015 +0100

    nwrap: catch error to add item to vector in nwrap_he_parse_line()
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 736fa61a9546c48d03cbd75897f7e6956ed48c0e
Author: Michael Adam <obnox at samba.org>
Date:   Thu Nov 19 00:30:17 2015 +0100

    nwrap: rename nwrap_he.entdata to nwrap_he.entries
    
    That's what is is the list of entries. In the guise
    nwrap_entdata structures but the code reads more
    naturally this way.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit e94a7c5a56b60056f0638223150df55b95b0b342
Author: Michael Adam <obnox at samba.org>
Date:   Thu Nov 19 00:24:14 2015 +0100

    nwrap: remove unused member list from struct nwrap_he
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 16b71aecab5233138dd609fffbc9296abe3628c5
Author: Robin Hack <hack.robin at gmail.com>
Date:   Mon Nov 16 23:38:51 2015 +0100

    nwrap: Small code shift in nwrap_ed_inventarize_add_to_existing()
    
    Allocate memory only when necessary.
    
    Signed-off-by: Robin Hack <hack.robin at gmail.com>
    Reviewed-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit db0ef5cc9e1a7aedb62ade34cd25e71f745dacc7
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Nov 16 10:19:27 2015 +0100

    nwrap: Cast max_hostents to avoid warnings
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 8fad97bc3428879f4c4b16b56c3d8c5f55c9f33b
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Nov 16 10:17:39 2015 +0100

    nwrap: Fix initialization of e entry
    
    This fixes a compiler warning.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit f1acb0e29657fcc97ab2d45b11c579392388f5d0
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 d198cdaefde851db80ff9e179bbecb5185c0ff82
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 ab2f41bed6e239ce09ed593995b473e8e0800599
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 062c97be191ef6b912af46e209941e858b0be3fd
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 a66606cd0215b973d768b61444858db38c501f69
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 bf65160ed2c9f07527151823d7ac38b187060643
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 a42f6589c795673cb89cdf9909d2f48de5048c75
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 07b6925242bc7fb33a8b4d63dec74a82c73a1cae
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 b996f0a60c05b2bfbf39c2b88cc665c7f7b7909f
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 07f1bef632af79ff75033e08d3d69937523d40c5
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 55e9606e68c56e942055b16d5624dbd9cad2f5da
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 34cff9e72947bbed536be185de814dfccaf40204
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 154080ce8549174a858a6170137d2355f9d31cb0
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 0dc34ea56afec67472af29dbb4c361dd27c7841b
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 18be46d87c468d6aae297f7d49e3ef6fb9170cfe
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 6078126eb5d60053811582c2f7bc267bc3bd41c9
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 fe7e1635154aed2eec9b4298fc6b5af1cf2c105e
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 4919f1cd210ce75116f7443f9a6a99bf379d2b6a
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 ccb407630997757c3d73798f7bfab81cf5de6950
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 f6e4c58663cea850b25ec2a006e2644a25deb320
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 ddd0ca82bb3c74de3996a8ddbe85b6d29e14f552
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 7ec5aaeb027c7b37ef9d1d522b194b939499647a
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 2974cef3d80aaa71d766524f1e89e371182f0b08
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 be8c7dc5af31d9da05b276dd65c2fe8dfe85df52
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 a725bd7728e079fc9f54c9d06cdd49f43daeb4e7
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 d681a084d993c2f1a96a8dfc749108eea1c69822
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 28f0a8b5a96bedec35e4f6a5266940769d652568
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 54c825b1cbc76e5d5df6e8e021e6eaab26b7a8c6
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 95025358d80c3c93476b934467d7ada7d6c060ed
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 19d54157a479a0fa45720a1f2e64b26d9e1eb31d
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 4ec47e739c024bbd2cb9ebcc310964011333eca4
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 69af963f8e7268842b51e147a6d68a84b271fda4
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 3cc12ec5548eb1eaaf9a11e2903a477ae5de7540
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 f7b28bd655d0b819830fa13d0f92bab96bd9037c
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 8f62cda726c6fd471b4c929c5fb757443fa08842
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 067978d785231670d24eabe30d0559cf7873365f
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 be182bab2e05290d525e25c59c406d350d3ed70e
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 559ed74a5aae5254b8b702a039b360a800af6d5c
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 9927e499f2a4f0f19ffd609eacc6d799da9861cd
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 b0569d40ce7e2e94095315e34d505f6d04e58a9f
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 53e633e4017cfb3270a4c81d7bb33b437f80ed97
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 8da2110a84922e495dcaa28c794922cf94fb9758
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 5bea2dc13f56b1cb52a3724c2fb1cc2007926a5b
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 40f9bf7835d2119bc127520f2f2d355787567f0a
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 522631b739821fd53d996d986197af1fb837ef2a
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 72764a6fd31da438cfe4d117dc2cafc1c8907c2d
Author: Robin Hack <hack.robin at gmail.com>
Date:   Tue Oct 13 14:41:14 2015 +0200

    nwrap: Better check service string sanity.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11501
    
    Patch use strtol() instead of atoi() to convert strings to numbers.
    This helps better check sanity of service input string.
    
    Signed-off-by: Robin Hack <hack.robin at gmail.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 200f5bf138ede63ad446c70ac291e79020262054
Author: Robin Hack <hack.robin at gmail.com>
Date:   Mon Oct 12 10:36:04 2015 +0200

    nwrap: Fix memory leak in nwrap_gethostbyname_r()
    
    Fix reimplements how memory is used.
    Results from vector are copied to user provided buf.
    
    Signed-off-by: Robin Hack <hack.robin at gmail.com>
    Reviewed-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 43d470a06fdc55f8ad2e91d92572c9125da8cf3d
Author: Robin Hack <hack.robin at gmail.com>
Date:   Thu Oct 8 15:27:47 2015 +0200

    nwrap: Fix memory leak in nwrap_files_gethostbyname()
    
    Signed-off-by: Robin Hack <hack.robin at gmail.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 853b2ff08e8bd62a592e31f4627fb0ef09e2ff9d
Author: Robin Hack <hack.robin at gmail.com>
Date:   Thu Oct 8 15:00:33 2015 +0200

    nwrap: Fix memory leak in nwrap_he_unload()
    
    Signed-off-by: Robin Hack <hack.robin at gmail.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 3cae3e55e7d575bf859ebbbb2827512012362007
Author: Robin Hack <hack.robin at gmail.com>
Date:   Thu Oct 8 14:09:11 2015 +0200

    nwrap: Rename cont to vector in nwrap_vector_add_item()
    
    Signed-off-by: Robin Hack <hack.robin at gmail.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit e1bb0094d49224f3f0aae6de3753a04382b560f7
Author: Robin Hack <hack.robin at gmail.com>
Date:   Thu Oct 8 14:02:56 2015 +0200

    nwrap: Fix memory leak inside nwrap_getaddrinfo()
    
    Memory leak was introduced by deep copy code.
    Item ai_tmp->ai_addr should not have deep copy.
    
    Signed-off-by: Robin Hack <hack.robin at gmail.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 0f1ffb9b5b76b9b009e895d67241d3b4b61c6c75
Author: Robin Hack <hack.robin at gmail.com>
Date:   Thu Oct 8 14:00:38 2015 +0200

    nwrap: Use nwrap_vector_foreach instead of for loop
    
    Replace for loop by nwrap_vector_foreach in nwrap_lines_unload().
    
    Signed-off-by: Robin Hack <hack.robin at gmail.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 9d71542cd96f1fd1d835db690042a34d50ec513a
Author: Robin Hack <hack.robin at gmail.com>
Date:   Thu Oct 8 11:36:33 2015 +0200

    nwrap: Fix memory leak when getline() is used.
    
    getline() allocates memory even if return code is < 0.
    
    Signed-off-by: Robin Hack <hack.robin at gmail.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 4505dcd64650f395baa4ca737e89c116bd2dada1
Author: Robin Hack <hack.robin at gmail.com>
Date:   Tue Mar 24 17:54:34 2015 +0100

    nwrap: Add basic locking for support multithreaded applications
    
    Signed-off-by: Robin Hack <hack.robin at gmail.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 1017031a295512e50c8aa8fe6d60be06efc0f368
Author: Robin Hack <hack.robin at gmail.com>
Date:   Fri Mar 27 15:51:11 2015 +0100

    nwrap: Add BSD libc support for gethost*_r functios.
    
    BSD libc stores data in thread local storage.
    
    Signed-off-by: Robin Hack <hack.robin at gmail.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 960345e617301f2695c9090a6a0feae3fd362c9f
Author: Robin Hack <hack.robin at gmail.com>
Date:   Thu Jul 16 16:10:20 2015 +0200

    nwrap: Use nwrap vectors as memory backend for getaddrinfo() and gethostbyname()
    
    Previous patches introduced nwrap vectors and hash functions.
    This patch will join all together.
    
    Main purpose of this patch is:
    	- support more records per hostname.
    	  For example: hostname now can have associated IPv4 and IPv6 address.
    	- better handling of big number of hostname records
    
    Signed-off-by: Robin Hack <hack.robin at gmail.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 090dec2fd1b99c7c3d6e145cb826b04b3d07e280
Author: Robin Hack <hack.robin at gmail.com>
Date:   Tue Mar 24 15:14:35 2015 +0100

    nwrap: Add string manipulation functions.
    
    Signed-off-by: Robin Hack <hack.robin at gmail.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 270d6f94dbacba10bbcb46372f2eb03c647a5198
Author: Robin Hack <hack.robin at gmail.com>
Date:   Wed Jul 15 15:05:28 2015 +0200

    nwrap: Add nwrap_add_hname() and nwrap_add_hname_alias().
    
    Functions adds a hostname or an alias to the hash table.
    
    Signed-off-by: Robin Hack <hack.robin at gmail.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 442fc3fcd27f849a7792f6d8d5cbf36cd8c35f82
Author: Robin Hack <hack.robin at gmail.com>
Date:   Wed Jul 15 15:04:32 2015 +0200

    nwrap: Add function nwrap_add_ai
    
    This adds an ip to the hash table.
    
    Signed-off-by: Robin Hack <hack.robin at gmail.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 15c14536d0e4055a7a9c4906b968ead5283e21a8
Author: Robin Hack <hack.robin at gmail.com>
Date:   Wed Jul 15 15:01:48 2015 +0200

    nwrap: Add a hash table to the nwrap structure
    
    The hash table will hold hostnames and ips internally. The new
    environment variable which is introduced is NSS_WRAPPER_MAX_HOSTENTS. It
    sets the maximum count of hostent (hostnames and ips) structs which the
    hash table can hold.
    
    Signed-off-by: Robin Hack <hack.robin at gmail.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit f3da6e4905320bff56db5dba8fd5a2873d829e1c
Author: Robin Hack <hack.robin at gmail.com>
Date:   Mon Mar 23 14:39:28 2015 +0100

    nwrap: Simplify file loading.
    
    Lines are stored into vectors now.
    
    Signed-off-by: Robin Hack <hack.robin at gmail.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit ff65d01333ef9e0c9dd53144186381b6b44c64af
Author: Robin Hack <hack.robin at gmail.com>
Date:   Mon Mar 23 14:10:18 2015 +0100

    nwrap: Add nwrap vector memory management functions
    
    Nwrap vectors  are just more inteligent arrays.
    They can look like very simple version of
    vectors from C++.
    
    TESTS: Add nwrap_vector tests.
    
    Signed-off-by: Robin Hack <hack.robin at gmail.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 6706ee485660e6e5360d750adef8fdb3b75e2415
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Oct 6 10:34:20 2015 +0200

    nwrap: Check for setspent and getspnam functions
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 22f159f45f791ef2b1664ebfbdf0867d5d8ce97f
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Oct 6 10:19:48 2015 +0200

    src: Add configure check for shadow.h
    
    This is the first part to fix FreeBSD.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 088887bda9cd8c25342d5bcf104536a888c48699
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Sep 17 10:39:15 2015 +0200

    nwrap: Add support for getspnam()
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 608fa2063a498bea66df1fb0c1336a2a649986b2
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Sep 17 10:38:49 2015 +0200

    nwrap: Add (set|get|end)spent functions
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit e971a44299057e9f6baece4a376baa6998dc0d3d
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Sep 17 10:37:50 2015 +0200

    nwrap: Add nss_wrapper_shadow_enabled() function
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 4be5853b4cbf460d6203dcc0c3297bf45e57eacb
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Sep 17 10:33:58 2015 +0200

    nwrap: Add shadow file parser
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 2a5335217e9e9d1c34c192f4a00c9a77bdacc112
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Sep 17 10:32:46 2015 +0200

    nwrap: Remove unused struct member in nwrap_main
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 90585c46ebad3af67d39152dc7b79ce2b36da74c
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Sep 11 13:37:57 2015 +0200

    nwrap: Implement nwrap_files_initgroups()
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 80abc70bc9685857af0dae6ea2e0c3904e854c9d
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Sep 14 14:57:40 2015 +0200

    nwrap: Remove unneeded memcpy in getgrouplist()
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit a104389de2798189cb2729042f5dd60ca626019d
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Sep 14 14:52:51 2015 +0200

    nwrap: Avoid a string comparsion in getgrouplist()
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 1c346a07ff85805a616f07682ecf2c4afb311dec
Author: Robin Hack <hack.robin at gmail.com>
Date:   Wed Jul 15 15:00:02 2015 +0200

    nwrap: Use ssize_t for aliases_count
    
    Signed-off-by: Robin Hack <hack.robin at gmail.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 02b5410466c89de404e4a406f79459448f9e12f3
Author: Robin Hack <hack.robin at gmail.com>
Date:   Wed Mar 25 09:36:10 2015 +0100

    nwrap: Prevent compilation failure on machine without IPv4
    
    Signed-off-by: Robin Hack <hack.robin at gmail.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 90dbe7beb87771e9f598c3ec4f783f90f19b4e62
Author: Robin Hack <hack.robin at gmail.com>
Date:   Sat Nov 29 13:22:46 2014 +0100

    nwrap: Replace free() calls by SAFE_FREE macro where possible.
    
    Signed-off-by: Robin Hack <hack.robin at gmail.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit ea741de64a92e4d1cf62c7a2539fefabbcb38a81
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Oct 1 17:15:35 2014 +0200

    nwrap: Fix the handle loops for older gcc versions.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 77d0fce7b75f6cb4b43850fd914829b0a94316c6
Author: Michael Adam <obnox at samba.org>
Date:   Sat Jan 9 00:19:03 2016 +0100

    torture: add torture comment output of name/ip to WinsBy{Ip,Name} tests
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 71ffd3b90b5c19ba8596dee86ed49881a22371cc
Author: Michael Adam <obnox at samba.org>
Date:   Fri Dec 18 19:11:43 2015 +0100

    torture: Fix winbind.wbclient.ResolveWinsByIp test
    
    The test gets handed a name, so we first need
    to resolve the name to an IP before we can
    pass that on to ResolveWinsByIp.
    
    Bug uncovered by the new nss_wrapper code (1.1.2).
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit fcb1ca86542831f226de4a8a0b8e51d6831d8895
Author: Michael Adam <obnox at samba.org>
Date:   Thu Dec 17 13:59:58 2015 +0100

    torture: fix check_pw_with_krb5 in the rpc:lsa test
    
    Don't use AI_NUMERICHOST for getaddrinfo.
    This is so that a host*NAME* handed in will get properly resolved.
    Bug uncovered by the new nss_wrapper code (1.1.2)  which fixed
    the handling of the AI_NUMERICHOST flag in getaddrinfo.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 688590f07f67047a47dd5ce47c7311745a3a7615
Author: Michael Adam <obnox at samba.org>
Date:   Thu Dec 17 13:59:40 2015 +0100

    torture: fix check_dom_trust_pw in the rpc:lsa test
    
    This makes sure a host*NAME* handed in will get properly resolved.
    Bug uncovered by the new nss_wrapper code (1.1.2) which fixed
    the handling of the AI_NUMERICHOST flag in getaddrinfo.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 38c2305fe535c12c1737acd456a857a7f793aef3
Author: Michael Adam <obnox at samba.org>
Date:   Thu Dec 17 13:58:12 2015 +0100

    torture: fix the ldap.netlogon-udp test
    
    This makes sure a host*NAME* handed in will get properly resolved.
    Bug uncovered by the new nss_wrapper code (1.1.2) which fixed
    the handling of the AI_NUMERICHOST flag in getaddrinfo.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 9b443d2f4ba850582f3a888ad89322f626e0e750
Author: Michael Adam <obnox at samba.org>
Date:   Thu Dec 17 13:56:16 2015 +0100

    torture: fix the ldap.cldap test
    
    This makes sure a host*NAME* handed in will get properly resolved.
    Bug uncovered by the new nss_wrapper code (1.1.2) which fixed
    the handling of the AI_NUMERICHOST flag in getaddrinfo.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 lib/nss_wrapper/nss_wrapper.c         | 2015 +++++++++++++++++++++++++++------
 lib/nss_wrapper/wscript               |    2 +-
 nsswitch/libwbclient/tests/wbclient.c |   20 +-
 source4/torture/ldap/cldap.c          |   13 +-
 source4/torture/ldap/netlogon.c       |   13 +-
 source4/torture/rpc/lsa.c             |   15 +-
 6 files changed, 1746 insertions(+), 332 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/nss_wrapper/nss_wrapper.c b/lib/nss_wrapper/nss_wrapper.c
index a41de9e..c4f1b33 100644
--- a/lib/nss_wrapper/nss_wrapper.c
+++ b/lib/nss_wrapper/nss_wrapper.c
@@ -35,6 +35,8 @@
 
 #include "config.h"
 
+#include <pthread.h>
+
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/socket.h>
@@ -50,6 +52,11 @@
 #include <unistd.h>
 #include <ctype.h>
 
+#include <netinet/in.h>
+
+#include <search.h>
+#include <assert.h>
+
 /*
  * Defining _POSIX_PTHREAD_SEMANTICS before including pwd.h and grp.h  gives us
  * the posix getpwnam_r(), getpwuid_r(), getgrnam_r and getgrgid_r calls on
@@ -61,6 +68,9 @@
 
 #include <pwd.h>
 #include <grp.h>
+#ifdef HAVE_SHADOW_H
+#include <shadow.h>
+#endif /* HAVE_SHADOW_H */
 
 #include <netdb.h>
 #include <arpa/inet.h>
@@ -140,6 +150,72 @@ typedef nss_status_t NSS_STATUS;
 
 #define ZERO_STRUCTP(x) do { if ((x) != NULL) memset((char *)(x), 0, sizeof(*(x))); } while(0)
 
+#ifndef SAFE_FREE
+#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); (x)=NULL;} } while(0)
+#endif
+
+#ifdef HAVE_IPV6
+#define NWRAP_INET_ADDRSTRLEN INET6_ADDRSTRLEN
+#else
+#define NWRAP_INET_ADDRSTRLEN INET_ADDRSTRLEN
+#endif
+
+#define NWRAP_LOCK(m) do { \
+	pthread_mutex_lock(&( m ## _mutex)); \
+} while(0)
+
+#define NWRAP_UNLOCK(m) do { \
+	pthread_mutex_unlock(&( m ## _mutex)); \
+} while(0)
+
+
+static bool nwrap_initialized = false;
+static pthread_mutex_t nwrap_initialized_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+/* The mutex or accessing the id */
+static pthread_mutex_t nwrap_global_mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t nwrap_gr_global_mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t nwrap_he_global_mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t nwrap_pw_global_mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t nwrap_sp_global_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+/* Add new global locks here please */
+/* Also don't forget to add locks to
+ * nwrap_init() function.
+ */
+# define NWRAP_LOCK_ALL do { \
+	NWRAP_LOCK(nwrap_initialized); \
+	NWRAP_LOCK(nwrap_global); \
+	NWRAP_LOCK(nwrap_gr_global); \
+	NWRAP_LOCK(nwrap_he_global); \
+	NWRAP_LOCK(nwrap_pw_global); \
+	NWRAP_LOCK(nwrap_sp_global); \
+} while (0);
+
+# define NWRAP_UNLOCK_ALL do {\
+	NWRAP_UNLOCK(nwrap_sp_global); \
+	NWRAP_UNLOCK(nwrap_pw_global); \
+	NWRAP_UNLOCK(nwrap_he_global); \
+	NWRAP_UNLOCK(nwrap_gr_global); \
+	NWRAP_UNLOCK(nwrap_global); \
+	NWRAP_UNLOCK(nwrap_initialized); \
+} while (0);
+
+static void nwrap_thread_prepare(void)
+{
+	NWRAP_LOCK_ALL;
+}
+
+static void nwrap_thread_parent(void)
+{
+	NWRAP_UNLOCK_ALL;
+}
+
+static void nwrap_thread_child(void)
+{
+	NWRAP_UNLOCK_ALL;
+}
+
 enum nwrap_dbglvl_e {
 	NWRAP_LOG_ERROR = 0,
 	NWRAP_LOG_WARN,
@@ -330,6 +406,7 @@ struct nwrap_ops {
 /* Public prototypes */
 
 bool nss_wrapper_enabled(void);
+bool nss_wrapper_shadow_enabled(void);
 bool nss_wrapper_hosts_enabled(void);
 
 /* prototypes for files backend */
@@ -455,25 +532,174 @@ struct nwrap_libc {
 };
 
 struct nwrap_main {
-	const char *nwrap_switch;
 	int num_backends;
 	struct nwrap_backend *backends;
 	struct nwrap_libc *libc;
 };
 
-struct nwrap_main *nwrap_main_global;
-struct nwrap_main __nwrap_main_global;
+static struct nwrap_main *nwrap_main_global;
+static struct nwrap_main __nwrap_main_global;
+
+/*
+ * PROTOTYPES
+ */
+static int nwrap_convert_he_ai(const struct hostent *he,
+			       unsigned short port,
+			       const struct addrinfo *hints,
+			       struct addrinfo **pai,
+			       bool skip_canonname);
+
+/*
+ * VECTORS
+ */
+
+#define DEFAULT_VECTOR_CAPACITY 16
+
+struct nwrap_vector {
+	void **items;
+	size_t count;
+	size_t capacity;
+};
+
+/* Macro returns pointer to first element of vector->items array.
+ *
+ * nwrap_vector is used as a memory backend which take care of
+ * memory allocations and other stuff like memory growing.
+ * nwrap_vectors should not be considered as some abstract structures.
+ * On this level, vectors are more handy than direct realloc/malloc
+ * calls.
+ *
+ * nwrap_vector->items is array inside nwrap_vector which can be
+ * directly pointed by libc structure assembled by cwrap itself.
+ *
+ * EXAMPLE:
+ *
+ * 1) struct hostent contains char **h_addr_list element.
+ * 2) nwrap_vector holds array of pointers to addresses.
+ *    It's easier to use vector to store results of
+ *    file parsing etc.
+ *
+ * Now, pretend that cwrap assembled struct hostent and
+ * we need to set h_addr_list to point to nwrap_vector.
+ * Idea behind is to shield users from internal nwrap_vector
+ * implementation.
+ * (Yes, not fully - array terminated by NULL is needed because
+ * it's result expected by libc function caller.)
+ *
+ *
+ * CODE EXAMPLE:
+ *
+ * struct hostent he;
+ * struct nwrap_vector *vector = malloc(sizeof(struct nwrap_vector));
+ * ... don't care about failed allocation now ...
+ *
+ * ... fill nwrap vector ...
+ *
+ * struct hostent he;
+ * he.h_addr_list = nwrap_vector_head(vector);
+ *
+ */
+#define nwrap_vector_head(vect) ((void *)((vect)->items))
+
+#define nwrap_vector_foreach(item, vect, iter) \
+	for (iter = 0, (item) = (vect).items == NULL ? NULL : (vect).items[0]; \
+	     item != NULL; \
+	     (item) = (vect).items[++iter])
+
+#define nwrap_vector_is_initialized(vector) ((vector)->items != NULL)
+
+static inline bool nwrap_vector_init(struct nwrap_vector *const vector)
+{
+	if (vector == NULL) {
+		return false;
+	}
+
+	/* count is initialized by ZERO_STRUCTP */
+	ZERO_STRUCTP(vector);
+	vector->items = malloc(sizeof(void *) * (DEFAULT_VECTOR_CAPACITY + 1));
+	if (vector->items == NULL) {
+		return false;
+	}
+	vector->capacity = DEFAULT_VECTOR_CAPACITY;
+	memset(vector->items, '\0', sizeof(void *) * (DEFAULT_VECTOR_CAPACITY + 1));
+
+	return true;
+}
+
+static bool nwrap_vector_add_item(struct nwrap_vector *vector, void *const item)
+{
+	assert (vector != NULL);
+
+	if (vector->items == NULL) {
+		nwrap_vector_init(vector);
+	}
+
+	if (vector->count == vector->capacity) {
+		/* Items array _MUST_ be NULL terminated because it's passed
+		 * as result to caller which expect NULL terminated array from libc.
+		 */
+		void **items = realloc(vector->items, sizeof(void *) * ((vector->capacity * 2) + 1));
+		if (items == NULL) {
+			return false;
+		}
+		vector->items = items;
+
+		/* Don't count ending NULL to capacity */
+		vector->capacity *= 2;
+	}
+
+	vector->items[vector->count] = item;
+
+	vector->count += 1;
+	vector->items[vector->count] = NULL;
+
+	return true;
+}
+
+static bool nwrap_vector_merge(struct nwrap_vector *dst,
+			       struct nwrap_vector *src)
+{
+	void **dst_items = NULL;
+	size_t count;
+
+	if (src->count == 0) {
+		return true;
+	}
+
+	count = dst->count + src->count;
+
+	/* We don't need reallocation if we have enough capacity. */
+	if (src->count > (dst->capacity - dst->count)) {
+		dst_items = (void **)realloc(dst->items, (count + 1) * sizeof(void *));
+		if (dst_items == NULL) {
+			return false;
+		}
+		dst->items = dst_items;
+		dst->capacity = count;
+	}
+
+	memcpy((void *)(((long *)dst->items) + dst->count),
+	       src->items,
+	       src->count * sizeof(void *));
+	dst->count = count;
+
+	return true;
+}
 
 struct nwrap_cache {
 	const char *path;
 	int fd;
+	FILE *fp;
 	struct stat st;
-	uint8_t *buf;
 	void *private_data;
+
+	struct nwrap_vector lines;
+
 	bool (*parse_line)(struct nwrap_cache *, char *line);
 	void (*unload)(struct nwrap_cache *);
 };
 
+/* passwd */
 struct nwrap_pw {
 	struct nwrap_cache *cache;
 
@@ -488,6 +714,24 @@ struct nwrap_pw nwrap_pw_global;
 static bool nwrap_pw_parse_line(struct nwrap_cache *nwrap, char *line);
 static void nwrap_pw_unload(struct nwrap_cache *nwrap);
 
+/* shadow */
+#if defined(HAVE_SHADOW_H) && defined(HAVE_GETSPNAM)
+struct nwrap_sp {
+	struct nwrap_cache *cache;
+
+	struct spwd *list;
+	int num;
+	int idx;
+};
+
+struct nwrap_cache __nwrap_cache_sp;
+struct nwrap_sp nwrap_sp_global;
+
+static bool nwrap_sp_parse_line(struct nwrap_cache *nwrap, char *line);
+static void nwrap_sp_unload(struct nwrap_cache *nwrap);
+#endif /* defined(HAVE_SHADOW_H) && defined(HAVE_GETSPNAM) */
+
+/* group */
 struct nwrap_gr {
 	struct nwrap_cache *cache;
 
@@ -499,29 +743,42 @@ struct nwrap_gr {
 struct nwrap_cache __nwrap_cache_gr;
 struct nwrap_gr nwrap_gr_global;
 
+/* hosts */
 static bool nwrap_he_parse_line(struct nwrap_cache *nwrap, char *line);
 static void nwrap_he_unload(struct nwrap_cache *nwrap);
 
 struct nwrap_addrdata {
 	unsigned char host_addr[16]; /* IPv4 or IPv6 address */
-	char *h_addr_ptrs[2]; /* host_addr pointer + NULL */
 };
 
+static size_t max_hostents = 100;
+
 struct nwrap_entdata {
-	struct nwrap_addrdata *addr;
+	struct nwrap_addrdata addr;
 	struct hostent ht;
+
+	struct nwrap_vector nwrap_addrdata;
+
+	ssize_t aliases_count;
+};
+
+struct nwrap_entlist {
+	struct nwrap_entlist *next;
+	struct nwrap_entdata *ed;
 };
 
 struct nwrap_he {
 	struct nwrap_cache *cache;
 
-	struct nwrap_entdata *list;
+	struct nwrap_vector entries;
+	struct nwrap_vector lists;
+
 	int num;
 	int idx;
 };
 
-struct nwrap_cache __nwrap_cache_he;
-struct nwrap_he nwrap_he_global;
+static struct nwrap_cache __nwrap_cache_he;
+static struct nwrap_he nwrap_he_global;
 
 
 /*********************************************************
@@ -575,11 +832,14 @@ static void *nwrap_load_lib_handle(enum nwrap_lib lib)
 #ifdef HAVE_LIBNSL
 		handle = nwrap_main_global->libc->nsl_handle;
 		if (handle == NULL) {
-			for (handle = NULL, i = 10; handle == NULL && i >= 0; i--) {
+			for (i = 10; i >= 0; i--) {
 				char soname[256] = {0};
 
 				snprintf(soname, sizeof(soname), "libnsl.so.%d", i);
 				handle = dlopen(soname, flags);
+				if (handle != NULL) {
+					break;
+				}
 			}
 
 			nwrap_main_global->libc->nsl_handle = handle;
@@ -591,11 +851,14 @@ static void *nwrap_load_lib_handle(enum nwrap_lib lib)
 #ifdef HAVE_LIBSOCKET
 		handle = nwrap_main_global->libc->sock_handle;
 		if (handle == NULL) {
-			for (handle = NULL, i = 10; handle == NULL && i >= 0; i--) {
+			for (i = 10; i >= 0; i--) {
 				char soname[256] = {0};
 
 				snprintf(soname, sizeof(soname), "libsocket.so.%d", i);
 				handle = dlopen(soname, flags);
+				if (handle != NULL) {
+					break;
+				}
 			}
 
 			nwrap_main_global->libc->sock_handle = handle;
@@ -606,11 +869,14 @@ static void *nwrap_load_lib_handle(enum nwrap_lib lib)
 	case NWRAP_LIBC:
 		handle = nwrap_main_global->libc->handle;
 		if (handle == NULL) {
-			for (handle = NULL, i = 10; handle == NULL && i >= 0; i--) {
+			for (i = 10; i >= 0; i--) {
 				char soname[256] = {0};
 
 				snprintf(soname, sizeof(soname), "libc.so.%d", i);
 				handle = dlopen(soname, flags);
+				if (handle != NULL) {
+					break;
+				}
 			}
 
 			nwrap_main_global->libc->handle = handle;
@@ -664,6 +930,19 @@ static void *_nwrap_load_lib_function(enum nwrap_lib lib, const char *fn_name)
 			_nwrap_load_lib_function(lib, #fn_name); \
 	}
 
+/* INTERNAL HELPER FUNCTIONS */
+static void nwrap_lines_unload(struct nwrap_cache *const nwrap)
+{
+	size_t p;
+	void *item;
+	nwrap_vector_foreach(item, nwrap->lines, p) {
+		/* Maybe some vectors were merged ... */
+		SAFE_FREE(item);
+	}
+	SAFE_FREE(nwrap->lines.items);
+	ZERO_STRUCTP(&nwrap->lines);
+}
+
 /*
  * IMPORTANT
  *
@@ -734,6 +1013,37 @@ static int libc_getpwuid_r(uid_t uid,
 }
 #endif
 
+static inline void str_tolower(char *dst, char *src)
+{
+	register char *src_tmp = src;
+	register char *dst_tmp = dst;
+
+	while (*src_tmp != '\0') {
+		*dst_tmp = tolower(*src_tmp);
+		++src_tmp;
+		++dst_tmp;
+	}
+}
+
+static bool str_tolower_copy(char **dst_name, const char *const src_name)
+{
+	char *h_name_lower;
+
+	if ((dst_name == NULL) || (src_name == NULL)) {
+		return false;
+	}
+
+	h_name_lower = strdup(src_name);
+	if (h_name_lower == NULL) {
+		NWRAP_LOG(NWRAP_LOG_DEBUG, "Out of memory while strdup");
+		return false;
+	}
+
+	str_tolower(h_name_lower, h_name_lower);
+	*dst_name = h_name_lower;
+	return true;
+}
+
 static void libc_setpwent(void)
 {
 	nwrap_load_lib_function(NWRAP_LIBC, setpwent);
@@ -1069,8 +1379,7 @@ static void *nwrap_load_module_fn(struct nwrap_backend *b,
 			  "Cannot find function %s in %s",
 			  s, b->so_path);
 	}
-	free(s);
-	s = NULL;
+	SAFE_FREE(s);
 	return res;
 }
 
@@ -1221,10 +1530,56 @@ static void nwrap_backend_init(struct nwrap_main *r)
 
 static void nwrap_init(void)
 {
-	static bool initialized;
+	const char *env;
+	char *endptr;
+	size_t max_hostents_tmp;
+
+	NWRAP_LOCK(nwrap_initialized);
+	if (nwrap_initialized) {
+		NWRAP_UNLOCK(nwrap_initialized);
+		return;
+	}
 
-	if (initialized) return;


-- 
Samba Shared Repository



More information about the samba-cvs mailing list