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 = \ ...@@ -283,7 +283,6 @@ DIST_http_lua = \
lua/http/dialogs/batch_window.html \ lua/http/dialogs/batch_window.html \
lua/http/dialogs/error_window.html \ lua/http/dialogs/error_window.html \
lua/http/dialogs/browse_window.html \ lua/http/dialogs/browse_window.html \
lua/http/dialogs/.hosts \
lua/http/dialogs/stream_window.html \ lua/http/dialogs/stream_window.html \
lua/http/dialogs/offset_window.html \ lua/http/dialogs/offset_window.html \
lua/http/dialogs/stream_config_window.html \ lua/http/dialogs/stream_config_window.html \
...@@ -346,7 +345,6 @@ DIST_http_lua = \ ...@@ -346,7 +345,6 @@ DIST_http_lua = \
lua/http/mobile_browse.html \ lua/http/mobile_browse.html \
lua/http/favicon.ico \ lua/http/favicon.ico \
lua/http/mobile_view.html \ lua/http/mobile_view.html \
lua/http/.hosts \
lua/http/requests/playlist.xml \ lua/http/requests/playlist.xml \
lua/http/requests/playlist.json \ lua/http/requests/playlist.json \
lua/http/requests/README.txt \ 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) ...@@ -116,7 +116,7 @@ function callback_error(path,url,msg)
</html>]] </html>]]
end end
function dirlisting(url,listing,acl_) function dirlisting(url,listing)
local list = {} local list = {}
for _,f in ipairs(listing) do for _,f in ipairs(listing) do
if not string.match(f,"^%.") then if not string.match(f,"^%.") then
...@@ -134,7 +134,7 @@ function dirlisting(url,listing,acl_) ...@@ -134,7 +134,7 @@ function dirlisting(url,listing,acl_)
</body> </body>
</html>]] </html>]]
end end
return h:file(url,"text/html",nil,password,acl_,callback,nil) return h:file(url,"text/html",nil,password,nil,callback,nil)
end end
-- FIXME: Experimental art support. Needs some cleaning up. -- FIXME: Experimental art support. Needs some cleaning up.
...@@ -181,7 +181,7 @@ Error ...@@ -181,7 +181,7 @@ Error
return content return content
end end
function file(h,path,url,acl_,mime) function file(h,path,url,mime)
local generate_page = process(path) local generate_page = process(path)
local callback = function(data,request) local callback = function(data,request)
-- FIXME: I'm sure that we could define a real sandbox -- FIXME: I'm sure that we could define a real sandbox
...@@ -207,10 +207,10 @@ function file(h,path,url,acl_,mime) ...@@ -207,10 +207,10 @@ function file(h,path,url,acl_,mime)
end end
return table.concat(page) return table.concat(page)
end 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 end
function rawfile(h,path,url,acl_) function rawfile(h,path,url)
local filename = path local filename = path
local mtime = 0 -- vlc.net.stat(filename).modification_time local mtime = 0 -- vlc.net.stat(filename).modification_time
local page = false -- io.open(filename):read("*a") local page = false -- io.open(filename):read("*a")
...@@ -228,7 +228,7 @@ function rawfile(h,path,url,acl_) ...@@ -228,7 +228,7 @@ function rawfile(h,path,url,acl_)
end end
return page return page
end 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 end
function parse_url_request(request) function parse_url_request(request)
...@@ -278,19 +278,9 @@ do ...@@ -278,19 +278,9 @@ do
package.path = oldpath package.path = oldpath
end end
local files = {} local files = {}
local function load_dir(dir,root,parent_acl) local function load_dir(dir,root)
local root = root or "/" local root = root or "/"
local has_index = false 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) local d = vlc.net.opendir(dir)
for _,f in ipairs(d) do for _,f in ipairs(d) do
if not string.match(f,"^%.") then if not string.match(f,"^%.") then
...@@ -307,20 +297,19 @@ local function load_dir(dir,root,parent_acl) ...@@ -307,20 +297,19 @@ local function load_dir(dir,root,parent_acl)
local mime = mimes[ext] local mime = mimes[ext]
-- print(url,mime) -- print(url,mime)
if mime and string.match(mime,"^text/") then 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 else
table.insert(files,rawfile(h,dir.."/"..f,url,my_acl)) table.insert(files,rawfile(h,dir.."/"..f,url))
end end
elseif s.type == "dir" then elseif s.type == "dir" then
load_dir(dir.."/"..f,root..f.."/",my_acl) load_dir(dir.."/"..f,root..f.."/")
end end
end end
end end
if not has_index and not config.no_index then if not has_index and not config.no_index then
-- print("Adding index for", root) -- print("Adding index for", root)
table.insert(files,dirlisting(root,d,my_acl)) table.insert(files,dirlisting(root,d))
end end
return my_acl
end end
if config.host then if config.host then
...@@ -331,5 +320,4 @@ end ...@@ -331,5 +320,4 @@ end
password = vlc.var.inherit(nil,"http-password") password = vlc.var.inherit(nil,"http-password")
h = vlc.httpd() h = vlc.httpd()
local root_acl = load_dir( http_dir ) local a = h:handler("/art",nil,password,nil,callback_art,nil)
local a = h:handler("/art",nil,password,root_acl,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