Commit Graph

167 Commits

Author SHA1 Message Date
Liangbin Lian 5ad9c3609e luci-base: rpc: fix luci/getMountPoints crash
getMountPoints crash on path containing '\xxx'.

`char` should be `chr`

Fixes https://github.com/openwrt/openwrt/issues/21459

Signed-off-by: Liangbin Lian <jjm2473@gmail.com>
2026-01-09 21:52:18 +01:00
Paul Donald b6d43252f4 luci-base: add odhcp6c stats to luci ucode
Provides odhcp6c statistics of DHCPv6 request and response traffic

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2025-12-08 15:02:38 +01:00
Paul Donald 89b55a7ae0 luci-base: shell quote package name variable to prevent command injection
Do not export the function for use elsewhere - it shall only be used within
the luci script (to determine netifd version).

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2025-11-05 22:11:17 +01:00
Paul Donald 9293433212 luci-base: extend luci WiFi features checks
sort list
include mesh

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2025-11-03 22:38:52 +01:00
Paul Donald 0a6180d1cc luci-base: remodel the LogreadBox after the syslog viewer
Remodeled the CBILogreadBox after the syslog viewer. Also
updated to use ubus log read, and drops the use of the logread binary
(logread is broken on snapshots). The JSON output from ubus is nice
enough to work with.

One potential drawback is that all log entries are sent to the browser
(as it always has been), and no on-device pre-filtering is available yet
except for line count.

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2025-10-20 21:11:10 +02:00
Paul Donald 54432996bb luci-base: rename getLocaltime to getUnixtime
There appear to be no consumers of getLocaltime. One instance of a
callGetLocaltime uses the system info call whose localtime property uses
tm->tm_gmtoff which is "Seconds East of UTC" i.e. a unixtime value
with the timezone baked in to the value.

Sometimes we actually want Unixtime. So rename to clarify what this
function actually returns.

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2025-10-17 13:44:25 +02:00
David Härdeman 50abd15e88 luci-mod-status,-network: remove checkUfpInstalled
Right now, the checkUfpInstalled RPC call is performed first, and only after
that can the other Promises be called. Simplify this by adding a single check
for /usr/sbin/ufpd in the rpcd ucode, and replace calls to checkUfpInstalled()
with simple L.hasSystemFeature('ufpd') check (which is only done once, and
cached).

This also allows the 'stat' permission to be removed from a couple of acls.

Signed-off-by: David Härdeman <david@hardeman.nu>
2025-10-16 01:24:42 +02:00
David Härdeman 90f10d6980 luci-base: add odhcpd feature detection
For dnsmasq, feature detection is currently supported like this:

	L.hasSystemFeature('dnsmasq', 'dhcpv6')

while for odhcpd, only a basic check is supported:

	L.hasSystemFeature('odhcpd')

With this patch, a similar feature check is also possible for odhcpd,
e.g.:

	L.hasSystemFeature('odhcpd', 'dhcpv6')

Signed-off-by: David Härdeman <david@hardeman.nu>
2025-10-10 19:04:07 +02:00
Paul Donald f5da7a6016 luci-base: implement Virtual Routing and Forwarding (VRF) options
VRF in netifd is now in main. See:
https://github.com/openwrt/netifd/pull/38/
https://github.com/openwrt/openwrt/commit/15c2ca0a834752cc9505751fc6d2f51861d34dfd

VRF netifd management was added to 24.10 in
https://github.com/openwrt/openwrt/pull/19125

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2025-06-17 00:08:06 +02:00
Paul Donald def988495a luci-base: detect WiFi availability - useful for non-WiFi devices
Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2024-12-22 00:39:46 +00:00
Paul Donald 7fe0218bcf luci-base: rename mii-tool object property to mii_tool
otherwise ucode function call breaks with:

RPC call to luci/getInitList failed with error -32000: Object not found

Follow-up fix to ab15b5e379

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2024-12-19 22:38:23 +00:00
Paul Donald ab15b5e379 luci-mod-network: gate bonding behind kmod presence
The kmod install link only displays in new device dialogues so as not
to be too prominent.

Closes #6996
Closes #7086

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2024-12-19 18:44:47 +00:00
Mustafa Can Elmacı ae8bbb814f treewide: HTML Cleanup
* HTML Cleanup: Meta tags.
* Converted charset to shorthand.
* Removed meta tags with `Content-Script-Type` attribute. (Invalid in HTML5 spec.)

* HTML Cleanup: CSS tags.
* Removed `type` attribute with CSS files from link tags. (HTML5 spec recommends omitting it.)
* Removed `type` attribute from style tags. (Deprecated in HTML5 spec.)
https://html.spec.whatwg.org/#attr-link-type
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style

* HTML Cleanup: Convert from XHTML to HTML5
* Removed XML declaration.
* Removed XML namespace.
* Changed doctype to HTML5.

* HTML Cleanup: CDATA tags.
* CDATA sections should not be used within HTML they are considered as comments and not displayed.
https://developer.mozilla.org/en-US/docs/Web/API/CDATASection

* HTML Cleanup: Script tags.
* Removed `language` attribute from script tags. (No longer valid in HTML5)
* Removed `type` attribute with JavaScript MIME type from script tags. (HTML5 spec recommends omitting it.)
https://html.spec.whatwg.org/multipage/scripting.html#attr-script-type
https://mimesniff.spec.whatwg.org/#javascript-mime-type

Signed-off-by: Mustafa Can Elmacı <mustafacan@elmaci.net>
2024-11-22 22:39:46 +01:00
Christian Marangi 591911d172 luci-base: add APK as detectable feature
Add APK as detectable feature so that generic luci-app-pkg can detect
OPKG or APK package manager.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
2024-10-24 00:04:47 +02:00
Rudy Andram 383edb4d6d luci-wireless: Add 11be support
Tested with filogic banana rpi4 / QNAP qualcommax ipq8074

Signed-off-by: Rudy Andram <rmandrad@gmail.com>
Tested-By: Daniel Pawlik <pawlik.dan@gmail.com>
2024-10-07 19:29:35 +02:00
Michael Yartys c082d458ed luci-base: add hostapd ocv feature flag
Required for luci to check whether installed hostapd or wpa_supplicant is
built with the Operating Channel Validation feature.

Signed-off-by: Michael Yartys <mail@yartys.no>
2024-07-26 01:48:12 +02:00
Florian Eckert 8f2dfa7058 luci-base: always add ucitrack independently of uci config
It is possible that the uci configuration file will be added to the system
later. Therefore, ucitrack json definitions are always added to ucitrack
triggers and it is not checked whether the uci configuration file exists.

Reported-by: Chen Minqiang <ptpt52@gmail.com>
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-04-29 08:57:30 +02:00
Florian Eckert 4cffc9fd63 luci-base: move and rename ucitrack luci_splash.json
Move the json file to where it belongs.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-04-11 16:15:52 +02:00
Florian Eckert 29678071f3 luci-base: move and rename ucitrack system.json
Move the json file to where it belongs.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-04-11 16:15:52 +02:00
Florian Eckert 549cecb0c5 luci-base: move and rename ucitrack odhcpd.json
Move the json file to where it belongs.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-04-11 16:15:52 +02:00
Florian Eckert cc44632367 luci-base: move and rename ucitrack firewall.json
Move the json file to where it belongs.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-04-11 16:15:52 +02:00
Florian Eckert e3c6eb2e44 luci-base: move and rename ucitrack dropbear.json
Move the json file to where it belongs.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-04-11 16:15:52 +02:00
Florian Eckert 4a95439531 luci-base: move and rename ucitrack dhcp.json
Move the json file to where it belongs.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-04-11 16:15:52 +02:00
Florian Eckert 5bc03b7274 luci-base: move and rename ucitrack upnp.json
Move the json file to where it belongs.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-04-11 16:15:52 +02:00
Florian Eckert c15b0bf513 luci-base: move and rename ucitrack fstab.json
Move the json file to where it belongs.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-04-11 16:15:52 +02:00
Florian Eckert a26eefd77c luci-base: move and rename ucitrack samba.json
Move the json file to where it belongs.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-04-11 16:15:52 +02:00
Florian Eckert a197b80270 luci-base: move and rename ucitrack network.json
Move the json file to where it belongs.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-04-11 16:15:52 +02:00
Florian Eckert 014b65786b luci-base: move and rename ucitrack wireless.json
Move the json file to where it belongs.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-04-11 16:15:52 +02:00
Florian Eckert bfe486e3bc luci-base: move and rename ucitrack qos.json
Move the json file to where it belongs.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-04-11 16:15:52 +02:00
Florian Eckert 706d8af9cc luci-base: move and rename ucitrack tinyproxy.json
Move the json file to where it belongs.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-04-11 16:15:52 +02:00
Florian Eckert ad73ffbce9 luci-base: remove deprecated ucitrack olsr.json
In the whole OpenWrt there is no olsr uci config, this must be a leftover
and can therefore be deleted.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-04-11 16:15:52 +02:00
Florian Eckert d7300c56b1 luci-base: remove deprecated ucitrack ntpclient.json
In the whole OpenWrt there is no ntpclient uci config, this must be a
leftover and can therefore be deleted.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-04-11 16:15:52 +02:00
Florian Eckert c36ec4d3ed luci-base: remove deprecated ucitrack httpd.json
In the whole OpenWrt there is no httpd uci config, this must be a leftover
from before uhttpd and can therefore be deleted.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-04-11 16:15:52 +02:00
Florian Eckert 411e78fc85 luci-base: delete unused luci-reload command
This script is no longer needed and can therefore be deleted.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-04-11 16:15:12 +02:00
Florian Eckert a55b601f37 luci-base: use json for ucitrack instead of uci
The 'ucitrack' configuration under '/etc/config' defines which service must
be restarted on a LuCI change. This uci file defines how all this works
together. Additionally there are 'uci-defaults' scripts in the various
applications that add additional configurations parameters to this ucitrack
file if a service must be reloaded/restarted on a LuCI change.

There are some problems with the current implementation:

* The uci should be used to configure the system and not for this kind of
  reload/restart dependency handling on LuCI changes.
* On a system update with configuration restore of the 'ucitrack' file
  the new behavior on LuCI reload/restart could not take into account
  because the new file is *not* used.

This commit converts the handling from uci to json.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-04-11 15:49:44 +02:00
Andre Heider 12378d77ce luci-base: extend Expires directive to prevent caching
Some browsers apparently act on fixed dates only, so add that too.
Tested on firefox.

Signed-off-by: Andre Heider <a.heider@gmail.com>
2024-02-17 18:03:31 +01:00
Jo-Philipp Wich 98e37433e7 luci-base: rpc: add call to enumerate builtin ethernet ports
Add a new luci/getBuiltinEthernetPorts RPC call which returns a consolidated
list of known ethernet ports found in `/etc/board.json`.

Add an x86/64 specific workaround which attempts to enumerate missing
ethernet devices too.

Ref: #6534, #6538
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2023-08-24 16:48:01 +02:00
Paul Dee 2c3018d426 luci-base: grammar fixes
Login (n) -> Log (v) in

Logout (n) -> Log (v) out

Signed-off-by: Paul Dee <itsascambutmailmeanyway@gmail.com>
2023-08-11 13:17:04 +02:00
Jo-Philipp Wich ad3509bf3b luci-base: rpcd: handle swap entries in getBlockDevices
Add entries from `/proc/swaps` to the result array as well in order to
let the ui properly deal with swap files.

Fixes: #6350
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2023-04-28 14:55:09 +02:00
Andre Heider 05f2901ffb luci-base: add a hostapd 11ax feature flag
Required for luci to check if it can acually offer that mode.

Signed-off-by: Andre Heider <a.heider@gmail.com>
2023-01-23 14:51:28 +01:00
Andre Heider 6914468e56 luci-base: remove the hostapd 11n feature flag
This feature flag doesn't exist anymore, see this commit on the main repo:
7c63295bf4 "treewide: remove DRIVER_11N_SUPPORT"

Signed-off-by: Andre Heider <a.heider@gmail.com>
2023-01-23 14:51:28 +01:00
Jo-Philipp Wich a27d2dbc32 luci-base, luci-mod-status: expose LuCI version via ubus
Instead of scraping the LuCI version from Lua sources, fetch it via ubus
in order to be independent from the Lua runtime.

Fixes: #6154
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-12-17 15:01:46 +01:00
Jo-Philipp Wich 2cbfd64dcb luci-base: fix ubus luci/getConntrackHelpers reporting with firewall3
The uci package name used to iterate the loaded configuration sections
must correspond to the file name being loaded.

Fixes: https://github.com/openwrt/openwrt/issues/11215
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-11-10 22:49:07 +01:00
Jo-Philipp Wich 7e30a5e11e luci-base: don't fail getInitList if no indexes can be determined
Gracefully handle missing indexes in the luci rpcd plugin getInitList
procedure.

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
Andre Heider a398ccfde6 luci-base: remove 'dsl' feature flag
This is now unused.

Signed-off-by: Andre Heider <a.heider@gmail.com>
2022-10-21 09:08:13 +02:00
Daniel Kucera 34dd31ae9a proper cache control in firefox
Added more meta headers to ensure proper cache control in Firefox.
Before this patch, the `/` url hasn't even been requested when opened in Firefox.

Signed-off-by: Daniel Kucera <daniel.kucera@gmail.com>
2022-09-17 07:18:52 +02:00
Jo-Philipp Wich e1932592c3 luci-base: use different cookie names for HTTP and HTTPS
Since HTTP cookies may not overwrite HTTPS ("secure") ones, users are
frequently unable to log into LuCI when a stale, "secure" `sysauth` cookie
is still present in the browser as it commonly happens after e.g. a
sysupgrade operation or when frequently jumping between HTTP and HTTPS
access.

Rework the dispatcher to set either a `sysauth_http` or `sysauth_https`
cookie, depending on the HTTPS state of the server connection and accept
both cookie names when verifying the session ID.

This allows users to log into a HTTP-only LuCI instance while a stale,
"secure" HTTPS cookie is still present.

Requires commit 2b0539ef9d ("lucihttp: update to latest Git HEAD") to
function properly.

Fixes: #5843
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-07-08 15:38:53 +02:00
Jo-Philipp Wich 111c551cdb luci-base: fix DSL feature detection
On boards with ADSL instead of VDSL support we need to expect an
`/sbin/dsl_cpe_control` instead of an `/sbin/vdsl_cpe_control` executable.

Ref: https://forum.openwrt.org/t/dsl-line-stats/126580
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-05-03 14:55:00 +02:00
Jo-Philipp Wich 7110635134 luci-base: ucitrack: fix broken affects logic
Changes on a given configuration should trigger change events on affected
configurations, not the other way around.

Fixes: #5745
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-03-30 14:12:38 +02:00