From 4bf7c04933f59a5afa245bf05644e1ecb5ddd36b Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Tue, 13 Jan 2009 16:01:06 +0000 Subject: 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/openssh/trunk@1677 ab2d0c66-481e-0410-8bed-d214d4d58bed --- openssh-model.lua | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/openssh-model.lua b/openssh-model.lua index a6722fc..b5efd74 100644 --- a/openssh-model.lua +++ b/openssh-model.lua @@ -69,7 +69,7 @@ function read_config() output.PasswordAuthentication = cfe({ type="boolean", value=true, label="Password Authentication" }) output.UseDNS = cfe({ type="boolean", value=true, label="Use DNS" }) - local config = format.parse_configfile(fs.read_file(configfile)) + local config = format.parse_configfile(fs.read_file(configfile) or "") if config then output.Port.value = config.Port or output.Port.value output.ListenAddress.value = config.ListenAddress or output.ListenAddress.value @@ -257,11 +257,7 @@ function create_auth(authstr) if success then local file = "/"..authstr.value.user.value.."/.ssh/authorized_keys" if authstr.value.user.value ~= "root" then file = "/home"..file end - local data = fs.read_file(file) - if not data then - posix.mkdir(dirname(file)) - data = "" - end + local data = fs.read_file(file) or "" if string.match(data, "^[%s\n]*$") then data = authstr.value.cert.value else -- cgit v1.2.3