mirror of
https://github.com/midoks/mdserver-web
synced 2026-11-04 19:16:00 +08:00
update
This commit is contained in:
@@ -1469,8 +1469,7 @@ def addDb():
|
||||
return mw.returnJson(False, '数据库已存在!')
|
||||
|
||||
try:
|
||||
result = pdb.execute("create database `" + dbname +
|
||||
"` DEFAULT CHARACTER SET " + codeing + " COLLATE " + codeStr)
|
||||
result = pdb.execute("create database `" + dbname +"` DEFAULT CHARACTER SET " + codeing + " COLLATE " + codeStr)
|
||||
except Exception as e:
|
||||
result = e
|
||||
# print result
|
||||
@@ -1478,14 +1477,10 @@ def addDb():
|
||||
if isError != None:
|
||||
return isError
|
||||
|
||||
# 清理同名残留用户,失败忽略(兼容DROP USER不支持IF EXISTS的旧版本)
|
||||
try:
|
||||
pdb.execute("drop user '" + dbuser + "'@'localhost'")
|
||||
except Exception:
|
||||
pass
|
||||
for a in address.split(','):
|
||||
db_users_access = getDbUserAccess(dbuser)
|
||||
for user_access in db_users_access:
|
||||
try:
|
||||
pdb.execute("drop user '" + dbuser + "'@'" + a + "'")
|
||||
pdb.execute("drop user `%s`@'%s'" % (db_user, user_access))
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@@ -1518,18 +1513,10 @@ def delDb():
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
users = pdb.query("select Host from user where User='" +
|
||||
username + "' AND Host!='localhost'")
|
||||
except Exception:
|
||||
users = []
|
||||
try:
|
||||
pdb.execute("drop user '" + username + "'@'localhost'")
|
||||
except Exception:
|
||||
pass
|
||||
for us in users:
|
||||
db_users_access = getDbUserAccess(username)
|
||||
for user_access in db_users_access:
|
||||
try:
|
||||
pdb.execute("drop user '" + username + "'@'" + us["Host"] + "'")
|
||||
pdb.execute("drop user '" + username + "'@'%s'" % (user_access,))
|
||||
except Exception:
|
||||
pass
|
||||
pdb.execute("flush privileges")
|
||||
|
||||
@@ -1644,14 +1644,10 @@ def addDb():
|
||||
if isError != None:
|
||||
return isError
|
||||
|
||||
# 清理同名残留用户,失败忽略(兼容DROP USER不支持IF EXISTS的旧版本)
|
||||
try:
|
||||
pdb.execute("drop user '" + dbuser + "'@'localhost'")
|
||||
except Exception:
|
||||
pass
|
||||
for a in address.split(','):
|
||||
db_users_access = getDbUserAccess(dbuser)
|
||||
for user_access in db_users_access:
|
||||
try:
|
||||
pdb.execute("drop user '" + dbuser + "'@'" + a + "'")
|
||||
pdb.execute("drop user `%s`@'%s'" % (db_user, user_access))
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@@ -1684,18 +1680,10 @@ def delDb():
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
users = pdb.query("select Host from mysql.user where User='" +
|
||||
username + "' AND Host!='localhost'")
|
||||
except Exception:
|
||||
users = []
|
||||
try:
|
||||
pdb.execute("drop user '" + username + "'@'localhost'")
|
||||
except Exception:
|
||||
pass
|
||||
for us in users:
|
||||
db_users_access = getDbUserAccess(username)
|
||||
for user_access in db_users_access:
|
||||
try:
|
||||
pdb.execute("drop user '" + username + "'@'" + us["Host"] + "'")
|
||||
pdb.execute("drop user '" + username + "'@'%s'" % (user_access,))
|
||||
except Exception:
|
||||
pass
|
||||
pdb.execute("flush privileges")
|
||||
|
||||
@@ -1856,7 +1856,7 @@ def addDb():
|
||||
db_users_access = getDbUserAccess(dbuser)
|
||||
for user_access in db_users_access:
|
||||
try:
|
||||
pdb.execute("drop user '" + dbuser + "'@'%s'" % (user_access,))
|
||||
pdb.execute("drop user `%s`@'%s'" % (db_user, user_access))
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@@ -2107,17 +2107,14 @@ def setDbRw(version=''):
|
||||
psdb = pSqliteDb('databases')
|
||||
dbname = psdb.where("id=?", (uid,)).getField('name')
|
||||
try:
|
||||
users = pdb.query(
|
||||
"select Host from mysql.user where User='" + username + "'")
|
||||
users = pdb.query("select Host from mysql.user where User='" + username + "'")
|
||||
except Exception as e:
|
||||
return mw.returnJson(-1, str(e))
|
||||
|
||||
# show grants for demo@"127.0.0.1";
|
||||
for x in users:
|
||||
# REVOKE ALL PRIVILEGES ON `imail`.* FROM 'imail'@'127.0.0.1';
|
||||
|
||||
sql = "REVOKE ALL PRIVILEGES ON `" + dbname + \
|
||||
"`.* FROM '" + username + "'@'" + x["Host"] + "';"
|
||||
sql = "REVOKE ALL PRIVILEGES ON `" + dbname + "`.* FROM '" + username + "'@'" + x["Host"] + "';"
|
||||
try:
|
||||
pdb.query(sql)
|
||||
except Exception:
|
||||
|
||||
Reference in New Issue
Block a user