users: Improve diagnostics

- Move diagnostics into main module instead of action script.

- Ability run diagnostics as non-root user (because it runs in Plinth
  instead of action).

- Diagnose whether LDAP server is listening.

- Diagnose directory entities created during setup.
This commit is contained in:
Sunil Mohan Adapa authored and James Valleroy committed 2015-08-29 06:22:01 -04:00
1 parent 0febeb7244
commit 4210332bf6
3 files changed
+31 -19

No files matched your search

+30 -3
View File
@@ -21,9 +21,11 @@ Plinth module to manage users
from gettext import gettext as _
import json
import subprocess
from plinth import cfg
from plinth import actions
from plinth import action_utils
depends = ['plinth.modules.system']
@@ -36,6 +38,31 @@ def init():
def diagnose():
"""Run diagnostics and result the results."""
output = actions.superuser_run('ldap', ['diagnose'])
return json.loads(output)
"""Run diagnostics and return the results."""
results = []
results.append(action_utils.diagnose_port_listening(389, 'tcp4'))
results.append(action_utils.diagnose_port_listening(389, 'tcp6'))
results.append(_diagnose_ldap_entry('dc=thisbox'))
results.append(_diagnose_ldap_entry('ou=people'))
results.append(_diagnose_ldap_entry('ou=groups'))
return results
def _diagnose_ldap_entry(search_item):
"""Diagnose that an LDAP entry exists."""
result = 'failed'
try:
subprocess.check_output(['ldapsearch', '-x', '-b', 'dc=thisbox',
search_item])
result = 'passed'
except subprocess.CalledProcessError:
pass
return [_('Check LDAP entry "{search_item}"')
.format(search_item=search_item), result]
@@ -60,8 +60,7 @@
{% endfor %}
</div>
<a href="{% url 'diagnostics:module' 'users' %}"
class="btn btn-default">Run Diagnostics</a>
{% include "diagnostics_button.html" with module="users" %}
</div>
</div>