summaryrefslogtreecommitdiffstats
path: root/lib/authenticator-plaintext.lua
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2008-08-16 15:21:41 +0000
committerTed Trask <ttrask01@yahoo.com>2008-08-16 15:21:41 +0000
commit29de360eb486521a4e65d6e1452a8c623201c945 (patch)
tree9dc5a39aa85b0a9a5a211d43b104633d35b51d87 /lib/authenticator-plaintext.lua
parente552a644c3930f4bffe2ff17c331c0a035d02531 (diff)
downloadacf-core-29de360eb486521a4e65d6e1452a8c623201c945.tar.bz2
acf-core-29de360eb486521a4e65d6e1452a8c623201c945.tar.xz
Modified roles and authenticator to delete all data fields when deleting a role or user. Modified all roles code to pass self for future move from text file to database. Roles cannot use authenticator unless or until roles file syntax is changed.
git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@1382 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'lib/authenticator-plaintext.lua')
-rw-r--r--lib/authenticator-plaintext.lua27
1 files changed, 25 insertions, 2 deletions
diff --git a/lib/authenticator-plaintext.lua b/lib/authenticator-plaintext.lua
index aa3e2e3..e90520d 100644
--- a/lib/authenticator-plaintext.lua
+++ b/lib/authenticator-plaintext.lua
@@ -9,8 +9,23 @@ create a different file for each field.
module (..., package.seeall)
+list_fields = function(self, tabl)
+ if not self or not tabl or tabl == "" then
+ return {}
+ end
+
+ local fields = {}
+ for file in fs.find(".*"..tabl, self.conf.confdir) do
+ local field = string.match(file, "([^/]*)"..tabl.."$") or ""
+ if fs.is_file(file) and field ~= "" then
+ fields[#fields + 1] = field
+ end
+ end
+ return fields
+end
+
read_field = function(self, tabl, field)
- if not tabl or tabl == "" or not field then
+ if not self or not tabl or tabl == "" or not field then
return nil
end
@@ -34,7 +49,7 @@ read_field = function(self, tabl, field)
end
delete_field = function(self, tabl, field)
- if not tabl or tabl == "" or not field then
+ if not self or not tabl or tabl == "" or not field then
return false
end
local passwd_path = self.conf.confdir .. field .. tabl
@@ -95,5 +110,13 @@ delete_entry = function (self, tabl, field, id)
fs.write_file(passwd_path, table.concat(output,"\n"))
end
+ -- If deleting the main field, delete all other fields also
+ if field == "" then
+ local fields = list_fields(self, tabl)
+ for i,fld in ipairs(fields) do
+ delete_entry(self, tabl, fld, id)
+ end
+ end
+
return result
end