Commit graph

18 commits

Author SHA1 Message Date
Jo-Philipp Wich
18b637fed9 luci-lua-runtime: dispatcher.lua: re-add post_on() dispatch action
Existing legacy Lua controllers still use the `post_on()` node dispatch
action, so restore this functionality.

Fixes: #6531
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2023-08-21 15:44:36 +02:00
Jo-Philipp Wich
2fd74a8239 luci-lua-runtime: dispatcher.lua: re-add test_post_security()
While no LuCI code utilizes this function anymore, some existing legacy
Lua controllers expect the function to exist, so restore it.

Fixes: #6532
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2023-08-21 15:35:41 +02:00
Jo-Philipp Wich
2a9c3a3173 luci-lua-runtime: fix legacy luci-mod-rpc authentication
The legacy RPC module authentication fixup was improperly ported into the
Lua dispatcher stub module, rendering legacy RPC authentication broken.

Additionally, the split of the former `sysauth` cookie into `sysauth_http`
and `sysauth_https` ones was also imposed upon the RPC module, without
leaving the option to use just `sysauth` in place, so allow this cookie
name again for the legacy RPC logins.

Fixes: #6333
Fixes: e1932592c3 ("luci-base: use different cookie names for HTTP and HTTPS")
Fixes: ded8ccf93e ("luci-base-ucode: add initial ucode based LuCI runtime")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2023-04-30 00:27:47 +02:00
Jo-Philipp Wich
fa17c1573f luci-base, luci-lua-runtime: adjust Lua template environment
To maintain full compatibility with the old Lua runtime, templates
rendered from a menu `template()` action must implicitly inherit the
`luci.dispatcher` namespace as scope while other indirectly included
templates must not.

Fixes: #6105
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-11-21 12:27:28 +01:00
Jo-Philipp Wich
08ae8d40a9 luci-base, luci-lua-runtime: fix "dispatched" and "requested" properties
Ensure to properly emulate the "dispatched" and "requested" properties
which refer to the executed and initially resolved menu node respectivey.

Also stop exposing a `node` property in Lua context to maintain full
compatibility with the old Lua runtime.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-11-21 12:24:31 +01:00
Jo-Philipp Wich
a1ee78fa69 luci-lua-runtime: proxy all dispatcher context property accesses
The ucode side dispatcher environment might not be fully populated yet
when the emulated Lua dispatcher is loaded, leading to `context.requested`
and some other properties to be `nil`.

Expose all properties through metatable `__index` lookups instead to
ensure that the Lua side dispatcher always sees the latest values.

Fixes: #6100
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-11-15 19:49:05 +01:00
Jo-Philipp Wich
0141732f87 luci-lua-runtime: preload luci.ltn12
Some existing legacy code expects the luci.ltn12 namespace to be implicitly
available, even without requiring it beforehand.

Fixes: #6091
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-11-11 00:42:14 +01:00
Jo-Philipp Wich
1da816ddf2 luci-lua-runtime: dispatcher.lua: translate legacy node "target" property
Some legacy Lua controllers declare menu entries by first invoking `node()`
and then setting the `.target` property on the resulting object.

Make sure to properly translate such menu nodes into the internal menu
JSON representation.

Fixes: #6090
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-11-10 22:33:38 +01:00
Jo-Philipp Wich
fd7427c4e5 luci-lua-runtime: also search luci.dispatcher scope when looking up values
Some legacy templates access dispatcher functions such as `build_url()`
without explicit scope, which worked in the old runtime since the template
view namespace was instantiated from the dispatcher.

Ensure that this continues to function in the emulated runtime.

Fixes: #6082
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-11-09 20:37:54 +01:00
Karl Palsson
37468c99a3 lua-runtime: template: fix "tpl" refactoring
This fixes crashes on "tpl" being undefined.

Signed-off-by: Karl Palsson <karlp@etactica.com>
2022-11-08 15:23:10 +00:00
Jo-Philipp Wich
a98e2ea17d luci-lua-runtime: render cbi header/footer templates via ucode runtime
Trigger rendering of CBI header and footer templates via the ucode runtime
`include()` in order to ensure that scope data is properly inherited from
Lua templates (`cbi/header`) including ucode templates (`header`).

This fixes automatic triggering of the config apply flow on legacy Lua CBI
forms.

Ref: https://github.com/openwrt/luci/pull/6056#issuecomment-1292396588
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-10-26 22:02:16 +02:00
Jo-Philipp Wich
81f204d38f luci-lua-runtime: fix loading header/footer templates for SimpleForms
Fixes: #6054
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-10-26 15:30:11 +02:00
Jo-Philipp Wich
ca57291bdd luci-lua-runtime: ensure proper forwarding of route arguments to cbi action
Ensure that the optional cbi() `config` argument is set to an empty table
if unspecified to ensure that the static call argument array is exactly
two elements long, otherwise call arguments are shifted and the invoked
method might not receive the expected parameter.

This fixes, among others, the dispatching of `arcombine()` targets.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-10-26 15:12:17 +02:00
Jo-Philipp Wich
94dd7fdf60 luci-lua-runtime: drop Lua server gateway modules
Remove the uhttpd and CGI gateway modules as they're not compatible with
the Lua compat stub runtime anymore.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-10-25 01:03:37 +02:00
Jo-Philipp Wich
18ee34def2 luci-lua-runtime: preload luci.sys
Some existing model code expects the luci.sys namespace to be implicitly
available, even without requiring it beforehand.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-10-25 01:03:37 +02:00
Jo-Philipp Wich
c7b300e614 luci-lua-runtime: add compatibility template for legacy Lua status includes
Add a compatibility template containing legacy Lua logic extracted from
the luci-mod-status main status page in order to free the status module
from any explicit or implicit Lua dependencies.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-10-25 01:03:37 +02:00
Jo-Philipp Wich
b15d768c9a luci.mk: automatically depend on luci-lua-runtime
Make packages having a non-empty luasrc/ directory automatically depend
on the LuCI Lua runtime package.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-10-25 01:03:37 +02:00
Jo-Philipp Wich
673f38246a treewide: separate Lua runtime resources
Move classes required for Lua runtime support into a new `luci-lua-runtime`
package. Also replace the `luci.http` and `luci.util` classes in
`luci-lib-base` with stubbed versions interacting with the ucode based
runtime environment.

Finally merge `luci-base-ucode` into the remainders of `luci-base`.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-10-25 01:03:37 +02:00