Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NAS-109732 / 12.0 / Clear various AD-related caches when service explicitly stopped #6573

Merged
merged 1 commit into from Mar 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/middlewared/middlewared/plugins/activedirectory.py
Expand Up @@ -750,6 +750,18 @@ async def stop(self):
await self.middleware.call('etc.generate', 'pam')
await self.middleware.call('etc.generate', 'nss')
await self.set_state(DSStatus['DISABLED'])
try:
os.unlink('/var/db/system/.AD_cache_backup')
except FileNotFoundError:
pass
except Exception:
self.logger.error("Failed to remove AD cache backup. Depending on the circumstances, this may result "
"in non-existent usernames and groups appearing in webui dropdown menus.", exc_info=True)
await self.middleware.call('cache.pop', 'AD_cache')
flush = await run([SMBCmd.NET.value, "cache", "flush"], check=False)
if flush.returncode != 0:
self.logger.warning("Failed to flush samba's general cache after stopping Active Directory service.")

if (await self.middleware.call('smb.get_smb_ha_mode')) == "LEGACY" and (await self.middleware.call('failover.status')) == 'MASTER':
try:
await self.middleware.call('failover.call_remote', 'activedirectory.stop')
Expand Down