summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-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
8 files changed, 42 insertions, 42 deletions
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)