Skip to content
Permalink
Browse files

bug fix: restore email password

  • Loading branch information
usmannasir committed Dec 16, 2019
2 parents 6c477c0 + d8cd429 commit 4714666048a476baeff09c75e6b47c75d004785d
Showing with 8 additions and 6 deletions.
  1. +1 −1 plogical/backupUtilities.py
  2. +7 −5 plogical/mailUtilities.py
@@ -695,7 +695,7 @@ def startRestore(backupName, dir):
username = email.split("@")[0]
password = emailAccount.find('password').text

result = mailUtilities.createEmailAccount(masterDomain, username, password)
result = mailUtilities.createEmailAccount(masterDomain, username, password, 'restore')
if result[0] == 0:
raise BaseException(result[1])

@@ -56,7 +56,7 @@ def AfterEffects(domain):
ProcessUtilities.normalExecutioner(command)

@staticmethod
def createEmailAccount(domain, userName, password):
def createEmailAccount(domain, userName, password, restore = None):
try:

## Check if already exists
@@ -139,14 +139,16 @@ def createEmailAccount(domain, userName, password):
CentOSPath = '/etc/redhat-release'

if os.path.exists(CentOSPath):
password = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt())
password = '{CRYPT}%s' % (password.decode())
if restore == None:
password = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt())
password = '{CRYPT}%s' % (password.decode())
emailAcct = EUsers(emailOwner=emailDomain, email=finalEmailUsername, password=password)
emailAcct.mail = 'maildir:/home/vmail/%s/%s/Maildir' % (domain, userName)
emailAcct.save()
else:
password = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt())
password = '{CRYPT}%s' % (password.decode())
if restore == None:
password = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt())
password = '{CRYPT}%s' % (password.decode())
emailAcct = EUsers(emailOwner=emailDomain, email=finalEmailUsername, password=password)
emailAcct.mail = 'maildir:/home/vmail/%s/%s/Maildir' % (domain, userName)
emailAcct.save()

0 comments on commit 4714666

Please sign in to comment.
You can’t perform that action at this time.