Skip to content

Commit

Permalink
NAS-101260 / 11.3 / Fix traceback in py-bonjour (#3217)
Browse files Browse the repository at this point in the history
* remove mdnsbrowser from middleware plugin
- The functionality appears to be simultaneously unused and disruptive.

* Fix common validate method for idmap plugin
- pass idmap type for validation logic

* change 'smb' to 'cifs' for service.restart in ldap plugin
  • Loading branch information
anodos325 committed Jun 18, 2019
1 parent d7bafd5 commit 94b7f9e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 289 deletions.
38 changes: 19 additions & 19 deletions src/middlewared/middlewared/plugins/idmap.py
Expand Up @@ -128,7 +128,7 @@ async def common_backend_compress(self, data):
return data

@private
async def _common_validate(self, data):
async def _common_validate(self, idmap_backend, data):
"""
Common validation checks for all idmap backends.
Expand Down Expand Up @@ -169,11 +169,11 @@ async def _common_validate(self, data):
continue

# Idmap settings under Services->SMB are ignored when autorid is enabled.
if data['idmap_backend'] == 'autorid' and i['domain']['id'] == 5:
if idmap_backend == 'autorid' and i['domain']['id'] == 5:
continue

# Overlap between ranges defined for 'ad' backend are permitted.
if data['idmap_backend'] == 'ad' and i['idmap_backend'] == 'ad':
if idmap_backend == 'ad' and i['idmap_backend'] == 'ad':
continue

existing_range = range(i['backend_data']['range_low'], i['backend_data']['range_high'])
Expand Down Expand Up @@ -485,7 +485,7 @@ async def do_create(self, data):
"""
verrors = ValidationErrors()
data = await self.middleware.call('idmap.common_backend_compress', data)
verrors.add_child('idmap_ad_create', await self.middleware.call('idmap._common_validate', data))
verrors.add_child('idmap_ad_create', await self.middleware.call('idmap._common_validate', 'ad', data))
if verrors:
raise verrors

Expand Down Expand Up @@ -513,7 +513,7 @@ async def do_update(self, id, data):
new = old.copy()
new.update(data)
verrors = ValidationErrors()
verrors.add_child('idmap_ad_update', await self.middleware.call('idmap._common_validate', new))
verrors.add_child('idmap_ad_update', await self.middleware.call('idmap._common_validate', 'ad', new))
if verrors:
raise verrors

Expand Down Expand Up @@ -564,7 +564,7 @@ async def do_create(self, data):
Create an entry in the idmap backend table.
"""
verrors = ValidationErrors()
verrors.add_child('idmap_autorid_create', await self.middleware.call('idmap._common_validate', data))
verrors.add_child('idmap_autorid_create', await self.middleware.call('idmap._common_validate', 'autorid', data))
if verrors:
raise verrors

Expand Down Expand Up @@ -593,7 +593,7 @@ async def do_update(self, id, data):
new = old.copy()
new.update(data)
verrors = ValidationErrors()
verrors.add_child('idmap_autorid_update', await self.middleware.call('idmap._common_validate', new))
verrors.add_child('idmap_autorid_update', await self.middleware.call('idmap._common_validate', 'autorid', new))

if verrors:
raise verrors
Expand Down Expand Up @@ -647,7 +647,7 @@ async def do_create(self, data):
Create an entry in the idmap backend table.
"""
verrors = ValidationErrors()
verrors.add_child('idmap_ldap_create', await self.middleware.call('idmap._common_validate', data))
verrors.add_child('idmap_ldap_create', await self.middleware.call('idmap._common_validate', 'ldap', data))
if verrors:
raise verrors

Expand Down Expand Up @@ -676,7 +676,7 @@ async def do_update(self, id, data):
new = old.copy()
new.update(data)
verrors = ValidationErrors()
verrors.add_child('idmap_ldap_update', await self.middleware.call('idmap._common_validate', new))
verrors.add_child('idmap_ldap_update', await self.middleware.call('idmap._common_validate', 'ldap', new))

if verrors:
raise verrors
Expand Down Expand Up @@ -725,7 +725,7 @@ async def do_create(self, data):
Create an entry in the idmap backend table.
"""
verrors = ValidationErrors()
verrors.add_child('idmap_nss_create', await self.middleware.call('idmap._common_validate', data))
verrors.add_child('idmap_nss_create', await self.middleware.call('idmap._common_validate', 'nss', data))
if verrors:
raise verrors

Expand Down Expand Up @@ -755,7 +755,7 @@ async def do_update(self, id, data):
new.update(data)
new = await self.middleware.call('idmap.common_backend_compress', new)
verrors = ValidationErrors()
verrors.add_child('idmap_nss_update', await self.middleware.call('idmap._common_validate', new))
verrors.add_child('idmap_nss_update', await self.middleware.call('idmap._common_validate', 'nss', new))

if verrors:
raise verrors
Expand Down Expand Up @@ -843,7 +843,7 @@ async def do_create(self, data):
a stand-alone ldap server.
"""
verrors = ValidationErrors()
verrors.add_child('idmap_rfc2307_create', await self.middleware.call('idmap._common_validate', data))
verrors.add_child('idmap_rfc2307_create', await self.middleware.call('idmap._common_validate', 'rfc2307', data))
if verrors:
raise verrors

Expand Down Expand Up @@ -872,7 +872,7 @@ async def do_update(self, id, data):
new = old.copy()
new.update(data)
verrors = ValidationErrors()
verrors.add_child('idmap_rfc2307_update', await self.middleware.call('idmap._common_validate', new))
verrors.add_child('idmap_rfc2307_update', await self.middleware.call('idmap._common_validate', 'rfc2307', new))

if verrors:
raise verrors
Expand Down Expand Up @@ -921,7 +921,7 @@ async def do_create(self, data):
Create an entry in the idmap_rid backend table.
"""
verrors = ValidationErrors()
verrors.add_child('idmap_rid_create', await self.middleware.call('idmap._common_validate', data))
verrors.add_child('idmap_rid_create', await self.middleware.call('idmap._common_validate', 'rid', data))
if verrors:
raise verrors

Expand Down Expand Up @@ -950,7 +950,7 @@ async def do_update(self, id, data):
new = old.copy()
new.update(data)
verrors = ValidationErrors()
verrors.add_child('idmap_rid_update', await self.middleware.call('idmap._common_validate', new))
verrors.add_child('idmap_rid_update', await self.middleware.call('idmap._common_validate', 'rid', new))

if verrors:
raise verrors
Expand Down Expand Up @@ -1001,7 +1001,7 @@ async def do_create(self, data):
`script` full path to the script or program that generates the mappings.
"""
verrors = ValidationErrors()
verrors.add_child('idmap_script_create', await self.middleware.call('idmap._common_validate', data))
verrors.add_child('idmap_script_create', await self.middleware.call('idmap._common_validate', 'script', data))
if verrors:
raise verrors

Expand Down Expand Up @@ -1030,7 +1030,7 @@ async def do_update(self, id, data):
new = old.copy()
new.update(data)
verrors = ValidationErrors()
verrors.add_child('idmap_script_update', await self.middleware.call('idmap._common_validate', new))
verrors.add_child('idmap_script_update', await self.middleware.call('idmap._common_validate', 'script', new))

if verrors:
raise verrors
Expand Down Expand Up @@ -1079,7 +1079,7 @@ async def do_create(self, data):
Create an entry in the idmap backend table.
"""
verrors = ValidationErrors()
verrors.add_child('idmap_tdb_create', await self.middleware.call('idmap._common_validate', data))
verrors.add_child('idmap_tdb_create', await self.middleware.call('idmap._common_validate', 'tdb', data))
if verrors:
raise verrors

Expand Down Expand Up @@ -1108,7 +1108,7 @@ async def do_update(self, id, data):
new = old.copy()
new.update(data)
verrors = ValidationErrors()
verrors.add_child('idmap_tdb_update', await self.middleware.call('idmap._common_validate', new))
verrors.add_child('idmap_tdb_update', await self.middleware.call('idmap._common_validate', 'tdb', new))

if verrors:
raise verrors
Expand Down
4 changes: 2 additions & 2 deletions src/middlewared/middlewared/plugins/ldap.py
Expand Up @@ -559,7 +559,7 @@ async def start(self):
if has_samba_schema:
await self.middleware.call('etc.generate', 'smb')
await self.middleware.call('smb.store_ldap_admin_password')
await self.middleware.call('service.restart', 'smb')
await self.middleware.call('service.restart', 'cifs')

await self.middleware.call('ldap.fill_cache')

Expand All @@ -574,7 +574,7 @@ async def stop(self):
await self.middleware.call('etc.generate', 'pam')
if ldap['has_samba_schema']:
await self.middleware.call('etc.generate', 'smb')
await self.middleware.call('service.restart', 'smb')
await self.middleware.call('service.restart', 'cifs')
await self.middleware.call('cache.pop', 'LDAP_State')
await self.middleware.call('cache.pop', 'LDAP_cache')
await self.nslcd_cmd('onestop')
Expand Down

0 comments on commit 94b7f9e

Please sign in to comment.