Skip to content

Commit 4714666

Browse files
committed
bug fix: restore email password
2 parents 6c477c0 + d8cd429 commit 4714666

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

plogical/backupUtilities.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ def startRestore(backupName, dir):
695695
username = email.split("@")[0]
696696
password = emailAccount.find('password').text
697697

698-
result = mailUtilities.createEmailAccount(masterDomain, username, password)
698+
result = mailUtilities.createEmailAccount(masterDomain, username, password, 'restore')
699699
if result[0] == 0:
700700
raise BaseException(result[1])
701701

plogical/mailUtilities.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def AfterEffects(domain):
5656
ProcessUtilities.normalExecutioner(command)
5757

5858
@staticmethod
59-
def createEmailAccount(domain, userName, password):
59+
def createEmailAccount(domain, userName, password, restore = None):
6060
try:
6161

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

141141
if os.path.exists(CentOSPath):
142-
password = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt())
143-
password = '{CRYPT}%s' % (password.decode())
142+
if restore == None:
143+
password = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt())
144+
password = '{CRYPT}%s' % (password.decode())
144145
emailAcct = EUsers(emailOwner=emailDomain, email=finalEmailUsername, password=password)
145146
emailAcct.mail = 'maildir:/home/vmail/%s/%s/Maildir' % (domain, userName)
146147
emailAcct.save()
147148
else:
148-
password = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt())
149-
password = '{CRYPT}%s' % (password.decode())
149+
if restore == None:
150+
password = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt())
151+
password = '{CRYPT}%s' % (password.decode())
150152
emailAcct = EUsers(emailOwner=emailDomain, email=finalEmailUsername, password=password)
151153
emailAcct.mail = 'maildir:/home/vmail/%s/%s/Maildir' % (domain, userName)
152154
emailAcct.save()

0 commit comments

Comments
 (0)