def run(_umc_instance, rerun=False, fix_log=''): if not util.is_service_active('Samba 4'): return error_descriptions = list() if rerun and fix_log: error_descriptions.append(fix_log) buttons = [{ 'action': 'run_samba_tool_dbcheck_fix', 'label': _('Run `samba-tool dbcheck --fix --cross-ncs --yes`'), }] cmd = ['samba-tool', 'dbcheck'] (success, output) = util.run_with_output(cmd) if [x for x in output.split('\n') if x.startswith("ERROR:")]: error = _( '`samba-tool dbcheck` found an error in the local AD database.') error_descriptions.append(error) error_descriptions.append(output) if not rerun: fix = _('You can run `samba-tool dbcheck --fix` to fix the issue.') error_descriptions.append(fix) raise Critical(description='\n'.join(error_descriptions), buttons=buttons) if rerun: fixed = _( '`samba-tool dbcheck` found no errors in the local AD database.') error_descriptions.append(fixed) MODULE.error('\n'.join(error_descriptions)) raise ProblemFixed(description='\n'.join(error_descriptions))
def run(_umc_instance, rerun=False, fix_log=''): if not util.is_service_active('Samba 4'): return error_descriptions = list() if rerun and fix_log: error_descriptions.append(fix_log) buttons = [{ 'action': 'run_samba_tool_ntacl_sysvolreset', 'label': _('Run `samba-tool ntacl sysvolreset`'), }] cmd = ['samba-tool', 'ntacl', 'sysvolcheck'] (success, output) = util.run_with_output(cmd) if not success or output: error = _( '`samba-tool ntacl sysvolcheck` returned a problem with the sysvol ACLs.' ) error_descriptions.append(error) error_descriptions.append(output) if not rerun: fix = _( 'You can run `samba-tool ntacl sysvolreset` to fix the issue.') error_descriptions.append(fix) raise Warning(description='\n'.join(error_descriptions), buttons=buttons) if rerun: fixed = _('`samba-tool ntacl sysvolcheck` found no problems.') error_descriptions.append(fixed) error_descriptions.append(output) raise ProblemFixed(description='\n'.join(error_descriptions))
def run_samba_tool_dbcheck_fix(umc_instance): if not util.is_service_active('Samba 4'): return cmd = ['samba-tool', 'dbcheck', '--fix', '--cross-ncs', '--yes'] (success, output) = util.run_with_output(cmd) cmd_string = ' '.join(cmd) MODULE.process('Output of %s:\n%s' % (cmd_string, output)) fix_log = [_('Output of `{cmd}`:').format(cmd=cmd_string)] fix_log.append(output.decode('utf-8', 'replace')) run(umc_instance, rerun=True, fix_log='\n'.join(fix_log))
def run_samba_tool_ntacl_sysvolreset(umc_instance): if not util.is_service_active('Samba 4'): return cmd = ['samba-tool', 'ntacl', 'sysvolreset'] (success, output) = util.run_with_output(cmd) cmd_string = ' '.join(cmd) if success: fix_log = [_('`{cmd}` succeeded.').format(cmd=cmd_string)] MODULE.process('Output of %s:\n%s' % (cmd_string, output)) else: fix_log = [_('`{cmd}` failed.').format(cmd=cmd_string)] MODULE.error('Error running %s:\n%s' % (cmd_string, output)) fix_log.append(output.decode('utf-8', 'replace')) run(umc_instance, rerun=True, fix_log='\n'.join(fix_log))
def run(_umc_instance, rerun=False, fix_log=''): if not util.is_service_active('Samba 4'): return error_descriptions = list() if rerun and fix_log: error_descriptions.append(fix_log) buttons = [{ 'action': 'run_samba_tool_ntacl_sysvolreset', 'label': _('Run `samba-tool ntacl sysvolreset`'), }] cmd = ['samba-tool', 'ntacl', 'sysvolcheck'] (success, output) = util.run_with_output(cmd) if not success or output: error = _( '`samba-tool ntacl sysvolcheck` returned a problem with the sysvol ACLs.' ) error_descriptions.append(error) fix = _("Running 'samba-tool ntacl sysvolreset' may fix the issue") #Filters an unhelpful error message from samba if output.find("NT_STATUS_OBJECT_NAME_NOT_FOUND") != -1: output_list = output.splitlines() for x in output_list: if x.find("NT_STATUS_OBJECT_NAME_NOT_FOUND") == -1: error_descriptions.append(x) else: fix = "" else: error_descriptions.append(output) if not rerun: error_descriptions.append(fix) raise Warning(description='\n'.join(error_descriptions), buttons=buttons) if rerun: fixed = _('`samba-tool ntacl sysvolcheck` found no problems.') error_descriptions.append(fixed) error_descriptions.append(output) raise ProblemFixed(description='\n'.join(error_descriptions))