Bug fixes:

Check if ejabberd is installed when running actions triggered by signals.
Encode LDAP passwords as bytes.
This commit is contained in:
James Valleroy 2015-07-20 19:57:10 -04:00 committed by Sunil Mohan Adapa
parent 97220b89f3
commit d144f6634a
3 changed files with 16 additions and 3 deletions

View File

@ -24,6 +24,7 @@ Configuration helper for the ejabberd service
import argparse import argparse
import subprocess import subprocess
import os import os
import shutil
import socket import socket
import re import re
import yaml import yaml
@ -140,6 +141,10 @@ def subcommand_disable(_):
def subcommand_pre_change_hostname(arguments): def subcommand_pre_change_hostname(arguments):
"""Prepare ejabberd for hostname change""" """Prepare ejabberd for hostname change"""
if not shutil.which('ejabberdctl'):
print('ejabberdctl not found. Is ejabberd installed?')
return
old_hostname = arguments.old_hostname old_hostname = arguments.old_hostname
new_hostname = arguments.new_hostname new_hostname = arguments.new_hostname
@ -156,6 +161,10 @@ def subcommand_pre_change_hostname(arguments):
def subcommand_change_hostname(arguments): def subcommand_change_hostname(arguments):
"""Update ejabberd and jwchat with new hostname""" """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') action_utils.service_stop('ejabberd')
subprocess.call(['pkill', '-u', 'ejabberd']) subprocess.call(['pkill', '-u', 'ejabberd'])
@ -182,6 +191,10 @@ def subcommand_change_hostname(arguments):
def subcommand_change_domainname(arguments): def subcommand_change_domainname(arguments):
"""Update ejabberd and jwchat with new domainname""" """Update ejabberd and jwchat with new domainname"""
if not shutil.which('ejabberdctl'):
print('ejabberdctl not found. Is ejabberd installed?')
return
domainname = arguments.domainname domainname = arguments.domainname
if not domainname: if not domainname:
# If new domainname is blank, use hostname instead. # If new domainname is blank, use hostname instead.

View File

@ -69,7 +69,7 @@ than 63 characters in length.'),
actions.superuser_run( actions.superuser_run(
'create-ldap-user', 'create-ldap-user',
[user.get_username()], [user.get_username()],
input=self.cleaned_data['password']) input=self.cleaned_data['password'].encode())
except ActionError: except ActionError:
messages.error(self.request, messages.error(self.request,
_('Creating LDAP user failed.')) _('Creating LDAP user failed.'))

View File

@ -63,7 +63,7 @@ class CreateUserForm(UserCreationForm):
actions.superuser_run( actions.superuser_run(
'create-ldap-user', 'create-ldap-user',
[user.get_username()], [user.get_username()],
input=self.cleaned_data['password1']) input=self.cleaned_data['password1'].encode())
except ActionError: except ActionError:
messages.error(self.request, messages.error(self.request,
_('Creating LDAP user failed.')) _('Creating LDAP user failed.'))
@ -159,7 +159,7 @@ class UserChangePasswordForm(SetPasswordForm):
actions.superuser_run( actions.superuser_run(
'change-ldap-user-password', 'change-ldap-user-password',
[user.get_username()], [user.get_username()],
input=self.cleaned_data['new_password1']) input=self.cleaned_data['new_password1'].encode())
except ActionError: except ActionError:
messages.error( messages.error(
self.request, self.request,