Skip to content
Permalink
Browse files

bug fix: Correctly store databases and users for cPanel Importer

  • Loading branch information...
usmannasir committed Sep 8, 2019
1 parent f7cb9bd commit 9652510e6618f3054dc25ca159ee76f8acb9a213
Showing with 30 additions and 4 deletions.
  1. +8 −1 filemanager/filemanager.py
  2. +1 −1 plogical/acl.py
  3. +21 −2 plogical/cPanelImporter.py
@@ -193,11 +193,18 @@ def copy(self):
if not self.data['newPath'].find(self.data['home']) > -1:
return self.ajaxPre(0, 'Not allowed to move in this path, please choose location inside home!')

if len(self.data['fileAndFolders']) == 1:
command = 'yes| cp -Rf %s %s' % (self.returnPathEnclosed(self.data['basePath']+ '/' + self.data['fileAndFolders'][0]), self.data['newPath'])
ProcessUtilities.executioner(command, website.externalApp)
self.changeOwner(self.data['newPath'])
json_data = json.dumps(finalData)
return HttpResponse(json_data)

command = 'mkdir ' + self.returnPathEnclosed(self.data['newPath'])
ProcessUtilities.executioner(command, website.externalApp)

for item in self.data['fileAndFolders']:
command = 'cp -R ' + self.returnPathEnclosed(self.data['basePath'] + '/' + item) + ' ' + self.returnPathEnclosed(self.data['newPath'] + '/' + item)
command = '%scp -Rf ' % ('yes |') + self.returnPathEnclosed(self.data['basePath'] + '/' + item) + ' ' + self.returnPathEnclosed(self.data['newPath'])
ProcessUtilities.executioner(command, website.externalApp)

self.changeOwner(self.data['newPath'])
@@ -519,7 +519,7 @@ def checkOwnershipZone(domain, admin, currentACL):

if currentACL['admin'] == 1:
return 1
elif domain.admin.admin == admin:
elif domain.admin == admin:
return 1
elif domain.admin.owner == admin.pk:
return 1
@@ -628,7 +628,7 @@ def RestoreDatabases(self):
logging.statusWriter(self.logFile, message, 1)

try:
cursor.execute("CREATE DATABASE " + items.replace('.sql', ''))
cursor.execute("CREATE DATABASE `%s`" % (items.replace('.sql', '')))
except BaseException, msg:
message = 'Failed while restoring database %s from backup file %s, error message: %s' % (items.replace('.sql', ''), self.backupFile, str(msg))
logging.statusWriter(self.logFile, message, 1)
@@ -644,7 +644,26 @@ def RestoreDatabases(self):

website = Websites.objects.get(domain=self.mainDomain)

db = Databases(website=website, dbName=items.replace('.sql', ''), dbUser=items.replace('.sql', ''))
## Trying to figure out dbname

CommandsPath = '%s/mysql.sql' % (CompletPathToExtractedArchive)

data = open(CommandsPath, 'r').readlines()

for inItems in data:
if inItems.find('GRANT ALL PRIVILEGES') > -1 and inItems.find('localhost') > -1 and inItems.find('_test') == -1:
cDBName = inItems.split('`')[1].replace('\\', '')
logging.statusWriter(self.logFile, inItems, 1)
if cDBName == items.replace('.sql', ''):
cDBUser = inItems.split("'")[1]
message = 'Database user for %s is %s.' % (cDBName, cDBUser)
logging.statusWriter(self.logFile, message, 1)
if Databases.objects.filter(dbUser=cDBUser).count() > 0:
continue
break


db = Databases(website=website, dbName=items.replace('.sql', ''), dbUser=cDBUser)
db.save()

message = 'MySQL dump successfully restored for %s.' % (items.replace('.sql', ''))

0 comments on commit 9652510

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