Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
anodos325 committed Jul 8, 2024
1 parent 5463e82 commit 5619724
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
22 changes: 7 additions & 15 deletions src/middlewared/middlewared/plugins/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']):
Expand Down Expand Up @@ -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'])

Expand Down Expand Up @@ -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 '
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down
11 changes: 6 additions & 5 deletions src/middlewared/middlewared/plugins/smb_/groupmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 5619724

Please sign in to comment.