1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00
Commit Graph

174 Commits

Author SHA1 Message Date
Volker Lendecke
ff6b49beeb nwrap: Fix the build on Solaris
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11816

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Tue Apr  5 08:57:06 CEST 2016 on sn-devel-144
2016-04-05 08:57:06 +02:00
Andreas Schneider
b9d93e7187 lib: Update nss_wrapper to version 1.1.3
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2016-03-22 00:23:20 +01:00
Michael Adam
7cec3092ff nss_wrapper: bump version to 1.1.2
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>

Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Mon Jan 11 15:30:49 CET 2016 on sn-devel-144
2016-01-11 15:30:49 +01:00
Andreas Schneider
da292b6062 nwrap: Fix segfaults while reloading hosts file
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-11 12:25:32 +01:00
Andreas Schneider
19b2dcbeb2 nwrap: Don't fail if we want to add an existing entry
Pair-Programmed-With: Michael Adam <obnox@samba.org>
Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Michael Adam <obnox@samba.org>
2016-01-11 12:25:32 +01:00
Andreas Schneider
9b7902090d nwrap: Fix the build on Solaris
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-11 12:25:32 +01:00
Andreas Schneider
5f621977fd nwrap: Don't leak memory from gethostbyname*() functions
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-11 12:25:32 +01:00
Andreas Schneider
b54bbb2b83 nwrap: Fix the build on FreeBSD
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-11 12:25:32 +01:00
Michael Adam
766e795518 nwrap: fix a copy and paste error in the destructor.
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:32 +01:00
Andreas Schneider
554963d887 nwrap: Cleanup shadow getspnam() memory
Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Michael Adam <obnox@samba.org>
2016-01-11 12:25:32 +01:00
Michael Adam
159fdb0185 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@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:32 +01:00
Michael Adam
bf496153bc nwrap: catch error to add item to vector in nwrap_he_parse_line()
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:32 +01:00
Michael Adam
736fa61a95 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@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:32 +01:00
Michael Adam
e94a7c5a56 nwrap: remove unused member list from struct nwrap_he
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:31 +01:00
Robin Hack
16b71aecab nwrap: Small code shift in nwrap_ed_inventarize_add_to_existing()
Allocate memory only when necessary.

Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:31 +01:00
Andreas Schneider
db0ef5cc9e nwrap: Cast max_hostents to avoid warnings
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-11 12:25:31 +01:00
Andreas Schneider
8fad97bc34 nwrap: Fix initialization of e entry
This fixes a compiler warning.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-11 12:25:31 +01:00
Michael Adam
f1acb0e296 nwrap: remove ai_tail argument from nwrap_files_getaddrinfo()
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:31 +01:00
Michael Adam
d198cdaefd 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@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:31 +01:00
Michael Adam
ab2f41bed6 nwrap: add an explaining comment for the ai duplicating loop
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:31 +01:00
Michael Adam
062c97be19 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@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:31 +01:00
Michael Adam
a66606cd02 nwrap: use symbols IPPROTO_TCP and IPPROTO_UDP
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:31 +01:00
Michael Adam
bf65160ed2 nwrap: rename _ai -> ai_new in nwrap_files_getaddrinfo()
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:31 +01:00
Michael Adam
a42f6589c7 nwrap: fix a memleak in nwrap_files_getaddrinfo()
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:31 +01:00
Michael Adam
07b6925242 nwrap: rename ai_prev -> ai_cur in nwrap_files_getaddrinfo()
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:31 +01:00
Michael Adam
b996f0a60c 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@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:31 +01:00
Michael Adam
07f1bef632 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@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:31 +01:00
Michael Adam
55e9606e68 nwrap: treat AI_NUMERICHOST correctly in getaddrinfo.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11477

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:31 +01:00
Michael Adam
34cff9e729 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@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:31 +01:00
Michael Adam
154080ce85 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@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:30 +01:00
Michael Adam
0dc34ea56a nwrap: in nwrap_files_getaddrinfo, treat failure of nwrap_convert_he_ai as error
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:30 +01:00
Michael Adam
18be46d87c nwrap: convert nwrap_files_getaddrinfo() to return EAI error codes
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:30 +01:00
Michael Adam
6078126eb5 nwrap: use the error code from nwrap_files_cache_reload() in callers
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:30 +01:00
Michael Adam
fe7e163515 nwrap: turn nwrap_files_cache_reload() into a bool function
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:30 +01:00
Michael Adam
4919f1cd21 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@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:30 +01:00
Michael Adam
ccb4076309 nwrap: log NULL alias name at ERROR level in nwrap_add_hname()
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:30 +01:00
Michael Adam
f6e4c58663 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@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:30 +01:00
Michael Adam
ddd0ca82bb 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@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:30 +01:00
Michael Adam
7ec5aaeb02 nwrap: catch NULL list in nwrap_add_hname_add_to_existing
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:30 +01:00
Michael Adam
2974cef3d8 nwrap: catch null h_name in nwrap_add_hname_add_new
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:30 +01:00
Michael Adam
be8c7dc5af nwrap: catch NULL ip in nwrap_add_ai
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:30 +01:00
Michael Adam
a725bd7728 nwrap: turn nwrap_add_hname_add_to_existing() into bool
for better error propagation.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:30 +01:00
Michael Adam
d681a084d9 nwrap: simplify nwrap_file_getaddrinfo: remove a variable
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:30 +01:00
Michael Adam
28f0a8b5a9 nwrap: simplify nwrap_files_gethostbyname: remove a variable
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:29 +01:00
Michael Adam
54c825b1cb nwrap: log hash table full message at error level
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:29 +01:00
Michael Adam
95025358d8 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@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:29 +01:00
Michael Adam
19d54157a4 nwrap: remove superfluous comments from nwrap_add_hname()
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:29 +01:00
Michael Adam
4ec47e739c nwrap: remove superfluous comments from nwrap_add_hname_alias()
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:29 +01:00
Michael Adam
69af963f8e nwrap: remove a superfluous comment from nwrap_add_hname_add_new()
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:29 +01:00
Michael Adam
3cc12ec554 nwrap: move var into scope in nwrap_add_hname()
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:29 +01:00