From 1197c8530638be7e8123301f47ca863cd9598338 Mon Sep 17 00:00:00 2001 From: Nathan Angelacos Date: Sun, 9 Dec 2007 18:07:00 +0000 Subject: 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 --- lib/authenticator-plaintext.lua | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'lib/authenticator-plaintext.lua') 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 -- cgit v1.2.3