diff --git a/src/freenas/etc/systemd/system/nfs-server.service.d/override.conf b/src/freenas/etc/systemd/system/nfs-server.service.d/override.conf index 2e72f8358683e..acb5f12bcb715 100644 --- a/src/freenas/etc/systemd/system/nfs-server.service.d/override.conf +++ b/src/freenas/etc/systemd/system/nfs-server.service.d/override.conf @@ -1,6 +1,3 @@ [Unit] ConditionDirectoryNotEmpty=!/etc/exports.d After=nslcd.service - -[Service] -ExecStartPre=/usr/local/bin/clear_nfs_rmtab.sh diff --git a/src/freenas/usr/local/bin/clear_nfs_rmtab.sh b/src/freenas/usr/local/bin/clear_nfs_rmtab.sh deleted file mode 100755 index e6d701aaf776c..0000000000000 --- a/src/freenas/usr/local/bin/clear_nfs_rmtab.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/bash - -# Clear rmtab at boot before NFS start. -# Purpose: Avoid accumulation of stale NFSv3 client entries. -# See NAS-131762 - -system_ready=$(midclt call system.ready) -if [[ "False" == "${system_ready}" ]]; then - midclt call nfs.clear_nfs3_rmtab -fi diff --git a/src/middlewared/middlewared/plugins/nfs.py b/src/middlewared/middlewared/plugins/nfs.py index 8f3d3c2e66fc1..43e11f5c253a7 100644 --- a/src/middlewared/middlewared/plugins/nfs.py +++ b/src/middlewared/middlewared/plugins/nfs.py @@ -188,6 +188,12 @@ def setup_directories(self): except Exception: self.logger.error('Unexpected failure initializing %r', path, exc_info=True) + # Clear rmtab on boot. + # We call this here because /var/db/system/nfs is not yet available + # in a middleware 'setup' hook. + if not self.middleware.call_sync('system.ready'): + self.middleware.call_sync('nfs.clear_nfs3_rmtab') + @private async def nfs_extend(self, nfs): keytab_has_nfs = await self.middleware.call("kerberos.keytab.has_nfs_principal")