From 56197249de2e520bea132594a1cd324fdde13c97 Mon Sep 17 00:00:00 2001 From: Andrew Walker Date: Mon, 8 Jul 2024 06:15:13 -0700 Subject: [PATCH] Fix --- .../middlewared/plugins/account.py | 22 ++++++------------- .../middlewared/plugins/smb_/groupmap.py | 11 +++++----- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/src/middlewared/middlewared/plugins/account.py b/src/middlewared/middlewared/plugins/account.py index 2fc9955f15d06..bf9e54e602895 100644 --- a/src/middlewared/middlewared/plugins/account.py +++ b/src/middlewared/middlewared/plugins/account.py @@ -298,7 +298,7 @@ async def query(self, filters, options): ds = await self.middleware.call('directoryservices.status') if ds['type'] is not None and ds['status'] == DSStatus.HEALTHY.name: ds_users = await self.middleware.call( - 'directoryservices.cache.query', 'USER', filters, options.copy() + 'directoryservices.cache.query', 'USER', filters, options.copy() ) match DSType(ds['type']): @@ -896,7 +896,6 @@ def do_delete(self, audit_callback, pk, options): '(LDAP server or domain controller).', errno.EPERM ) - user = self.middleware.call_sync('user.get_instance', pk) audit_callback(user['username']) @@ -1910,7 +1909,6 @@ async def do_update(self, audit_callback, pk, data): except KeyError: groupname = 'UNKNOWN' - audit_callback(groupname) raise CallError( 'Groups provided by a directory service must be modified through the identity provider ' @@ -1978,11 +1976,6 @@ async def do_update(self, audit_callback, pk, data): ) await self.middleware.call('service.reload', 'user') - - if groupmap_changed: - gm_job = await self.middleware.call('smb.synchronize_group_mappings') - await gm_job.wait() - return pk @accepts(Int('id'), Dict('options', Bool('delete_users', default=False)), audit='Delete group', audit_callback=True) @@ -2052,13 +2045,12 @@ async def get_next_gid(self): """ Get the next available/free gid. """ - used_gids = ( - { - group['bsdgrp_gid'] - for group in await self.middleware.call('datastore.query', 'account.bsdgroups') - } | - set((await self.middleware.call('privilege.used_local_gids')).keys()) - ) + used_gids = { + group['bsdgrp_gid'] + for group in await self.middleware.call('datastore.query', 'account.bsdgroups') + } + used_gids |= set((await self.middleware.call('privilege.used_local_gids')).keys()) + # We should start gid from 3000 to avoid potential conflicts - Reference: NAS-117892 next_gid = 3000 while next_gid in used_gids: diff --git a/src/middlewared/middlewared/plugins/smb_/groupmap.py b/src/middlewared/middlewared/plugins/smb_/groupmap.py index dbf091294b57b..c76102d1f34e7 100644 --- a/src/middlewared/middlewared/plugins/smb_/groupmap.py +++ b/src/middlewared/middlewared/plugins/smb_/groupmap.py @@ -119,7 +119,6 @@ def sync_foreign_groups(self): entries.append(SMBGroupMembership(sid=SMBBuiltin.GUESTS.sid, members=tuple(set(guests)))) insert_groupmap_entries(GroupmapFile.DEFAULT, entries) - @private def initialize_idmap_tdb(self, low_range): tdb_path = f'{SMBPath.STATEDIR.platform()}/winbindd_idmap.tdb' @@ -327,16 +326,18 @@ def synchronize_group_mappings(self, job, bypass_sentinel_check=False): """ entries = [] - if not bypass_sentinel_check and not await self.middleware.call('smb.is_configured'): + if not bypass_sentinel_check and not self.middleware.call_sync('smb.is_configured'): raise CallError( "SMB server configuration is not complete. " "This may indicate system dataset setup failure." ) - groupmap = await self.groupmap_list() + groupmap = self.groupmap_list() - groups = self.middleware.call_sync('group.query', [('builtin', '=', False), ('local', '=', True), ('smb', '=', True)]) - groups.append(await self.middleware.call('group.query', [('gid', '=', 545), ('local', '=', True)], {'get': True})) + groups = self.middleware.call_sync('group.query', [ + ('builtin', '=', False), ('local', '=', True), ('smb', '=', True) + ]) + groups.append(self.middleware.call_sync('group.query', [('gid', '=', 545), ('local', '=', True)], {'get': True})) gid_set = {x["gid"] for x in groups} for group in groups: