]> git.sesse.net Git - vlc/commitdiff
Fix acl use in http interface. Change default host to 0.0.0.0:8080. The default ...
authorAntoine Cellerier <antoine@macbook.(none)>
Mon, 14 Dec 2009 21:28:12 +0000 (22:28 +0100)
committerAntoine Cellerier <antoine@macbook.(none)>
Mon, 14 Dec 2009 22:29:51 +0000 (23:29 +0100)
modules/misc/lua/libs/httpd.c
share/lua/intf/http.lua

index 09ca8a4ec47e8cacb5eea92c09d842814091b789..1dcb1256fc59ece0ba2356163a9b6b44869f2bc2 100644 (file)
@@ -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 )
     {
index dbf4caaa8e4044f9b51983dddb8b63f7dcf42c25..484ec6a28a66dd17d89ae3ddd20a85ece2965728 100644 (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 )