Commit 9bb85a17 authored by Antoine Cellerier's avatar Antoine Cellerier

Fix acl use in http interface. Change default host to 0.0.0.0:8080. The...

Fix acl use in http interface. Change default host to 0.0.0.0:8080. The default .hosts file still limits access to default host.
parent b7c10087
......@@ -164,7 +164,7 @@ static int vlclua_httpd_handler_new( lua_State * L )
const char *psz_url = luaL_checkstring( L, 2 );
const char *psz_user = luaL_nilorcheckstring( L, 3 );
const char *psz_password = luaL_nilorcheckstring( L, 4 );
const vlc_acl_t *p_acl = lua_isnil( L, 5 ) ? NULL : luaL_checkudata( L, 5, "acl" );
const vlc_acl_t **pp_acl = lua_isnil( L, 5 ) ? NULL : luaL_checkudata( L, 5, "acl" );
/* Stack item 6 is the callback function */
luaL_argcheck( L, lua_isfunction( L, 6 ), 6, "Should be a function" );
/* Stack item 7 is the callback data */
......@@ -180,7 +180,8 @@ static int vlclua_httpd_handler_new( lua_State * L )
lua_xmove( L, p_sys->L, 2 );
httpd_handler_t *p_handler = httpd_HandlerNew(
*pp_host, psz_url, psz_user, psz_password,
p_acl, vlclua_httpd_handler_callback, p_sys );
pp_acl?*pp_acl:NULL,
vlclua_httpd_handler_callback, p_sys );
if( !p_handler )
{
free( p_sys );
......@@ -256,7 +257,7 @@ static int vlclua_httpd_file_new( lua_State *L )
const char *psz_mime = luaL_nilorcheckstring( L, 3 );
const char *psz_user = luaL_nilorcheckstring( L, 4 );
const char *psz_password = luaL_nilorcheckstring( L, 5 );
const vlc_acl_t *p_acl = lua_isnil( L, 6 ) ? NULL : luaL_checkudata( L, 6, "acl" );
const vlc_acl_t **pp_acl = lua_isnil( L, 6 ) ? NULL : luaL_checkudata( L, 6, "acl" );
/* Stack item 7 is the callback function */
luaL_argcheck( L, lua_isfunction( L, 7 ), 7, "Should be a function" );
/* Stack item 8 is the callback data */
......@@ -268,7 +269,8 @@ static int vlclua_httpd_file_new( lua_State *L )
p_sys->ref = luaL_ref( L, LUA_REGISTRYINDEX ); /* pops the object too */
lua_xmove( L, p_sys->L, 2 );
httpd_file_t *p_file = httpd_FileNew( *pp_host, psz_url, psz_mime,
psz_user, psz_password, p_acl,
psz_user, psz_password,
pp_acl?*pp_acl:NULL,
vlclua_httpd_file_callback, p_sys );
if( !p_file )
{
......
......@@ -258,9 +258,9 @@ 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 and my_acl.private,mime))
table.insert(files,file(h,dir.."/"..f,url,my_acl,mime))
else
table.insert(files,rawfile(h,dir.."/"..f,url,my_acl and my_acl.private))
table.insert(files,rawfile(h,dir.."/"..f,url,my_acl))
end
elseif s.type == "dir" then
load_dir(dir.."/"..f,root..f.."/",my_acl)
......@@ -269,11 +269,11 @@ local function load_dir(dir,root,parent_acl)
end
if not has_index and not config.no_index then
-- print("Adding index for", root)
table.insert(files,dirlisting(root,d,my_acl and my_acl.private))
table.insert(files,dirlisting(root,d,my_acl))
end
end
local u = vlc.net.url_parse( config.host or "localhost:8080" )
local u = vlc.net.url_parse( config.host or "0.0.0.0:8080" )
h = vlc.httpd(u.host,u.port)
load_dir( http_dir )
......
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