Commit 3e98b634 authored by Kaarle Ritvanen's avatar Kaarle Ritvanen

use lua-posix rather than lua-filesystem

parent 68213687
......@@ -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
......
......@@ -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)
......
......@@ -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')
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment