From fe31e42032f3e14d55eb57c73ab7070e5aafcce6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Denis-Courmont?= Date: Sun, 1 Apr 2012 22:47:30 +0300 Subject: [PATCH] Lua http: remove ACL in favor of the password --- share/Makefile.am | 2 -- share/lua/http/.hosts | 24 ----------------------- share/lua/http/dialogs/.hosts | 2 -- share/lua/intf/http.lua | 36 ++++++++++++----------------------- 4 files changed, 12 insertions(+), 52 deletions(-) delete mode 100644 share/lua/http/.hosts delete mode 100644 share/lua/http/dialogs/.hosts diff --git a/share/Makefile.am b/share/Makefile.am index 0794c7f001..cc00c68bf2 100644 --- a/share/Makefile.am +++ b/share/Makefile.am @@ -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 \ diff --git a/share/lua/http/.hosts b/share/lua/http/.hosts deleted file mode 100644 index 6f54ae01b6..0000000000 --- a/share/lua/http/.hosts +++ /dev/null @@ -1,24 +0,0 @@ -# -# 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 - diff --git a/share/lua/http/dialogs/.hosts b/share/lua/http/dialogs/.hosts deleted file mode 100644 index bec63ac185..0000000000 --- a/share/lua/http/dialogs/.hosts +++ /dev/null @@ -1,2 +0,0 @@ -# This file is an empty access list. Leave it as is. -# You are not supposed to access files from this directory directly. diff --git a/share/lua/intf/http.lua b/share/lua/intf/http.lua index aa0f1560c5..dc7d5d3697 100644 --- a/share/lua/intf/http.lua +++ b/share/lua/intf/http.lua @@ -116,7 +116,7 @@ function callback_error(path,url,msg) ]] 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_) ]] 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) -- 2.39.2