1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00
Commit Graph

74 Commits

Author SHA1 Message Date
Michael Adam
9927e499f2 nwrap: slightly simplify logic in nwrap_getaddrinfo()
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
b0569d40ce nwrap: simplify logic in nwrap_getaddrinfo, calling nwrap_files_getaddrinfo
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
53e633e401 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@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:29 +01:00
Michael Adam
8da2110a84 nwrap: remove code duplication in nwrap_getaddrinfo
The three formerly distinct cases now are all the same.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:28 +01:00
Michael Adam
5bea2dc13f 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@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:28 +01:00
Michael Adam
40f9bf7835 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@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:28 +01:00
Michael Adam
522631b739 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@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:28 +01:00
Robin Hack
72764a6fd3 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@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-11 12:25:28 +01:00
Robin Hack
200f5bf138 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@gmail.com>
Reviewed-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-01-11 12:25:28 +01:00
Robin Hack
43d470a06f nwrap: Fix memory leak in nwrap_files_gethostbyname()
Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-11 12:25:28 +01:00
Robin Hack
853b2ff08e nwrap: Fix memory leak in nwrap_he_unload()
Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-11 12:25:28 +01:00
Robin Hack
3cae3e55e7 nwrap: Rename cont to vector in nwrap_vector_add_item()
Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-11 12:25:28 +01:00
Robin Hack
e1bb0094d4 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@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-11 12:25:28 +01:00
Robin Hack
0f1ffb9b5b 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@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-11 12:25:28 +01:00
Robin Hack
9d71542cd9 nwrap: Fix memory leak when getline() is used.
getline() allocates memory even if return code is < 0.

Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-11 12:25:28 +01:00
Robin Hack
4505dcd646 nwrap: Add basic locking for support multithreaded applications
Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-11 12:25:28 +01:00
Robin Hack
1017031a29 nwrap: Add BSD libc support for gethost*_r functios.
BSD libc stores data in thread local storage.

Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-11 12:25:28 +01:00
Robin Hack
960345e617 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@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-11 12:25:28 +01:00
Robin Hack
090dec2fd1 nwrap: Add string manipulation functions.
Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-11 12:25:27 +01:00
Robin Hack
270d6f94db 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@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-11 12:25:27 +01:00
Robin Hack
442fc3fcd2 nwrap: Add function nwrap_add_ai
This adds an ip to the hash table.

Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-11 12:25:27 +01:00
Robin Hack
15c14536d0 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@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-11 12:25:27 +01:00
Robin Hack
f3da6e4905 nwrap: Simplify file loading.
Lines are stored into vectors now.

Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-11 12:25:27 +01:00
Robin Hack
ff65d01333 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@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-11 12:25:27 +01:00
Andreas Schneider
6706ee4856 nwrap: Check for setspent and getspnam functions
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-11 12:25:27 +01:00
Andreas Schneider
22f159f45f src: Add configure check for shadow.h
This is the first part to fix FreeBSD.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-11 12:25:27 +01:00
Andreas Schneider
088887bda9 nwrap: Add support for getspnam()
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-11 12:25:27 +01:00
Andreas Schneider
608fa2063a nwrap: Add (set|get|end)spent functions
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-11 12:25:27 +01:00
Andreas Schneider
e971a44299 nwrap: Add nss_wrapper_shadow_enabled() function
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-11 12:25:27 +01:00
Andreas Schneider
4be5853b4c nwrap: Add shadow file parser
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-11 12:25:27 +01:00
Andreas Schneider
2a5335217e nwrap: Remove unused struct member in nwrap_main
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-11 12:25:27 +01:00
Andreas Schneider
90585c46eb nwrap: Implement nwrap_files_initgroups()
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-11 12:25:27 +01:00
Andreas Schneider
80abc70bc9 nwrap: Remove unneeded memcpy in getgrouplist()
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-11 12:25:27 +01:00
Andreas Schneider
a104389de2 nwrap: Avoid a string comparsion in getgrouplist()
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-11 12:25:27 +01:00
Robin Hack
1c346a07ff nwrap: Use ssize_t for aliases_count
Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-11 12:25:26 +01:00
Robin Hack
02b5410466 nwrap: Prevent compilation failure on machine without IPv4
Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-11 12:25:26 +01:00
Robin Hack
90dbe7beb8 nwrap: Replace free() calls by SAFE_FREE macro where possible.
Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-11 12:25:26 +01:00
Andreas Schneider
ea741de64a nwrap: Fix the handle loops for older gcc versions.
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-11 12:25:26 +01:00
Andreas Schneider
c298542fe2 nwrap: Make sure addr is initialized.
CID #72755

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-10-09 12:24:03 +02:00
Andreas Schneider
2bbd403f39 nwrap: Use DNS_NAME_MAX cause it is not available on BSD.
Also HOST_NAME_MAX is only for the value returned by gethostname(). It
is normally limited to 64 chars on Linux.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-10-09 12:24:03 +02:00
Andreas Schneider
895b32b2e3 nwrap: Don't overflow the in_addr if convert IPv6.
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-10-09 12:24:03 +02:00
Andreas Schneider
94c87d1347 nwrap: Fix resolving hostnames with a trailing dot.
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-10-09 12:24:03 +02:00
Andreas Schneider
6979082779 nwrap: Fall back to RTLD_NEXT if we can't find libc.
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-10-09 12:24:03 +02:00
Volker Lendecke
159d1dde3a nss_wrapper: Fix some "discarding const" warnings
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-06-21 12:42:10 +02:00
Volker Lendecke
9a936f9698 nss_wrapper: Align indentation with the rest of Samba
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-06-21 12:42:10 +02:00
Andreas Schneider
5bb410f853 lib: Change nss_wrapper to preloadable version.
This imports nss_wrapper version 1.0.2.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-04-17 14:56:06 +02:00
Jeremy Allison
1c714850d5 Clean up some const and other compiler warnings.
Autobuild-User: Jeremy Allison <jra@samba.org>
Autobuild-Date: Thu May  5 00:59:40 CEST 2011 on sn-devel-104
2011-05-05 00:59:40 +02:00
Volker Lendecke
b0aba17538 nss_wrapper: Fix a segfault when libnss_winbind.so is not loadable
Autobuild-User: Volker Lendecke <vlendec@samba.org>
Autobuild-Date: Sat Feb 26 13:19:01 CET 2011 on sn-devel-104
2011-02-26 13:19:01 +01:00
Volker Lendecke
22d8d277c6 nss_wrapper: Make nwrap_module_init a bit more readable 2011-02-26 12:00:48 +01:00
Andreas Schneider
b46eccfb19 nss_wrapper: Fixed a possible NULL pointer problem. 2010-06-28 10:18:12 +02:00