Skip to content

Add USER-level SysVar.setString / SysVar.createString JSON-RPC methods - #130

Open
claymore666 wants to merge 1 commit into
eq-3:masterfrom
claymore666:feature/sysvar-string-methods
Open

Add USER-level SysVar.setString / SysVar.createString JSON-RPC methods#130
claymore666 wants to merge 1 commit into
eq-3:masterfrom
claymore666:feature/sysvar-string-methods

Conversation

@claymore666

Copy link
Copy Markdown

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

string is a first-class system-variable type — SysVar.getAll reports it as STRING, 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 has SysVar.create* and SysVar.set* at LEVEL=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 is LEVEL=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.tcl mirrors createenum.tcl, but sets sv.ValueType(ivtString) and sv.ValueSubType(istChar8859) — the same incantation the WebUI uses in rega/esp/system.fn, so the variable is correctly reported as STRING by SysVar.getAll.
  • setstring.tcl mirrors setfloat.tcl/setbool.tcl (dom.GetObject(name).State(value)).

Registered in methods.conf alongside their enum counterparts, both at LEVEL=USER — consistent with the existing setBool/setFloat/setEnum privilege. 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 (createStringgetAll shows type: STRINGsetStringgetValuedeleteSysVarByName) as a USER-level session would be the ideal confirmation before merge.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

USER-level string system-variable methods (SysVar.setString / createString)

1 participant