luci-mod-status: switch iptables_dump action to luci.sys.process.exec
authorJo-Philipp Wich <jo@mein.io>
Sun, 2 Dec 2018 19:15:34 +0000 (20:15 +0100)
committerJo-Philipp Wich <jo@mein.io>
Mon, 10 Dec 2018 12:41:34 +0000 (13:41 +0100)
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-mod-status/luasrc/controller/admin/status.lua

index 63b939077574796077b53cdf2bd41ad69da91f68..0d955c95fefac4144428b91c0a6899f980511c67 100644 (file)
@@ -52,22 +52,12 @@ function dump_iptables(family, table)
                local s
                for s in lines do
                        if s == table then
-                               local ipt = io.popen(
-                                       "/usr/sbin/%stables -w -t %s --line-numbers -nxvL"
-                                       %{ prefix, table })
-
-                               if ipt then
-                                       luci.http.prepare_content("text/plain")
-
-                                       while true do
-                                               s = ipt:read(1024)
-                                               if not s then break end
-                                               luci.http.write(s)
-                                       end
-
-                                       ipt:close()
-                                       return
-                               end
+                               luci.http.prepare_content("text/plain")
+                               luci.sys.process.exec({
+                                       "/usr/sbin/%stables" % prefix, "-w", "-t", table,
+                                       "--line-numbers", "-nxvL"
+                               }, luci.http.write)
+                               return
                        end
                end
        end