summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Angelacos <nangel@tetrasec.net>2007-12-09 18:07:00 +0000
committerNathan Angelacos <nangel@tetrasec.net>2007-12-09 18:07:00 +0000
commit1197c8530638be7e8123301f47ca863cd9598338 (patch)
tree3e9719a5114fcf3142aa1f3a17cd1ff618e278ba
parent48cf8a5a2da228724e519187469539d8a006d83f (diff)
downloadacf-core-1197c8530638be7e8123301f47ca863cd9598338.tar.bz2
acf-core-1197c8530638be7e8123301f47ca863cd9598338.tar.xz
added logevent function (hardcoded to write to /var/log/acf.log)
git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@421 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r--app/acf-util/logon-controller.lua32
-rw-r--r--app/acf-util/logon-model.lua2
-rw-r--r--app/acf_www-controller.lua12
-rw-r--r--lib/authenticator-plaintext.lua13
4 files changed, 33 insertions, 26 deletions
diff --git a/app/acf-util/logon-controller.lua b/app/acf-util/logon-controller.lua
index 18e4e0f..c0fa8b9 100644
--- a/app/acf-util/logon-controller.lua
+++ b/app/acf-util/logon-controller.lua
@@ -29,27 +29,23 @@ logon = function(self)
userid.errtxt = "There was a problem logging in"
else
-- the login was successful - give them a new session, and redir to logged in
- session.id = session.random_hash ( 512)
- session.userinfo = self.model.get_userinfo (userid)
- self.conf.controller="welcome"
- self.conf.action = ""
- self.conf.type = "redir"
- error (self.conf)
+ session.id = session.random_hash ( 512)
+ session.userinfo = self.model.get_userinfo (userid)
+ self.conf.controller="welcome"
+ self.conf.action = ""
+ self.conf.type = "redir"
+ logevent ("Logon was successful for " .. session.userinfo.username)
+ error (self.conf)
end
else
- self.conf.controller = ""
- self.conf.action = ""
- self.conf.prefix = ""
- self.conf.type = "redir"
- error(self.conf)
- end
-- If we reach this point, just give them the login page
- return ( cfe ({type="form",
- option={ script=ENV["SCRIPT_NAME"],
- prefix=self.conf.prefix,
- controller = self.conf.controller,
- action = "logon" },
- value = { userid, password, logon } }))
+ return ( cfe ({type="form",
+ option={ script=ENV["SCRIPT_NAME"],
+ prefix=self.conf.prefix,
+ controller = self.conf.controller,
+ action = "logon" },
+ value = { userid, password, logon } }))
+ end
end
diff --git a/app/acf-util/logon-model.lua b/app/acf-util/logon-model.lua
index 48b3cf2..dac48cd 100644
--- a/app/acf-util/logon-model.lua
+++ b/app/acf-util/logon-model.lua
@@ -26,7 +26,7 @@ logon = function (self, id, password )
-- record event and ignore the attempt
-- All ok?
-- look up their role, issue new session
- return auth.authenticate (id, password)
+ return auth.authenticate (self, id, password)
end
logoff = function (self, sessionid)
diff --git a/app/acf_www-controller.lua b/app/acf_www-controller.lua
index 03ad5da..1d5966e 100644
--- a/app/acf_www-controller.lua
+++ b/app/acf_www-controller.lua
@@ -17,7 +17,9 @@ local parent_exception_handler
mvc = {}
mvc.on_load = function (self, parent)
-
+ -- open the log file
+ self.conf.logfile = io.open ("/var/log/acf.log", "a+")
+
-- Make sure we have some kind of sane defaults for libdir and sessiondir
self.conf.libdir = self.conf.libdir or ( self.conf.appdir .. "/lib/" )
self.conf.sessiondir = self.conf.sessiondir or "/tmp/"
@@ -71,6 +73,8 @@ mvc.post_exec = function (self)
sessionlib.save_session(conf.sessiondir,
sessiondata.id, sessiondata)
end
+ -- Close the logfile
+ conf.logfile:close()
end
@@ -228,3 +232,9 @@ cfe = function ( optiontable )
return me
end
+-- FIXME - need to think more about this..
+logevent = function ( message )
+ conf.logfile:write (string.format("%s: %s\n", os.date(), message))
+end
+
+
diff --git a/lib/authenticator-plaintext.lua b/lib/authenticator-plaintext.lua
index 6c58565..d18f5bb 100644
--- a/lib/authenticator-plaintext.lua
+++ b/lib/authenticator-plaintext.lua
@@ -21,13 +21,14 @@ pvt.parse_authfile = function(filename)
-- open our password file
local f = io.open (filename)
if f then
- local m = f:read("*all") .. "\n"
+ local m = (f:read("*all") or "" ).. "\n"
f:close()
-
+
for l in string.gmatch(m, "(%C*)\n") do
local userid, password, username, roles =
string.match(l, "([^:]*):([^:]*):([^:]*):(.*)")
local r = {}
+ roles=roles or ""
for x in string.gmatch(roles, "([^,]*),?") do
table.insert (r, x )
end
@@ -58,11 +59,11 @@ end
-- This function returns true or false, and
-- if false: the reason for failure
-authenticate = function ( userid, password )
+authenticate = function ( self, userid, password )
password = password or ""
userid = userid or ""
- local t = pvt.parse_authfile(conf.confdir .. "/passwd")
+ local t = pvt.parse_authfile(self.conf.confdir .. "/passwd")
if t == false then
return false, "password file is missing"
@@ -81,8 +82,8 @@ authenticate = function ( userid, password )
-- This function returns the username and roles
-- or false on an error
-userinfo = function ( userid )
- local t = pvt.parse_authfile(conf.confdir .. "/passwd")
+userinfo = function ( self, userid )
+ local t = pvt.parse_authfile(self.conf.confdir .. "/passwd")
if t == false then
return false
else