summaryrefslogtreecommitdiffstats
path: root/lbu-model.lua
diff options
context:
space:
mode:
authorMika Havela <mika.havela@gmail.com>2008-01-23 14:31:44 +0000
committerMika Havela <mika.havela@gmail.com>2008-01-23 14:31:44 +0000
commitb6c2c25e5e99b6d8515a777a00f5a97c1f6b1d23 (patch)
tree8d38ec02518e736922c41961545d8123191641b0 /lbu-model.lua
parent8d5450a1ad2402c0e5b764a5e033cd9134dd4d23 (diff)
downloadacf-alpine-conf-b6c2c25e5e99b6d8515a777a00f5a97c1f6b1d23.tar.bz2
acf-alpine-conf-b6c2c25e5e99b6d8515a777a00f5a97c1f6b1d23.tar.xz
Forcing user to enter valid options in the config-tab before making a commit.
Displaying current errors in the config/settings. git-svn-id: svn://svn.alpinelinux.org/acf/alpine-conf/trunk@628 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'lbu-model.lua')
-rw-r--r--lbu-model.lua30
1 files changed, 25 insertions, 5 deletions
diff --git a/lbu-model.lua b/lbu-model.lua
index b0f5cf7..3b804ee 100644
--- a/lbu-model.lua
+++ b/lbu-model.lua
@@ -33,10 +33,18 @@ local function getLbuStatus()
end
local function getLbuCommit(flag)
+ local err = {}
+ local ret = ""
local f = io.popen("/sbin/lbu commit " .. flag .. " 2>&1", "r")
- local ret = f:read("*a")
+-- local ret = f:read("*a")
+ for line in f:lines() do
+ ret = ret .. line .. "\n"
+ --Look for error messages in output
+ local searchrow, search = string.match(line, "^(lbu.*(%-%a).*)")
+ if (search) then err[search] = searchrow end
+ end
f:close()
- return ret
+ return ret, err
end
local function getciphers()
@@ -83,6 +91,7 @@ end
function getstatus ()
local path = configfile
local status = {}
+ local errors = {}
local statustxt = nil
local lbustatus = list()
if (#lbustatus == 0) then
@@ -96,7 +105,16 @@ function getstatus ()
status["DEFAULT_CIPHER"] = config["DEFAULT_CIPHER"]
status["version"] = get_version()
status["status"] = statustxt
- return status
+ if (status["LBU_MEDIA"] == "") or (status["LBU_MEDIA"] == nil) then
+ errors["LBU_MEDIA"] = "'Media' needs to be configured!"
+ end
+ if (config["PASSWORD"] == nil) and (config["ENCRYPTION"] ~= nil) then
+ errors["PASSWORD"] = "Encryption without password is not allowed!<BR> Deactivate 'Password protection' or configure a password!"
+ end
+ for k,v in pairs(errors) do
+ errors["last"] = v
+ end
+ return status, errors
end
function list(self)
@@ -110,11 +128,13 @@ function list(self)
end
function getcommit(self, flag)
- if flag ~= "-d" then flag = "" end
+ --See to that only allowed flags are passed to the process
+ flag = string.match(flag or "", "%-%a") or ""
return getLbuCommit("-v " .. flag)
end
function getsimulate(self, flag)
- if flag ~= "-d" then flag = "" end
+ --See to that only allowed flags are passed to the process
+ flag = string.match(flag or "", "%-%a") or ""
return getLbuCommit("-n " .. flag)
end