|
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 ldap |
35 |
import socket |
36 |
import psutil |
37 |
|
38 |
import univention.uldap |
39 |
|
40 |
import univention.config_registry |
41 |
from univention.management.console.modules.diagnostic import Critical |
42 |
|
43 |
from univention.lib.i18n import Translation |
44 |
_ = Translation('univention-management-console-module-diagnostic').translate |
45 |
|
46 |
title = _('Check Heimdal KDC on Samba 4 DC') |
47 |
description = _('Samba 4 KDC running.') |
48 |
umc_modules = [{'module': 'services'}] |
49 |
|
50 |
|
51 |
def is_service_active(service): |
52 |
lo = univention.uldap.getMachineConnection() |
53 |
raw_filter = '(&(univentionService=%s)(cn=%s))' |
54 |
filter_expr = ldap.filter.filter_format(raw_filter, (service, socket.gethostname())) |
55 |
for (dn, _attr) in lo.search(filter_expr, attr=['cn']): |
56 |
if dn is not None: |
57 |
return True |
58 |
return False |
59 |
|
60 |
|
61 |
def samba_kdc_running(): |
62 |
try: |
63 |
import samba.messaging |
64 |
except ImportError: |
65 |
return False |
66 |
msg = samba.messaging.Messaging() |
67 |
try: |
68 |
ids = msg.irpc_servers_byname('kdc_server') |
69 |
except KeyError: |
70 |
return False |
71 |
return bool(ids) |
72 |
|
73 |
|
74 |
def is_heimdal_kdc_running(): |
75 |
kdc_paths = ('/usr/lib/heimdal-servers/kdc', '/usr/lib/heimdal-servers/kpasswdd') |
76 |
process_paths = (p.exe() for p in psutil.process_iter()) |
77 |
return any(path in kdc_paths for path in process_paths) |
78 |
|
79 |
|
80 |
def is_kerberos_autostart_disabled(): |
81 |
configRegistry = univention.config_registry.ConfigRegistry() |
82 |
configRegistry.load() |
83 |
return configRegistry.is_false('kerberos/autostart') |
84 |
|
85 |
|
86 |
def run(): |
87 |
error = _('This is a Samba 4 DC, but `samba-tool processes` reports no `kdc_server`.') |
88 |
heimdal_error = _('This may be, because Heimdal KDC seems to be running.') |
89 |
autostart_error = _('This may be, because `kerberos/autostart` is not disabled.') |
90 |
solution = _('You may want to stop Heimdal KDC and restart Samba via {services}') |
91 |
|
92 |
if is_service_active('Samba 4') and not samba_kdc_running(): |
93 |
error_descriptions = [error] |
94 |
if is_heimdal_kdc_running(): |
95 |
error_descriptions.append(heimdal_error) |
96 |
if not is_kerberos_autostart_disabled(): |
97 |
error_descriptions.append(autostart_error) |
98 |
error_descriptions.append(solution) |
99 |
raise Critical('\n'.join(error_descriptions)) |
100 |
|
101 |
|
102 |
if __name__ == '__main__': |
103 |
from univention.management.console.modules.diagnostic import main |
104 |
main() |
1 |
heimdal_on_samba4_dc (po) |
105 |
heimdal_on_samba4_dc (po) |
2 |
-- |
|
|
3 |
.../umc/python/diagnostic/de.po | 33 ++++++++++++++++++++-- |
106 |
.../umc/python/diagnostic/de.po | 33 ++++++++++++++++++++-- |
4 |
1 file changed, 31 insertions(+), 2 deletions(-) |
107 |
1 file changed, 31 insertions(+), 2 deletions(-) |