private IEnumerator GetGroupsAndFileOwner() { while (true) { if (virtualSystem.userRegistry != null) { if (virtualSystem.userRegistry.ready) { break; } } yield return(null); } IGC_UserRegistry ur = virtualSystem.userRegistry; if (fileAccessGroups != null) { int i = 0; foreach (string groupName in fileAccessGroups) { IGC_UserGroup group = ur.GetGroup(groupName); if (group != null) { accessGroups.Add(group); } else { fileAccessGroups[i] = "GROUP IS NULL. CHECK /groups"; Debug.LogWarning("group " + groupName + " assigned to IGC_File @ " + virtualSystem.transform.name + " " + path + " does not exist. it was not assigned."); } i++; } } if (fileEditGroups != null) { int i = 0; foreach (string groupName in fileEditGroups) { IGC_UserGroup group = ur.GetGroup(groupName); if (group != null) { editGroups.Add(group); } else { fileEditGroups[i] = "GROUP IS NULL. CHECK /groups"; Debug.LogWarning("group " + groupName + " assigned to IGC_File @ " + virtualSystem.transform.name + " " + path + " does not exist. it was not assigned."); } i++; } } }
private string RemoveUserFromGroup() { if (argv.Length != 4) { return(malformed_error + "\n" + "usage: groups rmuser <group_name> <username>"); } IGC_UserGroup group = registry.GetGroup(argv [2]); if (group == null) { return("group " + argv[2] + " does not exist"); } IGC_User user = registry.GetUser(argv[3]); if (user == null) { return("user " + argv[3] + " does not exist"); } if (!user.groups.Contains(group)) { return(user.name + " is not in " + group.name); } if (!group.admins.Contains(issuer) && !issuer.isAdmin) { return("only system or group administrators can add or remove users"); } if (group.RemoveUser(user, issuer)) { return(user.name + " removed from group " + group.name); } else { return("insufficient privilages or user not in group."); } }
private string GroupActions() { if (argv.Length != 5) { return(malformed_error + "\nusage: file -r|w <add|rm> <groupname> <filename>"); } string action = argv [2]; if (action != "add" && action != "rm") { return("action " + argv[2] + " not understood"); } IGC_UserGroup group = registry.GetGroup(argv [3]); if (group == null) { return(argv[3] + " does not exist"); } IGC_URL url = fs.ParseURL(argv [4], issuer.cwd); IGC_File file = fs.GetFile(url.fullpath); if (file == null) { return(url.fullpath + " does not exist"); } bool writeGroup = argv [1] == "-w"; if (fs.CanAccessFile(file, issuer)) { if (action == "add") { if (writeGroup) { if (file.ApplyEditGroup(group) != null) { return(group.name + " added to " + file.path); } else { return(file.path + " already belongs to " + group.name); } } else { if (file.ApplyAccesGroup(group) != null) { return(group.name + " added to " + file.path); } else { return(file.path + " already belongs to " + group.name); } } } else if (action == "rm") //redundant, but more legible { if (writeGroup) { if (file.RemoveEditGroup(group)) { return(group.name + " removed from " + file.path); } else { return(file.path + " does not belong to " + group.name); } } else { if (file.RemoveAccessGroup(group)) { return(group.name + " removed from " + file.path); } else { return(file.path + " does not belong to " + group.name); } } } } return("you do not have permission to alter this file"); }