Skip to content

Commit

Permalink
bug fix: amazon rds
Browse files Browse the repository at this point in the history
  • Loading branch information
usmannasir committed Aug 26, 2020
1 parent 7040b3e commit 2404080
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 4 additions & 1 deletion install/mysqlUtilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'"

Expand Down
11 changes: 10 additions & 1 deletion plogical/mysqlUtilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
class mysqlUtilities:

LOCALHOST = 'localhost'
RDS = 0

@staticmethod
def getPagination(records, toShow):
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2404080

Please sign in to comment.