nwrap: rewrite linked-list datastructures to be properly separated.
authorMichael Adam <obnox@samba.org>
Wed, 11 Nov 2015 09:27:50 +0000 (10:27 +0100)
committerMichael Adam <obnox@samba.org>
Thu, 12 Nov 2015 10:42:32 +0000 (11:42 +0100)
commite284e1da502c03725cfc83ecace78fb6d24b9d0b
treef164db93e3302cd31ad58bf83ecab2aafee4a9ad
parent5df5236e53e7a7f8151367eddfdbfe94adaf9c49
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>
src/nss_wrapper.c