summaryrefslogtreecommitdiffstats
path: root/utils/mountd
Commit message (Collapse)AuthorAgeFilesLines
...
* Fixed segfault in rpc.mountdSteve Dickson2011-01-261-0/+1
| | | | | | | | | A unallocated piece of memory, instead of a NULL point, was being used to initialize a ->next point in the mount link list which caused a segfault after a few remote accesses via the showmount command. Signed-off-by: Steve Dickson <steved@redhat.com>
* Updated rpc.mountd man pageSteve Dickson2010-10-201-3/+3
| | | | | | | | Updated the rpc.mountd man page to no longer reference v3 as the "newer" version and also mentioned v4 as a supported version. Signed-off-by: Steve Dickson <steved@redhat.com>
* mountd: Clear mountd registrations at start upChuck Lever2010-10-141-6/+4
| | | | | | | | Clear stale MNT registrations before mountd tries to create fresh listeners, to ensure that mountd starts. This is also what statd does. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mountd: Update mountd/exportfs man pages to reflect IPv6 changesChuck Lever2010-09-271-86/+154
| | | | | | | | | | | | Document IPv6 support in rpc.mountd and exportfs, and clarify existing language in the man page. Clean up: Use bold consistently for program names, and italics consistently for file names. Use "rpc.mountd" consistently as the name of the mountd daemon. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mountd: Use MNT status values instead of NFSERRChuck Lever2010-09-271-11/+11
| | | | | | | | | Clean up: The MNT protocol has its own enum type defining error status values. While the values can be the same as the NFSERR enum type on some systems, it's not guaranteed to be true everywhere. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mountd: Fix up version and usage messagesChuck Lever2010-09-271-16/+22
| | | | | | | | | Clean up: rpc.mountd is no longer known as kmountd. Use the program's basename rather than the full pathname for the usage message. Display a version message at start up similar to statd's. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mountd: Unregister mountd if my_svc_run() returnsChuck Lever2010-09-271-1/+2
| | | | | | | | | | | Fix a long standing bug: when my_svc_run() returns, mountd should unregister itself with the local rpcbind so that it can subsequently start cleanly. Log a more helpful error message in this case. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mountd: Support TI-RPC mountd listenerChuck Lever2010-09-271-9/+17
| | | | | | | | | | | If TI-RPC is available, use it to create mountd's svc listener. If not, use the old function, rpc_init(), to create mountd's listener. IPv6 can be supported if TI-RPC is available. In this case, /etc/netconfig is searched to determine which transports to advertise. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mountd: Make NFS version checks more strictChuck Lever2010-09-271-8/+39
| | | | | | | | Ensure users and programmers specify NFS version numbers correctly. This also makes the next patch more clean. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mountd: Ensure cache downcall can handle IPv6 addressesChuck Lever2010-09-161-1/+1
| | | | | Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mountd: Handle IPv6 addresses in kernel auth_unix_ip upcallsChuck Lever2010-09-161-3/+3
| | | | | Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mountd: clean up cache APIChuck Lever2010-09-163-14/+43
| | | | | | | | | | | | | | | | | | | | | | | Clean up: Squelch compiler warnings and document public parts of cache API. cache.c: At top level: cache.c:67: warning: no previous prototype for auth_unix_ip cache.c:123: warning: no previous prototype for auth_unix_gid cache.c:217: warning: no previous prototype for get_uuid cache.c:247: warning: no previous prototype for uuid_by_path cache.c:326: warning: no previous prototype for nfsd_fh cache.c:745: warning: no previous prototype for nfsd_export cache.c:820: warning: no previous prototype for cache_open cache.c:832: warning: no previous prototype for cache_set_fd cache.c:841: warning: no previous prototype for cache_process_req cache.c:921: warning: no previous prototype for cache_export cache.c:953: warning: no previous prototype for cache_get_filehandle Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mountd: Support IPv6 in mountlist_list()Chuck Lever2010-09-161-7/+9
| | | | | | | | | | | Replace inet_aton(3) and gethostbyaddr(3) calls in mountlist_list() with calls to the new host_foo() DNS helpers. The new functions will support IPv6 without additional changes, once IPv6 is enabled in the generic hostname helpers. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mountd: Handle memory exhaustion in mountlist_list()Chuck Lever2010-09-161-8/+24
| | | | | | | | | | | | I'm about to replace inet_aton(3)/gethostbyaddr(3) with host_pton()/host_canonname() in mountlist_list(). Since host_canonname() returns a string allocated with strdup(3) instead of xstrdup(), mountlist_list() must now deal with memory exhaustion properly. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mountd: Add mountlist_freeall()Chuck Lever2010-09-161-6/+13
| | | | | | | | I'm about to add a second bit of logic that needs to free all mountlist records, so introduce a helper for freeing them. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mountd: support IPv6 in mountlist_del_all()Chuck Lever2010-09-163-9/+7
| | | | | | | | Replace IPv4-specific code in the mountlist_del_all() path with code that is address family agnostic. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mountd: Support IPv6 in mountd's svc routinesChuck Lever2010-09-161-20/+59
| | | | | | | | | | | | | | Replace IPv4-specific code with use of our generic hostname helpers in the routines that handle incoming MNT RPC requests. These functions will support IPv6 without additional changes, once IPv6 is enabled in the generic hostname helpers. As part of this update, I've modified all of mountd's _svc routines to use a debug message format that is consistent with statd. It may be overkill for some of these; if so we can pull them out later. Signed-off-by: Steve Dickson <steved@redhat.com>
* mountd: add IPv6 support in auth_authenticate()Chuck Lever2010-09-164-35/+39
| | | | | | | 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>
* libnfs.a: Fix API for getfh() & friendsChuck Lever2010-09-161-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is more of a clean-up than a behavioral change. POSIX requires that a "struct sockaddr" is the same size as a "struct sockaddr_in". Therefore, a variable or field of type "struct sockaddr" cannot contain an AF_INET6 address. However, "struct sockaddr *" is often used to reference a generic (ie non-address family specific) socket address, generating some confusion about this. The nfsctl_arg struct uses a struct sockaddr (not a pointer) to pass the client's IP address to the kernel. This means the legacy nfsctl() kernel API can never support IPv6. Fortunately for us, this legacy interface was replaced by a text-based cache interface a few years back. We don't need to support non-AF_INET addresses here. The getfh() functions in nfs-utils provide a handy C API for the kernel's nfsctl interface. The getfh() functions still take a struct sockaddr *, though, and that can imply that a non-IPv4 address can be passed via this API. To make it abundantly clear that only IPv4 addresses can be used with this interface, change the synopses of getfh() and friends to take a struct sockaddr_in * instead of a struct sockaddr * . This makes these functions conform with other places in mountd and exportfs that already grok the difference between a struct sockaddr and a struct sockaddr_in. While we're here... Introduce some nice documenting comments for the get_fh() functions, and... Since mountd will support IPv6 in the near future, assert that the family of client addresses passed to this API is indeed AF_INET, in order to prevent non-AF_INET addresses from ever being passed to the legacy nfsctl() interface. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Removed warnings from mountd.cSteve Dickson2010-08-091-6/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | mountd.c: In function 'mount_null_1_svc': mountd.c:195: warning: unused parameter 'rqstp' mountd.c:195: warning: unused parameter 'argp' mountd.c:195: warning: unused parameter 'resp' mountd.c: In function 'mount_dump_1_svc': mountd.c:213: warning: unused parameter 'argp' mountd.c: In function 'mount_umnt_1_svc': mountd.c:224: warning: unused parameter 'resp' mountd.c: In function 'mount_umntall_1_svc': mountd.c:248: warning: unused parameter 'argp' mountd.c:248: warning: unused parameter 'resp' mountd.c: In function 'mount_export_1_svc': mountd.c:258: warning: unused parameter 'argp' mountd.c: In function 'mount_exportall_1_svc': mountd.c:269: warning: unused parameter 'argp' mountd.c: In function 'mount_dump_1_svc': mountd.c:216: warning: unused parameter 'argp' mountd.c: In function 'mount_umnt_1_svc': mountd.c:227: warning: unused parameter 'resp' mountd.c: In function 'mount_umntall_1_svc': mountd.c:251: warning: unused parameter 'argp' mountd.c:251: warning: unused parameter 'resp' mountd.c: In function 'mount_export_1_svc': mountd.c:261: warning: unused parameter 'argp' mountd.c: In function 'mount_exportall_1_svc': mountd.c:272: warning: unused parameter 'argp' Signed-off-by: Steve Dickson <steved@redhat.com>
* Removed warnings from cache.cSteve Dickson2010-08-091-9/+9
| | | | | | | | | | | | | | | | | | cache.c:812: warning: missing initializer cache.c:812: warning: (near initialization for 'cachelist[0].f') cache.c:813: warning: missing initializer cache.c:813: warning: (near initialization for 'cachelist[1].f') cache.c:814: warning: missing initializer cache.c:814: warning: (near initialization for 'cachelist[2].f') cache.c:815: warning: missing initializer cache.c:815: warning: (near initialization for 'cachelist[3].f') cache.c:816: warning: missing initializer cache.c:816: warning: (near initialization for 'cachelist[4].f') cache.c: In function 'cache_export_ent': cache.c:887: warning: comparison between signed and unsigned integer expressions cache.c:907: warning: comparison between signed and unsigned integer expressions Signed-off-by: Steve Dickson <steved@redhat.com>
* Removed warnings from fsloc.cSteve Dickson2010-08-093-3/+3
| | | | | | | fsloc.c: In function 'replicas_lookup': fsloc.c:149: warning: unused parameter 'key' Signed-off-by: Steve Dickson <steved@redhat.com>
* mountd: Fix memcmp result comparison error for uuid match.Doug Nazar2010-07-191-1/+1
| | | | | | Fixed Small typo in the new fs uuid comparison code Signed-off-by: Steve Dickson <steved@redhat.com>
* mountd: Replace "struct hostent" with "struct addrinfo"Chuck Lever2010-06-223-58/+67
| | | | | | | | | | | | | | | | | | | 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>
* libexport.a: Add helpers to manage DNS lookupsChuck Lever2010-06-222-9/+12
| | | | | | | | | | | | | | | Introduce DNS query helpers based on getaddrinfo(3) and getnameinfo(3). These will eventually replace the existing hostent-based functions in support/export/hostname.c. Put some of these new helpers to immediate use, where convenient. As they are part of libexport.a, I've added the forward declarations for these new functions in exportfs.h rather than misc.h, where the hostent-based forward declarations are currently. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Improve support for exporting btrfs subvolumesNeilBrown2010-06-221-29/+78
| | | | | | | | | | | | | | | | | | | If you export two subvolumes of a btrfs filesystem, they will both be given the same uuid so lookups will be confused. blkid cannot differentiate the two, so we must use the fsid from statfs64 to identify the filesystem. We cannot tell if blkid or statfs is best without knowing internal details of the filesystem in question, so we need to encode specific knowledge of btrfs in mountd. This is unfortunate. To ensure smooth handling of this and possible future changes in uuid generation, we add infrastructure for multiple different uuids to be recognised on old filehandles, but only the preferred on is used on new filehandles. Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Steve Dickson <steved@redhat.com>
* Mountd listens on 2 different versions for NFSv2 (MOUNTv1 and MOUNTv2)NeilBrown2010-05-241-6/+8
| | | | | | | | | | | | | | | | | | | | | and one for NFSv3 (MOUNTv3) When --no-nfs-version requests an NFS version to be disabled, the code actually disabled the MOUNT version. This works is several cases, but requires --no-nfs-version 1 to completely disable NFSv2, which is wrong. So if we do disable 1, 2, and 3. mountd complain and won't run, it is not possible to run just v4 - i.e. not listening for MOUNT requests at all (as v4 doesn't need them). So change the handling of "--no-nfs-version 2" it disable MOUNTv1 as well as MOUNTv2, and allow mountd to continue running as long as one of NFSv2 NFSv3 NFSv4 is enabled. Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Steve Dickson <steved@redhat.com>
* mountd/exportfs: Make m_addrlist field a nfs_sockaddrChuck Lever2010-05-052-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | 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: trivial: name parameters for clarityJ. Bruce Fields2010-03-081-4/+4
| | | | | | | | | | Part of the reason for the previous bug was confusion between "subpath" and "path"; which is the shorter path, and which the longer? "child" and "parent" seem less ambiguous. Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu> Signed-off-by: Steve Dickson <steved@redhat.com>
* mountd: fix path comparison for v4 crossmntJ. Bruce Fields2010-03-081-1/+1
| | | | | | | | This was obviously wrong, since path[strlen(path)] == '\0' should always be true. Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu> Signed-off-by: Steve Dickson <steved@redhat.com>
* mountd: fix --manage-gids hang due to int/uint bugSteve Dickson2010-03-081-7/+7
| | | | | | | | | | | | | A uid or gid should be represented as unsigned, not signed. The conversion to signed here could cause a hang on access by an unknown user to a server running mountd with --manage-gids; such a user is likely to be mapped to 232-1, which may be converted to 231-1 when represented as an int, resulting in a downcall for uid 231-1, hence the original rpc hanging forever waiting for a cache downcall for 232-1. Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu> Signed-off-by: Steve Dickson <steved@redhat.com>
* nfs-utils: dont leak fd in mountlist_listBen Myers2010-02-121-1/+4
| | | | | | Don't leak this file descriptor if stat should fail. Signed-off-by: Steve Dickson <steved@redhat.com>
* tcpwrapper: Add support for IPv6Chuck Lever2010-01-171-4/+2
| | | | | | | | | | Assuming the tcp_wrappers library can actually support IPv6 addresses, here's a crack at IPv6 support in nfs-utils' TCP wrapper shim. Some reorganization is done to limit the number of times that @sap is converted to a presentation address string. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
* tcp_wrapper: Clean up logit()Chuck Lever2010-01-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Eliminate these compiler warnings: tcpwrapper.c: In function logit tcpwrapper.c:225: warning: unused parameter procnum tcpwrapper.c:225: warning: unused parameter prognum Actually, @procnum is not used anywhere in our tcpwrapper.c, so let's just get rid of it. Since there is only one logit() call site in tcpwrapper.c, the macro wrapper just adds needless clutter. Let's get rid of that too. Finally, both mountd and statd now use xlog(), which adds an appropriate program name prefix to every message. Replace the open-coded syslog(2) call with an xlog() call in order to consistently identify the RPC service reporting the intrusion. Since logit() no longer references "deny_severity" and no nfs-utils caller sets either allow_severity or deny_severity, we remove them. 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: minor v4root_set cleanup, check strdup returnJ. Bruce Fields2010-01-131-18/+28
| | | | | | | | | | | | Move more of v4root_set into a helper function. Also, check the return value from strdup. (We don't really handle the error well yet--we'll end up giving negative replies to export upcalls when we should be giving the kernel exports, resulting in spurious -ENOENTs or -ESTALE's--but that's better than crashing with a NULL dereference.) Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
* mountd: simplify export list deferral in v4root_setJ. Bruce Fields2010-01-131-3/+2
| | | | | | | We're adding new entries, but not deleting them, so we don't need to do the usual double-counter trick here. Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
* mountd: minor optimization in v4root_setJ. Bruce Fields2010-01-131-0/+7
| | | | | | | | | | | | | | Since we're adding new exports as we traverse the export list, it's possible we may find ourselves revisiting an export we just added. It's harmless to reprocess those exports, as we're currently doing. But it's also pointless. (Actually, the current code appears to always add new export entries at the head of each list, so we shouldn't hit this case. It still may be a good idea to keep this check, though, as insulation against future changes to that data structure.) 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: mountlist_del_all cleanupJ. Bruce Fields2010-01-131-17/+13
| | | | | | Common exit code. 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>
* mountd: get_exportlist() cleanupJ. Bruce Fields2010-01-131-7/+4
| | | | | | Comment clarification, minor style cleanup. Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
* mountd: move most of get_exportlist() into helpersJ. Bruce Fields2010-01-131-59/+84
| | | | | | | | | | | | I needed to understand get_exportlist() recently, and it gave me trouble. Move detail work into helper functions to make the basic logic clear, and to remove need for excessive nesting (and fix inconsistent indentation levels). Also remove unnecessary casts of void returns from xmalloc(). 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>
* exports: hide pseudo exports from clientsSteve Dickson2010-01-131-0/+4
| | | | | | | Don't show pseudo exports when clients ask to see what is exported via the showmount mount command. Signed-off-by: Steve Dickson <steved@redhat.com>
* mountd: prefer non-V4ROOT exports.J. Bruce Fields2010-01-131-0/+5
| | | | | | | | | | | | | | | | | | | If paths A and A/B are both exported, then we have a choice of exports to return for A (or under A but still above A/B): we could return A itself, or we could return a V4ROOT export leading to B. For now, we will always prefer the non-V4ROOT export, whenever that is an option. This will allow clients to reach A/B as long as adminstrators keep to the rule that the security on a parent permits the union of the access permitted on any descendant. In the future we may support more complicated arrangements. (Note: this can't be avoided by simply not creating v4root exports with the same domain and path, because different domains may have some overlap.) Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
* exports: NFSv4 pseudoroot support routinesSteve Dickson2010-01-132-1/+181
| | | | | | | | | Create v4root exports for each directory that is a parent of an explicit export. Give each the minimal security required to traverse to any of its children. Signed-off-by: Steve Dickson <steved@redhat.com> Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
* mountd: don't require mountpoint in crossmnt caseJ. Bruce Fields2010-01-131-2/+1
| | | | | | | | | | | | | | | | Currently, mount --bind /path /path where /path is a subdirectory of a crossmnt export, can cause client hangs, since the kernel detects that as a mountpoint, but nfs-util's is_mountpoint() function does not. I don't see any sure-fire way to detect such mountpoints. But that's OK: it's harmless to allow this upcall to succeed even when the directory is not a mountpoint, so let's just remove this check. Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
* mountd: further split up lookup_exportJ. Bruce Fields2010-01-131-19/+29
| | | | | | | More trivial cleanup (no change in functionality) to group logical operations together into a single function. Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>