summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README2
-rw-r--r--acf-hooks.lua16
-rw-r--r--acf.conf2
-rw-r--r--app/README2
-rw-r--r--app/acf-util/password-listlockevents-html.lsp8
-rw-r--r--app/acf-util/password-model.lua14
-rw-r--r--app/acf-util/roles-model.lua6
-rw-r--r--app/acf-util/roles-read-html.lsp2
-rw-r--r--app/acf_cli-controller.lua2
-rw-r--r--app/acf_www-controller.lua46
-rw-r--r--app/dispatcherror-html.lsp2
-rw-r--r--app/exception-html.lsp2
-rw-r--r--app/status-html.lsp2
-rw-r--r--app/template-html.lsp14
-rwxr-xr-xbin/acf-cli2
-rw-r--r--lib/README4
-rw-r--r--lib/authenticator-plaintext.lua6
-rw-r--r--lib/authenticator.lua14
-rw-r--r--lib/htmlviewfunctions.lua6
-rw-r--r--lib/menubuilder.lua10
-rw-r--r--lib/modelfunctions.lua12
-rw-r--r--lib/roles.lua10
-rw-r--r--lib/session.lua22
-rwxr-xr-xlua/mvc.lua68
-rwxr-xr-xwww/cgi-bin/acf4
25 files changed, 139 insertions, 139 deletions
diff --git a/README b/README
index f7eccd7..bcd5f7f 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-Alpine Configuration Framework
+Alpine Configuration Framework
To install the package run:
diff --git a/acf-hooks.lua b/acf-hooks.lua
index b301c5d..634cbf8 100644
--- a/acf-hooks.lua
+++ b/acf-hooks.lua
@@ -2,14 +2,14 @@
-- This file is loaded into self.conf.app_hooks using loadfile;
-- it must be correct lua source code.
-- The current format for this file is a table for each controller,
--- and then values (or tables) under the controller.
---
+-- and then values (or tables) under the controller.
+--
-- The purpose of this file is to add user-specified hooks into the
--- acf code.
---
+-- acf code.
+--
-- Currently the only use for this is a per-controller audit function
-- (this overrides the acf.conf audit_precommit / postcommit globals)
---
+--
-- audit_precommit | audit_postcommit can be strings (like in acf.conf)
-- or functions. For functions, three variables are passed:
-- self, CONFFILE, and TEMPFILE
@@ -18,7 +18,7 @@
format = require("acf.format")
local precommit=function(self, conf, temp)
local logfile = "/var/log/acf-" .. self.conf.controller .. ".log"
- fs.write_line_file (logfile, "#---- BEGIN TRANSACTION - " ..
+ fs.write_line_file (logfile, "#---- BEGIN TRANSACTION - " ..
os.date() .. "\n" .. self.sessiondata.userinfo.userid ..
" modifed " .. conf .. " as follows:")
os.execute ("diff -u " .. format.escapespecialcharacters(conf) .. " " .. format.escapespecialcharacters(temp) .. " >>" .. format.escapespecialcharacters(logfile))
@@ -28,7 +28,7 @@ local precommit=function(self, conf, temp)
interfaces = {
- -- note that we must define the audit command as a
+ -- note that we must define the audit command as a
-- new function to wrap the local func:
audit_precommit=function(self,conf,temp)
precommit(self, conf, temp)
@@ -38,6 +38,6 @@ interfaces = {
}
-- but after defining the audit_* commands as direct functions,
--- assining other controllers to be the same is fine...
+-- assining other controllers to be the same is fine...
tinydns=interfaces
diff --git a/acf.conf b/acf.conf
index 102186f..2872eed 100644
--- a/acf.conf
+++ b/acf.conf
@@ -2,7 +2,7 @@
# Directories where the application resides
# appdir, libdir, and skindir may be comma-separated lists
-# paths are checked from left to right
+# paths are checked from left to right
# for .lua and .lsp files - the first found file will be used
# for .roles and .menu files - all files will be combined
appdir=/usr/share/acf/app/
diff --git a/app/README b/app/README
index 83e69af..9c7169c 100644
--- a/app/README
+++ b/app/README
@@ -16,7 +16,7 @@ Create a Makefile that describes the the following:
* what files should be installed on the running system
- * what additional files should be included in the distribution package
+ * what additional files should be included in the distribution package
(tar.gz source package). The Makefile and acf-pkg.mk wil automatically be
added so only extra files like README and ChangeLog needs to be specified
here.
diff --git a/app/acf-util/password-listlockevents-html.lsp b/app/acf-util/password-listlockevents-html.lsp
index bb81846..aff2aba 100644
--- a/app/acf-util/password-listlockevents-html.lsp
+++ b/app/acf-util/password-listlockevents-html.lsp
@@ -1,4 +1,4 @@
-<% local view, viewlibrary, page_info, session = ...
+<% local view, viewlibrary, page_info, session = ...
htmlviewfunctions = require("htmlviewfunctions")
html = require("acf.html")
%>
@@ -8,7 +8,7 @@ html = require("acf.html")
document.write('<script type="text/javascript" src="<%= html.html_escape(page_info.wwwprefix) %>/js/jquery-latest.js"><\/script>');
}
</script>
-
+
<script type="text/javascript">
if (typeof $.tablesorter == 'undefined') {
document.write('<script type="text/javascript" src="<%= html.html_escape(page_info.wwwprefix) %>/js/jquery.tablesorter.js"><\/script>');
@@ -36,7 +36,7 @@ html = require("acf.html")
<th>User ID</th>
<th>IP Address</th>
<th>Time</th>
- </tr>
+ </tr>
</thead><tbody>
<% for i,lock in ipairs( view.value ) do %>
<tr>
@@ -48,7 +48,7 @@ html = require("acf.html")
</tbody></table>
<% htmlviewfunctions.displaysectionend(header_level) %>
-<% if viewlibrary and viewlibrary.dispatch_component then
+<% if viewlibrary and viewlibrary.dispatch_component then
viewlibrary.dispatch_component("unlockuser")
viewlibrary.dispatch_component("unlockip")
end %>
diff --git a/app/acf-util/password-model.lua b/app/acf-util/password-model.lua
index 72ae416..6644841 100644
--- a/app/acf-util/password-model.lua
+++ b/app/acf-util/password-model.lua
@@ -10,10 +10,10 @@ local weak_password = function(password)
-- If password is too short, return false
if (#password < 4) then
return true, "Password is too short!"
- end
+ end
if (tonumber(password)) then
return true, "Password can't contain only numbers!"
- end
+ end
return false, nil
end
@@ -49,7 +49,7 @@ end
local function get_blank_user(self)
local result = cfe({ type="group", value={}, label="User Account" })
-
+
if not avail_roles then
avail_roles = roles.list_all_roles(self)
for x,role in ipairs(avail_roles) do
@@ -59,7 +59,7 @@ local function get_blank_user(self)
end
end
end
-
+
-- Call into skins controller to get the list of skins
if not avail_skins then
avail_skins = {""}
@@ -123,7 +123,7 @@ end
function mymodule.update_user(self, settings, submit, create)
local success, settings = validate_settings(settings, create)
-
+
if success then
local userinfo = authenticator.get_userinfo(self, settings.value.userid.value)
if userinfo and create then
@@ -182,7 +182,7 @@ end
function mymodule.read_user_without_roles(self, clientdata)
local result = mymodule.read_user(self, clientdata)
-
+
-- We don't allow a user to modify his own roles
-- Since they can't modify roles, we should restrict the available options for home
result.value.home.option = {""}
@@ -203,7 +203,7 @@ function mymodule.get_users(self)
local users = {}
local userlist = authenticator.list_users(self)
table.sort(userlist)
-
+
for x,user in pairs(userlist) do
users[#users+1] = get_user(self, user)
end
diff --git a/app/acf-util/roles-model.lua b/app/acf-util/roles-model.lua
index 8b51503..0e49b4e 100644
--- a/app/acf-util/roles-model.lua
+++ b/app/acf-util/roles-model.lua
@@ -17,7 +17,7 @@ end
mymodule.get_role_perms = function(self, role)
return cfe({ type="structure", value=roles.get_role_perm(self, role), label="Permissions" })
end
-
+
-- Return list of all permissions
mymodule.get_perms_list = function(self)
return cfe({ type="structure", value=roles.get_all_permissions(self), label="All Permissions" })
@@ -37,7 +37,7 @@ mymodule.getpermissions = function(self, clientdata)
local tmp, all_perms = roles.get_all_permissions(self)
table.sort(all_perms)
local my_perms = {}
- local default_perms = {}
+ local default_perms = {}
if clientdata.role then
role_cfe.readonly = true
@@ -62,7 +62,7 @@ mymodule.getpermissions = function(self, clientdata)
all_perms = newall
end
end
-
+
local permissions_cfe = cfe({ type="multi", value=my_perms, option=all_perms, label="Role permissions", seq=2 })
return cfe({ type="structure", value={role=role_cfe, permissions=permissions_cfe} })
diff --git a/app/acf-util/roles-read-html.lsp b/app/acf-util/roles-read-html.lsp
index 87772b7..79700cf 100644
--- a/app/acf-util/roles-read-html.lsp
+++ b/app/acf-util/roles-read-html.lsp
@@ -72,7 +72,7 @@ end %>
end
%>
</tbody></table>
-<%
+<%
if view.value.userid or view.value.role then
htmlviewfunctions.displaysectionend(header_level2)
end
diff --git a/app/acf_cli-controller.lua b/app/acf_cli-controller.lua
index 14badd9..c871455 100644
--- a/app/acf_cli-controller.lua
+++ b/app/acf_cli-controller.lua
@@ -43,7 +43,7 @@ mymodule.handle_clientdata = function(form, clientdata, group)
value.value = (clientdata[name] == "true")
elseif value.type == "multi" or value.type == "list" then
-- for cli we use name[num] as the name
- local temp = {}
+ local temp = {}
for n,val in pairs(clientdata) do
if string.find(n, "^"..name.."%[%d+%]$") then
temp[tonumber(string.match(n, "%[(%d+)%]$"))] = val
diff --git a/app/acf_www-controller.lua b/app/acf_www-controller.lua
index 61dac76..3c53d77 100644
--- a/app/acf_www-controller.lua
+++ b/app/acf_www-controller.lua
@@ -1,4 +1,4 @@
---[[ Code for the Alpine Configuration WEB framework
+--[[ Code for the Alpine Configuration WEB framework
see http://wiki.alpinelinux.org
Copyright (C) 2007 Nathan Angelacos
Licensed under the terms of GPL2
@@ -27,7 +27,7 @@ local function build_menus(self)
end
local permissions = roll.get_roles_perm(self,roles)
self.sessiondata.permissions = permissions
-
+
--Build the menu
local cats = m.get_menuitems(self)
-- now, loop through menu and remove actions without permission
@@ -71,7 +71,7 @@ local check_permission_string = function (self, str)
local prefix, controller, action = self.parse_redir_string(str)
if prefix == "/" then prefix = self.conf.prefix end
if controller == "" then controller = self.conf.controller end
-
+
if "" == action then
action = rawget(self.worker, "default_action") or ""
end
@@ -89,12 +89,12 @@ find_template = function ( appdir, prefix, controller, action, viewtype )
if template then break end
end
return template
- end
+ end
local targets = {
- appdir .. prefix .. "template-" .. controller .. "-" ..
+ appdir .. prefix .. "template-" .. controller .. "-" ..
action .. "-" .. viewtype .. ".lsp",
- appdir .. prefix .. "template-" .. controller .. "-" ..
+ appdir .. prefix .. "template-" .. controller .. "-" ..
viewtype .. ".lsp",
appdir .. prefix .. "template-" .. action .. "-" ..
viewtype .. ".lsp",
@@ -112,7 +112,7 @@ find_template = function ( appdir, prefix, controller, action, viewtype )
if prefix == "/" then -- already at the top level - fail
return nil
end
- prefix = posix.dirname (prefix)
+ prefix = posix.dirname (prefix)
return find_template ( appdir, prefix, controller, action, viewtype )
end
@@ -258,7 +258,7 @@ mymodule.mvc.on_load = function (self, parent)
parent_exception_handler = parent.exception_handler
parent_create_helper_library = parent.create_helper_library
parent_view_resolver = parent.view_resolver
-
+
sessionlib=require ("session")
-- before we look at sessions, remove old sessions and events
@@ -272,10 +272,10 @@ mymodule.mvc.on_load = function (self, parent)
--self.logevent("Found session id = " .. self.clientdata.sessionid)
-- Load existing session data
local timestamp
- timestamp, self.sessiondata =
+ timestamp, self.sessiondata =
sessionlib.load_session(self.conf.sessiondir,
self.clientdata.sessionid)
- if timestamp == nil then
+ if timestamp == nil then
-- invalid session id, report event and create new one
sessionlib.record_event(self.conf.sessiondir, nil, self.conf.clientip)
--self.logevent("Didn't find session")
@@ -348,7 +348,7 @@ mymodule.exception_handler = function (self, message )
if message.type == "redir" then
io.write ("Location: " .. ENV["SCRIPT_NAME"] ..
message.prefix .. message.controller ..
- "/" .. message.action ..
+ "/" .. message.action ..
(message.extra or "" ) .. "\n")
elseif message.type == "dispatch" then
-- We got a dispatch error because the user session timed out
@@ -384,10 +384,10 @@ mymodule.exception_handler = function (self, message )
if viewtable then
if not self.conf.suppress_view then
- local success, err = xpcall ( function ()
+ local success, err = xpcall ( function ()
local viewfunc, p1, p2, p3 = self.view_resolver(self)
viewfunc (viewtable, p1, p2, p3)
- end,
+ end,
self:soft_traceback()
)
@@ -402,11 +402,11 @@ end
-- check permissions and redirect if not allowed to see
-- pass more parameters to the view
-- allow display of views without actions
-mymodule.dispatch = function (self, userprefix, userctlr, useraction)
+mymodule.dispatch = function (self, userprefix, userctlr, useraction)
local controller = nil
local viewtable
local starttime = os.time()
- local success, err = xpcall ( function ()
+ local success, err = xpcall ( function ()
if userprefix == nil then
self.conf.prefix, self.conf.controller, self.conf.action =
@@ -470,7 +470,7 @@ mymodule.dispatch = function (self, userprefix, userctlr, useraction)
if self.conf.action == "" then self.conf.action = default_action end
if "" ~= self.conf.action then
local perm = check_permission(controller, self.conf.prefix, self.conf.controller, self.conf.action)
- -- Because of the inheritance, normally the
+ -- Because of the inheritance, normally the
-- controller.worker.action will flow up, so that all children have
-- actions of all parents. We use rawget to make sure that only
-- controller defined actions are used on dispatch
@@ -497,7 +497,7 @@ mymodule.dispatch = function (self, userprefix, userctlr, useraction)
end
if controller then
- -- run the (first found) pre_exec code, starting at the controller
+ -- run the (first found) pre_exec code, starting at the controller
-- and moving up the parents
if type(controller.worker.mvc.pre_exec) == "function" then
controller.worker.mvc.pre_exec ( controller )
@@ -520,13 +520,13 @@ mymodule.dispatch = function (self, userprefix, userctlr, useraction)
local viewfunc, p1, p2, p3 = self.view_resolver(self)
viewfunc (viewtable, p1, p2, p3)
end
-
- end,
+
+ end,
self:soft_traceback(message)
)
if not success then
- if controller then
+ if controller then
controller:exception_handler(err)
controller:destroy()
controller = nil
@@ -553,7 +553,7 @@ mymodule.redirect = function (self, str, result)
local prefix, controller, action = self.parse_redir_string(str)
if prefix ~= "/" then self.conf.prefix = prefix end
if controller ~= "" then self.conf.controller = controller end
-
+
if "" == action then
action = rawget(self.worker, "default_action") or ""
end
@@ -566,7 +566,7 @@ end
-- this is the same as URI string, but opposite preference
-- if only one is defined, it's assumed to be the action
mymodule.parse_redir_string = function( str )
- str = str or ""
+ str = str or ""
str = string.gsub(str, "/+$", "")
local action = string.match(str, "[^/]+$") or ""
str = string.gsub(str, "/*[^/]*$", "")
@@ -672,7 +672,7 @@ mymodule.handle_form = function(self, getFunction, setFunction, clientdata, opti
if not form.errtxt and descr then
form.descr = descr
end
-
+
if clientdata.redir then
form.value.redir = cfe({ type="hidden", value=clientdata.redir, label="" })
end
diff --git a/app/dispatcherror-html.lsp b/app/dispatcherror-html.lsp
index 208a467..d38b7df 100644
--- a/app/dispatcherror-html.lsp
+++ b/app/dispatcherror-html.lsp
@@ -17,7 +17,7 @@
document.write('<script type="text/javascript" src="<%= html.html_escape(page_info.wwwprefix) %>/js/jquery-latest.js"><\/script>');
}
</script>
-
+
<script type="text/javascript">
var clickIt = function(){
$("p.hiddendetail").removeClass("hiddendetail").show("slow");
diff --git a/app/exception-html.lsp b/app/exception-html.lsp
index 5a00ed1..91b7c12 100644
--- a/app/exception-html.lsp
+++ b/app/exception-html.lsp
@@ -17,7 +17,7 @@
document.write('<script type="text/javascript" src="<%= html.html_escape(page_info.wwwprefix) %>/js/jquery-latest.js"><\/script>');
}
</script>
-
+
<script type="text/javascript">
var clickIt = function(){
$("p.hiddendetail").removeClass("hiddendetail").show("slow");
diff --git a/app/status-html.lsp b/app/status-html.lsp
index 8c764b3..4ff6530 100644
--- a/app/status-html.lsp
+++ b/app/status-html.lsp
@@ -1,4 +1,4 @@
-<% local data, viewlibrary, page_info, session = ...
+<% local data, viewlibrary, page_info, session = ...
htmlviewfunctions = require("htmlviewfunctions")
html = require("acf.html")
%>
diff --git a/app/template-html.lsp b/app/template-html.lsp
index e784d08..7b75007 100644
--- a/app/template-html.lsp
+++ b/app/template-html.lsp
@@ -1,12 +1,12 @@
-<% local viewtable, viewlibrary, pageinfo, session = ...
+<% local viewtable, viewlibrary, pageinfo, session = ...
html=require("acf.html")
posix=require("posix")
%>
Status: 200 OK
Content-Type: text/html
<%
-if (session.id) then
- io.write( html.cookie.set("sessionid", session.id) )
+if (session.id) then
+ io.write( html.cookie.set("sessionid", session.id) )
else
io.write (html.cookie.unset("sessionid"))
end
@@ -64,21 +64,21 @@ end
<p class="links">
<%
local ctlr = pageinfo.script .. "/acf-util/logon/"
-
+
if session.userinfo and session.userinfo.userid then
print("<a href=\""..html.html_escape(ctlr).."logoff\">Log off as '" .. html.html_escape(session.userinfo.userid) .. "'</a> |")
else
print("<a href=\""..html.html_escape(ctlr).."logon\">Log on</a> |" )
end
%>
- <a href="<%= html.html_escape(pageinfo.wwwprefix) %>/">home</a> |
+ <a href="<%= html.html_escape(pageinfo.wwwprefix) %>/">home</a> |
<a href="http://www.alpinelinux.org">about</a>
</p>
</div> <!-- header -->
<div id="main">
<div id="nav">
- <%
+ <%
local class
local tabs
if (#session.menu.cats > 0) then
@@ -136,6 +136,6 @@ end
</div> <!-- page -->
<% end --pageinfo.skinned %>
-
+
</body>
</html>
diff --git a/bin/acf-cli b/bin/acf-cli
index dab8c0f..13a05cd 100755
--- a/bin/acf-cli
+++ b/bin/acf-cli
@@ -24,7 +24,7 @@ posix = require("posix")
mvc = require("acf.mvc")
FRAMEWORK=mvc:new()
-FRAMEWORK:read_config("acf")
+FRAMEWORK:read_config("acf")
APP=FRAMEWORK:new("acf_cli")
-- command line will have URI-type string defining prefix/controller/action
diff --git a/lib/README b/lib/README
index be6f1dc..a886dbc 100644
--- a/lib/README
+++ b/lib/README
@@ -5,7 +5,7 @@ Also we use Lua Posix for the rest of the functionality.
*** These are currently being worked on. ***
apk.lua - Helps with package version/install/remove
-authenticator-plaintext.lua - sub-authenticator for plaintext files
+authenticator-plaintext.lua - sub-authenticator for plaintext files
authenticator.lua - Used for authentication and roles, generic and uses sub-authenticator
date.lua - Date and Time functions
format.lua - Library to help reformat strings and tables.
@@ -16,5 +16,5 @@ modelfunctions.lua - Common model functions
processinfo.lua - Start/stop, find running, find version - process helpers
roles.lua - Used to determine roles and permissions
session.lua - Helps with Session mangement in ACF
-validator.lua - Validate web input for ACF.
+validator.lua - Validate web input for ACF.
htmlviewfunctions.lua - Common functions for HTML views
diff --git a/lib/authenticator-plaintext.lua b/lib/authenticator-plaintext.lua
index c1db54a..8cbf7a8 100644
--- a/lib/authenticator-plaintext.lua
+++ b/lib/authenticator-plaintext.lua
@@ -50,7 +50,7 @@ mymodule.read_field = function(self, tabl, field)
end
end
return row
- else
+ else
return nil
end
end
@@ -106,7 +106,7 @@ mymodule.delete_entry = function (self, tabl, field, id)
return false
end
local result = false
-
+
local passwd_path = self.conf.confdir .. field .. tabl
local passwdfilecontent = fs.read_file_as_array(passwd_path) or {}
local output = {}
@@ -117,7 +117,7 @@ mymodule.delete_entry = function (self, tabl, field, id)
result = true
end
end
-
+
--Save the updated table
if result == true then
fs.write_file(passwd_path, table.concat(output,"\n"))
diff --git a/lib/authenticator.lua b/lib/authenticator.lua
index bce2af7..3bc9716 100644
--- a/lib/authenticator.lua
+++ b/lib/authenticator.lua
@@ -137,7 +137,7 @@ local load_database = function(self)
complete = true
end
end
-
+
local get_id = function(self, userid)
if not authstruct[userid] then
parse_entry(userid, auth.read_entry(self, mymodule.usertable, "", userid))
@@ -150,7 +150,7 @@ end
-- true if password matches or
-- false if password does not match
local verify_password = function(plaintext, pwhash)
- --[[
+ --[[
from man crypt(3):
If salt is a character string starting with the characters "$id$" fol-
@@ -175,7 +175,7 @@ local verify_password = function(plaintext, pwhash)
return (pwhash == posix.crypt(plaintext, algo_salt))
end
-- fall back to old style md5 checksum
- return (pwhash == md5.sumhexa(plaintext))
+ return (pwhash == md5.sumhexa(plaintext))
end
local b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./"
@@ -185,7 +185,7 @@ local mksalt = function()
local str = ""
if file == nil then return nil end
for i = 1,16 do
- local offset = (string.byte(file:read(1)) % 64) + 1
+ local offset = (string.byte(file:read(1)) % 64) + 1
str = str .. string.sub (b64, offset, offset)
end
return "$6$"..str.."$"
@@ -218,7 +218,7 @@ mymodule.authenticate = function(self, userid, password)
errtxt = "Invalid parameter"
else
local id = get_id(self, userid)
-
+
if not id then
errtxt = "Userid not found"
elseif not verify_password(password, id.password) then
@@ -285,7 +285,7 @@ mymodule.write_userinfo = function(self, userinfo)
return success
end
-
+
mymodule.list_users = function (self)
auth = mymodule.get_subauth(self)
load_database(self)
@@ -298,7 +298,7 @@ end
mymodule.delete_user = function (self, userid)
auth = mymodule.get_subauth(self)
- authstruct[userid] = nil
+ authstruct[userid] = nil
return auth.delete_entry(self, mymodule.usertable, "", userid)
end
diff --git a/lib/htmlviewfunctions.lua b/lib/htmlviewfunctions.lua
index 033370b..3571220 100644
--- a/lib/htmlviewfunctions.lua
+++ b/lib/htmlviewfunctions.lua
@@ -58,7 +58,7 @@ function mymodule.displayitemstart(myitem, page_info, header_level)
header_level = header_level or page_info.header_level or 1
if 0 <= header_level then
io.write('<div class="item')
- if myitem.errtxt then
+ if myitem.errtxt then
io.write(' error')
end
io.write('"><label class="left')
@@ -124,7 +124,7 @@ function mymodule.displayitem(myitem, page_info, header_level, name, group)
elseif myitem.key and not myitem.readonly then
mymodule.displayformitem(myitem, name, header_level, group)
elseif myitem.type ~= "hidden" then
- if myitem.errtxt then
+ if myitem.errtxt then
myitem.class = "error"
end
header_level = mymodule.displayitemstart(myitem, page_info, header_level)
@@ -141,7 +141,7 @@ function mymodule.displayformitem(myitem, name, header_level, group)
if not myitem then return end
myitem.name = name or myitem.name or ""
if group and group ~= "" then myitem.name = group.."."..myitem.name end
- if myitem.errtxt then
+ if myitem.errtxt then
myitem.class = "error"
end
if myitem.type ~= "hidden" and myitem.type ~= "group" then
diff --git a/lib/menubuilder.lua b/lib/menubuilder.lua
index 6bb981f..b4f69ed 100644
--- a/lib/menubuilder.lua
+++ b/lib/menubuilder.lua
@@ -9,7 +9,7 @@ posix = require("posix")
format = require("acf.format")
fs = require("acf.fs")
--- returns a table of the "*.menu" tables
+-- returns a table of the "*.menu" tables
-- startdir should be the app dir.
local get_candidates = function (startdir)
return fs.find_files_as_array(".*%.menu", startdir, true)
@@ -80,9 +80,9 @@ mymodule.get_menuitems = function (self)
for i = 1,1 do -- loop so break works
-- Add the category
if nil == reversecats[result.cat] then
- table.insert ( cats,
- { name=result.cat,
- groups = {},
+ table.insert ( cats,
+ { name=result.cat,
+ groups = {},
reversegroups = {} } )
reversecats[result.cat] = #cats
end
@@ -165,7 +165,7 @@ mymodule.get_menuitems = function (self)
end
end
end
-
+
-- create new groups for each prefix/controller
for con in pairs(group.controllers) do
table.insert ( cat.groups,
diff --git a/lib/modelfunctions.lua b/lib/modelfunctions.lua
index e9210ee..b72e610 100644
--- a/lib/modelfunctions.lua
+++ b/lib/modelfunctions.lua
@@ -68,7 +68,7 @@ function mymodule.getstatus(servicename, packagename, label)
if servicename then
status.status = mymodule.getenabled(servicename)
-
+
local autostart_value, autostart_errtxt = processinfo.process_autostart(servicename)
status.autostart = cfe({
label="Autostart status",
@@ -96,7 +96,7 @@ function mymodule.getfiledetails(file, validatefilename, validatefiledetails)
elseif type(validatefilename) == "table" then
success = false
filedetails.value.filename.errtxt = "Invalid File"
- for i,f in ipairs(validatefilename) do
+ for i,f in ipairs(validatefilename) do
if f == filedetails.value.filename.value then
success = true
filedetails.value.filename.errtxt = nil
@@ -130,7 +130,7 @@ function mymodule.setfiledetails(self, filedetails, validatefilename, validatefi
elseif type(validatefilename) == "table" then
success = false
filedetails.value.filename.errtxt = "Invalid File"
- for i,f in ipairs(validatefilename) do
+ for i,f in ipairs(validatefilename) do
if f == filedetails.value.filename.value then
success = true
filedetails.value.filename.errtxt = nil
@@ -186,10 +186,10 @@ function mymodule.write_file_with_audit (self, path, str)
local pre = ""
local post = ""
- local tmpfile = (self.conf.sessiondir or "/tmp/") ..
+ local tmpfile = (self.conf.sessiondir or "/tmp/") ..
(self.sessiondata.userinfo.userid or "unknown") .. "-" ..
os.time() .. ".tmp"
-
+
if type(self.conf) == "table" then
-- we make temporary globals for expand_bash_syntax_vars
local a,b,c = TEMPFILE,CONFFILE,_G.self
@@ -205,7 +205,7 @@ function mymodule.write_file_with_audit (self, path, str)
if m.audit_postcommit then post = m.audit_postcommit end
m=nil
- if (type(pre) == "string") then
+ if (type(pre) == "string") then
pre = format.expand_bash_syntax_vars(pre)
end
if type (post) == "string" then
diff --git a/lib/roles.lua b/lib/roles.lua
index eb64305..cef1d28 100644
--- a/lib/roles.lua
+++ b/lib/roles.lua
@@ -81,7 +81,7 @@ mymodule.get_controllers_func = function(self,controller_info)
_G[controller_info.name] = loaded
temp1 = {}
for a,b in pairs(temp) do
- local c = string.match(a,"^mvc") or string.match(a,"^_")
+ local c = string.match(a,"^mvc") or string.match(a,"^_")
if c == nil and type(temp[a])=="function" then
temp1[#temp1 +1] = a
end
@@ -96,7 +96,7 @@ mymodule.get_controllers_view = function(self,controller_info)
for file in fs.find(controller_info.sname.."%-[^%.]+%-html%.lsp", controller_info.path) do
temp[#temp + 1] = string.match(file, controller_info.sname.."%-([^%./]+)%-html%.lsp")
end
- return temp
+ return temp
end
mymodule.get_all_permissions = function(self)
@@ -166,7 +166,7 @@ mymodule.list_default_roles = function(self)
table.sort(default_roles, function(a,b)
if string.byte(a, 1) == 47 and string.byte(b,1) ~= 47 then return false
elseif string.byte(a, 1) ~= 47 and string.byte(b,1) == 47 then return true
- else return a<b
+ else return a<b
end
end)
end
@@ -205,7 +205,7 @@ mymodule.list_all_roles = function(self)
defined_roles[#defined_roles + 1] = role
end
return defined_roles
-end
+end
-- Go through the roles files and determine the permissions for the specified list of roles
local determine_perms = function(self,roles)
@@ -328,7 +328,7 @@ mymodule.set_role_perm = function(self, role, permissions, permissions_array)
end
end
end
-
+
local auth = authenticator.get_subauth(self)
return auth.write_entry(self, authenticator.roletable, "", role, table.concat(permissions_array or {},","))
end
diff --git a/lib/session.lua b/lib/session.lua
index cc2e0d7..ab98409 100644
--- a/lib/session.lua
+++ b/lib/session.lua
@@ -1,10 +1,10 @@
-- Session handling routines - written for acf
-- Copyright (C) 2007 N. Angelacos - GPL2 License
---[[ Note that in this library, we use empty (0 byte) files
+--[[ Note that in this library, we use empty (0 byte) files
-- everwhere we can, as they only take up dir entries, not inodes
--- as the tmpfs blocksize is 4K, and under denial of service
--- attacks hundreds or thousands of events can come in each
+-- as the tmpfs blocksize is 4K, and under denial of service
+-- attacks hundreds or thousands of events can come in each
-- second, we could end up in a disk full condition if we did
-- not take this precaution.
-- ]]--
@@ -27,7 +27,7 @@ mymodule.random_hash = function (size)
local str = ""
if file == nil then return nil end
while (size > 0 ) do
- local offset = (string.byte(file:read(1)) % 64) + 1
+ local offset = (string.byte(file:read(1)) % 64) + 1
str = str .. string.sub (b64, offset, offset)
size = size - 6
end
@@ -51,7 +51,7 @@ mymodule.ip_addr_from_hash = function (hash)
return string.sub(str, 1, string.len(str)-1)
end
---[[
+--[[
These functions serialize a table, including nested tables.
The code based on code in PiL 2nd edition p113
]]--
@@ -97,9 +97,9 @@ end
-- return true or false for success
mymodule.save_session = function( sessionpath, sessiontable)
if nil == sessiontable or nil == sessiontable.id then return false end
-
+
-- clear the id key, don't need to store that
- local id = sessiontable.id
+ local id = sessiontable.id
sessiontable.id = nil
-- If the table only has an "id" field, then don't save it
@@ -157,7 +157,7 @@ mymodule.load_session = function ( sessionpath, session )
end
s = s or {}
- s.id = session
+ s.id = session
return ts, s
else
return nil, {}
@@ -177,12 +177,12 @@ mymodule.unlink_session = function (sessionpath, session)
return statos
end
--- Record an invalid logon event
+-- Record an invalid logon event
-- ID would typically be an ip address or username
-- the format is lockevent.id.datetime.processid
mymodule.record_event = function( sessionpath, id_u, id_ip )
local x = io.open (string.format ("%s/lockevent.%s.%s.%s.%s",
- sessionpath or "/", id_u or "", mymodule.hash_ip_addr(id_ip), os.time(),
+ sessionpath or "/", id_u or "", mymodule.hash_ip_addr(id_ip), os.time(),
(posix.getpid("pid")) or "" ), "w")
io.close(x)
end
@@ -232,7 +232,7 @@ mymodule.expired_events = function (sessionpath, minutes)
local searchfor = sessionpath .. "/lockevent.*"
--first do the lockevent files
local temp = posix.glob(searchfor)
- if temp ~= nil then
+ if temp ~= nil then
for a,b in pairs(temp) do
if posix.stat(b,"mtime") < minutes_ago then
os.remove(b)
diff --git a/lua/mvc.lua b/lua/mvc.lua
index efed01f..0026020 100755
--- a/lua/mvc.lua
+++ b/lua/mvc.lua
@@ -1,4 +1,4 @@
---[[ Basic MVC framework
+--[[ Basic MVC framework
Written for Alpine Configuration Framework (ACF)
see www.alpinelinux.org for more information
Copyright (C) 2007 Nathan Angelacos
@@ -20,7 +20,7 @@ mymodule.mvc = {}
-- the constructor
--[[ Builds a new MVC object. If "module" is given, then tries to load
self.conf.appdir .. module "-controller.lua" in c.worker and
- self.conf.appdir .. module "-model.lua" in c.model
+ self.conf.appdir .. module "-model.lua" in c.model
The returned .conf table is guaranteed to have the following
appdir - where the application lives
@@ -35,16 +35,16 @@ mymodule.new = function (self, modname)
local c = {}
c.worker = {}
c.model = {}
-
+
-- make defaults if the parent doesn't have them
if self.conf == nil then
- c.conf = { appdir = "", confdir = "",
+ c.conf = { appdir = "", confdir = "",
tempdir = "", appname = "" }
end
-- If no clientdata, then clientdata is a null table
- if self.clientdata == nil then
- c.clientdata = {}
+ if self.clientdata == nil then
+ c.clientdata = {}
end
-- If we don't have an application name, use the modname
@@ -54,51 +54,51 @@ mymodule.new = function (self, modname)
-- load the module code here
if (modname) then
- c.worker = self:soft_require( modname .. "-controller")
+ c.worker = self:soft_require( modname .. "-controller")
if c.worker == nil then
c.worker = {}
worker_loaded = false
end
- c.model = self:soft_require( modname .. "-model" )
+ c.model = self:soft_require( modname .. "-model" )
if c.model == nil then
c.model = {}
model_loaded = false
end
end
- -- The magic that makes all the metatables point in the correct
- -- direction. c.model -> c.worker -> parent -> parent.worker ->
+ -- The magic that makes all the metatables point in the correct
+ -- direction. c.model -> c.worker -> parent -> parent.worker ->
-- grandparent -> grandparent -> worker (and so on)
-
- -- The model looks in worker for missing
+
+ -- The model looks in worker for missing
setmetatable (c.model, c.model )
c.model.__index = c.worker
- -- the worker looks in the parent table for missing
+ -- the worker looks in the parent table for missing
setmetatable (c.worker, c.worker)
c.worker.__index = self
-
+
-- the table looks in the worker for missing
setmetatable (c, c)
c.__index = c.worker
-
+
-- ensure an "mvc" table exists, even if empty
if (type(rawget(c.worker, "mvc")) ~= "table") then
c.worker.mvc = {}
end
-
+
setmetatable (c.worker.mvc, c.worker.mvc)
- -- If creating a new parent container, then
+ -- If creating a new parent container, then
-- we are the top of the chain.
if (modname) then
c.worker.mvc.__index = self.worker.mvc
else
c.worker.mvc.__index = self.mvc
- end
-
+ end
+
-- run the worker on_load code
if type(rawget(c.worker.mvc, "on_load")) == "function" then
- c.worker.mvc.on_load(c, self)
+ c.worker.mvc.on_load(c, self)
c.worker.mvc.on_load = nil
end
@@ -130,10 +130,10 @@ mymodule.destroy = function (self)
if self.model and self.model["_NAME"] then package.loaded[self.model["_NAME"]] = nil end
end
--- This is a sample front controller/dispatch.
-mymodule.dispatch = function (self, userprefix, userctlr, useraction, clientdata)
+-- This is a sample front controller/dispatch.
+mymodule.dispatch = function (self, userprefix, userctlr, useraction, clientdata)
local controller = nil
- local success, err = xpcall ( function ()
+ local success, err = xpcall ( function ()
self.conf.prefix = userprefix or "/"
self.conf.controller = userctlr or ""
self.conf.action = useraction or ""
@@ -153,7 +153,7 @@ mymodule.dispatch = function (self, userprefix, userctlr, useraction, clientdata
local action = controller.conf.action
- -- Because of the inheritance, normally the
+ -- Because of the inheritance, normally the
-- controller.worker.action will flow up, so that all children have
-- actions of all parents. We use rawget to make sure that only
-- controller defined actions are used on dispatch
@@ -163,13 +163,13 @@ mymodule.dispatch = function (self, userprefix, userctlr, useraction, clientdata
error (self.conf)
end
- -- run the (first found) pre_exec code, starting at the controller
+ -- run the (first found) pre_exec code, starting at the controller
-- and moving up the parents
if type(controller.worker.mvc.pre_exec) == "function" then
controller.worker.mvc.pre_exec ( controller )
end
- -- run the action
+ -- run the action
local viewtable = controller.worker[action](controller)
-- run the post_exec code
@@ -186,20 +186,20 @@ mymodule.dispatch = function (self, userprefix, userctlr, useraction, clientdata
local viewfunc, p1, p2, p3 = controller:view_resolver()
viewfunc (viewtable, p1, p2, p3)
end
-
+
-- we're done with the controller, destroy it
controller:destroy()
controller = nil
return viewtable
- end,
+ end,
self:soft_traceback(message)
)
if not success then
local handler
- if controller then
+ if controller then
handler = controller.worker or controller
if handler then handler:exception_handler(err) end
controller:destroy()
@@ -222,7 +222,7 @@ mymodule.soft_require = function (self, name )
if file then
file:close()
local PATH=package.path
- -- FIXME - this should really try to open the lua file,
+ -- FIXME - this should really try to open the lua file,
-- and if it doesnt exist silently fail.
-- This version allows things from /usr/local/lua/5.1 to
-- be loaded
@@ -270,7 +270,7 @@ mymodule.read_config = function( self, appname, home )
if self.conf.libdir then
package.path = string.gsub(self.conf.libdir, ",", "/?.lua;") .. "/?.lua;" .. package.path
end
-
+
if (#self.conf.confdir) then -- check for an appname-hooks.lua file
self.conf.app_hooks = {}
setmetatable (self.conf.app_hooks, {__index = _G})
@@ -295,7 +295,7 @@ end
-- parse a "URI" like string into a prefix, controller and action
-- return them (or blank strings)
mymodule.parse_path_info = function( str )
- str = str or ""
+ str = str or ""
local words = {}
str = string.gsub(str, "/+$", "")
for x=1,3 do
@@ -373,7 +373,7 @@ mymodule.view_resolver = function(self)
if viewname then
func = haserl.loadfile (viewname)
end
-
+
-- create the view helper library
viewlibrary = self:create_helper_library()
@@ -389,7 +389,7 @@ mymodule.view_resolver = function(self)
orig_action = self.conf.orig_action or self.conf.prefix .. self.conf.controller .. "/" .. self.conf.action,
clientdata = self.clientdata,
}
-
+
return func, viewlibrary, pageinfo, self.sessiondata
end
diff --git a/www/cgi-bin/acf b/www/cgi-bin/acf
index ef4ac56..9fbd7b2 100755
--- a/www/cgi-bin/acf
+++ b/www/cgi-bin/acf
@@ -1,5 +1,5 @@
#!/usr/bin/haserl-lua5.2 --shell=lua --upload-limit=256
-<%
+<%
mvc = require("acf.mvc")
-- create a new container
@@ -7,7 +7,7 @@ FRAMEWORK=mvc:new()
-- set the configuration parameters
-- This loads the container with the config info
--- but does not load the application worker/model
+-- but does not load the application worker/model
FRAMEWORK:read_config("acf")
-- Create an application container -