Commit 02edfdc2 authored by Ted Trask's avatar Ted Trask
Browse files

Initial cut at heimdal ACF.

parents
APP_NAME=heimdal
PACKAGE=acf-$(APP_NAME)
VERSION=0.1.0
APP_DIST=\
heimdal* \
EXTRA_DIST=README Makefile config.mk
DISTFILES=$(APP_DIST) $(EXTRA_DIST)
TAR=tar
P=$(PACKAGE)-$(VERSION)
tarball=$(P).tar.bz2
install_dir=$(DESTDIR)/$(appdir)/$(APP_NAME)
all:
clean:
rm -rf $(tarball) $(P)
dist: $(tarball)
install:
mkdir -p "$(install_dir)"
cp -a $(APP_DIST) "$(install_dir)"
$(tarball): $(DISTFILES)
rm -rf $(P)
mkdir -p $(P)
cp -a $(DISTFILES) $(P)
$(TAR) -jcf $@ $(P)
rm -rf $(P)
# target that creates a tar package, unpacks is and install from package
dist-install: $(tarball)
$(TAR) -jxf $(tarball)
$(MAKE) -C $(P) install DESTDIR=$(DESTDIR)
rm -rf $(P)
include config.mk
.PHONY: all clean dist install dist-install
ACF for heimdal
prefix=/usr
datadir=${prefix}/share
sysconfdir=${prefix}/etc
localstatedir=${prefix}/var
acfdir=${datadir}/acf
wwwdir=${acfdir}/www
cgibindir=${acfdir}/cgi-bin
appdir=${acfdir}/app
acflibdir=${acfdir}/lib
sessionsdir=${localstatedir}/lib/acf/sessions
module(..., package.seeall)
-- Load libraries
require("controllerfunctions")
default_action = "status"
function status(self)
return self.model.getstatus()
end
function expert(self)
return controllerfunctions.handle_form(self, self.model.get_filedetails, self.model.update_filedetails, self.clientdata, "Save", "Edit Heimdal Config", "Configuration Set")
end
function klist(self)
return self.model.klist()
end
function kinit(self)
return controllerfunctions.handle_form(self, self.model.get_kinit, self.model.set_kinit, self.clientdata, "Submit", "Obtain Kerberos Ticket")
end
function kdestroy(self)
return self:redirect_to_referrer(self.model.kdestroy())
end
../expert-html.lsp
\ No newline at end of file
<% local form, viewlibrary, page_info = ...
require("viewfunctions")
%>
<H1><%= html.html_escape(form.label) %></H1>
<%
form.action = page_info.script .. page_info.prefix .. page_info.controller .. "/" .. page_info.action
form.value.password.type = "password"
displayform(form)
%>
<% local data, viewlibrary, page_info, session = ... %>
<% require("viewfunctions") %>
<% displaycommandresults({"kdestroy"}, session) %>
<% displaycommandresults({"kinit"}, session, true) %>
<H1><%= data.label %></H1>
<pre>
<%= html.html_escape(data.value) %>
</pre>
<% if viewlibrary and viewlibrary.dispatch_component and session.permissions[page_info.controller].kdestroy then %>
<DL>
<form action="<%= html.html_escape(page_info.script .. page_info.prefix .. page_info.controller .. "/kdestroy") %>">
<DT>Destroy Tickets</DT>
<DD><input class="submit" type="submit" value="Destroy"></DD>
</form>
</DL>
<% end %>
<% if viewlibrary and viewlibrary.dispatch_component and session.permissions[page_info.controller].kinit then
viewlibrary.dispatch_component("kinit")
end %>
module(..., package.seeall)
-- Load libraries
require("processinfo")
require("modelfunctions")
require("fs")
require("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
../status-html.lsp
\ No newline at end of file
#CAT GROUP/DESC TAB ACTION
Applications 18Kerberos Status status
Applications 18Kerberos Tickets klist
Applications 18Kerberos Expert expert
USER=heimdal:status,heimdal:klist
EXPERT=heimdal:kinit,heimdal:expert,heimdal:kdestroy
ADMIN=heimdal:status,heimdal:klist,heimdal:kinit,heimdal:expert,heimdal:kdestroy
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