|
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 ldap |
| 35 |
import socket |
| 36 |
import subprocess |
| 37 |
|
| 38 |
import univention.uldap |
| 39 |
from univention.management.console.modules.diagnostic import Warning |
| 40 |
|
| 41 |
from univention.lib.i18n import Translation |
| 42 |
_ = Translation('univention-management-console-module-diagnostic').translate |
| 43 |
|
| 44 |
title = _('Check Samba sysvol ACLs for errors') |
| 45 |
description = _('No errors found.'), |
| 46 |
|
| 47 |
|
| 48 |
def is_service_active(service): |
| 49 |
lo = univention.uldap.getMachineConnection() |
| 50 |
raw_filter = '(&(univentionService=%s)(cn=%s))' |
| 51 |
filter_expr = ldap.filter.filter_format(raw_filter, (service, socket.gethostname())) |
| 52 |
for (dn, _attr) in lo.search(filter_expr, attr=['cn']): |
| 53 |
if dn is not None: |
| 54 |
return True |
| 55 |
return False |
| 56 |
|
| 57 |
|
| 58 |
def run_with_output(cmd): |
| 59 |
output = list() |
| 60 |
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
| 61 |
(stdout, stderr) = process.communicate() |
| 62 |
if stdout: |
| 63 |
output.append('\nSTDOUT:\n{}'.format(stdout)) |
| 64 |
if stderr: |
| 65 |
output.append('\nSTDERR:\n{}'.format(stderr)) |
| 66 |
return (process.returncode == 0, '\n'.join(output)) |
| 67 |
|
| 68 |
|
| 69 |
def run(): |
| 70 |
if not is_service_active('Samba 4'): |
| 71 |
return |
| 72 |
|
| 73 |
error_descriptions = list() |
| 74 |
cmd = ['samba-tool', 'ntacl', 'sysvolcheck'] |
| 75 |
(success, output) = run_with_output(cmd) |
| 76 |
if not success or output: |
| 77 |
error = _('`samba-tool ntacl sysvolcheck` returned a problem with the sysvol ACLs.') |
| 78 |
error_descriptions.append(error) |
| 79 |
error_descriptions.append(output) |
| 80 |
raise Warning(description='\n'.join(error_descriptions)) |
| 81 |
|
| 82 |
|
| 83 |
if __name__ == '__main__': |
| 84 |
from univention.management.console.modules.diagnostic import main |
| 85 |
main() |
| 1 |
`samba_tool_sysvolcheck.py` (po) |
86 |
`samba_tool_sysvolcheck.py` (po) |
| 2 |
-- |
|
|
| 3 |
.../umc/python/diagnostic/de.po | 18 ++++++++++++++++-- |
87 |
.../umc/python/diagnostic/de.po | 18 ++++++++++++++++-- |
| 4 |
1 file changed, 16 insertions(+), 2 deletions(-) |
88 |
1 file changed, 16 insertions(+), 2 deletions(-) |