summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--openssh-connectedpeers-html.lsp47
-rw-r--r--openssh-controller.lua5
-rw-r--r--openssh-model.lua47
-rw-r--r--openssh-status-html.lsp3
-rw-r--r--openssh-welcome-html.lsp10
-rw-r--r--openssh.menu2
-rw-r--r--openssh.roles2
7 files changed, 112 insertions, 4 deletions
diff --git a/openssh-connectedpeers-html.lsp b/openssh-connectedpeers-html.lsp
new file mode 100644
index 0000000..6cf24b1
--- /dev/null
+++ b/openssh-connectedpeers-html.lsp
@@ -0,0 +1,47 @@
+<% local data = ...
+require("viewfunctions")
+--[[
+io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>")
+io.write(html.cfe_unpack(data))
+io.write("</span>")
+--]]
+%>
+
+<H1>Connected peers</H1>
+<DL>
+<%
+local col1="180px"
+for k,v in pairs(data) do
+ io.write("<H3><IMG SRC='/skins/static/tango/16x16/devices/computer.png' HEIGHT='16' WIDTH='16'> " .. (tostring(v.host) or "unkown") .. "</H3>")
+ io.write("<TABLE>")
+ for i=1, v.cnt do
+ io.write("<TR>")
+ if (v.tty[i]) then
+ io.write("<TD WIDTH='20px' STYLE='padding-left:20px;vertical-align:top;'><IMG SRC='/skins/static/tango/16x16/apps/utilities-terminal.png' HEIGHT='16' WIDTH='16'></TD>")
+ io.write("<TD STYLE='padding-bottom:10px'>")
+ io.write("<TABLE>")
+ io.write("<TR><TD WIDTH='"..col1.."' STYLE='font-weight:bold;'>Session TTY:</TD><TD>".. tostring(v.tty[i]['tty']) .. "</TD></TR>")
+ io.write("<TR><TD WIDTH='"..col1.."' STYLE='font-weight:bold;'>Session Started:</TD><TD>".. tostring(v.tty[i]['time']) .. "</TD></TR>")
+ io.write("<TR><TD WIDTH='"..col1.."' STYLE='font-weight:bold;'>Session Idle:</TD><TD>".. tostring(v.tty[i]['idle']) .. "</TD></TR>")
+
+ io.write("</TABLE>")
+ io.write("</TD>")
+
+ else
+ io.write("<TD WIDTH='20px' STYLE='padding-left:20px;vertical-align:top;'><IMG SRC='/skins/static/tango/16x16/emblems/emblem-unreadable.png' HEIGHT='16' WIDTH='16'></TD>")
+ io.write("<TD STYLE='padding-bottom:10px'>")
+ io.write("<TABLE>")
+ io.write("<TR><TD WIDTH='"..col1.."' STYLE='font-weight:bold;'>Session TTY:</TD><TD>No records</TD></TR>")
+ io.write("<TR><TD WIDTH='"..col1.."' STYLE='font-weight:bold;'>Session Started:</TD><TD>No records</TD></TR>")
+ io.write("<TR><TD WIDTH='"..col1.."' STYLE='font-weight:bold;'>Session Idle:</TD><TD>No records</TD></TR>")
+ io.write("<TR><TD WIDTH='"..col1.."' STYLE='font-weight:bold;'>Other:</TD><TD>This could be a sshfs session</TD></TR>")
+
+ io.write("</TABLE>")
+ io.write("</TD>")
+ end
+ io.write("</TR>")
+ end
+ io.write("</TABLE>")
+end
+%>
+</DL>
diff --git a/openssh-controller.lua b/openssh-controller.lua
index c5b199a..30800f5 100644
--- a/openssh-controller.lua
+++ b/openssh-controller.lua
@@ -91,3 +91,8 @@ function expert(self)
return controllerfunctions.handle_form(self, self.model.getconfigfile, self.model.setconfigfile, self.clientdata, "Save", "Edit Config", "Configuration Saved")
end
+function connectedpeers(self)
+ return self.model.list_conn_peers()
+end
+function welcome(self)
+end
diff --git a/openssh-model.lua b/openssh-model.lua
index 0ebce53..2f657f9 100644
--- a/openssh-model.lua
+++ b/openssh-model.lua
@@ -12,6 +12,7 @@ local configfile = "/etc/ssh/sshd_config"
local processname = "sshd"
local packagename = "openssh-server"
local header = "SSH"
+local path="PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin "
local default = {
Port = 22,
@@ -97,7 +98,8 @@ function read_config()
end
-function startstop_service(action)
+function startstop_service(action)require("getopts")
+
return modelfunctions.startstop_service(processname, action)
end
@@ -159,3 +161,46 @@ function write_config(config)
return true
end
+function list_conn_peers()
+ local output = {}
+ local netstat = {}
+ local ps = {}
+ local who = {}
+ config = read_config()
+ local f = io.popen( path .. 'netstat -lna | grep ' .. tostring(config.Port) .. ' | grep "ESTABLISHED"' )
+ for line in f:lines() do
+ local peer = string.match(line, "^.-:.-:.-:.-:.-:.-:.-:(.-):.-$")
+ if not (netstat[peer]) then netstat[peer] = {cnt=0} end
+ netstat[peer]['cnt'] = (tonumber(netstat[peer]['cnt']) + 1)
+ end
+ f:close()
+
+ local f = io.popen( path .. 'ps | grep "sshd:" | grep -v "grep"' )
+ for line in f:lines() do
+ table.insert(ps, string.match(line,".-%@(%S*)$"))
+ end
+ f:close()
+
+ for peer,v in pairs(netstat) do
+ if not (netstat[peer]['tty']) then netstat[peer]['tty'] = {} end
+ local f = io.popen( path .. 'who | grep "' .. tostring(peer) .. '" | egrep "' .. table.concat(ps, "|") .. '"' )
+ for line in f:lines() do
+ local user,tty,idle,time = string.match(line, "^(%S*)%s*(%S*)%s*(%S*)%s*(%S*%s*%S*%s*%S*)")
+
+ table.insert(netstat[peer]['tty'], {
+ user=user,
+ tty=tty,
+ idle=idle,
+ time=time,
+ })
+ end
+ f:close()
+ end
+
+ for k,v in pairs(netstat) do
+ table.insert(output, v)
+ output[#output]['host'] = k
+ end
+
+ return output
+end
diff --git a/openssh-status-html.lsp b/openssh-status-html.lsp
index a9ab0d3..c126d2e 100644
--- a/openssh-status-html.lsp
+++ b/openssh-status-html.lsp
@@ -1,4 +1,4 @@
-<% local data = ...
+<% local data, viewlibrary, page_info, session = ...
require("viewfunctions")
--[[
io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>")
@@ -15,3 +15,4 @@ displayitem(data.value.version)
displayitem(data.value.autostart)
%>
</DL>
+
diff --git a/openssh-welcome-html.lsp b/openssh-welcome-html.lsp
new file mode 100644
index 0000000..d627bd6
--- /dev/null
+++ b/openssh-welcome-html.lsp
@@ -0,0 +1,10 @@
+<% local data, viewlibrary, page_info, session = ...
+%>
+
+<% if viewlibrary and viewlibrary.dispatch_component and session.permissions[page_info.controller].connectedpeers then
+ viewlibrary.dispatch_component("status")
+end %>
+
+<% if viewlibrary and viewlibrary.dispatch_component and session.permissions[page_info.controller].connectedpeers then
+ viewlibrary.dispatch_component("connectedpeers")
+end %>
diff --git a/openssh.menu b/openssh.menu
index 324f80a..173160d 100644
--- a/openssh.menu
+++ b/openssh.menu
@@ -1,5 +1,5 @@
#CAT GROUP/DESC TAB ACTION
-Networking 20SSH Status status
+Networking 20SSH Status welcome
Networking 20SSH Config config
Networking 20SSH Expert expert
#Networking 20SSH Logfile logfile
diff --git a/openssh.roles b/openssh.roles
index 534a776..5ff2469 100644
--- a/openssh.roles
+++ b/openssh.roles
@@ -1,2 +1,2 @@
-READ=openssh:status,openssh:logfile
+READ=openssh:status,openssh:logfile,openssh:connectedpeers,openssh:welcome,
UPDATE=openssh:expert,openssh:config,openssh:startstop,