diff options
author | Konstantin Khorenko <khorenko@virtuozzo.com> | 2022-05-26 12:55:12 -0400 |
---|---|---|
committer | Steve Dickson <steved@redhat.com> | 2022-05-26 13:11:57 -0400 |
commit | 8ca592af5fba8aea8b11ee28bf3543bfab02e4b2 (patch) | |
tree | 3be2b8cffee40ec33ecfd3194ceb7aa6b2107dac | |
parent | f347c3c8c605b874733019685b7f8ae84e86b55e (diff) | |
download | nfs-utils-8ca592af5fba8aea8b11ee28bf3543bfab02e4b2.tar.gz |
mountd: Check 'nfsd/clients' directory presence instead of kernel version
Kernel major version does not always provide 100% certainty about
presence or absence of a feature, for example:
- some distros backport feature from mainstream kernel to older kernels
- if NFS server is run inside a system container the reported kernel
version inside the container may be faked
So let's determine the feature presence by checking
'/proc/fs/nfsd/clients/' directory presence instead of checking the
kernel version.
Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
-rw-r--r-- | support/export/v4clients.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/support/export/v4clients.c b/support/export/v4clients.c index 5e4f105..5f15b61 100644 --- a/support/export/v4clients.c +++ b/support/export/v4clients.c @@ -8,9 +8,9 @@ #include <unistd.h> #include <stdlib.h> #include <sys/inotify.h> +#include <sys/stat.h> #include <errno.h> #include "export.h" -#include "version.h" /* search.h declares 'struct entry' and nfs_prot.h * does too. Easiest fix is to trick search.h into @@ -24,7 +24,10 @@ static int clients_fd = -1; void v4clients_init(void) { - if (linux_version_code() < MAKE_VERSION(5, 3, 0)) + struct stat sb; + + if (!stat("/proc/fs/nfsd/clients", &sb) == 0 || + !S_ISDIR(sb.st_mode)) return; if (clients_fd >= 0) return; |