diff options
author | Jo-Philipp Wich <jo@mein.io> | 2019-08-20 15:33:48 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2019-09-10 15:28:16 +0200 |
commit | 0674fc20414e575c346ceb2066ff3af7e8601a48 (patch) | |
tree | 9450fc860f03c0fdff2b92e630d10320e63e999a /modules/luci-base | |
parent | 55b1ae6c9b60164afbccfb6d69db9216898c833e (diff) |
luci-base: rpcd: add getHostname and getTTYDevices calls
Also add IPv6 feature indication.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base')
-rwxr-xr-x | modules/luci-base/root/usr/libexec/rpcd/luci | 46 | ||||
-rw-r--r-- | modules/luci-base/root/usr/share/rpcd/acl.d/luci-base.json | 2 |
2 files changed, 47 insertions, 1 deletions
diff --git a/modules/luci-base/root/usr/libexec/rpcd/luci b/modules/luci-base/root/usr/libexec/rpcd/luci index b895013736..e27149127c 100755 --- a/modules/luci-base/root/usr/libexec/rpcd/luci +++ b/modules/luci-base/root/usr/libexec/rpcd/luci @@ -335,6 +335,7 @@ local methods = { rv.odhcpd = fs.access("/usr/sbin/odhcpd") rv.zram = fs.access("/sys/class/zram-control") rv.sysntpd = fs.readlink("/usr/sbin/ntpd") and true + rv.ipv6 = fs.access("/proc/net/ipv6_route") local wifi_features = { "eap", "11n", "11ac", "11r", "11w", "acs", "sae", "owe", "suiteb192" } @@ -407,6 +408,51 @@ local methods = { return rv end + }, + + getHostname = { + call = function() + local fs = require "nixio.fs" + local hostname, code, err = fs.readfile("/proc/sys/kernel/hostname") + if err then + return { error = err }, 1 + end + return { result = hostname:gsub("\n$", "") } + end + }, + + getTTYDevices = { + args = { with_cdc = false, with_tts = true }, + call = function(args) + local fs = require "nixio.fs" + local iter = fs.glob("/dev/tty[A-Z]*") + local rv = {} + if iter then + local node + for node in iter do + rv[#rv+1] = node + end + end + if args.with_tts then + iter = fs.glob("/dev/tts/*") + if iter then + local node + for node in iter do + rv[#rv+1] = node + end + end + end + if args.with_cdc then + iter = fs.glob("/dev/cdc-wdm*") + if iter then + local node + for node in iter do + rv[#rv+1] = node + end + end + end + return { result = rv } + end } } diff --git a/modules/luci-base/root/usr/share/rpcd/acl.d/luci-base.json b/modules/luci-base/root/usr/share/rpcd/acl.d/luci-base.json index 5ffcbdc2e6..34183da6d8 100644 --- a/modules/luci-base/root/usr/share/rpcd/acl.d/luci-base.json +++ b/modules/luci-base/root/usr/share/rpcd/acl.d/luci-base.json @@ -22,7 +22,7 @@ "read": { "ubus": { "iwinfo": [ "info" ], - "luci": [ "getBoardJSON", "getDUIDHints", "getHostHints", "getIfaddrs", "getInitList", "getLocaltime", "getTimezones", "getDHCPLeases", "getLEDs", "getNetworkDevices", "getUSBDevices" ], + "luci": [ "getBoardJSON", "getDUIDHints", "getHostHints", "getIfaddrs", "getInitList", "getLocaltime", "getTimezones", "getDHCPLeases", "getLEDs", "getNetworkDevices", "getUSBDevices", "getHostname", "getTTYDevices" ], "network.device": [ "status" ], "network.interface": [ "dump" ], "network.wireless": [ "status" ], |