Skip to content

Commit 2404080

Browse files
committed
bug fix: amazon rds
1 parent 7040b3e commit 2404080

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

install/mysqlUtilities.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ def createDatabase(dbname, dbuser, dbpassword, publicip):
5757
return 0
5858
else:
5959
if remote:
60-
dropDB = "GRANT ALL PRIVILEGES ON " + dbname + ".* TO '" + dbuser + "'@'%s'" % (publicip)
60+
if mysqlData['mysqlhost'].find('rds.amazon') == -1:
61+
dropDB = "GRANT ALL PRIVILEGES ON " + dbname + ".* TO '" + dbuser + "'@'%s'" % (publicip)
62+
else:
63+
dropDB = "GRANT SELECT, INSERT, DELETE ON " + dbname + ".* TO '" + dbuser + "'@'%s'" % (publicip)
6164
else:
6265
dropDB = "GRANT ALL PRIVILEGES ON " + dbname + ".* TO '" + dbuser + "'@'localhost'"
6366

plogical/mysqlUtilities.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
class mysqlUtilities:
2727

2828
LOCALHOST = 'localhost'
29+
RDS = 0
2930

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

71+
if mysqlhost.find('rds.amazon') > -1:
72+
mysqlUtilities.RDS = 1
73+
7074
## Also set localhost to this server
7175

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

151-
cursor.execute("GRANT ALL PRIVILEGES ON " + dbName + ".* TO '" + globalUser + "'@'%s'" % (mysqlUtilities.LOCALHOST))
155+
if mysqlUtilities.RDS == 0:
156+
cursor.execute("GRANT ALL PRIVILEGES ON " + dbName + ".* TO '" + globalUser + "'@'%s'" % (mysqlUtilities.LOCALHOST))
157+
else:
158+
cursor.execute("GRANT SELECT, INSERT, DELETE ON " + dbName + ".* TO '" + globalUser + "'@'%s'" % (
159+
mysqlUtilities.LOCALHOST))
160+
152161
connection.close()
153162

154163
return 1

0 commit comments

Comments
 (0)