summaryrefslogtreecommitdiffstats
path: root/openssl-model.lua
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2009-01-13 16:01:06 +0000
committerTed Trask <ttrask01@yahoo.com>2009-01-13 16:01:06 +0000
commit9457621e19a8c7475412782ad15225a44302006d (patch)
tree3c8653f859d45a1770d6cdef0c8af8f8786361cf /openssl-model.lua
parent48b96d8cdb497db2ea0320d27fd6e15907dd8809 (diff)
downloadacf-openssl-9457621e19a8c7475412782ad15225a44302006d.tar.bz2
acf-openssl-9457621e19a8c7475412782ad15225a44302006d.tar.xz
Modified fs.lua to survive nil parameters. Added create_directory and used within create_file and write_file. Reviewed each read_file call to make sure handles nil return value.
git-svn-id: svn://svn.alpinelinux.org/acf/openssl/trunk@1677 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'openssl-model.lua')
-rw-r--r--openssl-model.lua18
1 files changed, 9 insertions, 9 deletions
diff --git a/openssl-model.lua b/openssl-model.lua
index 01edc07..470d9ba 100644
--- a/openssl-model.lua
+++ b/openssl-model.lua
@@ -308,7 +308,7 @@ getreqdefaults = function()
value=config.ca.default_ca, option=find_ca_sections() })
-- Add in the extensions
local extensions = ""
- local content = fs.read_file(configfile)
+ local content = fs.read_file(configfile) or ""
config = config or format.parse_ini_file(content)
if config.req.req_extensions then
extensions = format.get_ini_section(content, config.req.req_extensions)
@@ -323,7 +323,7 @@ setreqdefaults = function(defaults)
-- If success, write the values to the config file
if success then
- local fileval = fs.read_file(configfile)
+ local fileval = fs.read_file(configfile) or ""
config = config or format.parse_ini_file(fileval)
local ext_section
if not config.req or not config.req.req_extensions then
@@ -384,7 +384,7 @@ submitrequest = function(defaults, user)
local subject = create_subject_string(defaults, {"password", "password_confirm", "certtype", "extensions"})
-- Generate a temp config file for this request
- local fileval = fs.read_file(configfile)
+ local fileval = fs.read_file(configfile) or ""
config = config or format.parse_ini_file(fileval)
local temp = format.dostounix(defaults.value.extensions.value)
local ext_section
@@ -468,7 +468,7 @@ approverequest = function(request)
-- Add the serial number to the end of the cert file name
local serialpath = getconfigentry(certtype, "serial")
- local serialfile = fs.read_file(serialpath)
+ local serialfile = fs.read_file(serialpath) or ""
local serial = string.match(serialfile, "%x%x")
local certname = certdir..request.."."..serial
@@ -562,7 +562,7 @@ viewcert = function(cert)
end
getcert = function(cert)
- local f = fs.read_file(certdir..cert..".pfx")
+ local f = fs.read_file(certdir..cert..".pfx") or ""
local a,b,c,d = string.match(cert, "([^%.]*)%.([^%.]*)%.([^%.]*).([^%.]*)")
c = string.gsub(unhashname(c), "[^%w_-]", "")
return cfe({ type="raw", value=f, label=c..".pfx", option="application/x-pkcs12" })
@@ -640,7 +640,7 @@ listrevoked = function()
config = config or format.parse_ini_file(fs.read_file(configfile) or "")
local databasepath = getconfigentry(config.ca.default_ca, "database")
local revoked = {}
- local database = fs.read_file_as_array(databasepath)
+ local database = fs.read_file_as_array(databasepath) or {}
for x,line in ipairs(database) do
if string.sub(line,1,1) == "R" then
revoked[#revoked + 1] = string.match(line, "^%S+%s+%S+%s+%S+%s+(%S+)")
@@ -659,12 +659,12 @@ getcrl = function(crltype)
f:close()
if crltype == "DER" then
crlfile.label = "ca-der-crl.crl"
- crlfile.value = fs.read_file(crlfile.label)
+ crlfile.value = fs.read_file(crlfile.label) or ""
elseif crltype == "PEM" then
crlfile.label = "ca-crl.crl"
- crlfile.value = fs.read_file(crlfile.label)
+ crlfile.value = fs.read_file(crlfile.label) or ""
else
- crlfile.value = fs.read_file("ca-crl.crl")
+ crlfile.value = fs.read_file("ca-crl.crl") or ""
end
return crlfile
end