mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-08-26 12:46:08 +00:00
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:
parent
0febeb7244
commit
4210332bf6
14
actions/ldap
14
actions/ldap
@ -121,17 +121,6 @@ remove_user_from_group()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
diagnose()
|
|
||||||
{
|
|
||||||
result="failed"
|
|
||||||
if lsldap | grep 'dn: dc=thisbox' > /dev/null; then
|
|
||||||
result="passed"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "[[\"Access LDAP server locally\", \"$result\"]]"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
setup()
|
setup()
|
||||||
{
|
{
|
||||||
# XXX: Password setting on users is disabled as changing passwords
|
# XXX: Password setting on users is disabled as changing passwords
|
||||||
@ -174,9 +163,6 @@ case $command in
|
|||||||
remove-user-from-group)
|
remove-user-from-group)
|
||||||
remove_user_from_group "$@"
|
remove_user_from_group "$@"
|
||||||
;;
|
;;
|
||||||
diagnose)
|
|
||||||
diagnose "$@"
|
|
||||||
;;
|
|
||||||
*)
|
*)
|
||||||
echo "Invalid sub-command"
|
echo "Invalid sub-command"
|
||||||
exit -1
|
exit -1
|
||||||
|
|||||||
@ -21,9 +21,11 @@ Plinth module to manage users
|
|||||||
|
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
import json
|
import json
|
||||||
|
import subprocess
|
||||||
|
|
||||||
from plinth import cfg
|
from plinth import cfg
|
||||||
from plinth import actions
|
from plinth import actions
|
||||||
|
from plinth import action_utils
|
||||||
|
|
||||||
depends = ['plinth.modules.system']
|
depends = ['plinth.modules.system']
|
||||||
|
|
||||||
@ -36,6 +38,31 @@ def init():
|
|||||||
|
|
||||||
|
|
||||||
def diagnose():
|
def diagnose():
|
||||||
"""Run diagnostics and result the results."""
|
"""Run diagnostics and return the results."""
|
||||||
output = actions.superuser_run('ldap', ['diagnose'])
|
results = []
|
||||||
return json.loads(output)
|
|
||||||
|
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 %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<a href="{% url 'diagnostics:module' 'users' %}"
|
{% include "diagnostics_button.html" with module="users" %}
|
||||||
class="btn btn-default">Run Diagnostics</a>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user