/* ========================================================================= * * Nanite Systems Advanced Research Encapsulation System * * Copyright (c) 2022–2024 Nanite Systems Corporation * * ========================================================================= * * Security System Module * * This program is covered under the terms of the ARES Software Copyright * License, Section 1 (ASCL-i). It is offered to you on a limited basis to * facilitate modification and customization. * * To see the full text of the ASCL, type 'help license' on any standard * ARES distribution, or visit http://nanite-systems.com/ASCL for the * current version. * * DISCLAIMER * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS * IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. * * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY * DAMAGES HOWEVER CAUSED ON ANY THEORY OF LIABILITY ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * * ========================================================================= * */ #include #include #define CLIENT_VERSION ARES_VERSION #define CLIENT_VERSION_TAGS ARES_VERSION_TAGS integer recognition_inhibited; integer allow_time = 30; key name_lookup_pipe; list name_lookup_queue; list RANK_LIST = [0, 0, 0, "user", "manager", "owner", "self", "?"]; list RULE_TERMINOLOGY = ["nobody","all","consent","user","manager","owner","self","cycle","toggle"]; main(integer src, integer n, string m, key outs, key ins, key user) { @restart_main; if(n == SIGNAL_INVOKE) { list argv = split(m, " "); integer argc = count(argv); string msg = ""; string target; key identified_owner = getdbl("id", ["owner"]); integer identified_owner_affected; if(argc == 1) { msg = "ARES security status\n\nType '" + PROGRAM_NAME + " help' for a quick syntax guide or 'help security' for the full manual page.\n"; print(outs, user, msg); list topics = ["ban", "guest", "user"]; integer ti = 3; while(ti--) { string topic = gets(topics, ti); list people = jskeys(getdbl("security", [topic])); if(count(people)) { msg = llChar(llOrd(topic, 0) & 0x5f) + substr(topic, 1, LAST) + "s:\n"; integer pi = count(people); while(pi--) { string person = gets(people, pi); integer pvalue = (integer)getdbl("security", [topic, person]); string spvalue = "indefinite"; if(topic == "user") { spvalue = gets(RANK_LIST, pvalue); } else if(pvalue > 1600000000) { if(pvalue < llGetUnixTime()) { spvalue = "expired"; deletedbl("security", [topic, person]); } else { spvalue = "expires in " + format_time(pvalue - llGetUnixTime()); } } msg += " - secondlife:///app/agent/" + person + "/about (" + spvalue + ")\n"; } } else { msg = "No " + topic + "s configured.\n"; } llSleep(0.0625); print(outs, user, msg); } msg = ""; } else { string topic; target = gets(argv, 2); string action = gets(argv, 1); if(action == "yes" || action == "no" || action == "trust" || action == "block") { key h = (key)target; string request = getjs(tasks_queue, [h]); if(user != avatar) { tell(user, 0, "Only the unit may respond to consent prompts."); } else if(request != JSON_INVALID) { key subject = getjs(request, [2]); key s_outs = getjs(request, [3]); string callsign = getdbl("id", ["callsign"]); string s_msg; if(action == "yes" && !recognition_inhibited) { setdbl("security", ["guest", (string)subject], (string)(llGetUnixTime() + allow_time)); s_msg = "You have been granted access to " + callsign + " for " + (string)allow_time + " seconds."; } else if(action == "no") { setdbl("security", ["ban", (string)subject], (string)(llGetUnixTime() + allow_time)); s_msg = "You have been denied access to " + callsign + " for " + (string)allow_time + " seconds."; } else if(action == "trust" && !recognition_inhibited) { setdbl("security", ["guest", (string)subject], "1"); s_msg = "You have been granted access to " + callsign + " indefinitely."; } else if(action == "block") { setdbl("security", ["ban", (string)subject], "1"); s_msg = "You have been denied access to " + callsign + " indefinitely."; } print(s_outs, subject, s_msg); if(recognition_inhibited && (action == "yes" || action == "trust")) echo("Consent failed due to radiation interference. Instruct operator to try again."); else echo("[" + PROGRAM_NAME + "] implementing consent decision (" + action + ")"); string outcome; if(action == "no" || action == "block" || recognition_inhibited) outcome = getjs(request, [1]); else outcome = getjs(request, [0]); if(outcome != "") invoke(outcome, s_outs, NULL_KEY, subject); task_end(h); jump add_name; } else { echo("No pending consent request: " + (string)h); } } else if(action == "help") { msg = "Syntax: \n\n" + " " + PROGRAM_NAME + " yes|no|trust|block : Respond to a consent prompt.\n" + " " + PROGRAM_NAME + " user|manager|owner : Add or update a user.\n" + " " + PROGRAM_NAME + " guest|ban [