add versions of the nsh utils with authentication support
This commit is contained in:
parent
206da60f0f
commit
42a0bd3e6e
31
modules/applications/nshc-auth.lua
Normal file
31
modules/applications/nshc-auth.lua
Normal file
@ -0,0 +1,31 @@
|
||||
function nshc_w(evPP,nid,pW)
|
||||
local sI = E().sI or 1
|
||||
chauthc(nid,evPP,pW)
|
||||
while true do
|
||||
if ev[1] == "net_msg" then
|
||||
local V,msg=false,tostring(ev[4])
|
||||
if ev[3] == evPP and ev[2] == nid then
|
||||
if msg:sub(1,3) == "dis" then
|
||||
write(msg:sub(4))
|
||||
end
|
||||
end
|
||||
elseif ev[1] == "key" and ev[2] == sI and ev[3] == 29 and ev[4] == 27 then
|
||||
break
|
||||
elseif ev[1] == "key" and ev[2] == sI then
|
||||
ns(nid,evPP,"key"..tostring(ev[3]))
|
||||
end
|
||||
C.yield()
|
||||
end
|
||||
ns(nid,evPP,"exit")
|
||||
end
|
||||
|
||||
function nshc(P,nid,pW)
|
||||
ns(nid,P,"initnsh")
|
||||
while true do
|
||||
if ev[1] == "net_msg" and ev[2] == nid and ev[3] == P then
|
||||
break
|
||||
end
|
||||
C.yield()
|
||||
end
|
||||
nshc_w(ev[4],nid,pW)
|
||||
end
|
38
modules/applications/nshd-auth.lua
Normal file
38
modules/applications/nshd-auth.lua
Normal file
@ -0,0 +1,38 @@
|
||||
function nshd_w(evPP,cA,sI,pW)
|
||||
s("nshd - "..tostring(sI),function()
|
||||
chauths(cA,evPP,pW)
|
||||
luash({["sI"]=sI})
|
||||
while true do
|
||||
if ev[1] == "net_msg" then
|
||||
local msg=tostring(ev[4])
|
||||
if ev[3] == evPP and ev[2] == cA then
|
||||
if msg:sub(1,3) == "key" then
|
||||
h("key",tT[cT][3].sI,tonumber(msg:sub(4)),0)
|
||||
elseif msg == "exit" then pcall(killsession,sI) break
|
||||
end
|
||||
end
|
||||
elseif ev[1] == "display" and ev[3] == tT[cT][3].sI then
|
||||
ns(cA,evPP,"dis"..tostring(ev[2]))
|
||||
end
|
||||
C.yield()
|
||||
end
|
||||
end,{["sI"]=sI})
|
||||
end
|
||||
|
||||
function nshd(P,pW)
|
||||
s("nshd",function()
|
||||
local Cc=1
|
||||
while true do
|
||||
if ev[1] == "net_msg" and ev[3] == P then
|
||||
if ev[4] == "initnsh" then
|
||||
nnID="nsh-"..tostring(Cc)
|
||||
Cc=Cc+1
|
||||
ns(ev[2],P,nnID)
|
||||
nshd_w(nnID,ev[2],nnID,pW)
|
||||
print("[nshd]Spawned "..nnID.." for "..tostring(ev[2]))
|
||||
end
|
||||
end
|
||||
C.yield()
|
||||
end
|
||||
end,{["sI"]="log"})
|
||||
end
|
Loading…
Reference in New Issue
Block a user