summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base
diff options
context:
space:
mode:
Diffstat (limited to 'modules/luci-base')
-rwxr-xr-xmodules/luci-base/root/usr/libexec/rpcd/luci95
-rw-r--r--modules/luci-base/root/usr/share/rpcd/acl.d/luci-base.json11
2 files changed, 102 insertions, 4 deletions
diff --git a/modules/luci-base/root/usr/libexec/rpcd/luci b/modules/luci-base/root/usr/libexec/rpcd/luci
index fb15dab6a5..8215fb95dd 100755
--- a/modules/luci-base/root/usr/libexec/rpcd/luci
+++ b/modules/luci-base/root/usr/libexec/rpcd/luci
@@ -590,6 +590,101 @@ local methods = {
}) == 0)
}
end
+ },
+
+ getBlockDevices = {
+ call = function()
+ local fs = require "nixio.fs"
+
+ local block = io.popen("/sbin/block info", "r")
+ if block then
+ local rv = {}
+
+ while true do
+ local ln = block:read("*l")
+ if not ln then
+ break
+ end
+
+ local dev = ln:match("^/dev/(.-):")
+ if dev then
+ local s = tonumber((fs.readfile("/sys/class/block/" .. dev .."/size")))
+ local e = {
+ dev = "/dev/" .. dev,
+ size = s and s * 512
+ }
+
+ local key, val = { }
+ for key, val in ln:gmatch([[(%w+)="(.-)"]]) do
+ e[key:lower()] = val
+ end
+
+ rv[dev] = e
+ end
+ end
+
+ block:close()
+
+ return rv
+ else
+ return { error = "Unable to execute block utility" }
+ end
+ end
+ },
+
+ setBlockDetect = {
+ call = function()
+ return { result = (os.execute("/sbin/block detect > /etc/config/fstab") == 0) }
+ end
+ },
+
+ getMountPoints = {
+ call = function()
+ local fs = require "nixio.fs"
+
+ local fd, err = io.open("/proc/mounts", "r")
+ if fd then
+ local rv = {}
+
+ while true do
+ local ln = fd:read("*l")
+ if not ln then
+ break
+ end
+
+ local device, mount, fstype, options, freq, pass = ln:match("^(%S*) (%S*) (%S*) (%S*) (%d+) (%d+)$")
+ if device and mount then
+ device = device:gsub("\\(%d+)", function(n) return string.char(tonumber(n, 8)) end)
+ mount = mount:gsub("\\(%d+)", function(n) return string.char(tonumber(n, 8)) end)
+
+ local stat = fs.statvfs(mount)
+ if stat and stat.blocks > 0 then
+ rv[#rv+1] = {
+ device = device,
+ mount = mount,
+ size = stat.bsize * stat.blocks,
+ avail = stat.bsize * stat.bavail,
+ free = stat.bsize * stat.bfree
+ }
+ end
+ end
+ end
+
+ fd:close()
+
+ return { result = rv }
+ else
+ return { error = err }
+ end
+ end
+ },
+
+ setUmount = {
+ args = { path = "/mnt" },
+ call = function(args)
+ local util = require "luci.util"
+ return { result = (os.execute(string.format("/bin/umount %s", util.shellquote(args.path))) == 0) }
+ 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 32cb10596b..af06d840d0 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
@@ -25,13 +25,15 @@
"/*": [ "list" ],
"/etc/crontabs/root": [ "read" ],
"/etc/dropbear/authorized_keys": [ "read" ],
+ "/etc/filesystems": [ "read" ],
"/etc/rc.local": [ "read" ],
+ "/proc/filesystems": [ "read" ],
"/proc/sys/kernel/hostname": [ "read" ]
},
"ubus": {
"file": [ "list", "read", "stat" ],
"iwinfo": [ "assoclist", "freqlist", "txpowerlist", "countrylist" ],
- "luci": [ "getBoardJSON", "getDUIDHints", "getHostHints", "getIfaddrs", "getInitList", "getLocaltime", "getTimezones", "getDHCPLeases", "getLEDs", "getNetworkDevices", "getUSBDevices", "getWirelessDevices", "getSwconfigFeatures", "getSwconfigPortState" ],
+ "luci": [ "getBoardJSON", "getDUIDHints", "getHostHints", "getIfaddrs", "getInitList", "getLocaltime", "getTimezones", "getDHCPLeases", "getLEDs", "getNetworkDevices", "getUSBDevices", "getWirelessDevices", "getSwconfigFeatures", "getSwconfigPortState", "getBlockDevices", "getMountPoints" ],
"network.device": [ "status" ],
"network.interface": [ "dump" ],
"network": [ "get_proto_handlers" ],
@@ -45,12 +47,13 @@
"/etc/crontabs/root": [ "write" ],
"/etc/dropbear/authorized_keys": [ "write" ],
"/etc/luci-uploads/*": [ "write" ],
- "/etc/rc.local": [ "write" ]
+ "/etc/rc.local": [ "write" ],
+ "/sbin/block": [ "exec" ]
},
"ubus": {
- "file": [ "write", "remove" ],
+ "file": [ "write", "remove", "exec" ],
"iwinfo": [ "scan" ],
- "luci": [ "setInitAction", "setLocaltime", "setPassword" ],
+ "luci": [ "setInitAction", "setLocaltime", "setPassword", "setBlockDetect", "setUmount" ],
"uci": [ "add", "apply", "confirm", "delete", "order", "set", "rename" ]
},
"uci": [ "*" ]