Add USER-level SysVar.setString / SysVar.createString JSON-RPC methods - #130
Open
claymore666 wants to merge 1 commit into
Open
Add USER-level SysVar.setString / SysVar.createString JSON-RPC methods#130claymore666 wants to merge 1 commit into
claymore666 wants to merge 1 commit into
Conversation
String is a first-class system-variable type (reported as STRING by SysVar.getAll, creatable via the WebUI), but unlike bool/float/enum it has no typed JSON-RPC create/set method. The only way to create or write a string sysvar over JSON-RPC was ReGa.runScript, which is LEVEL=ADMIN, so string sysvars were effectively admin-only. Add SysVar.createString and SysVar.setString at LEVEL=USER, mirroring the existing enum/float methods. createString sets ValueType(ivtString) + ValueSubType(istChar8859) so the variable is reported as STRING, matching how the WebUI (rega/esp/system.fn) creates string variables. Refs eq-3#129
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds two JSON-RPC methods at
LEVEL=USER, completing the typed system-variable API for the string type:SysVar.createString—{name, init_val, internal, chnID}SysVar.setString—{name, value}Closes #129.
Why
stringis a first-class system-variable type —SysVar.getAllreports it asSTRING, and the WebUI's own editor (rega/pages/tabs/admin/msg/newSysVar.htm) offers it as one of five creatable types. But unlike bool, float, and enum — each of which hasSysVar.create*andSysVar.set*atLEVEL=USER— string had no typed method at all.The only JSON-RPC path to create or write a string sysvar was therefore
ReGa.runScript, which isLEVEL=ADMIN. As a result a normal (USER) account can fully manage bool/float/enum sysvars but cannot create or set a string one without full admin rights. This change removes that asymmetry.How
The two methods mirror the existing enum/float implementations:
createstring.tclmirrorscreateenum.tcl, but setssv.ValueType(ivtString)andsv.ValueSubType(istChar8859)— the same incantation the WebUI uses inrega/esp/system.fn, so the variable is correctly reported asSTRINGbySysVar.getAll.setstring.tclmirrorssetfloat.tcl/setbool.tcl(dom.GetObject(name).State(value)).Registered in
methods.confalongside their enum counterparts, both atLEVEL=USER— consistent with the existingsetBool/setFloat/setEnumprivilege. They expose only typed string access (no arbitrary script execution), so there is no new privilege-escalation surface.Changes
WebUI/www/api/methods/sysvar/createstring.tcl(new)WebUI/www/api/methods/sysvar/setstring.tcl(new)WebUI/www/api/methods.conf(+2 method registrations)Testing
Validated by structural review against the existing enum/float/bool methods and the WebUI's string-creation path. Note: I have not been able to run this against physical CCU hardware — a maintainer round-trip test (
createString→getAllshowstype: STRING→setString→getValue→deleteSysVarByName) as aUSER-level session would be the ideal confirmation before merge.