1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
module(..., package.seeall)
-- Load libraries
require("modelfunctions")
processinfo = require("acf.processinfo")
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
-- ################################################################################
-- PUBLIC FUNCTIONS
function getstatus()
local status = {}
local value, errtxt = processinfo.package_version(packagename)
status.version = cfe({
label="Program version",
value=value,
errtxt=errtxt,
name=packagename
})
return cfe({ type="group", value=status, label="Heimdal Status" })
end
function get_filedetails()
return modelfunctions.getfiledetails(configfile)
end
function update_filedetails(filedetails)
return modelfunctions.setfiledetails(filedetails, {configfile})
end
function get_kinit()
local value = {}
value.login = cfe({ label="KDC login" })
value.password = cfe({ label="KDC password" })
return cfe({ type="group", value=value, label="Kinit Parameters" })
end
function set_kinit(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()
os.remove(tmp)
if 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" })
end
function kdestroy()
local cmd = path.."kdestroy"
local f = io.popen(cmd)
local result = f:read("*a") or ""
f:close()
if result == "" then result = "Success" end
return cfe({ value=result, label="Result of kdestroy" })
end
|