summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2013-01-01 21:16:29 +0000
committerTed Trask <ttrask01@yahoo.com>2013-01-01 21:16:29 +0000
commit13d27723c1b8400cdfec8227199d596e1b0a8949 (patch)
tree73e5e2f80a0bc0e883f5b9d55dad32f238b29193
parent2a5206459e07932adb07ed90e7cc100198034b89 (diff)
downloadacf-openssh-13d27723c1b8400cdfec8227199d596e1b0a8949.tar.bz2
acf-openssh-13d27723c1b8400cdfec8227199d596e1b0a8949.tar.xz
Replace io.popen with modelfunctions.run_executable
-rw-r--r--openssh-model.lua20
1 files changed, 7 insertions, 13 deletions
diff --git a/openssh-model.lua b/openssh-model.lua
index 2ca966c..b7cde44 100644
--- a/openssh-model.lua
+++ b/openssh-model.lua
@@ -12,7 +12,6 @@ local configfile = "/etc/ssh/sshd_config"
local processname = "sshd"
local packagename = "openssh"
local header = "SSH"
-local path="PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin "
-- ################################################################################
-- LOCAL FUNCTIONS
@@ -130,12 +129,10 @@ function list_conn_peers()
local ps = {}
local who = {}
config = read_config()
- local f = io.popen( path .. 'netstat -lnaW' )
- local flines = format.search_for_lines(f:read("*a") or "", "ESTABLISHED")
- f:close()
- local g = io.popen( path .. 'netstat -laW' )
- local glines = format.search_for_lines(g:read("*a") or "", "ESTABLISHED")
- g:close()
+ local f = modelfunctions.run_executable({"netstat", "-lnaW"})
+ local flines = format.search_for_lines(f, "ESTABLISHED")
+ local g = modelfunctions.run_executable({"netstat", "-laW"})
+ local glines = format.search_for_lines(g, "ESTABLISHED")
for i,line in ipairs(flines) do
local loc, peer = string.match(line, "^%S+%s+%S+%s+%S+%s+(%S+)%s+(%S+)")
if loc then
@@ -151,15 +148,12 @@ function list_conn_peers()
end
end
- local f = io.popen( path .. 'ps' )
- for i,line in ipairs(format.search_for_lines(f:read("*a") or "", "sshd:")) do
+ f = modelfunctions.run_executable({"ps"})
+ for i,line in ipairs(format.search_for_lines(f, "sshd:")) do
table.insert(ps, string.match(line,"@(%S+)"))
end
- f:close()
- local f = io.popen( path .. 'who' )
- local who = f:read("*a") or ""
- f:close()
+ local who = modelfunctions.run_executable({"who"})
for peer,v in pairs(netstat) do
if not (netstat[peer].tty) then netstat[peer].tty = {} end
for line in string.gmatch(who, "[^\n]+") do