aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2017-04-28 10:13:48 +0300
committerKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2017-04-28 10:52:30 +0300
commit6ff7a43ec705cb25acf8f8d207f41ca7e85f944d (patch)
tree1c9dc43950bf5001b47e82b82d0ed96fd00048fd
parent5a4cb73b78f08accce72b6cf94a1cf6af9e0291e (diff)
downloadawall-6ff7a43ec705cb25acf8f8d207f41ca7e85f944d.tar.bz2
awall-6ff7a43ec705cb25acf8f8d207f41ca7e85f944d.tar.xz
Log: allow spaces in prefixv1.4.2
-rw-r--r--awall/model.lua3
-rw-r--r--awall/modules/log.lua10
-rw-r--r--awall/util.lua5
3 files changed, 12 insertions, 6 deletions
diff --git a/awall/model.lua b/awall/model.lua
index 7e6eb81..fbe4f34 100644
--- a/awall/model.lua
+++ b/awall/model.lua
@@ -551,8 +551,7 @@ function M.Rule:trules()
if not self.string.match then self:error('String match not defined') end
setdefault(self.string, 'algo', 'bm')
- local opts = '-m string --string "'..
- self.string.match:gsub('(["\\])', '\\%1')..'"'
+ local opts = '-m string --string '..util.quote(self.string.match)
for _, attr in ipairs{'algo', 'from', 'to'} do
if self.string[attr] then
diff --git a/awall/modules/log.lua b/awall/modules/log.lua
index d9e4b6c..2256228 100644
--- a/awall/modules/log.lua
+++ b/awall/modules/log.lua
@@ -9,13 +9,13 @@ local model = require('awall.model')
local class = model.class
local combinations = require('awall.optfrag').combinations
-local setdefault = require('awall.util').setdefault
+local util = require('awall.util')
local LogLimit = class(model.Limit)
function LogLimit:init(...)
- setdefault(self, 'src-mask', false)
+ util.setdefault(self, 'src-mask', false)
LogLimit.super(self):init(...)
end
@@ -74,7 +74,11 @@ function Log:target()
local res = mode:upper()
for s, t in pairs(optmap[mode]) do
- if self[s] then res = res..' --'..mode..'-'..t..' '..self[s] end
+ local value = self[s]
+ if value then
+ if s == 'prefix' then value = util.quote(value) end
+ res = res..' --'..mode..'-'..t..' '..value
+ end
end
return res
end
diff --git a/awall/util.lua b/awall/util.lua
index 909e3fb..a43da4a 100644
--- a/awall/util.lua
+++ b/awall/util.lua
@@ -1,6 +1,6 @@
--[[
Utility module for Alpine Wall
-Copyright (C) 2012-2016 Kaarle Ritvanen
+Copyright (C) 2012-2017 Kaarle Ritvanen
See LICENSE file for license details
]]--
@@ -116,6 +116,9 @@ function M.join(a, sep, b)
end
+function M.quote(s) return '"'..s:gsub('(["\\])', '\\%1')..'"' end
+
+
function M.printtabulars(tables)
local colwidth = {}
for i, tbl in ipairs(tables) do