* libs/httpd: also handle missing directory permissions correctly

This commit is contained in:
Jo-Philipp Wich 2008-06-30 12:06:49 +00:00
parent d7697624c4
commit 3b2eae63a3

View file

@ -137,6 +137,7 @@ function Simple.handle_get(self, request, sourcein, sinkerr)
local entries = luci.fs.dir( file ) local entries = luci.fs.dir( file )
if type(entries) == "table" then
for i, e in luci.util.spairs( for i, e in luci.util.spairs(
entries, function(a,b) entries, function(a,b)
if entries[a] == '..' then if entries[a] == '..' then
@ -163,7 +164,8 @@ function Simple.handle_get(self, request, sourcein, sinkerr)
html = html .. string.format( html = html .. string.format(
'<li><p><a href="%s/%s">%s</a> ' .. '<li><p><a href="%s/%s">%s</a> ' ..
'<small>(%s)</small><br />' .. '<small>(%s)</small><br />' ..
'<small>Size: %i Bytes | Changed: %s</small></li>', '<small>Size: %i Bytes | ' ..
'Changed: %s</small></li>',
ruri, self.proto.urlencode( e ), e, ruri, self.proto.urlencode( e ), e,
self.mime.to_mime( e ), self.mime.to_mime( e ),
estat.size, self.date.to_http( estat.mtime ) estat.size, self.date.to_http( estat.mtime )
@ -180,6 +182,9 @@ function Simple.handle_get(self, request, sourcein, sinkerr)
["Content-Type"] = "text/html; charset=ISO-8859-15"; ["Content-Type"] = "text/html; charset=ISO-8859-15";
} }
), ltn12.source.string(html) ), ltn12.source.string(html)
else
return self:failure(403, "Permission denied")
end
else else
return self:failure(403, "Unable to transmit " .. stat.type .. " " .. file) return self:failure(403, "Unable to transmit " .. stat.type .. " " .. file)
end end