summaryrefslogtreecommitdiffstats
path: root/support/export/client.c
Commit message (Collapse)AuthorAgeFilesLines
* gcc complained:NeilBrown2010-10-141-0/+1
| | | | | | | | | | | | | | | | | client.c: In function 'init_netmask6': client.c:181:1: warning: no return statement in function returning non-void and Suse' build system complained I: Program returns random data in a function E: nfs-utils no-return-in-nonvoid-function client.c:181 when I built without --enable-ipv6 Reviewed-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Steve Dickson <steved@redhat.com>
* libexport.a: Refactor init_netmask()Chuck Lever2010-09-091-57/+106
| | | | | | | | | | | | | | | Instead of a single function that can handle both AF_INET and AF_INET6 addresses, two separate functions might be cleaner. The original plan was to keep code redundancy at a minimum, but the resulting code was cumbersome at best. I think I've traded a little extra code for something that will be much easier to read, understand, and maintain. I've also eliminated the "#if / #endif" instances inside the functions. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* libexport.a: IPv6 support in client_check()Chuck Lever2010-08-311-22/+43
| | | | | | | | | Introduce support for IPv6 in client_check()'s helpers. The local addrs_match() twins are no longer needed since we can use nfs_compare_addrs() now. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* libexport.a: IPv6 support for client_init_subnet()Chuck Lever2010-08-311-0/+32
| | | | | | | | | | | | | | | To parse and store an IPv6 host or subnet address, init_netmask() needs to handle 128 bit subnet masks. Unfortunately what once was a pretty simple little function has grown much larger. This logic must now not only parse IPv6 addresses correctly, but must also distinguish between IPv4 and IPv6. To avoid code duplication, I'm "bending" the cardinal rule of not using "#ifdef" inside functions. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* libexport.a: Prepare init_subnetwork() for IPv6 supportChuck Lever2010-08-311-22/+59
| | | | | | | | | | | | | | | | Retire the slash32 logic in inet_netmask() in favor of a more generic netmask parser that can support IPv6 addresses. If an invalid IP address string is given to inet_addr(3), it returns INADDR_NONE, which is actually a "valid" address (255.255.255.255). We're none the wiser to the substitution until something breaks later. This patch provides better sanity checking of the parsed address, now that such an error can be reported to client_init()'s callers. We can also check the prefixlen value a little more carefully as well. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* libexport.a: Use host helper to parse address in client_init()Chuck Lever2010-08-311-5/+8
| | | | | | | | | | Take the first step towards making it possible to parse either IPv4 or IPv6 addresses in client_init(). It won't handle IPv6 until host_pton() has IPv6 support enabled, and it still doesn't deal with IPv6 netmasks yet. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* libexport.a: Prepare to recognize IPv6 addresses in client_gettype()Chuck Lever2010-08-311-9/+14
| | | | | | | | | | | | The current open-coded parsing logic in client_gettype() will be hard to modify to recognize IPv6 addresses. Use a more generic mechanism for detecting IP presentation addresses. IPv6 will be enabled automatically in client_gettype() when host_pton() is changed to support IPv6 addresses. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* libexport: Fix IP address check in check_netgroup()Chuck Lever2010-08-241-7/+20
| | | | | | | | | | | | | | | | | | | | | | | | Neil Brown reports that recent changes to replace gethostby{addr,name}(3) with get{addr,info}name(3) may have inadvertently broken netgroup support. There used to be a gethostbyaddr(3) call in the third paragraph in check_netgroup(). The reason for that gethostbyaddr(3) call was that the first innetgr(3) call has already confirmed that hname is not a member of the netgroup. We also need to confirm that, if hname happens to be an IP address, the hostname bound to that IP address is not a member of the netgroup, either. Fix this by restoring appropriate address to hostname mapping of hname before retrying the innetgr(3) call. See http://marc.info/?l=linux-nfs&m=128084830214653&w=2 . Introduced by commit 0509d3428f523776ddd9d6e9fa318587d3ec7d84. Reviewed-by: Neil Brown <neilb@suse.de> Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* bexport: Add a common exit label to check_netgroup()Chuck Lever2010-08-241-7/+16
| | | | | | | | | | check_netgroup() is going to be changed to free dynamically allocated resources before it returns, so a common exit point is needed. Reviewed-by: Neil Brown <neilb@suse.de> Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* libexport.a: Add documenting commentsChuck Lever2010-06-221-3/+22
| | | | | | | | Clean up. Add a few additional documenting comments for globally visible functions. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mountd: Replace "struct hostent" with "struct addrinfo"Chuck Lever2010-06-221-109/+134
| | | | | | | | | | | | | | | | | | | struct hostent can store either IPv4 or IPv6 addresses, but it can't store both address families concurrently for the same host. Neither can hostent deal with parts of socket addresses that are outside of the sin{,6}_addr field. Replace the use of "struct hostent" everywhere in libexport.a, mountd, and exportfs with "struct addrinfo". This is a large change, but there are so many strong dependencies on struct hostent that this can't easily be broken into smaller pieces. One benefit of this change is that hostent_dup() is no longer required, since the results of getaddrinfo(3) are already dynamically allocated. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mountd/exportfs: Make m_addrlist field a nfs_sockaddrChuck Lever2010-05-051-10/+29
| | | | | | | | | | | | | | | | | | | | | | | | To store non-AF_INET addresses in the nfs_client structure, we need to use more than in_addr for the m_addrlist field. Make m_addrlist larger, then add a few helper functions to handle type casting and array indexing cleanly. We could treat the nfs_client address list as if all the addresses in the list were the same family. This might work for MCL_SUBNETWORK type nfs_clients. However, during the transition to IPv6, most hosts will have at least one IPv4 and one IPv6 address. For MCL_FQDN, I think we need to have the ability to store addresses from both families in one nfs_client. Additionally, IPv6 scope IDs are not part of struct sin6_addr. To support link-local IPv6 addresses and the like, a scope ID must be stored. Thus, each slot in the address list needs to be capable of storing an entire socket address, and not simply the network address part. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* libexport.a: Clean up client_add()Chuck Lever2010-05-051-14/+12
| | | | | | | | | | | Clean up: client_add()'s current callers never set unknown m_type values, so the m_type check is unnecessary. All of client_add()'s callers are in the same source file where it is defined, so make it a static helper function. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* libexport.a: Refactor client_init()Chuck Lever2010-05-051-43/+56
| | | | | | | | | | Clean up: Move subnet hostname parsing logic out of client_init() to make it simpler to introduce IPv6 support. Make client_init() a helper, since it's already static. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* libexport.a: Allow malloc(3) failures in client_lookup() and friendsChuck Lever2010-04-231-6/+9
| | | | | | | | | | | | | Clean up: Use malloc(3) instead of xmalloc() in client_lookup() and client_dup(), ensuring that a failed memory allocation here doesn't cause our process to exit suddenly. Allocation of nfs_client records and the m_hostname string are now consistently handled with malloc(3), calloc(3), strdup(3), and free(3). Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* libexport.a: Allow m_hostname allocation to fail instead of exitChuck Lever2010-04-231-6/+4
| | | | | | | | | | | | Clean up: Replace xstrdup() with strdup(3) in client_init(), to prevent the process from exiting if the memory allocation fails. Note that both of client_init()'s callers set m_hostname equal to NULL before calling, thus the extra free(3) at the top of client_init() is unneeded. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* libexport.a: Allow client_init() to fail instead of exitChuck Lever2010-04-231-7/+17
| | | | | | | | | client_init()'s current callers can now deal correctly with a failure. Get rid of code that can cause our process to exit in client_init(), if address mask parsing or memory allocation fails. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* libexport.a: Add client_free()Chuck Lever2010-04-231-2/+8
| | | | | | | Clean up: Introduce a helper to free a nfs_client record. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* libexport.a: Add helper for populating m_addrlist[]Chuck Lever2010-04-151-18/+20
| | | | | | | | | Clean up: Move common code that populates an nfs_client record's m_addrlist to a helper function. This eliminates a little code duplication, and makes it simpler to add IPv6 support later. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* libexport.a: Reduce code duplication in client_init()Chuck Lever2010-04-151-4/+5
| | | | | | | | | Clean up: Most cases in client_init() set clp->m_naddr to zero. Move it to the common part of the function, and simplify the logic. This will make adding IPv6 support here more straightforward. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* libexport.a: replace xlog(L_FATAL) in client_check()Chuck Lever2010-04-081-4/+9
| | | | | | | | | | | Clean up: Prevent the process from exiting in client_check(). Report bad m_type values, but return 0. This removes another site where a mountd or exportfs process can exit sideways. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* libexport.a: Refactor wildcard checking in client_check()Chuck Lever2010-04-081-12/+26
| | | | | | | | | | Clean up: refactor wildcard logic out of client_check() to make it easier to introduce IPv6 support. Match the style used for client_check_{fqdn,subnetwork,netgroup}. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* libexport.a: Refactor netgroup checking in client_check()Chuck Lever2010-04-081-40/+57
| | | | | | | | | | | | | | | | | | Clean up: refactor netgroup logic out of client_check() to make it easier to introduce IPv6 support. + Use preferred style of keeping #ifdef out of the middle of function definitions. Squelch compiler warnings for "#ifndef HAVE_INNETGR" by using __attribute__((unused)). + Use preferred style of not using curly braces around switch cases. + Match style used for check_{fqdn,subnetwork}. + Clarify comment documenting use of h_aliases Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* libexport.a: Remove unused function client_checkaddr()Chuck Lever2010-04-081-7/+0
| | | | | | | Clean up. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* libexport.a: Factor SUBNETWORK checking out of check_client()Chuck Lever2010-04-081-10/+22
| | | | | | | | | | | | | | | | | | | | Clean up: Factor the MCL_SUBNETWORK case out of check_client() and client_checkaddr(). This will make it easier to add IPv6 support eventually. The logic in the new helper function will get a little more tangled once IPv6 support is introduced. Each slot in the clp address list eventually may contain an address from either address family. Note that the switch statement in client_checkaddr() is redundant, since clp->cl_mtype is loop invariant. This change makes SUBNETWORK client checking more computationally efficient, at the cost of a few extra lines of code. This commit should not change code behavior in any way. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* libexport.a: Factor FQDN checking out of check_client()Chuck Lever2010-04-081-8/+23
| | | | | | | | | | | | | | | | | | | | Clean up: Factor the MCL_FQDN case out of check_client() and client_checkaddr(). This will make it easier to add IPv6 support eventually. The logic in the new helper function will get a little more tangled once IPv6 support is introduced. Each slot in the clp address list eventually may contain an address from either address family. Note that the switch statement in client_checkaddr() is redundant, since clp->cl_mtype is loop invariant. This change makes FQDN client checking more computationally efficient, at the cost of a few extra lines of code. This commit should not change code behavior in any way. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* libexport.a: Clean up client_compose() and client_member()Chuck Lever2010-03-221-16/+27
| | | | | | | | Clean up: Replace outdated comments, and fix some function declarations. Use proper type for a couple of automatic variables. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* libexport.a: Remove dead codeChuck Lever2010-03-221-22/+0
| | | | | | | | Clean up: I can't find any call sites for client_find() or client_match(). Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* libexport.a: fix a long-standing typo in name_cmp()Chuck Lever2009-12-231-1/+1
| | | | | | | | | Not sure what "(!*a || !a == ',')" means... but just a few lines later is "(!*a || *a == ',')". I think "a is '\0' or ','" is what was intended. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Host aliases need to be checked when netgroups is used in exports.Steve Dickson2009-04-291-1/+7
| | | | Signed-off-by: Steve Dickson <steved@redhat.com>
* rpc.mountd: create client_resolve and change client_compose to take a ↵Jeff Layton2007-09-281-8/+14
| | | | | | | | | | | | | | hostent arg This moves the resolution of IP address to hostent into a helper function and has other functions call it. Having client_compose take a hostent arg allows us to avoid an extra hostname lookup in the auth_authenticate codepath as well. Instead of redoing this lookup in client_compose, we can simply reuse the hostent that was already generated in auth_authenticate. Signed-off-by: Jeff Layton <jlayton@redhat.com> Acked-by: Steve Dickson <steved@redhat.com> Signed-off-by: Neil Brown <neilb@suse.de>
* rpc.mountd: Change nfs_client->m_hostname to be a dynamically-allocated stringJeff Layton2007-09-281-8/+7
| | | | | | | | | | | Change nfs_client->m_hostname to be dynamically allocated rather than a fixed length array of size NFSCLNT_IDMAX. This also adds a bit of micro-optimization in a few places since it reduces the amount of string copying that needs to be done. Signed-off-by: Jeff Layton <jlayton@redhat.com> Acked-by: Steve Dickson <steved@redhat.com> Signed-off-by: Neil Brown <neilb@suse.de>
* Memory leak in mountdSteinar H. Gunderson2007-05-111-0/+1
| | | | | | | | | | In client_compose(), free() the hostent structure returned before exiting. Normally, gethostbyaddr() returns a pointer to a static struct, but this hostent comes from either get_reliable_hostbyaddr() or get_hostent(), both which return a pointer they privately xmalloc()ed, which thus can and should be free()d. Signed-Off-By: Steinar H. Gunderson <sesse@debian.org>
* Fix memory leak in mountd.Steinar H. Gunderson2007-03-161-0/+1
| | | | Signed-off-by: Neil Brown <neilb@suse.de>
* Fix a number of the easier compile warnings: unused variables,Greg Banks2006-06-221-0/+1
| | | | unused labels, constness, signedness.
* Autogen updateneilbrown2005-12-201-4/+6
|
* treat N.N.N.N as a special case of MCL_SUBNETWORK instead ofneilbrown2005-03-141-1/+10
| | | | MCL_FQDN
* Prepare to support gss authentication and idmap looks for nfsv4neilbrown2004-09-151-0/+4
|
* Support new kernel upcalls for export cache management.neilbrown2003-05-211-0/+98
|
* see changelogneilbrown2001-12-201-1/+10
|
* See Changelogneilbrown2001-12-201-1/+1
|
* make "exportfs -au" do no DNS lookupneilbrown2001-09-201-2/+6
|
* call gethostbyaddr to make sure that we have canonical hostnameneilbrown2001-09-201-1/+11
| | | | for all exports
* 2001-05-06 Anne Milicia <milicia@missioncriticallinux.com>hjl2001-05-071-1/+12
| | | | | | | | | | * support/export/client.c (client_check): Check IP address againet netgroup. 2001-05-06 Neil Brown <neilb@cse.unsw.edu.au> * support/export/client.c (client_gettype): Treat `*' as MCL_ANONYMOUS.
* 2000-10-17 Scott McDermott <mcdermot@questra.com>hjl2000-10-181-1/+14
| | | | | * support/export/client.c (client_init): Support CIDR netmask in /etc/exports.
* "dot+1" is bogus - it is a DNS domain, not a yp domainneilbrown2000-08-241-1/+1
|
* Initial revisionhjl1999-10-181-0/+298