diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPUserManager.m | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/Source/SPUserManager.m b/Source/SPUserManager.m index ede7e7a9..3fe37ae7 100644 --- a/Source/SPUserManager.m +++ b/Source/SPUserManager.m @@ -1156,17 +1156,15 @@ static NSString * const SPTableViewNameColumnID = @"NameColumn"; NSString *dbName = [schemaPriv valueForKey:@"db"]; dbName = [dbName stringByReplacingOccurrencesOfString:@"_" withString:@"\\_"]; - NSString *statement = [NSString stringWithFormat:@"SELECT USER, HOST FROM mysql.db WHERE USER = %@ AND HOST = %@ AND DB = %@", - [[schemaPriv valueForKeyPath:@"user.parent.user"] tickQuotedString], - [[schemaPriv valueForKeyPath:@"user.host"] tickQuotedString], - [dbName tickQuotedString]]; - - NSArray *matchingUsers = [connection getAllRowsFromQuery:statement]; + NSArray *changedKeys = [[schemaPriv changedValues] allKeys]; for (NSString *key in [self privsSupportedByServer]) { if (![key hasSuffix:@"_priv"]) continue; + //ignore anything that we didn't change + if (![changedKeys containsObject:key]) continue; + NSString *privilege = [key stringByReplacingOccurrencesOfString:@"_priv" withString:@""]; NS_DURING @@ -1174,9 +1172,7 @@ static NSString * const SPTableViewNameColumnID = @"NameColumn"; [grantPrivileges addObject:[privilege replaceUnderscoreWithSpace]]; } else { - if ([matchingUsers count] || [grantPrivileges count] > 0) { - [revokePrivileges addObject:[privilege replaceUnderscoreWithSpace]]; - } + [revokePrivileges addObject:[privilege replaceUnderscoreWithSpace]]; } NS_HANDLER NS_ENDHANDLER @@ -1236,10 +1232,15 @@ static NSString * const SPTableViewNameColumnID = @"NameColumn"; NSMutableArray *grantPrivileges = [NSMutableArray array]; NSMutableArray *revokePrivileges = [NSMutableArray array]; + NSArray *changedKeys = [[user changedValues] allKeys]; + for (NSString *key in [self privsSupportedByServer]) { if (![key hasSuffix:@"_priv"]) continue; + //ignore anything that we didn't change + if (![changedKeys containsObject:key]) continue; + NSString *privilege = [key stringByReplacingOccurrencesOfString:@"_priv" withString:@""]; // Check the value of the priv and assign to grant or revoke query as appropriate; do this |