mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 05:45:59 +01:00
bug fix remote access
This commit is contained in:
@@ -16,6 +16,7 @@ import argparse
|
|||||||
from loginSystem.models import Administrator
|
from loginSystem.models import Administrator
|
||||||
import plogical.randomPassword as randomPassword
|
import plogical.randomPassword as randomPassword
|
||||||
from plogical.httpProc import httpProc
|
from plogical.httpProc import httpProc
|
||||||
|
from backup.models import DBUsers
|
||||||
|
|
||||||
class DatabaseManager:
|
class DatabaseManager:
|
||||||
|
|
||||||
@@ -250,12 +251,17 @@ class DatabaseManager:
|
|||||||
db = Databases.objects.filter(dbUser=userName)
|
db = Databases.objects.filter(dbUser=userName)
|
||||||
|
|
||||||
admin = Administrator.objects.get(pk=userID)
|
admin = Administrator.objects.get(pk=userID)
|
||||||
|
|
||||||
if ACLManager.checkOwnership(db[0].website.domain, admin, currentACL) == 1:
|
if ACLManager.checkOwnership(db[0].website.domain, admin, currentACL) == 1:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
return ACLManager.loadErrorJson()
|
return ACLManager.loadErrorJson()
|
||||||
|
|
||||||
mysqlUtilities.allowRemoteAccess(db[0].dbName, userName, remoteIP)
|
# mysqlUtilities.allowRemoteAccess(db[0].dbName, userName, remoteIP)
|
||||||
|
|
||||||
|
mysqlUtilities.createDatabase(db[0].dbName, userName, 'cyberpanel', 0, remoteIP)
|
||||||
|
dbUserInMysql = DBUsers.objects.get(user=userName, host='localhost')
|
||||||
|
mysqlUtilities.changePassword(userName, dbUserInMysql.password, 1, remoteIP)
|
||||||
|
|
||||||
metaData = {'remoteIP': remoteIP}
|
metaData = {'remoteIP': remoteIP}
|
||||||
|
|
||||||
|
|||||||
@@ -804,6 +804,7 @@ class backupUtilities:
|
|||||||
|
|
||||||
if float(version) > 2.0 or float(build) > 0:
|
if float(version) > 2.0 or float(build) > 0:
|
||||||
if path.find('/home/%s/public_html' % masterDomain) == -1:
|
if path.find('/home/%s/public_html' % masterDomain) == -1:
|
||||||
|
|
||||||
#copy_tree('%s/%s-docroot' % (completPath, domain), path)
|
#copy_tree('%s/%s-docroot' % (completPath, domain), path)
|
||||||
|
|
||||||
## First remove if already exists
|
## First remove if already exists
|
||||||
@@ -899,8 +900,10 @@ class backupUtilities:
|
|||||||
if mysqlUtilities.mysqlUtilities.restoreDatabaseBackup(dbName, completPath, password, 1) == 0:
|
if mysqlUtilities.mysqlUtilities.restoreDatabaseBackup(dbName, completPath, password, 1) == 0:
|
||||||
raise BaseException
|
raise BaseException
|
||||||
|
|
||||||
mysqlUtilities.mysqlUtilities.createDatabase(dbName, dbUser, password, 0, dbHost)
|
|
||||||
|
|
||||||
|
### This function will not create database, only database user is created as third value is 0 for createDB
|
||||||
|
|
||||||
|
mysqlUtilities.mysqlUtilities.createDatabase(dbName, dbUser, password, 0, dbHost)
|
||||||
mysqlUtilities.mysqlUtilities.changePassword(dbUser, password, 1, dbHost)
|
mysqlUtilities.mysqlUtilities.changePassword(dbUser, password, 1, dbHost)
|
||||||
|
|
||||||
# UserInMySQLTable = DBUsers.objects.get(user=dbUser, host=dbHost)
|
# UserInMySQLTable = DBUsers.objects.get(user=dbUser, host=dbHost)
|
||||||
|
|||||||
@@ -840,8 +840,6 @@ password=%s
|
|||||||
return 0
|
return 0
|
||||||
cursor.execute("use mysql")
|
cursor.execute("use mysql")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if host != None:
|
if host != None:
|
||||||
LOCALHOST = host
|
LOCALHOST = host
|
||||||
else:
|
else:
|
||||||
@@ -916,18 +914,6 @@ password=%s
|
|||||||
execPath = "/usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/mysqlUtilities.py enableRemoteMYSQL"
|
execPath = "/usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/mysqlUtilities.py enableRemoteMYSQL"
|
||||||
ProcessUtilities.executioner(execPath)
|
ProcessUtilities.executioner(execPath)
|
||||||
|
|
||||||
connection, cursor = mysqlUtilities.setupConnection()
|
|
||||||
|
|
||||||
if connection == 0:
|
|
||||||
return 0
|
|
||||||
cursor.execute("use mysql")
|
|
||||||
|
|
||||||
cursor.execute("update db set Host='%s' where Db='%s'" % (remoteIP, dbName))
|
|
||||||
cursor.execute("update user set Host='%s' where user='%s'" % (remoteIP, userName))
|
|
||||||
cursor.execute("FLUSH PRIVILEGES")
|
|
||||||
|
|
||||||
connection.close()
|
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
except BaseException as msg:
|
except BaseException as msg:
|
||||||
|
|||||||
Reference in New Issue
Block a user