Commit f498d2b0 authored by Ted Trask's avatar Ted Trask
Browse files

Replaced io.popen calls with modelfunction.run_executable

parent 172b5853
......@@ -3,14 +3,11 @@ module(..., package.seeall)
-- Load libraries
require("modelfunctions")
fs = require("acf.fs")
format = require("acf.format")
-- Set variables
local configfile = "/etc/krb5.conf"
local packagename = "heimdal"
local path = "PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin "
-- ################################################################################
-- LOCAL FUNCTIONS
......@@ -39,22 +36,16 @@ end
function set_kinit(self, data)
local tmp = "/tmp/k"..os.time()
fs.write_file(tmp, data.value.password.value)
local cmd = path.."kinit --password-file="..tmp.." "..format.escapespecialcharacters(data.value.login.value).." 2>&1"
local f = io.popen(cmd)
data.descr = f:read("*a") or ""
f:close()
data.descr, data.errtxt = modelfunctions.run_executable({"kinit", "--password-file="..tmp, data.value.login.value}, true)
os.remove(tmp)
if data.descr == "" then data.descr = "Success" end
if not data.errtxt and data.descr == "" then data.descr = "Success" end
return data
end
function klist()
local cmd = path.."klist"
local f = io.popen(cmd)
local result = f:read("*a") or ""
f:close()
if result == "" then result = "No tickets found" end
return cfe({ value=result, label="List of Kerberos Tickets" })
local result, errtxt = modelfunctions.run_executable({"klist"})
if not errtxt and result == "" then result = "No tickets found" end
return cfe({ value=result, label="List of Kerberos Tickets", errtxt=errtxt })
end
function get_kdestroy()
......@@ -62,10 +53,7 @@ function get_kdestroy()
end
function kdestroy(self, kd)
local cmd = path.."kdestroy"
local f = io.popen(cmd)
kd.descr = f:read("*a") or ""
f:close()
if kd.descr == "" then kd.descr = "Successfully Destroyed Tickets" end
kd.descr, kd.errtxt = modelfunctions.run_executable({"kdestroy"})
if not kd.errtxt and kd.descr == "" then kd.descr = "Successfully Destroyed Tickets" end
return kd
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment