diff --git a/IncBackups/IncBackupsControl.py b/IncBackups/IncBackupsControl.py index 10b8f5a96..73d94a3cd 100644 --- a/IncBackups/IncBackupsControl.py +++ b/IncBackups/IncBackupsControl.py @@ -461,14 +461,17 @@ class IncJobs(multi.Thread): userToTry = mysqlUtilities.mysqlUtilities.fetchuser(items.dbName) + if userToTry == 0 or userToTry == 1: + continue + try: dbuser = DBUsers.objects.get(user=userToTry) except: dbusers = DBUsers.objects.all().filter(user=userToTry) for it in dbusers: - if it.find('_') > -1: - dbuser = it - break + dbuser = it + break + databaseXML = Element('database') diff --git a/databases/databaseManager.py b/databases/databaseManager.py index 52ec9aad3..e915a5147 100755 --- a/databases/databaseManager.py +++ b/databases/databaseManager.py @@ -190,10 +190,10 @@ class DatabaseManager: userName = data['dbUserName'] dbPassword = data['dbPassword'] - db = Databases.objects.get(dbUser=userName) + db = Databases.objects.filter(dbUser=userName) admin = Administrator.objects.get(pk=userID) - if ACLManager.checkOwnership(db.website.domain, admin, currentACL) == 1: + if ACLManager.checkOwnership(db[0].website.domain, admin, currentACL) == 1: pass else: return ACLManager.loadErrorJson() diff --git a/plogical/backupUtilities.py b/plogical/backupUtilities.py index dacbf0d93..3fcd121c4 100755 --- a/plogical/backupUtilities.py +++ b/plogical/backupUtilities.py @@ -115,15 +115,18 @@ class backupUtilities: userToTry = mysqlUtilities.mysqlUtilities.fetchuser(items.dbName) + if userToTry == 0 or userToTry == 1: + continue + try: dbuser = DBUsers.objects.get(user=userToTry) except: try: dbusers = DBUsers.objects.all().filter(user=userToTry) for it in dbusers: - if it.find('_') > -1: - dbuser = it - break + dbuser = it + break + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( 'While creating backup for %s, we failed to backup database %s. Error message: %s' % ( diff --git a/plogical/mysqlUtilities.py b/plogical/mysqlUtilities.py index b3aeab14d..77ea5b9e3 100755 --- a/plogical/mysqlUtilities.py +++ b/plogical/mysqlUtilities.py @@ -727,13 +727,11 @@ password=%s return 0 @staticmethod - def fetchuser(userName): + def fetchuser(databaseName): try: connection, cursor = mysqlUtilities.setupConnection() cursor.execute("use mysql") - - database = Databases.objects.get(dbUser=userName) - databaseName = database.dbName + database = Databases.objects.get(dbName=databaseName) databaseName = databaseName.replace('_', '\_') query = "select user from db where db = '%s'" % (databaseName) @@ -748,6 +746,7 @@ password=%s if row[0].find('_') > -1: database.dbUser = row[0] database.save() + try: connection.close() except: diff --git a/plogical/upgrade.py b/plogical/upgrade.py index 0f45cce02..2d6c7638a 100755 --- a/plogical/upgrade.py +++ b/plogical/upgrade.py @@ -526,6 +526,11 @@ class Upgrade: except: pass + try: + cursor.execute('alter table databases_databases drop index dbUser;') + except: + pass + try: cursor.execute("ALTER TABLE loginSystem_administrator ADD state varchar(15) DEFAULT 'ACTIVE'") except: