Commit fe31e420 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Lua http: remove ACL in favor of the password

parent e8150e43
......@@ -283,7 +283,6 @@ DIST_http_lua = \
lua/http/dialogs/batch_window.html \
lua/http/dialogs/error_window.html \
lua/http/dialogs/browse_window.html \
lua/http/dialogs/.hosts \
lua/http/dialogs/stream_window.html \
lua/http/dialogs/offset_window.html \
lua/http/dialogs/stream_config_window.html \
......@@ -346,7 +345,6 @@ DIST_http_lua = \
lua/http/mobile_browse.html \
lua/http/favicon.ico \
lua/http/mobile_view.html \
lua/http/.hosts \
lua/http/requests/playlist.xml \
lua/http/requests/playlist.json \
lua/http/requests/README.txt \
......
#
# Access-list for VLC HTTP interface
# $Id$
#
# localhost
::1
127.0.0.1
# link-local addresses
#fe80::/64
# private addresses
#fc00::/7
#fec0::/10
#10.0.0.0/8
#172.16.0.0/12
#192.168.0.0/16
#169.254.0.0/16
# The world (uncommenting these 2 lines is not quite safe)
#::/0
#0.0.0.0/0
# This file is an empty access list. Leave it as is.
# You are not supposed to access files from this directory directly.
......@@ -116,7 +116,7 @@ function callback_error(path,url,msg)
</html>]]
end
function dirlisting(url,listing,acl_)
function dirlisting(url,listing)
local list = {}
for _,f in ipairs(listing) do
if not string.match(f,"^%.") then
......@@ -134,7 +134,7 @@ function dirlisting(url,listing,acl_)
</body>
</html>]]
end
return h:file(url,"text/html",nil,password,acl_,callback,nil)
return h:file(url,"text/html",nil,password,nil,callback,nil)
end
-- FIXME: Experimental art support. Needs some cleaning up.
......@@ -181,7 +181,7 @@ Error
return content
end
function file(h,path,url,acl_,mime)
function file(h,path,url,mime)
local generate_page = process(path)
local callback = function(data,request)
-- FIXME: I'm sure that we could define a real sandbox
......@@ -207,10 +207,10 @@ function file(h,path,url,acl_,mime)
end
return table.concat(page)
end
return h:file(url or path,mime,nil,password,acl_,callback,nil)
return h:file(url or path,mime,nil,password,nil,callback,nil)
end
function rawfile(h,path,url,acl_)
function rawfile(h,path,url)
local filename = path
local mtime = 0 -- vlc.net.stat(filename).modification_time
local page = false -- io.open(filename):read("*a")
......@@ -228,7 +228,7 @@ function rawfile(h,path,url,acl_)
end
return page
end
return h:file(url or path,nil,nil,password,acl_,callback,nil)
return h:file(url or path,nil,nil,password,nil,callback,nil)
end
function parse_url_request(request)
......@@ -278,19 +278,9 @@ do
package.path = oldpath
end
local files = {}
local function load_dir(dir,root,parent_acl)
local function load_dir(dir,root)
local root = root or "/"
local has_index = false
local my_acl = parent_acl
do
local af = dir.."/.hosts"
local s = vlc.net.stat(af)
if s and s.type == "file" then
-- We found an acl
my_acl = vlc.acl(false)
my_acl:load_file(af)
end
end
local d = vlc.net.opendir(dir)
for _,f in ipairs(d) do
if not string.match(f,"^%.") then
......@@ -307,20 +297,19 @@ local function load_dir(dir,root,parent_acl)
local mime = mimes[ext]
-- print(url,mime)
if mime and string.match(mime,"^text/") then
table.insert(files,file(h,dir.."/"..f,url,my_acl,mime))
table.insert(files,file(h,dir.."/"..f,url,mime))
else
table.insert(files,rawfile(h,dir.."/"..f,url,my_acl))
table.insert(files,rawfile(h,dir.."/"..f,url))
end
elseif s.type == "dir" then
load_dir(dir.."/"..f,root..f.."/",my_acl)
load_dir(dir.."/"..f,root..f.."/")
end
end
end
if not has_index and not config.no_index then
-- print("Adding index for", root)
table.insert(files,dirlisting(root,d,my_acl))
table.insert(files,dirlisting(root,d))
end
return my_acl
end
if config.host then
......@@ -331,5 +320,4 @@ end
password = vlc.var.inherit(nil,"http-password")
h = vlc.httpd()
local root_acl = load_dir( http_dir )
local a = h:handler("/art",nil,password,root_acl,callback_art,nil)
local a = h:handler("/art",nil,password,nil,callback_art,nil)
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