From 63c4b0abf1bfb922d6497a816108c35b971a1d2d Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Tue, 11 Nov 2008 20:07:32 +0000 Subject: Fixed bug in authenticator-plaintext that erased user data from other fields when saving user data. git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@1594 ab2d0c66-481e-0410-8bed-d214d4d58bed --- lib/authenticator-plaintext.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lib/authenticator-plaintext.lua') diff --git a/lib/authenticator-plaintext.lua b/lib/authenticator-plaintext.lua index 73438e3..ad6c632 100644 --- a/lib/authenticator-plaintext.lua +++ b/lib/authenticator-plaintext.lua @@ -61,14 +61,20 @@ write_entry = function(self, tabl, field, id, entry) if not self or not tabl or tabl == "" or not field or not id or not entry then return false end - delete_entry(self, tabl, field, id) -- Set path to passwordfile local passwd_path = self.conf.confdir .. field .. tabl -- Write the newline into the file if fs.is_file(passwd_path) == false then fs.create_file(passwd_path) end if fs.is_file(passwd_path) == false then return false end - fs.write_line_file(passwd_path, id .. ":" .. entry) + local passwdfilecontent = fs.read_file_as_array(passwd_path) or {} + local output = {id .. ":" .. entry} + for k,v in pairs(passwdfilecontent) do + if not ( string.match(v, "^".. id .. "[:=]") ) and not string.match(v, "^%s*$") then + table.insert(output, v) + end + end + fs.write_file(passwd_path, table.concat(output, "\n")) return true end -- cgit v1.2.3