diff options
author | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2014-09-29 16:19:43 +0300 |
---|---|---|
committer | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2014-09-29 16:19:43 +0300 |
commit | 3e98b6347234d2d2fc48d3da866f75960503974a (patch) | |
tree | 32f18f8a09381b63a26599996e418392fedbda1b | |
parent | 68213687a1624f67e3647d0d8b44e6855835e02b (diff) | |
download | awall-3e98b6347234d2d2fc48d3da866f75960503974a.tar.bz2 awall-3e98b6347234d2d2fc48d3da866f75960503974a.tar.xz |
use lua-posix rather than lua-filesystem
-rwxr-xr-x | awall-cli | 2 | ||||
-rw-r--r-- | awall/init.lua | 14 | ||||
-rw-r--r-- | awall/iptables.lua | 2 | ||||
-rw-r--r-- | awall/policy.lua | 11 |
4 files changed, 16 insertions, 13 deletions
@@ -276,7 +276,7 @@ if not call( if mode == 'dump' then dump(level) elseif mode == 'diff' then - if not require('lfs').attributes(dumpfile) then + if not require('posix').stat(dumpfile) then io.stderr:write('Please translate or activate first\n') os.exit(1) end diff --git a/awall/init.lua b/awall/init.lua index 4845b61..6e41c37 100644 --- a/awall/init.lua +++ b/awall/init.lua @@ -16,7 +16,9 @@ M.PolicySet = require('awall.policy') local util = require('awall.util') -local lfs = require('lfs') +local posix = require('posix') +local chdir = posix.chdir + local endswith = require('stringy').endswith @@ -42,11 +44,13 @@ function M.loadmodules(path) readmetadata(require('awall.model')) - local cdir = lfs.currentdir() - if path then lfs.chdir(path) end + local cdir = posix.getcwd() + if path then assert(chdir(path)) end local modules = {} - for modfile in lfs.dir((path or '/usr/share')..'/awall/modules') do + for _, modfile in ipairs( + posix.dir((path or '/usr/share')..'/awall/modules') + ) do if stringy.endswith(modfile, '.lua') then table.insert(modules, 'awall.modules.'..modfile:sub(1, -5)) end @@ -58,7 +62,7 @@ function M.loadmodules(path) util.extend(imported, readmetadata(require(name))) end - lfs.chdir(cdir) + assert(chdir(cdir)) events['%modules'] = {before=imported} procorder = resolve(events) diff --git a/awall/iptables.lua b/awall/iptables.lua index ef53706..dd5447b 100644 --- a/awall/iptables.lua +++ b/awall/iptables.lua @@ -12,7 +12,7 @@ local util = require('awall.util') local sortedkeys = util.sortedkeys -local mkdir = require('lfs').mkdir +local mkdir = require('posix').mkdir local lpc = require('lpc') diff --git a/awall/policy.lua b/awall/policy.lua index 0160a6f..8ad87db 100644 --- a/awall/policy.lua +++ b/awall/policy.lua @@ -17,7 +17,7 @@ local map = util.map local json = require('cjson') -local lfs = require('lfs') +local posix = require('posix') local PolicyConfig = class() @@ -86,7 +86,7 @@ end function Policy:enable() self:checkoptional() if self.enabled then raise('Policy already enabled: '..self.name) end - assert(lfs.link(self.path, self.confdir..'/'..self.fname, true)) + assert(posix.link(self.path, self.confdir..'/'..self.fname, true)) end function Policy:disable() @@ -110,18 +110,17 @@ function PolicySet:init(dirs) for i, cls in ipairs{'private', 'optional', 'mandatory'} do for i, dir in ipairs(dirs[cls] or defdirs[cls]) do - for fname in lfs.dir(dir) do + for _, fname in ipairs(posix.dir(dir)) do local si, ei, name = fname:find('^([%w-]+)%.json$') if name then local pol = self.policies[name] local path = dir..'/'..fname if path:sub(1, 1) ~= '/' then - path = lfs.currentdir()..'/'..path + path = posix.getcwd()..'/'..path end - local attrs = lfs.attributes(path) - local loc = attrs.dev..':'..attrs.ino + local loc = posix.realpath(path) if pol then if pol.loc ~= loc then |