Skip to content
Permalink
Browse files
bug fix: amazon rds
  • Loading branch information
usmannasir committed Aug 26, 2020
1 parent 7040b3e commit 2404080530d75a875d6519bb4fcaf222b0f7cf86
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
@@ -57,7 +57,10 @@ def createDatabase(dbname, dbuser, dbpassword, publicip):
return 0
else:
if remote:
dropDB = "GRANT ALL PRIVILEGES ON " + dbname + ".* TO '" + dbuser + "'@'%s'" % (publicip)
if mysqlData['mysqlhost'].find('rds.amazon') == -1:
dropDB = "GRANT ALL PRIVILEGES ON " + dbname + ".* TO '" + dbuser + "'@'%s'" % (publicip)
else:
dropDB = "GRANT SELECT, INSERT, DELETE ON " + dbname + ".* TO '" + dbuser + "'@'%s'" % (publicip)
else:
dropDB = "GRANT ALL PRIVILEGES ON " + dbname + ".* TO '" + dbuser + "'@'localhost'"

@@ -26,6 +26,7 @@
class mysqlUtilities:

LOCALHOST = 'localhost'
RDS = 0

@staticmethod
def getPagination(records, toShow):
@@ -67,6 +68,9 @@ def setupConnection():
mysqlport = jsonData['mysqlport']
mysqlhost = jsonData['mysqlhost']

if mysqlhost.find('rds.amazon') > -1:
mysqlUtilities.RDS = 1

## Also set localhost to this server

ipFile = "/etc/cyberpanel/machineIP"
@@ -148,7 +152,12 @@ def allowGlobalUserAccess(globalUser, dbName):
if connection == 0:
return 0

cursor.execute("GRANT ALL PRIVILEGES ON " + dbName + ".* TO '" + globalUser + "'@'%s'" % (mysqlUtilities.LOCALHOST))
if mysqlUtilities.RDS == 0:
cursor.execute("GRANT ALL PRIVILEGES ON " + dbName + ".* TO '" + globalUser + "'@'%s'" % (mysqlUtilities.LOCALHOST))
else:
cursor.execute("GRANT SELECT, INSERT, DELETE ON " + dbName + ".* TO '" + globalUser + "'@'%s'" % (
mysqlUtilities.LOCALHOST))

connection.close()

return 1

0 comments on commit 2404080

Please sign in to comment.