Univention Bugzilla – Attachment 8895 Details for
Bug 40605
UMC system diagnostic module should run samba-tool dbcheck
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
40605-diagnostic-samba-tool-dbcheck-420.patch
40605-diagnostic-samba-tool-dbcheck-420.patch (text/plain), 10.29 KB, created by
Lukas Oyen
on 2017-06-01 18:09:43 CEST
(
hide
)
Description:
40605-diagnostic-samba-tool-dbcheck-420.patch
Filename:
MIME Type:
Creator:
Lukas Oyen
Created:
2017-06-01 18:09:43 CEST
Size:
10.29 KB
patch
obsolete
>From 4055cc0035856db880be815eb91338ced0a29c95 Mon Sep 17 00:00:00 2001 >From: Lukas Oyen <oyen@univention.de> >Date: Thu, 1 Jun 2017 17:19:26 +0200 >Subject: [PATCH 1/3] Bug #40605: umc-diagnostic: new check > samba_tool_dbcheck.py > >This is Julius Hinrichs version with little cleanup >(https://forge.univention.org/bugzilla/attachment.cgi?id=8058). >--- > .../diagnostic/plugins/samba_tool_dbcheck.py | 54 ++++++++++++++++++++++ > 1 file changed, 54 insertions(+) > create mode 100644 management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/samba_tool_dbcheck.py > >diff --git a/management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/samba_tool_dbcheck.py b/management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/samba_tool_dbcheck.py >new file mode 100644 >index 0000000..2309cd6 >--- /dev/null >+++ b/management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/samba_tool_dbcheck.py >@@ -0,0 +1,54 @@ >+#!/usr/bin/python2.7 >+# coding: utf-8 >+# >+# Univention Management Console module: >+# System Diagnosis UMC module >+# >+# Copyright 2016-2017 Univention GmbH >+# >+# http://www.univention.de/ >+# >+# All rights reserved. >+# >+# The source code of this program is made available >+# under the terms of the GNU Affero General Public License version 3 >+# (GNU AGPL V3) as published by the Free Software Foundation. >+# >+# Binary versions of this program provided by Univention to you as >+# well as other copyrighted, protected or trademarked materials like >+# Logos, graphics, fonts, specific documentations and configurations, >+# cryptographic keys etc. are subject to a license agreement between >+# you and Univention and not subject to the GNU AGPL V3. >+# >+# In the case you use this program under the terms of the GNU AGPL V3, >+# the program is provided in the hope that it will be useful, >+# but WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU Affero General Public License for more details. >+# >+# You should have received a copy of the GNU Affero General Public >+# License with the Debian GNU/Linux or Univention distribution in file >+# /usr/share/common-licenses/AGPL-3; if not, see >+# <http://www.gnu.org/licenses/>. >+ >+from subprocess import Popen, PIPE, STDOUT >+ >+from univention.management.console.modules.diagnostic import Critical >+ >+from univention.lib.i18n import Translation >+_ = Translation('univention-management-console-module-diagnostic').translate >+ >+title = _('Check local AD database for errors') >+description = _('No errors found.'), >+ >+ >+def run(): >+ process = Popen(['samba-tool', 'dbcheck'], stdout=PIPE, stderr=STDOUT) >+ stdout, stderr = process.communicate() >+ if process.returncode: >+ raise Critical('\n'.join([description, '', stdout])) >+ >+ >+if __name__ == '__main__': >+ from univention.management.console.modules.diagnostic import main >+ main() >-- >2.7.4 > > >From d4c22213c9bc694198ba9926b3b33d705aac3184 Mon Sep 17 00:00:00 2001 >From: Lukas Oyen <oyen@univention.de> >Date: Thu, 1 Jun 2017 17:55:31 +0200 >Subject: [PATCH 2/3] Bug #40605: umc-diagnostic: simplify new check > samba_tool_dbcheck.py > >--- > .../diagnostic/plugins/samba_tool_dbcheck.py | 81 ++++++++++++++++++++-- > 1 file changed, 74 insertions(+), 7 deletions(-) > >diff --git a/management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/samba_tool_dbcheck.py b/management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/samba_tool_dbcheck.py >index 2309cd6..b5b2190 100644 >--- a/management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/samba_tool_dbcheck.py >+++ b/management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/samba_tool_dbcheck.py >@@ -31,9 +31,12 @@ > # /usr/share/common-licenses/AGPL-3; if not, see > # <http://www.gnu.org/licenses/>. > >-from subprocess import Popen, PIPE, STDOUT >+import ldap >+import socket >+import subprocess > >-from univention.management.console.modules.diagnostic import Critical >+import univention.uldap >+from univention.management.console.modules.diagnostic import Critical, ProblemFixed > > from univention.lib.i18n import Translation > _ = Translation('univention-management-console-module-diagnostic').translate >@@ -42,11 +45,75 @@ title = _('Check local AD database for errors') > description = _('No errors found.'), > > >-def run(): >- process = Popen(['samba-tool', 'dbcheck'], stdout=PIPE, stderr=STDOUT) >- stdout, stderr = process.communicate() >- if process.returncode: >- raise Critical('\n'.join([description, '', stdout])) >+def run_samba_tool_dbcheck_fix(): >+ if not is_service_active('Samba 4'): >+ return >+ >+ cmd = ['samba-tool', 'dbcheck', '--fix', '--yes'] >+ (success, output) = run_with_output(cmd) >+ if success: >+ fix_log = [_('`samba-tool dbcheck --fix --yes` failed.')] >+ else: >+ fix_log = [_('`samba-tool dbcheck --fix --yes` succeeded.')] >+ fix_log.append(output) >+ run(rerun=True, fix_log='\n'.join(fix_log)) >+ >+ >+actions = { >+ 'run_samba_tool_dbcheck_fix': run_samba_tool_dbcheck_fix >+} >+ >+ >+def is_service_active(service): >+ lo = univention.uldap.getMachineConnection() >+ raw_filter = '(&(univentionService=%s)(cn=%s))' >+ filter_expr = ldap.filter.filter_format(raw_filter, (service, socket.gethostname())) >+ for (dn, _attr) in lo.search(filter_expr, attr=['cn']): >+ if dn is not None: >+ return True >+ return False >+ >+ >+def run_with_output(cmd): >+ output = list() >+ process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) >+ (stdout, stderr) = process.communicate() >+ if stdout: >+ output.append('\nSTDOUT:\n{}'.format(stdout)) >+ if stderr: >+ output.append('\nSTDERR:\n{}'.format(stderr)) >+ return (process.returncode == 0, '\n'.join(output)) >+ >+ >+def run(rerun=False, fix_log=''): >+ if not 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 --yes`'), >+ }] >+ >+ cmd = ['samba-tool', 'dbcheck'] >+ (success, output) = run_with_output(cmd) >+ if not success: >+ error = _('`samba-tool dbcheck` returned a problem with 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 problems with the local AD database.') >+ error_descriptions.append(fixed) >+ error_descriptions.append(output) >+ raise ProblemFixed(description='\n'.join(error_descriptions)) > > > if __name__ == '__main__': >-- >2.7.4 > > >From 6d483eeaba16960227213b70e4c4a0bb7fb2c800 Mon Sep 17 00:00:00 2001 >From: Lukas Oyen <oyen@univention.de> >Date: Thu, 1 Jun 2017 18:03:50 +0200 >Subject: [PATCH 3/3] Bug #40605: umc-diagnostic: simplify new check > samba_tool_dbcheck.py (po) > >--- > .../umc/python/diagnostic/de.po | 36 ++++++++++++++++++++-- > 1 file changed, 34 insertions(+), 2 deletions(-) > >diff --git a/management/univention-management-console-module-diagnostic/umc/python/diagnostic/de.po b/management/univention-management-console-module-diagnostic/umc/python/diagnostic/de.po >index affad86..fe824c1 100644 >--- a/management/univention-management-console-module-diagnostic/umc/python/diagnostic/de.po >+++ b/management/univention-management-console-module-diagnostic/umc/python/diagnostic/de.po >@@ -2,8 +2,8 @@ > msgid "" > msgstr "" > "Project-Id-Version: univention-management-console-module-diagnostic\n" >-"Report-Msgid-Bugs-To: packages@univention.de\n" >-"POT-Creation-Date: 2016-01-14 12:19+0100\n" >+"Report-Msgid-Bugs-To: \n" >+"POT-Creation-Date: 2017-06-01 18:00+0200\n" > "PO-Revision-Date: \n" > "Last-Translator: Univention GmbH <packages@univention.de>\n" > "Language-Team: Univention GmbH <packages@univention.de>\n" >@@ -27,6 +27,10 @@ msgstr "" > msgid "Adjust to suggested limits" > msgstr "An vorgeschlagene Limits anpassen" > >+#: umc/python/diagnostic/plugins/samba_tool_dbcheck.py:44 >+msgid "Check local AD database for errors" >+msgstr "Teste die locale AD Datenbank auf Fehler" >+ > #: umc/python/diagnostic/plugins/gateway.py:11 > msgid "Gateway is not reachable" > msgstr "Gateway ist nicht erreichbar" >@@ -97,6 +101,10 @@ msgstr "" > msgid "Nameserver(s) are not responsive" > msgstr "Nameserver sind nicht ansprechbar" > >+#: umc/python/diagnostic/plugins/samba_tool_dbcheck.py:45 >+msgid "No errors found." >+msgstr "Keine Fehler gefunden." >+ > #: umc/python/diagnostic/plugins/package_status.py:11 > msgid "Package status corrupt" > msgstr "Paketstatus korrupt" >@@ -129,6 +137,10 @@ msgstr "" > msgid "Proxy server failure" > msgstr "Proxy-Server-Fehler" > >+#: umc/python/diagnostic/plugins/samba_tool_dbcheck.py:98 >+msgid "Run `samba-tool dbcheck --fix --yes`" >+msgstr "Führe `samba-tool dbcheck --fix --yes` aus" >+ > #: umc/python/diagnostic/plugins/ssh_connection.py:16 > msgid "SSH connection to UCS server failed!" > msgstr "SSH-Verbindung zu anderem UCS Server fehlgeschlagen!" >@@ -260,6 +272,26 @@ msgstr "" > "dass Authentifikations-Zugangsdaten (falls existierend) korrekt sind und die " > "ACL's des Proxy-Servers nicht verbieten, Anfragen an %s zu stellen." > >+#: umc/python/diagnostic/plugins/samba_tool_dbcheck.py:108 >+msgid "You can run `samba-tool dbcheck --fix` to fix the issue." >+msgstr "Sie können `samba-tool dbcheck --fix` ausführen um die Probleme zu beheben." >+ >+#: umc/python/diagnostic/plugins/samba_tool_dbcheck.py:55 >+msgid "`samba-tool dbcheck --fix --yes` failed." >+msgstr "`samba-tool dbcheck --fix --yes` ist fehlgeschlagen." >+ >+#: umc/python/diagnostic/plugins/samba_tool_dbcheck.py:57 >+msgid "`samba-tool dbcheck --fix --yes` succeeded." >+msgstr "`samba-tool dbcheck --fix --yes` war erfolgreich." >+ >+#: umc/python/diagnostic/plugins/samba_tool_dbcheck.py:113 >+msgid "`samba-tool dbcheck` found no problems with the local AD database." >+msgstr "`samba-tool dbcheck` hat keine Probleme mit der lokalen AD Datenbank gefunden." >+ >+#: umc/python/diagnostic/plugins/samba_tool_dbcheck.py:104 >+msgid "`samba-tool dbcheck` returned a problem with the local AD database." >+msgstr "`samba-tool dbcheck` fand Probleme mit der lokalen AD Datenbank." >+ > #: umc/python/diagnostic/plugins/package_status.py:28 > msgid "some" > msgstr "einigen" >-- >2.7.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 40605
:
8058
| 8895