summaryrefslogtreecommitdiffstats
path: root/utils/mountd/auth.c
Commit message (Collapse)AuthorAgeFilesLines
* mountd: auth.c no longer needs #include xmalloc.hChuck Lever2012-12-121-1/+2
| | | | | Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mountd: prepend '$' to make use_ipaddr clients self-describingJ. Bruce Fields2012-05-031-3/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | From: "J. Bruce Fields" <bfields@redhat.com> Mountd is responsible for filling three interrelated kernel caches: - auth_unix_ip maps an incoming ip addresses to a "domain". - nfsd_fh maps (domain, filehandle-fragment) pairs to paths. - nfsd_export maps (domain, path) pairs to export options. Note that each export is assocated with a "client" string--the part before the parentheses in an /etc/export line--which may be a domain name, a netgroup, etc. The "domain" string in the above three caches may be either: - in the !use_ipaddr case, a comma-separated list of client strings. - in the use_ipaddr case, an ip address. In the former case, mountd does the hard work of matching an ip address to the clients when doing the auth_unix_ip mapping. In the latter case, it delays that until the nfsd_fh or nfsd_export upcall. We're currently depending on being able to flush the kernel caches completely when switching between the use_ipaddr and !use_ipaddr cases. However, the kernel's cache-flushing doesn't really provide reliable guarantees on return; it's still possible we could see nfsd_fh or nfsd_export upcalls with the old domain-type after flushing. So, instead, make the two domain types self-describing by prepending a "$" in the use_ipaddr case. Reviewed-by: NeilBrown <neilb@suse.de> Signed-off-by: J. Bruce Fields <bfields@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mountd: add trivial helpers for client-matchingJ. Bruce Fields2012-05-031-3/+18
| | | | | | | | | | | From: "J. Bruce Fields" <bfields@redhat.com> Pull out a tiny bit of common logic from three functions. Possibly minor overkill, but simplifies the next patch. Signed-off-by: J. Bruce Fields <bfields@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* auth_authenticate_newcache: prefer non-V4ROOT export over V4ROOT exportsNeilBrown2012-05-011-4/+3
| | | | | | | | | | | | | Currently auth_authenticate_internal finds an export and if it is a V4ROOT export, it reports that there is no match. Unlike lookup_export() it doesn't keep looking for an acceptable export. So remove the test from auth_authenticate_internal(), and add it to auth_authenticate_newcache(), where the search can be allowed to continue. Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Steve Dickson <steved@redhat.com>
* mountd: add IPv6 support in auth_authenticate()Chuck Lever2010-09-161-25/+27
| | | | | | | Make the entire auth_authenticate() code path address-family agnostic. 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-23/+25
| | | | | | | | | | | | | | | | | | | 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-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* mountd: better hiding of v4root exports from mountd clientsJ. Bruce Fields2010-01-131-0/+4
| | | | | | | | | | | | | We've hidden v4root exports from get_exportlist (hence from the showmount command), but not from other mountd operations--allowing clients to attempt to mount exports when they should be getting an immediate error. Symptoms observed on a linux client were that a mount that previously would have returned an error immediately now hung. This restores the previous behavior. Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
* mountd: kill unnecessary m_mayexport checkJ. Bruce Fields2010-01-131-4/+0
| | | | | | | | Only exportfs uses m_mayexport; mountd always populates the export list with auth_reload(), which always sets m_mayexport on the entries it creates. Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
* mountd: auth_authenticate_internal further cleanupJ. Bruce Fields2010-01-131-28/+42
| | | | | | Move newcache case into its own function. Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
* mountd: auth_authenticate_internal cleanupJ. Bruce Fields2010-01-131-16/+17
| | | | | | Break up another big function. Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
* exports: turn on pseudo exportsSteve Dickson2010-01-131-0/+3
| | | | | | | | If a pseudo root is not defined in the export file, the v4root_needed global variable will be set, signaling v4root_set() create the dynamic pseudo root. Signed-off-by: Steve Dickson <steved@redhat.com>
* relax insecure option on mountdRobert Gordon2009-11-161-2/+1
| | | | | | | | | | | In nfs-utils 1.2.0, I noticed that the insecure option validates that the client port is a subset of IPPORT_RESERVED as opposed to just validating it is a valid reserved port. The following proposed patch would correct that issue. Acked-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Robert Gordon <rbg@openrbg.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Exportfs and rpc.mountd optimalizationTomas Richter2009-02-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | There were some problems with exportfs and rpc.mountd for long export lists - see https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=76643 I do optimalization as my bachelors thesis (Facuulty of informatics, Masaryk's university Brno, Czech Republic), under lead of Yenya Kasprzak. Both exportfs and rpc.mount build linked list of exports (shared functions in export.c). Every time they are inserting new export into list, they search for same export in list. I replaced linked list by hash table and functions export_add and export_lookup by functions hash_export_add and hash_export_lookup (export.c). Because some other functions required exportlist as linked list, hash table has some implementation modification im comparison with ordinary hash table. It also keeps exports in linked list and has pointer to head of the list. So there's no need of implementation function <for_all_in_hash_table>. Signed-off-by: Tomas Richter <krik3t@gmail.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mountd: change "unknown host" error message to "unmatched host"Jeff Layton2008-09-291-1/+1
| | | | | | | | | | | | | mount request from unknown host 10.11.14.99 for /export The hosts are listed in DNS with proper reverse records, so the reason why the host is "unknown" isn't clear. This patch just changes the wording of this error to hopefully make it more clear why the mount request was rejected. This also makes this error message use a format more similar to the other error messages in auth_authenticate(). Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mountd: address a minor compiler warningChuck Lever2007-10-121-1/+1
| | | | | | | | | | | auth.c: In function ‘auth_authenticate’: auth.c:190: warning: ‘error’ may be used uninitialized in this function "error" is used as an output parameter, but the compiler has no way of knowing that. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Neil Brown <neilb@suse.de>
* mountd: eliminate a spurious compiler warningChuck Lever2007-10-121-1/+1
| | | | | | | auth.c:61: warning: function declaration isn’t a prototype Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Neil Brown <neilb@suse.de>
* rpc.mountd: add new mode for handling netgroup-heavy configurationsJeff Layton2007-09-281-11/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a host is a member of a large number of netgroups, it becomes easily possible for client_compose to generate a m_hostname string that overflows the maximum string length allowed by the kernel caches. This patch adds a new mode for mountd where it will map IP address to IP address in the auth.unix.ip cache. When this enabled, mountd doesn't bother using client_compose to build the m_hostname string. It just populates it with the dotted-quad ip address. When mountd handles a mount request, it then has an IP address and a path. It then calls client_check to check the host against export entries where the path has already matched. Since we don't bother looking up netgroups which have no relation to the mount, this can be a big performance gain in netgroup-heavy configurations. The downside is that every host has a corresponding entry in the nfsd.export and nfsd.fh caches as well as the auth.unix.ip cache. The new behavior is automatically enabled if the length of all of the concatenated netgroup names in the export table is longer than half NFSCLNT_IDMAX. The rationale for this logic is that this should allow for a host to be a member of a long list of netgroups while still allowing for other matches. 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: create client_resolve and change client_compose to take a ↵Jeff Layton2007-09-281-6/+2
| | | | | | | | | | | | | | 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-2/+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>
* nfs-utils: have mountd hold open etab file to force inode number to changeJeff Layton2007-05-111-9/+20
| | | | | | | | | | | | | This patch changes mountd to hold the etab file open so that when it's changed by exportfs, the inode number should change. We then change auth_reload to reload the file based on whether st_ino is different from the last time it was checked. It also changes auth_reload to maintain a static counter value and return it instead of a timestamp and fixes up get_exportlist accordingly. Finally, it adds some comments to xtab_write to warn people about editing the etab in place. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Ensure 'showmount -e' gets current information.Neil Brown2007-01-111-3/+3
| | | | | | If auth_reload has been called by someone else, get_exportlist can incorrectly return old data. So track modify times better and only use cached data if the modify time matches.
* Don't rely on old info in my_clientJeff Layton2006-12-191-15/+9
| | | | | | | | | | | | | | | | | | | | | | | Here's a new set of patches to fix up "showmount -a", based on the approach suggested by Neil. This first patch is fairly simple. It just stops the current caching of my_client. For an explanation, consider this situation with the current code: 1) Client mounts an NFS export from server that is restricted to a particular hostname or netgroup. 2) DNS or netgroup changes so that the client would be denied. 3) Client attempts mount again. Mount succeeds, even though it shouldn't due to the fact that mountd relies on cached info in my_client. This situation can occur as long as no other client attempts a mount between 1 and 3 above. The patch below removes this caching, and causes a new invocation of client_compose for each pass through auth_authenticate: Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Neil Brown <neilb@suse.de>
* Autogen updateneilbrown2005-12-201-1/+3
|
* auth_reload fixneilbrown2004-12-061-2/+3
|
* fix uninitialise variableneilbrown2004-09-061-0/+1
|
* Assorted fixesneilbrown2003-07-141-1/+0
|
* bug fixneilbrown2003-05-221-5/+4
|
* Support new kernel upcalls for export cache management.neilbrown2003-05-211-14/+54
|
* Define and use get_reliable_hostbynameneilbrown2003-05-211-66/+13
|
* * utils/mountd/auth.c (auth_authenticate_internal): Reverseneilbrown2001-09-121-18/+6
| | | | | | change from 2000-08-02: It causes problems if someone exports to both a hostname and IP addresses. nfs-utils must be consistant about the canonical name that it chooses.
* 2000-11-27 Tobias Ringstrom <tori@tellus.mine.nu>hjl2000-11-271-1/+5
| | | | | * utils/mountd/auth.c (auth_authenticate): Log the bad path warning.
* 2000-09-26 H.J. Lu <hjl@lucon.org>hjl2000-09-251-2/+3
| | | | | * utils/mountd/auth.c (auth_authenticate_internal): Make sure a non-NULL hostent is always returned.
* 2000-08-02 H.J. Lu <hjl@lucon.org>hjl2000-08-101-6/+17
| | | | | * utils/mountd/auth.c (auth_authenticate_internal): Try to avoid the reverse name lookup.
* Mon Jan 10 14:26:33 2000 H.J. Lu <hjl@lucon.org>hjl2000-01-101-2/+8
| | | | | | | | * utils/mountd/auth.c (auth_authenticate_internal): Call xstrdup for hostname before passing it to gethostbyname. * utils/mountd/mountd.c (get_exportlist): Use xstrdup instead of strdup.
* Fix forward/reverse DNS lookup for authentication.hjl1999-10-261-16/+29
|
* Initial revisionhjl1999-10-181-0/+215