From ebd09332b4330001ecd3a86d1b379e0afc3bafee Mon Sep 17 00:00:00 2001 From: Ayushman Tripathi Date: Mon, 26 Jun 2023 01:23:48 +0530 Subject: luci-app-olsr: migrate to js Signed-off-by: Ayushman Tripathi luci-app-olsr: migrate to js fix XSS vulnerability Signed-off-by: Ayushman Tripathi luci-app-olsr: migrate to js luci-app-olsr: migrate to js fix minor bugs Signed-off-by: Ayushman Tripathi luci-app-olsr: migrate to js luci-app-olsr: migrate to js fix plugins bugs Signed-off-by: Ayushman Tripathi luci-app-olsr: migrate to js luci-app-olsr: migrate to js fix interfaces bugs Signed-off-by: Ayushman Tripathi luci-app-olsr: migrate to js luci-app-olsr: migrate to js fix interface & snr bugs Signed-off-by: Ayushman Tripathi luci-app-olsr: migrate to js luci-app-olsr: migrate to js fix hostname Signed-off-by: Ayushman Tripathi luci-app-olsr: migrate to js luci-app-olsr: migrate to js fix typo Signed-off-by: Ayushman Tripathi luci-app-olsr: migrate to js luci-app-olsr: migrate to js fix missing files, use rpc for hostnames, remove luci-compat Signed-off-by: Ayushman Tripathi luci-app-olsr: migrate to js luci-app-olsr: migrate to js fix menu order Signed-off-by: Ayushman Tripathi luci-app-olsr: migrate to js --- .../luci-app-olsr/root/usr/libexec/rpcd/olsrinfo | 78 ++++++++++++++++++++ .../share/luci/menu.d/luci-app-olsr-backend.json | 86 ++++++++++++++++++++++ .../share/luci/menu.d/luci-app-olsr-frontend.json | 72 ++++++++++++++++++ .../rpcd/acl.d/luci-app-olsr-unauthenticated.json | 20 +++++ .../root/usr/share/rpcd/acl.d/luci-app-olsr.json | 30 +++++++- 5 files changed, 283 insertions(+), 3 deletions(-) create mode 100755 applications/luci-app-olsr/root/usr/libexec/rpcd/olsrinfo create mode 100644 applications/luci-app-olsr/root/usr/share/luci/menu.d/luci-app-olsr-backend.json create mode 100644 applications/luci-app-olsr/root/usr/share/luci/menu.d/luci-app-olsr-frontend.json create mode 100644 applications/luci-app-olsr/root/usr/share/rpcd/acl.d/luci-app-olsr-unauthenticated.json (limited to 'applications/luci-app-olsr/root/usr') diff --git a/applications/luci-app-olsr/root/usr/libexec/rpcd/olsrinfo b/applications/luci-app-olsr/root/usr/libexec/rpcd/olsrinfo new file mode 100755 index 0000000000..831a964202 --- /dev/null +++ b/applications/luci-app-olsr/root/usr/libexec/rpcd/olsrinfo @@ -0,0 +1,78 @@ +#!/bin/sh +. /usr/share/libubox/jshn.sh +. /lib/functions.sh + +HOSTSFILE="-1" + +find_hosts_config() { + local cfg="$1" + + config_get library "$cfg" library + if [ "$library" != "olsrd_nameservice" ]; then + return 1 + fi + config_get hosts_file "$cfg" hosts_file + HOSTSFILE=$hosts_file +} + +load_hosts() { + config_load olsrd + config_foreach find_hosts_config LoadPlugin + local hosts4=$(cat $HOSTSFILE) + HOSTSFILE="" + config_load olsrd6 + config_foreach find_hosts_config LoadPlugin + if [ -f "$HOSTSFILE" ]; then + local hosts6=$(cat "$HOSTSFILE") + else + local hosts6="" + fi + local hosts="$hosts4$hosts6" + json_init + json_add_string hosts "$hosts" + json_dump +} + +case "$1" in +list) + json_init + json_add_object "getjsondata" + json_add_string 'otable' 'String' + json_add_int 'v4_port' 'Integer' + json_add_int 'v6_port' 'Integer' + json_close_object + json_add_object "hasipip" + json_close_object + json_add_object "hosts" + json_close_object + json_dump + ;; +call) + case "$2" in + getjsondata) + json_init + json_load "$(cat)" + json_get_var otable otable + json_get_var v4_port v4_port + json_get_var v6_port v6_port + + jsonreq4=$(echo "/${otable}" | nc 127.0.0.1 "${v4_port}" | sed -n '/^[}{ ]/p' 2>/dev/null) + jsonreq6=$(echo "/${otable}" | nc ::1 "${v6_port}" | sed -n '/^[}{ ]/p' 2>/dev/null) + + json_init + json_add_string "jsonreq4" "$jsonreq4" + json_add_string "jsonreq6" "$jsonreq6" + json_dump + ;; + hasipip) + result=$(ls /etc/modules.d/ | grep -E "[0-9]*-ipip") + json_init + json_add_string "result" "$result" + json_dump + ;; + hosts) + load_hosts + ;; + esac + ;; +esac diff --git a/applications/luci-app-olsr/root/usr/share/luci/menu.d/luci-app-olsr-backend.json b/applications/luci-app-olsr/root/usr/share/luci/menu.d/luci-app-olsr-backend.json new file mode 100644 index 0000000000..9daa5c72ff --- /dev/null +++ b/applications/luci-app-olsr/root/usr/share/luci/menu.d/luci-app-olsr-backend.json @@ -0,0 +1,86 @@ +{ + "admin/services/olsrd": { + "title": "OLSR IPv4", + "order": 5, + "depends": { + "acl": ["luci-app-olsr"] + }, + "action": { + "type": "view", + "path": "olsr/frontend/olsrd" + } + }, + "admin/services/olsrd/display": { + "title": "Display", + "order": 10, + "action": { + "type": "view", + "path": "olsr/frontend/olsrddisplay" + } + }, + "admin/services/olsrd/iface": { + "order": 10, + "action": { + "type": "view", + "path": "olsr/frontend/olsrdiface" + } + }, + "admin/services/olsrd/hna": { + "title": "HNA Announcements", + "order": 15, + "action": { + "type": "view", + "path": "olsr/frontend/olsrdhna" + } + }, + "admin/services/olsrd/plugins": { + "title": "Plugins", + "order": 20, + "action": { + "type": "view", + "path": "olsr/frontend/olsrdplugins" + } + }, + "admin/services/olsrd6": { + "title": "OLSR IPv6", + "order": 5, + "depends": { + "acl": ["luci-app-olsr"] + }, + "action": { + "type": "view", + "path": "olsr/frontend/olsrd6" + } + }, + "admin/services/olsrd6/display": { + "title": "Display", + "order": 10, + "action": { + "type": "view", + "path": "olsr/frontend/olsrddisplay" + } + }, + "admin/services/olsrd6/iface": { + "order": 10, + "action": { + "type": "view", + "path": "olsr/frontend/olsrdiface6" + } + }, + "admin/services/olsrd6/hna": { + "title": "HNA Announcements", + "order": 15, + "action": { + "type": "view", + "path": "olsr/frontend/olsrdhna6" + } + }, + "admin/services/olsrd6/plugins": { + "title": "Plugins", + "order": 20, + "action": { + "type": "view", + "path": "olsr/frontend/olsrdplugins6" + } + } +} diff --git a/applications/luci-app-olsr/root/usr/share/luci/menu.d/luci-app-olsr-frontend.json b/applications/luci-app-olsr/root/usr/share/luci/menu.d/luci-app-olsr-frontend.json new file mode 100644 index 0000000000..2c1f055e2d --- /dev/null +++ b/applications/luci-app-olsr/root/usr/share/luci/menu.d/luci-app-olsr-frontend.json @@ -0,0 +1,72 @@ +{ + "olsr": { + "title": "OLSR", + "order": 5, + "action": { + "type": "firstchild" + } + }, + "olsr/neighbours": { + "title": "Neighbours", + "order": 15, + "action": { + "type": "view", + "path": "olsr/status-olsr/neighbors" + } + }, + "olsr/routes": { + "title": "Routes", + "order": 20, + "action": { + "type": "view", + "path": "olsr/status-olsr/routes" + } + }, + "olsr/topology": { + "title": "Topology", + "order": 25, + "action": { + "type": "view", + "path": "olsr/status-olsr/topology" + } + }, + "olsr/hna": { + "title": "HNA", + "order": 30, + "action": { + "type": "view", + "path": "olsr/status-olsr/hna" + } + }, + "olsr/mid": { + "title": "MID", + "order": 35, + "action": { + "type": "view", + "path": "olsr/status-olsr/mid" + } + }, + "olsr/interface": { + "title": "Interface", + "order": 35, + "action": { + "type": "view", + "path": "olsr/status-olsr/interfaces" + } + }, + "olsr/smartgw": { + "title": "SmartGW", + "order": 40, + "action": { + "type": "view", + "path": "olsr/status-olsr/smartgw" + } + }, + "olsr/error_olsr": { + "order": 45, + "action": { + "type": "view", + "path": "olsr/status-olsr/error_olsr" + } + } +} diff --git a/applications/luci-app-olsr/root/usr/share/rpcd/acl.d/luci-app-olsr-unauthenticated.json b/applications/luci-app-olsr/root/usr/share/rpcd/acl.d/luci-app-olsr-unauthenticated.json new file mode 100644 index 0000000000..66bd8b7372 --- /dev/null +++ b/applications/luci-app-olsr/root/usr/share/rpcd/acl.d/luci-app-olsr-unauthenticated.json @@ -0,0 +1,20 @@ +{ + "unauthenticated": { + "description": "Grant read access", + "read": { + "ubus": { + "uci": ["get"], + "luci-rpc": ["*"], + "network.interface": ["dump"], + "network": ["get_proto_handlers"], + "olsrd": ["olsrd_jsoninfo"], + "olsrd6": ["olsrd_jsoninfo"], + "olsrinfo": ["getjsondata", "hasipip", "hosts"], + "file": ["read"], + "iwinfo": ["assoclist"] + + }, + "uci": ["luci_olsr", "olsrd", "olsrd6", "network", "network.interface"] + } + } +} diff --git a/applications/luci-app-olsr/root/usr/share/rpcd/acl.d/luci-app-olsr.json b/applications/luci-app-olsr/root/usr/share/rpcd/acl.d/luci-app-olsr.json index 246afbc941..11c6946727 100644 --- a/applications/luci-app-olsr/root/usr/share/rpcd/acl.d/luci-app-olsr.json +++ b/applications/luci-app-olsr/root/usr/share/rpcd/acl.d/luci-app-olsr.json @@ -2,10 +2,34 @@ "luci-app-olsr": { "description": "Grant UCI access for luci-app-olsr", "read": { - "uci": [ "luci_olsr", "olsrd", "olsrd6" ] + "ubus": { + "luci-rpc": [ + "*" + ], + "olsrinfo": [ + "getjsondata", + "hasipip" + ] + }, + "file": { + "/etc/modules.d": [ + "list", + "read" + ], + "/usr/lib": [ "list" ] + }, + "uci": [ + "luci_olsr", + "olsrd", + "olsrd6" + ] }, "write": { - "uci": [ "luci_olsr", "olsrd", "olsrd6" ] + "uci": [ + "luci_olsr", + "olsrd", + "olsrd6" + ] } } -} +} \ No newline at end of file -- cgit v1.2.3