public override string command_function()
    {
        IGC_UserRegistry ur = virtualSystem.userRegistry;

        if (argv.Length > 2)
        {
            if (!ur.users.ContainsKey(argv[1]))
            {
                return("user '" + argv[1] + "' does not exist");
            }

            InGameComputer terminal = issuer == null ? virtualSystem.terminal : issuer.terminal;

            IGC_User checkLoggedIn = ur.GetUser(argv[1]);

            if (ur.loggedInUsers.Contains(checkLoggedIn))
            {
                return(argv[1] + " is already logged in");
            }

            if (issuer != null)
            {
                if (issuer.terminal != null)
                {
                    if (issuer.terminal.currentUser != null)
                    {
                        if (issuer.loggedInRemotely)
                        {
                            ur.loggedInUsers.Remove(issuer);                             //the logout function will bounce the user back to their own terminal so here, if remotelogged, we will keep things simple
                        }
                        else
                        {
                            virtualSystem.userRegistry.Logout(issuer.terminal.currentUser);
                        }
                    }
                }
            }

            IGC_User user = ur.Login(argv [1], argv [2], terminal);

            if (user != null)
            {
                return("welcome, " + user.name);
            }
            else
            {
                return("password incorrect, try again");
            }
        }
        else
        {
            return("error: command malformed\n" + usage);
        }
    }
Beispiel #2
0
    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++;
            }
        }
    }
Beispiel #3
0
    public override string command_function()
    {
        registry = virtualSystem.userRegistry;

        if (argv.Length == 1)
        {
            return("users: " + string.Join(", ", registry.ListUsers()));
        }

        if (argv.Length > 1)
        {
            keyword = argv[1];
            return(UserActions());
        }
        return("");
    }
Beispiel #4
0
    private IEnumerator SetCurrenUserWhenURReady(IGC_UserRegistry ur, string currentuser, string prevuser)
    {
        while (!ur.ready)
        {
            yield return(null);
        }

        //set current user
        if (!string.IsNullOrEmpty(currentuser) && currentuser != "null")
        {
            currentUser          = virtualSystem.userRegistry.users[currentuser];
            currentUser.terminal = this;
            UpdateInfoLine();
        }

        //set prev user
        if (!string.IsNullOrEmpty(prevuser) && prevuser != "null")
        {
            this.previousUser = currentUser.terminal.gameObject.GetComponent <IGC_VirtualSystem>().userRegistry.users[prevuser];
        }
    }
Beispiel #5
0
    public override string command_function()
    {
        registry = virtualSystem.userRegistry;
        fs       = virtualSystem.fileSystem;

        if (argv.Length > 1)
        {
            keyword = argv[1];
            switch (keyword)
            {
            case "-w": return(GroupActions());

            case "-r": return(GroupActions());

            case "-p": return(ProtectedYN());;

            default: return(FileInfo());
            }
        }

        return(malformed_error + "\nusage: file -<g|p> ...");
    }
    void Awake()
    {
        GenerateUniqueID();

        if (IP == "")
        {
            GenerateIP();
        }
        else
        {
            hasPermanentIP = true;
        }

        if (eraseSaveDataOnStart || !hasPermanentIP)
        {
            EraseSaveData();
            gameObject.GetComponent <InGameComputer>().EraseSaveData();
        }

        terminal     = gameObject.GetComponent <InGameComputer> ();
        userRegistry = gameObject.GetComponent <IGC_UserRegistry> ();
        fileSystem   = gameObject.GetComponent <IGC_FileSystem> ();
    }
    public override string command_function()
    {
        //terminal
        string termOutput = "___TERMINAL___\n";

        InGameComputer igc = issuer.terminal;

        termOutput += "instance id: " + igc.instanceID + "\n";
        termOutput += "current power state: " + igc.powerState + "\n";
        termOutput += "login name/pass: "******"/" + issuer.terminal.loginPass + "\n";
        termOutput += "start in on state: " + igc.startInOnState + "\n";
        termOutput += "current user: "******"null") + "\n";
        termOutput += "bounce back user: "******"null") + "\n";
        termOutput += "remote login: "******"\n";
        termOutput += "in use: " + igc.inUse + "\n";
        termOutput += "terminal occupied: " + igc.terminalOccupied + "\n";
        termOutput += "booting up: " + igc.bootingUp + "\n";
        termOutput += "network ready: " + igc.networkReady + "\n";

        //shell
        string shellOutput = "___SHELL___\n";

        IGC_Shell sh = issuer.terminal.shell;

        shellOutput += "display width/height: " + sh.displayWidth + "/" + sh.displayHeight + "\n";
        shellOutput += "prompt width: " + sh.promptWidth + "\n";
        shellOutput += "language: " + sh.lang.LangName + "\n";
        shellOutput += "terminal id: " + sh.computer.instanceID + "\n";
        shellOutput += "input mode: " + sh.inputMode + "\n";
        shellOutput += "capslock: " + sh.capslock + "\n";
        shellOutput += "ctrl: " + sh.ctrl + "\n";
        shellOutput += "history count: " + sh.history.Count + "\n";
        shellOutput += "cursor offset x/y: " + sh.cursorOffset + "/" + sh.cursorOffsetVertical + "\n";
        shellOutput += "display line offset: " + sh.lineOffset + "\n";
        shellOutput += "last edited: " + (sh.lastEditedFile != null ? sh.lastEditedFile.path : "null") + "\n";
        shellOutput += "raw edit string len: " + sh.rawEditString.Length + "\n";
        shellOutput += "raw display text len: " + sh.rawDisplayText.Length + "\n";
        shellOutput += "formatted display len: " + sh.output.text.Length + "\n";
        shellOutput += "raw prompt text len: " + sh.rawPromptText.Length + "\n";
        shellOutput += "formatted prompt len: " + sh.prompt.text.Length + "\n";
        shellOutput += "infoline len: " + sh.infoLine.text.Length + "\n";


        //virtual system
        string vsOutput = "___VIRTUAL SYSTEM___\n";

        IGC_VirtualSystem vs = virtualSystem;

        vsOutput += "instance id: " + vs.instanceID + "\n";
        vsOutput += "model name: " + vs.modelName + "\n";
        vsOutput += "ip: " + vs.IP + "\n";
        vsOutput += "permanent ip: " + vs.hasPermanentIP + "\n";
        vsOutput += "language: " + vs.language.LangName + "\n";
        vsOutput += "startup stasks complete: " + vs.startUpTasksComplete + "\n";
        vsOutput += "network ready: " + vs.networkReady + "\n";
        vsOutput += "erase save data on start: " + vs.eraseSaveDataOnStart + "\n";
        vsOutput += "resore data len: " + vs.restoreData.Length + "\n";

        //userregistry
        string urOutput = "___USER REGISTRY___\n";

        IGC_UserRegistry ur = virtualSystem.userRegistry;

        urOutput += "virtual system id: " + ur.virtualSystem.instanceID + "\n";
        urOutput += "ready for use: " + ur.ready + "\n";
        urOutput += "users logged in: " + ur.loggedInUsers.Count + "\n";
        urOutput += "users: " + ur.users.Count + "\n";
        urOutput += "groups: " + ur.groups.Count + "\n";
        urOutput += "users editor string: \n" + string.Join("\n", ur.usersList) + "\n";
        urOutput += "groups editor string: \n" + string.Join("\n", ur.groupsList) + "\n";

        //file system
        string fsOutput = "___FILE SYSTEM___\n";

        IGC_FileSystem fs = virtualSystem.fileSystem;

        fsOutput += "virtual system id: " + fs.virtualSystem.instanceID + "\n";
        fsOutput += "ready for use: " + fs.ready + "\n";
        fsOutput += "files: " + fs.files.Count + "\n";
        fsOutput += "root node: " + fs.rootNode.name + "\n";

        //unique game instance id
        string gameID = "unique game instance id: " + IGC_VirtualSystem.uniqueID + "\n";

        string output = "";

        if (flags.Count > 0)
        {
            foreach (var k in flags.Keys)
            {
                if (k == "g")
                {
                    output = gameID;
                }
                if (k == "t")
                {
                    output = termOutput;
                }
                if (k == "s")
                {
                    output = shellOutput;
                }
                if (k == "vs")
                {
                    output = vsOutput;
                }
                if (k == "fs")
                {
                    output = fsOutput;
                }
                if (k == "ur")
                {
                    output = urOutput;
                }
            }
            if (output == "")
            {
                return("flag(s) not recognised");
            }
        }
        else
        {
            output = gameID + termOutput + shellOutput + vsOutput + urOutput + fsOutput;
        }

        issuer.terminal.shell.EnterViewMode(output);

        return("");
    }