From d144f6634ad2ff44e8cebcc22836f44c49f8e651 Mon Sep 17 00:00:00 2001 From: James Valleroy Date: Mon, 20 Jul 2015 19:57:10 -0400 Subject: [PATCH] Bug fixes: Check if ejabberd is installed when running actions triggered by signals. Encode LDAP passwords as bytes. --- actions/xmpp | 13 +++++++++++++ plinth/modules/first_boot/forms.py | 2 +- plinth/modules/users/forms.py | 4 ++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/actions/xmpp b/actions/xmpp index 996dc7762..ab9e0b286 100755 --- a/actions/xmpp +++ b/actions/xmpp @@ -24,6 +24,7 @@ Configuration helper for the ejabberd service import argparse import subprocess import os +import shutil import socket import re import yaml @@ -140,6 +141,10 @@ def subcommand_disable(_): def subcommand_pre_change_hostname(arguments): """Prepare ejabberd for hostname change""" + if not shutil.which('ejabberdctl'): + print('ejabberdctl not found. Is ejabberd installed?') + return + old_hostname = arguments.old_hostname new_hostname = arguments.new_hostname @@ -156,6 +161,10 @@ def subcommand_pre_change_hostname(arguments): def subcommand_change_hostname(arguments): """Update ejabberd and jwchat with new hostname""" + if not shutil.which('ejabberdctl'): + print('ejabberdctl not found. Is ejabberd installed?') + return + action_utils.service_stop('ejabberd') subprocess.call(['pkill', '-u', 'ejabberd']) @@ -182,6 +191,10 @@ def subcommand_change_hostname(arguments): def subcommand_change_domainname(arguments): """Update ejabberd and jwchat with new domainname""" + if not shutil.which('ejabberdctl'): + print('ejabberdctl not found. Is ejabberd installed?') + return + domainname = arguments.domainname if not domainname: # If new domainname is blank, use hostname instead. diff --git a/plinth/modules/first_boot/forms.py b/plinth/modules/first_boot/forms.py index caee55abd..5c8a62a32 100644 --- a/plinth/modules/first_boot/forms.py +++ b/plinth/modules/first_boot/forms.py @@ -69,7 +69,7 @@ than 63 characters in length.'), actions.superuser_run( 'create-ldap-user', [user.get_username()], - input=self.cleaned_data['password']) + input=self.cleaned_data['password'].encode()) except ActionError: messages.error(self.request, _('Creating LDAP user failed.')) diff --git a/plinth/modules/users/forms.py b/plinth/modules/users/forms.py index 669f4d955..97698dfcc 100644 --- a/plinth/modules/users/forms.py +++ b/plinth/modules/users/forms.py @@ -63,7 +63,7 @@ class CreateUserForm(UserCreationForm): actions.superuser_run( 'create-ldap-user', [user.get_username()], - input=self.cleaned_data['password1']) + input=self.cleaned_data['password1'].encode()) except ActionError: messages.error(self.request, _('Creating LDAP user failed.')) @@ -159,7 +159,7 @@ class UserChangePasswordForm(SetPasswordForm): actions.superuser_run( 'change-ldap-user-password', [user.get_username()], - input=self.cleaned_data['new_password1']) + input=self.cleaned_data['new_password1'].encode()) except ActionError: messages.error( self.request,