View | Details | Raw Unified | Return to bug 36012 | Differences between
and this patch

Collapse All | Expand All

(-)a/management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/hostname_check.py (-2 / +83 lines)
Line 0    Link Here 
0
- 
1
#!/usr/bin/python2.7
2
# coding: utf-8
3
#
4
# Univention Management Console module:
5
#  System Diagnosis UMC module
6
#
7
# Copyright 2017 Univention GmbH
8
#
9
# http://www.univention.de/
10
#
11
# All rights reserved.
12
#
13
# The source code of this program is made available
14
# under the terms of the GNU Affero General Public License version 3
15
# (GNU AGPL V3) as published by the Free Software Foundation.
16
#
17
# Binary versions of this program provided by Univention to you as
18
# well as other copyrighted, protected or trademarked materials like
19
# Logos, graphics, fonts, specific documentations and configurations,
20
# cryptographic keys etc. are subject to a license agreement between
21
# you and Univention and not subject to the GNU AGPL V3.
22
#
23
# In the case you use this program under the terms of the GNU AGPL V3,
24
# the program is provided in the hope that it will be useful,
25
# but WITHOUT ANY WARRANTY; without even the implied warranty of
26
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
# GNU Affero General Public License for more details.
28
#
29
# You should have received a copy of the GNU Affero General Public
30
# License with the Debian GNU/Linux or Univention distribution in file
31
# /usr/share/common-licenses/AGPL-3; if not, see
32
# <http://www.gnu.org/licenses/>.
33
34
import re
35
36
import univention.uldap
37
from univention.management.console.modules.diagnostic import Warning
38
39
from univention.lib.i18n import Translation
40
_ = Translation('univention-management-console-module-diagnostic').translate
41
42
title = _('Check hostname RFC compliance')
43
description = _('No uncompliant hostnames found.')
44
links = [{
45
	'name': 'rfc1123',
46
	'href': _('https://tools.ietf.org/html/rfc1123#section-2'),
47
	'label': _('RFC 1123 - 2.1 Host Names and Numbers')
48
}]
49
50
VALID_HOSTNAME = re.compile(r"^(?!-)[A-Z0-9-]{1,63}(?<!-)$", re.IGNORECASE)
51
52
53
def univention_hostnames():
54
	lo = univention.uldap.getMachineConnection()
55
	for (dn, attr) in lo.search('(objectClass=univentionHost)', attr=['cn']):
56
		if dn is not None:
57
			for hostname in attr.get('cn'):
58
				yield hostname
59
60
61
def valid_hostname(hostname):
62
	return bool(VALID_HOSTNAME.match(hostname))
63
64
65
def invalid_hostnames():
66
	for hostname in univention_hostnames():
67
		if not valid_hostname(hostname):
68
			yield hostname
69
70
71
def run():
72
	hostnames = list(invalid_hostnames())
73
	if hostnames:
74
		invalid = _('The following invalid hostnames have been found: {hostnames}.')
75
		problem = _('This may lead to DNS problems.')
76
		specification = _('Please refer to {rfc1123} for the syntax of host names.')
77
		description = [invalid.format(hostnames=', '.join(hostnames)), problem, specification]
78
		raise Warning(description='\n'.join(description))
79
80
81
if __name__ == '__main__':
82
	from univention.management.console.modules.diagnostic import main
83
	main()
1
hostame_check.py
84
hostame_check.py
2
--
3
.../umc/python/diagnostic/plugins/hostname_check.py          | 12 ++++++------
85
.../umc/python/diagnostic/plugins/hostname_check.py          | 12 ++++++------
4
1 file changed, 6 insertions(+), 6 deletions(-)
86
1 file changed, 6 insertions(+), 6 deletions(-)
5
mode change 100644 => 100755 management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/hostname_check.py
87
mode change 100644 => 100755 management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/hostname_check.py
(-)a/management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/hostname_check.py (-8 / +6 lines)
 Lines 40-46   from univention.lib.i18n import Translation Link Here 
40
_ = Translation('univention-management-console-module-diagnostic').translate
40
_ = Translation('univention-management-console-module-diagnostic').translate
41
41
42
title = _('Check hostname RFC compliance')
42
title = _('Check hostname RFC compliance')
43
description = _('No uncompliant hostnames found.')
43
description = _('No non-compliant hostnames found.')
44
links = [{
44
links = [{
45
	'name': 'rfc1123',
45
	'name': 'rfc1123',
46
	'href': _('https://tools.ietf.org/html/rfc1123#section-2'),
46
	'href': _('https://tools.ietf.org/html/rfc1123#section-2'),
 Lines 58-77   def univention_hostnames(): Link Here 
58
				yield hostname
58
				yield hostname
59
59
60
60
61
def valid_hostname(hostname):
61
def compliant_hostname(hostname):
62
	return bool(VALID_HOSTNAME.match(hostname))
62
	return bool(VALID_HOSTNAME.match(hostname))
63
63
64
64
65
def invalid_hostnames():
65
def non_compliant_hostnames():
66
	for hostname in univention_hostnames():
66
	for hostname in univention_hostnames():
67
		if not valid_hostname(hostname):
67
		if not compliant_hostname(hostname):
68
			yield hostname
68
			yield hostname
69
69
70
70
71
def run():
71
def run():
72
	hostnames = list(invalid_hostnames())
72
	hostnames = list(non_compliant_hostnames())
73
	if hostnames:
73
	if hostnames:
74
		invalid = _('The following invalid hostnames have been found: {hostnames}.')
74
		invalid = _('The following non-compliant hostnames have been found: {hostnames}.')
75
		problem = _('This may lead to DNS problems.')
75
		problem = _('This may lead to DNS problems.')
76
		specification = _('Please refer to {rfc1123} for the syntax of host names.')
76
		specification = _('Please refer to {rfc1123} for the syntax of host names.')
77
		description = [invalid.format(hostnames=', '.join(hostnames)), problem, specification]
77
		description = [invalid.format(hostnames=', '.join(hostnames)), problem, specification]
78
- 
79
(pe)
78
(pe)
80
--
81
.../umc/python/diagnostic/de.po                    | 35 ++++++++++++++++++++--
79
.../umc/python/diagnostic/de.po                    | 35 ++++++++++++++++++++--
82
1 file changed, 33 insertions(+), 2 deletions(-)
80
1 file changed, 33 insertions(+), 2 deletions(-)
(-)a/management/univention-management-console-module-diagnostic/umc/python/diagnostic/de.po (-3 / +33 lines)
 Lines 2-9    Link Here 
2
msgid ""
2
msgid ""
3
msgstr ""
3
msgstr ""
4
"Project-Id-Version: univention-management-console-module-diagnostic\n"
4
"Project-Id-Version: univention-management-console-module-diagnostic\n"
5
"Report-Msgid-Bugs-To: packages@univention.de\n"
5
"Report-Msgid-Bugs-To: \n"
6
"POT-Creation-Date: 2016-01-14 12:19+0100\n"
6
"POT-Creation-Date: 2017-06-08 14:53+0200\n"
7
"PO-Revision-Date: \n"
7
"PO-Revision-Date: \n"
8
"Last-Translator: Univention GmbH <packages@univention.de>\n"
8
"Last-Translator: Univention GmbH <packages@univention.de>\n"
9
"Language-Team: Univention GmbH <packages@univention.de>\n"
9
"Language-Team: Univention GmbH <packages@univention.de>\n"
 Lines 27-32   msgstr "" Link Here 
27
msgid "Adjust to suggested limits"
27
msgid "Adjust to suggested limits"
28
msgstr "An vorgeschlagene Limits anpassen"
28
msgstr "An vorgeschlagene Limits anpassen"
29
29
30
#: umc/python/diagnostic/plugins/hostname_check.py:42
31
msgid "Check hostname RFC compliance"
32
msgstr "Überprüfe Rechnernamen auf RFC Konformität"
33
30
#: umc/python/diagnostic/plugins/gateway.py:11
34
#: umc/python/diagnostic/plugins/gateway.py:11
31
msgid "Gateway is not reachable"
35
msgid "Gateway is not reachable"
32
msgstr "Gateway ist nicht erreichbar"
36
msgstr "Gateway ist nicht erreichbar"
 Lines 97-102   msgstr "" Link Here 
97
msgid "Nameserver(s) are not responsive"
101
msgid "Nameserver(s) are not responsive"
98
msgstr "Nameserver sind nicht ansprechbar"
102
msgstr "Nameserver sind nicht ansprechbar"
99
103
104
#: umc/python/diagnostic/plugins/hostname_check.py:43
105
msgid "No non-compliant hostnames found."
106
msgstr "Keine nicht konformen Rechnernamen gefunden."
107
100
#: umc/python/diagnostic/plugins/package_status.py:11
108
#: umc/python/diagnostic/plugins/package_status.py:11
101
msgid "Package status corrupt"
109
msgid "Package status corrupt"
102
msgstr "Paketstatus korrupt"
110
msgstr "Paketstatus korrupt"
 Lines 116-121   msgstr "" Link Here 
116
"Bitte sicherstellen, dass die DNS-Einstellungen in {setup:network} korrekt "
124
"Bitte sicherstellen, dass die DNS-Einstellungen in {setup:network} korrekt "
117
"konfiguriert sind."
125
"konfiguriert sind."
118
126
127
#: umc/python/diagnostic/plugins/hostname_check.py:76
128
#, python-brace-format
129
msgid "Please refer to {rfc1123} for the syntax of host names."
130
msgstr "Siehe {rfc1123} für die Syntax von Rechnernamen."
131
119
#: umc/python/diagnostic/plugins/ssh_connection.py:52
132
#: umc/python/diagnostic/plugins/ssh_connection.py:52
120
#, python-format
133
#, python-format
121
msgid ""
134
msgid ""
 Lines 129-134   msgstr "" Link Here 
129
msgid "Proxy server failure"
142
msgid "Proxy server failure"
130
msgstr "Proxy-Server-Fehler"
143
msgstr "Proxy-Server-Fehler"
131
144
145
#: umc/python/diagnostic/plugins/hostname_check.py:47
146
msgid "RFC 1123 - 2.1 Host Names and Numbers"
147
msgstr ""
148
132
#: umc/python/diagnostic/plugins/ssh_connection.py:16
149
#: umc/python/diagnostic/plugins/ssh_connection.py:16
133
msgid "SSH connection to UCS server failed!"
150
msgid "SSH connection to UCS server failed!"
134
msgstr "SSH-Verbindung zu anderem UCS Server fehlgeschlagen!"
151
msgstr "SSH-Verbindung zu anderem UCS Server fehlgeschlagen!"
 Lines 149-154   msgstr "" Link Here 
149
"Die folgende Liste zeigt die betroffenen entfernten Rechner und den Grund "
166
"Die folgende Liste zeigt die betroffenen entfernten Rechner und den Grund "
150
"für die fehlgeschlagene SSH-Verbindung."
167
"für die fehlgeschlagene SSH-Verbindung."
151
168
169
#: umc/python/diagnostic/plugins/hostname_check.py:74
170
#, python-brace-format
171
msgid "The following non-compliant hostnames have been found: {hostnames}."
172
msgstr ""
173
"Die folgenden nicht konformen Rechnernamen wurden gefunden: {hostnames}."
174
152
#: umc/python/diagnostic/plugins/gateway.py:13
175
#: umc/python/diagnostic/plugins/gateway.py:13
153
#, python-format
176
#, python-format
154
msgid ""
177
msgid ""
 Lines 249-254   msgstr "" Link Here 
249
"an Samba-Servern unmöglich, Dateioperationen (Kopieren, Verschieben) auf "
272
"an Samba-Servern unmöglich, Dateioperationen (Kopieren, Verschieben) auf "
250
"Freigaben kann fehlschlagen, uvm.)"
273
"Freigaben kann fehlschlagen, uvm.)"
251
274
275
#: umc/python/diagnostic/plugins/hostname_check.py:75
276
msgid "This may lead to DNS problems."
277
msgstr "Dies kann zu DNS Problemen führen."
278
252
#: umc/python/diagnostic/plugins/proxy.py:83
279
#: umc/python/diagnostic/plugins/proxy.py:83
253
#, python-format
280
#, python-format
254
msgid ""
281
msgid ""
 Lines 260-265   msgstr "" Link Here 
260
"dass Authentifikations-Zugangsdaten (falls existierend) korrekt sind und die "
287
"dass Authentifikations-Zugangsdaten (falls existierend) korrekt sind und die "
261
"ACL's des Proxy-Servers nicht verbieten, Anfragen an %s zu stellen."
288
"ACL's des Proxy-Servers nicht verbieten, Anfragen an %s zu stellen."
262
289
290
#: umc/python/diagnostic/plugins/hostname_check.py:46
291
msgid "https://tools.ietf.org/html/rfc1123#section-2"
292
msgstr ""
293
263
#: umc/python/diagnostic/plugins/package_status.py:28
294
#: umc/python/diagnostic/plugins/package_status.py:28
264
msgid "some"
295
msgid "some"
265
msgstr "einigen"
296
msgstr "einigen"
266
- 

Return to bug 36012