Commit 10086c53 authored by Mika Havela's avatar Mika Havela

Config-tab information: Some config-info is displayed in the config-tab.

Postmaster and etrn info (if it exists in the config).

git-svn-id: svn://svn.alpinelinux.org/acf/fetchmail/trunk@688 ab2d0c66-481e-0410-8bed-d214d4d58bed
parent 2eb595db
......@@ -194,7 +194,7 @@ if (cmdform) and (cmdform[tags[1]]) then
<? end ?>
<?
--[[ DEBUG INFORMATION
---[[ DEBUG INFORMATION
io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>")
io.write(html.cfe_unpack(form))
io.write("</span>")
......
......@@ -85,6 +85,105 @@ local function getmailboxes()
return mailboxes
end
local function read_config()
--[[
imap/pop3 lines are:
1 2 3 4 5 6 7 8 9 10
poll <host> protocol <proto> no dns username <uname> password <passwd>
11 12 13 14 15 16 17
is <localmailbox> smtphost <desthost> no rewrite fetchall
pop3domain lines are:
1 2 3 4 5 6 7 8 9 10 11 12
poll <host> localdomainst <domain> protocol pop3 no dns username <uname> password <passwd>
13 14 15 16 17 18 19 20 21 22
to * here smtphost <desthost> smtpaddress <domain> no rewrite fetchall
etrn is:
1 2 3 4 5 6
pool <host> protocol etrn smtpdomain <mydomain>
--]]
-- local configcontent = {}
local configcontent_popimap = {}
local configcontent_popdomain = {}
local configcontent_postmaster = {}
local configcontent_etrn = {}
local path = configfile
local valid = nil
configcontenttable = fs.read_file_as_array(path) or {}
for k,v in pairs(configcontenttable) do
if (string.match(v, "^%s*#Begin Fetchmail Webconf")) then valid=1 end
if (valid) then
-- if not (configcontent[k]) then configcontent[k] = {} end
-- if not (configcontent_popimap[k]) then configcontent_popimap[k] = {} end
-- if not (configcontent_popdomain[k]) then configcontent_popdomain[k] = {} end
local DISABLED = string.match(v, "^%s*(#)")
-- Set parameters for POP3 or IMAP
local val = {RHOST=2, CHECK=9 ,METHOD=4, RBOX=8, PASSWD=10, LBOX=12, LHOST=14}
local configcontent = {}
configcontent[k] = {}
for kk,vv in pairs(val) do
configcontent[k][kk] = tostring(string.match(v,"^%s*" .. string.rep("%S*%s*",vv-1) .. "(%S*)%s*"))
end
-- Remove quotes from passwords
if (configcontent[k]["PASSWD"]) then
configcontent[k]["PASSWD"] = string.match(configcontent[k]["PASSWD"], "^\"(.-)\"")
end
-- Check if row is valid config
if (configcontent[k]["CHECK"]) and (string.lower(configcontent[k]["CHECK"]) == "password") then
table.insert(configcontent_popimap,configcontent[k])
end
-- Set parameters for POP3domain
local val = {RHOST=2, METHOD=6, RBOX=10, CHECK=11, PASSWD=12, LHOST=17, DOMAIN=19,}
local configcontent = {}
configcontent[k] = {}
for kk,vv in pairs(val) do
configcontent[k][kk] = tostring(string.match(v,"^%s*" .. string.rep("%S*%s*",vv-1) .. "(%S*)%s*"))
end
-- Remove quotes from passwords
if (configcontent[k]["PASSWD"]) then
configcontent[k]["PASSWD"] = string.match(configcontent[k]["PASSWD"], "^\"(.-)\"")
end
-- Check if row is valid config
if (configcontent[k]["CHECK"]) and (string.lower(configcontent[k]["CHECK"]) == "password") then
table.insert(configcontent_popdomain,configcontent[k])
end
-- Set parameters for etrn
local val = {ETRNSMTPHOST=2, CHECK=4, ETRNDOMAIN=6}
local configcontent = {}
configcontent[k] = {}
for kk,vv in pairs(val) do
configcontent[k][kk] = tostring(string.match(v,"^%s*" .. string.rep("%S*%s*",vv-1) .. "(%S*)%s*"))
end
-- Check if row is valid config
if (configcontent[k]["CHECK"]) and (string.lower(configcontent[k]["CHECK"]) == "etrn") then
configcontent_etrn=configcontent[k]
end
-- Set parameters for postmaster
local val = {CHECK=2, POSTMASTER=3}
local configcontent = {}
configcontent[k] = {}
for kk,vv in pairs(val) do
configcontent[k][kk] = tostring(string.match(v,"^%s*" .. string.rep("%S*%s*",vv-1) .. "(%S*)%s*"))
end
-- Check if row is valid config
if (configcontent[k]["CHECK"]) and (string.lower(configcontent[k]["CHECK"]) == "postmaster") then
configcontent_postmaster=configcontent[k]
end
end
if (string.match(v, "^%s*#End Fetchmail Webconf")) then valid=nil end
end
configcontent = configcontent_postmaster
return configcontent,configcontent_etrn,configcontent_postmaster
end
-- ################################################################################
-- PUBLIC FUNCTIONS
......@@ -139,7 +238,6 @@ function get_filedetails()
local config = {}
local filenameerrtxt
if (fs.is_file(path)) then
configcontent = getopts.getoptsfromfile(path) or config
filedetails = fs.stat(path)
config = getconfig(path)
else
......@@ -190,12 +288,18 @@ function get_filedetails()
end
function getconfig()
local config = {}
if (fs.is_file(configfile)) then
configcontent = getopts.getoptsfromfile(configfile) or config
else
local configcontent, configcontentetrn, configcontent_postmaster = read_config()
if not (fs.is_file(configfile)) then
config["configfile"] = "Config file '".. configfile .. "' is missing!"
end
config["debug"] = cfe({
name="debug",
label = "Debug info",
type = "longtext",
value = configcontent,
})
-- Next section selects which configurations we should show to the user
......@@ -214,17 +318,17 @@ function getconfig()
config["postmaster"] = cfe({
name="postmaster",
label = "Postmaster",
value = "xxx@xxx.xx",
value = configcontent_postmaster["POSTMASTER"],
})
config["etrnremote"] = cfe({
name="etrnremote",
label = "Remote server",
value = "xxx",
value = configcontentetrn["ETRNSMTPHOST"],
})
config["etrnquedomain"] = cfe({
name="etrnquedomain",
label = "Queued domain",
value = "xxx",
value = configcontentetrn["ETRNDOMAIN"],
})
--[[
......
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