summaryrefslogtreecommitdiff
path: root/support/misc
Commit message (Collapse)AuthorAgeFilesLines
* Replace statfs64 with statfsKhem Raj2023-01-101-12/+12
| | | | | | | | | | | | | | autoconf AC_SYS_LARGEFILE is used by configure to add needed defines when needed for enabling 64bit off_t, therefore replacing statfs64 with statfs should be functionally same. Additionally this helps compiling with latest musl where 64bit LFS functions like statfs64 and friends are now moved under _LARGEFILE64_SOURCE feature test macro, this works on glibc systems because _GNU_SOURCE macros also enables _LARGEFILE64_SOURCE indirectly. This is not case with musl and this latest issue is exposed. Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Fix `statx()` emulation breaking exportsPatrick Steinhardt2021-05-061-0/+2
| | | | | | | | | | | | | | | | | | | | | | | Ever since commit 76c21e3f (mountd: Check the stat() return values in match_fsid(), 2020-05-08), it wasn't possible to export filesystems on my musl based system anymore. The root cause of this is the innocuous-looking change to decide based on `errno` whether `is_mountpoint()` raised a real error or whether it simply didn't match. The issue is that `is_mountpoint()` transitively calls into our `xlstat()` wrapper, which either executes `statx()` if the system supports it or otherwise falls back to `fstatat()`. But if `statx()` is not supported, then we'll always first set `errno = ENOSYS` before calling `fstatat()`. So effectively, all systems which do not have `statx()` and whose `fstatat()` doesn't reset `errno` will cause us to end up with errno set to `ENOSYS`. Fix the issue by resetting `errno` before calling `fstatat()` in both `xlstat()` and `xstat()`. Fixes: 76c21e3f (mountd: Check the stat() return values in match_fsid(), 2020-05-08) Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Steve Dickson <steved@redhat.com>
* nfs-utils: remove leftover debugging messagesHolger Hoffst?tte2020-10-311-1/+1
| | | | | | | | | After updating to nfs-utils-2.5.2 I noticed extra output on the console when exporting mounts. Apparently commit 482e72ba04 forgot to remove some debugging messages and accidentally committed them. Signed-off-by: Holger Hoffst?tte <holger@applied-asynchrony.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* nfsidmap:umich_ldap return success only if attributes are found in ldap resp.Srikrishan Malik2020-09-171-0/+1
| | | | | | | Return ENOENT if the UID/GID attributes are not found in ldap response. Signed-off-by: Srikrishan Malik <srikrishanmalik@gmail.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* nfsd: Support running nfsd_name_to_handle_at() in the root jailTrond Myklebust2020-05-081-0/+66
| | | | | | | | When running nfsd_name_to_handle_at(), we usually want to see the same namespace as knfsd, so add helpers. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* mountd: Add a helper nfsd_path_statfs64() for uuid_by_path()Trond Myklebust2020-05-081-0/+43
| | | | | | | | Ensure uuid_by_path() works correctly when 'rootdir' is set in the [exports] section of nfs.conf. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Disable statx if using glibc emulationDoug Nazar2019-12-091-0/+3
| | | | | | | | | On older kernels without statx, glibc with statx support will attempt to emulate the call. However it doesn't support AT_STATX_DONT_SYNC and will return EINVAL. This causes all xstat/xlstat calls to fail. Signed-off-by: Doug Nazar <nazard@nazar.ca> Signed-off-by: Steve Dickson <steved@redhat.com>
* Ensure consistent struct stat definitionDoug Nazar2019-11-172-0/+8
| | | | | | | | | | | Although 2fbc62e2a13fc ("Fix include order between config.h and stat.h") reorganized those files that were already including config.h, not all files were including config.h. Fixes at least stack smashing crashes in mountd on 32-bit systems. Signed-off-by: Doug Nazar <nazard@nazar.ca> Signed-off-by: Steve Dickson <steved@redhat.com>
* Annotate unused fields with UNUSEDPatrick Steinhardt2019-09-051-1/+2
| | | | | | | | There are some parameters that may be potentially unused. Add the UNUSED macro to avoid any warnings. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Steve Dickson <steved@redhat.com>
* Fix include order between config.h and stat.hZoltan Karcagi2019-08-122-2/+8
| | | | | | | | | | | | | At least on Arch linux ARM, the definition of struct stat in stat.h depends on __USE_FILE_OFFSET64. This symbol comes from config.h when defined, therefore config.h must always be included before stat.h. Fix all occurrences where the order is wrong by moving config.h to the top. This fixes the client side error "Stale file handle" when mounting from a server running Arch Linux ARM. Signed-off-by: Zoltan Karcagi <zkr7432@gmail.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Make chroot() failures more verboseSteve Dickson2019-06-101-1/+1
| | | | | | | | When chroot() in xthread_workqueue_do_chroot fails show both the error and the path in the error message. Signed-off-by: Steve Dickson <steved@redhat.com>
* mountd: Ensure nfsd_path_strip_root() uses the canonicalised pathTrond Myklebust2019-06-101-5/+12
| | | | | | | | When attempting to strip the root path, we should first canonicalise the root pathname. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Add a helper for resolving symlinked nfsd paths via realpath()Trond Myklebust2019-06-101-0/+35
| | | | | | | | Add a helper to resolve symlinked nfsd paths when the user has set the "[exports] rootdir" nfs.conf option. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Add a helper to return the real path given an export entryTrond Myklebust2019-06-101-1/+3
| | | | | | | | Add a helper that can prepend the nfsd root directory path in order to allow mountd to perform its comparisons with mtab etc. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Add helpers to read/write to a file through the chrooted threadTrond Myklebust2019-06-101-0/+84
| | | | | | | | | Add helper functions to do synchronous I/O to a nfsd filesystem pseudofile from inside the chrooted environment. This ensures that calls to kern_path() in knfsd resolves to paths that are relative to the nfsd root directory. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Use xstat() with no synchronisation if availableTrond Myklebust2019-06-101-0/+72
| | | | | | | | We normally expect the exported system to be stable, so don't revalidate attributes. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Add utilities for resolving nfsd paths and stat()ing themTrond Myklebust2019-06-103-1/+203
| | | | | | | | | Add helper functions that can resolve nfsd paths by prepending the necessary prefix if the admin has specified a root path in the nfs.conf file. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Allow callers to check mountpoint status using a custom lstat functionTrond Myklebust2019-06-101-3/+5
| | | | | Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Add a simple workqueue mechanismTrond Myklebust2019-06-102-1/+229
| | | | | | | | Add a simple workqueue mechanism to allow us to run threads that are subject to chroot(), and have them operate on the knfsd kernel daemon. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* file: fix missing include for PATH_MAX constantPatrick Steinhardt2019-02-271-0/+1
| | | | | | | | | | | While making use of the PATH_MAX constant, "file.c" does not include the "limits.h" header. While it is being transitively included via other headers on most platforms, it is not on e.g. musl-based systems. Add the include to fix compilation. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Steve Dickson <steved@redhat.com>
* Remove a number of stringop-truncation warningsSteve Dickson2018-06-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | client.c:486:3: warning: ‘strncpy’ destination unchanged after copying no bytes [-Wstringop-truncation] file.c:99:2: warning: ‘strncpy’ specified bound 4096 equals destination size [-Wstringop-truncation] v4root.c:95:2: warning: ‘strncpy’ specified bound 1025 equals destination size [-Wstringop-truncation] sm-notify.c:572:3: warning: ‘strncpy’ specified bound 1025 equals destination size [-Wstringop-truncation] nfs4mount.c:221:3: warning: ‘strncpy’ specified bound 1024 equals destination size [-Wstringop-truncation] nfsmount.c:831:2: warning: ‘strncpy’ specified bound 256 equals destination size [-Wstringop-truncation] Signed-off-by: Steve Dickson <steved@redhat.com>
* Removed missing-prototypes warnings.Steve Dickson2018-02-231-0/+1
| | | | | | | Added the -Werror=missing-prototypes warning flag then cleaned up the mess. Signed-off-by: Steve Dickson <steved@redhat.com>
* present_address: Fixed error pathSteve Dickson2017-07-261-0/+1
| | | | | | | When inet_ntop fails do not fall into the AF_INET6 case, instead break out and take the error path out. Signed-off-by: Steve Dickson <steved@redhat.com>
* libnsm.a: refactor nsm_setup_pathnames() and nsm_make_pathname()Scott Mayhew2017-02-152-1/+111
| | | | | | | | | | Move the logic in nsm_setup_pathnames() and nsm_make_pathname() to similar generic functions in libmisc.a so that the exportfs and rpc.mountd programs can make use of them later. Reviewed-by: NeilBrown <neilb@suse.com> Signed-off-by: Scott Mayhew <smayhew@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* tcpwrapper: Add support for IPv6nfs-utils-1-2-2-rc8Chuck Lever2010-01-171-36/+79
| | | | | | | | | | 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>
* tcpwrapper: Eliminated shadowed declaration warningsChuck Lever2010-01-171-17/+15
| | | | | | | | | | | | | | | | | | | | | | Clean up: the use of identifiers called "access" and "daemon" shadow function declarations in unistd.h. Seen with "-Wextra -pedantic". tcpwrapper.c: In function haccess_add: tcpwrapper.c:112: warning: declaration of access shadows a global declaration /usr/include/unistd.h:288: warning: shadowed declaration is here tcpwrapper.c: In function good_client: tcpwrapper.c:161: warning: declaration of daemon shadows a global declaration /usr/include/unistd.h:953: warning: shadowed declaration is here tcpwrapper.c: In function check_default: tcpwrapper.c:212: warning: declaration of daemon shadows a global declaration /usr/include/unistd.h:953: warning: shadowed declaration is here good_client() is used only in support/misc/tcpwrapper.c, so make it static (and update its prototype to c99 standard form). Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* tcpwrapper: Fix signage problems in the tcp_wrappers hash functionChuck Lever2010-01-171-14/+20
| | | | | | | | | | | | | | | | | | | | Eliminate the following compiler warnings: tcpwrapper.c:78: warning: no previous prototype for strtoint tcpwrapper.c: In function strtoint tcpwrapper.c:81: warning: conversion to int size_t may change the sign of the result tcpwrapper.c:85: warning: conversion to unsigned int from int may change the sign of the result tcpwrapper.c: In function hashint: tcpwrapper.c:91: warning: conversion to int from unsigned int may change the sign of the result The hash value is probably computed consistently even with unexpected sign inversions. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* tcp_wrapper: Clean up logit()Chuck Lever2010-01-171-32/+24
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* tcp_wrappers: Use getifaddrs(3) if it is availableChuck Lever2010-01-172-8/+90
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After glibc 2.3.3, getifaddrs(3) can return AF_INET6 addresses for local network interfaces. Using the library call is easier than trying to update the open code in from_local(), and means we have less to maintain in nfs-utils going forward. And, since from_local() can now support IPv6, change its synopsis to take a "struct sockaddr *" . Note that the original code discovers local addresses once. These days, with wifi, DHCP, and NetworkManager, the local network configuration can change dynamically over time. So, call getifaddrs() more often to ensure from_local() has up-to-date network configuration information. This implementation refreshes the list if from_local() has not been called in the last second. This is actually not terribly honerous. check_default() invokes from_local() only when the remote host is not in its access cache, or the access/deny files have changed. So new hosts will cause a refresh, but previously seen hosts (including localhost) should not. On the other hand, it still may not be often enough. After the first call, if only previously seen hosts attempt to access our daemons, from_local() would never be called, and the local list would never be updated. This might be possible during steady-state operation with a small number of servers and clients. It would also be nice if we could free the local interface address list at shutdown time, but that would be a lot of trouble for little gain. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
* tcpwrappers: Use xlog() instead of perror(3) and syslog(2)Chuck Lever2010-01-171-12/+13
| | | | | | | | | | | | Clean up: Replace calls to syslog(2) and perror(3) in from_local.c with calls to xlog(). The problems displayed by the perror(3) calls especially should be reported. Currently they are never seen in the system log. As part of a build test, I defined TEST, and found a couple of problems with main(), which are also addressed in this patch. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
* Replace the Sun RPC license with the BSD license,nfs-utils-1-2-0Tom spot Callaway2009-06-021-25/+23
| | | | | | | with the explicit permission of Sun Microsystems Signed-off-by: Tom "spot" Callaway <tcallawa@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>
* Added back the some logging variables which are nonfs-utils-1-1-6-rc1nfs-utils-1-1-5-rc1Steve Dickson2009-03-081-1/+9
| | | | | | | | | longer used but, unfortunately, they are extern-ed by public headers files which are not under the control of this package. Spotted-by: Juergen Daubert <jue@jue.li> Signed-off-by: Steve Dickson <steved@redhat.com>
* General clean up. Removed unused routines. Reworked syslogSteve Dickson2009-03-041-130/+5
| | | | | | | | message to (hopefully) make it more sensible. Move "#ifdef HAVE_LIBWRAP" around so nothing will be defined when tcp wrapper is not configured. Signed-off-by: Steve Dickson <steved@redhat.com>
* Converted good_client() to correctly use the tcp wrapperSteve Dickson2009-03-041-50/+7
| | | | | | | interface and added a note to the mountd man page saying hostnames will be ignored when they can not be looked up. Signed-off-by: Steve Dickson <steved@redhat.com>
* Only hash on IP address and Program number. Including the ProcedureSteve Dickson2009-03-041-12/+11
| | | | | | number only creates needles extra hash entries. 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>
* Now that the TCP wrapper actually works, mounts willSteve Dickson2009-01-031-4/+16
| | | | | | | | be denied with misconfigured DNS configurations. Warnings will be logged when these types of configurations are detected. Signed-off-by: Steve Dickson <steved@redhat.com>
* To ensure the hash table of clients has validSteve Dickson2008-12-191-3/+42
| | | | | | | | | access rights, check the modification times on both access files. If one of them have change, update the hash entry instead of creating a new entry. Signed-off-by: Steve Dickson <steved@redhat.com>
* Clients IP address and host names are check onSteve Dickson2008-12-191-0/+79
| | | | | | | | | | every RPC request, to both mountd and statd when TCP wrappers are enabled. To help this process scale better the access rights are stored in a hash table, which are hashed per IP address, RPC program and procudure numbers. Signed-off-by: Steve Dickson <steved@redhat.com>
* When clients are define as IP addresses in /etc/hosts.deny,Steve Dickson2008-12-191-44/+45
| | | | | | | | access is allow due to misinterpreting the return value of hosts_ctl(). This patch reworks that logic which closes that hole. Signed-off-by: Steve Dickson <steved@redhat.com>
* Fixed arguments to the hosts_ctl() call in the good_client() routineSten Spans2008-05-051-2/+2
| | | | | | used in the tcpwrapper support. Signe-off-by: Steve Dickson <steved@redhat.com>
* Add -Wstrict-prototypes to compiler args, and fix warnings caused.Neil Brown2007-07-292-20/+12
|
* Include the right header to get xmalloc() declaration.Greg Banks2006-07-031-1/+1
|
* Merge branch 'master' of git://linux-nfs.org/nfs-utilsGreg Banks2006-07-031-7/+12
|\
| * Further coverity related cleanups.Neil Brown2006-06-231-3/+2
| | | | | | | | | | Greg Banks suggested some variations, particularly improved use of xmalloc/xstrdup functions. Thanks.
| * Fix various issues discovered by CoverityNeil Brown2006-06-231-6/+12
| | | | | | | | Thanks to Michael Halcrow for finding them.
* | Comment out the decades-old SCCS id strings from the original SunGreg Banks2006-06-271-1/+1
|/ | | | | | distribution. They cause compile warnings, there is no longer any reason to try to build them into the binaries, and gcc seems to be eliding some of them anyway.
* Remove **/Makefile.in, aclocal.m4, configure, anddevel-neilbNeil Brown2006-04-171-470/+0
| | | | | | support/include/config.h.in from source control These are auto autogenerated by aclocal -I aclocal ; autoheader ; automake ; autoconf
* 2006-04-10 "Kevin Coffman" <kwc@citi.umich.edu>neilbrown2006-04-101-0/+2
| | | | | Check for sufficient version of librpcsecgss and libgssapi in configure.in
* 2006-04-10 "Kevin Coffman" <kwc@citi.umich.edu>neilbrown2006-04-101-0/+2
| | | | | Update aclocal/tcp-wrappers.m4 to define HAVE_LIBWRAP and HAVE_TCP_WRAPPERS as appropriate.