From c89e42cf158941545540ad4f8e94f478dec50c1a Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Tue, 13 Jan 2009 16:01:06 +0000 Subject: Modified fs.lua to survive nil parameters. Added create_directory and used within create_file and write_file. Reviewed each read_file call to make sure handles nil return value. git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@1677 ab2d0c66-481e-0410-8bed-d214d4d58bed --- lib/roles.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/roles.lua') diff --git a/lib/roles.lua b/lib/roles.lua index e6e6515..b828458 100644 --- a/lib/roles.lua +++ b/lib/roles.lua @@ -89,7 +89,7 @@ list_default_roles = function(self) local rolesfiles = get_roles_candidates(self.conf.appdir) for x,file in ipairs(rolesfiles) do - f = fs.read_file_as_array(file) + f = fs.read_file_as_array(file) or {} for y,line in pairs(f) do if not reverseroles[string.match(line,"^[%w_]+")] then default_roles[#default_roles+1] = string.match(line,"^[%w_]+") @@ -139,7 +139,7 @@ get_roles_perm = function(self,roles) local rolesfiles = get_roles_candidates(self.conf.appdir) for x,file in ipairs(rolesfiles) do - f = fs.read_file_as_array(file) + f = fs.read_file_as_array(file) or {} for y,line in pairs(f) do if reverseroles[string.match(line,"^[%w_]+")] then temp = format.string_to_table(string.match(line,"[,%w_:]+$"),",") @@ -192,7 +192,7 @@ get_role_perm = function(self,role) local rolesfiles = get_roles_candidates(self.conf.appdir) for x,file in ipairs(rolesfiles) do - f = fs.read_file_as_array(file) + f = fs.read_file_as_array(file) or {} for y,line in pairs(f) do if role == string.match(line,"^[%w_]+") then temp = format.string_to_table(string.match(line,"[,%w_:]+$"),",") -- cgit v1.2.3