]> git.sesse.net Git - vlc/commitdiff
httpd: remove ACL support
authorRémi Denis-Courmont <remi@remlab.net>
Sun, 1 Apr 2012 20:03:23 +0000 (23:03 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Sun, 1 Apr 2012 20:08:16 +0000 (23:08 +0300)
Lua was the only remaining user of ACL instead of (login/)password.
This is now fixed, so there is no need to clutter the httpd core.

include/vlc_httpd.h
modules/lua/libs/httpd.c
modules/stream_out/rtp.c
src/missing.c
src/network/httpd.c

index 1c4aaf75bc19bca8e6d660ddb7efed35089682c5..f48a05ed5f42ebc47b6a7b592ac4ce032f75ed75 100644 (file)
@@ -112,11 +112,11 @@ VLC_API char* httpd_ServerIP( const httpd_client_t *cl, char *, int * );
 
 /* High level */
 
-VLC_API httpd_file_t * httpd_FileNew( httpd_host_t *, const char *psz_url, const char *psz_mime, const char *psz_user, const char *psz_password, const vlc_acl_t *p_acl, httpd_file_callback_t pf_fill, httpd_file_sys_t * ) VLC_USED;
+VLC_API httpd_file_t * httpd_FileNew( httpd_host_t *, const char *psz_url, const char *psz_mime, const char *psz_user, const char *psz_password, httpd_file_callback_t pf_fill, httpd_file_sys_t * ) VLC_USED;
 VLC_API httpd_file_sys_t * httpd_FileDelete( httpd_file_t * );
 
 
-VLC_API httpd_handler_t * httpd_HandlerNew( httpd_host_t *, const char *psz_url, const char *psz_user, const char *psz_password, const vlc_acl_t *p_acl, httpd_handler_callback_t pf_fill, httpd_handler_sys_t * ) VLC_USED;
+VLC_API httpd_handler_t * httpd_HandlerNew( httpd_host_t *, const char *psz_url, const char *psz_user, const char *psz_password, httpd_handler_callback_t pf_fill, httpd_handler_sys_t * ) VLC_USED;
 VLC_API httpd_handler_sys_t * httpd_HandlerDelete( httpd_handler_t * );
 
 
index 7a975d4bb6d4df997bd315de0c7d3380dd83669a..28f3abd949f6b3fd560cec2c076eed84b21a8c88 100644 (file)
@@ -163,7 +163,7 @@ static int vlclua_httpd_handler_new( lua_State * L )
      * the callback's stack. */
     lua_xmove( L, p_sys->L, 2 );
     httpd_handler_t *p_handler = httpd_HandlerNew(
-                            *pp_host, psz_url, psz_user, psz_password, NULL,
+                            *pp_host, psz_url, psz_user, psz_password,
                             vlclua_httpd_handler_callback, p_sys );
     if( !p_handler )
     {
@@ -251,7 +251,7 @@ 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, NULL,
+                                          psz_user, psz_password,
                                           vlclua_httpd_file_callback, p_sys );
     if( !p_file )
     {
index 38316f9fbdd75cdcd00ab6bcc9da7a6a10c7c9ea..db3d69f9940d1a8f7fa5b9d48fb189394f2f7dfc 100644 (file)
@@ -1364,7 +1364,7 @@ static int HttpSetup( sout_stream_t *p_stream, const vlc_url_t *url)
         p_sys->p_httpd_file = httpd_FileNew( p_sys->p_httpd_host,
                                              url->psz_path ? url->psz_path : "/",
                                              "application/sdp",
-                                             NULL, NULL, NULL,
+                                             NULL, NULL,
                                              HttpCallback, (void*)p_sys );
     }
     if( p_sys->p_httpd_file == NULL )
index de6a7717ebe51298f429ede58426f254a150b2fb..7118d11ec69a14f53fb2f0c2dc9165a5794dfc27 100644 (file)
@@ -59,12 +59,11 @@ httpd_file_sys_t *httpd_FileDelete (httpd_file_t *file)
 httpd_file_t *httpd_FileNew (httpd_host_t *host,
                              const char *url, const char *content_type,
                              const char *login, const char *password,
-                             const vlc_acl_t *acl,
                              httpd_file_callback_t cb, httpd_file_sys_t *data)
 {
     (void) host;
     (void) url; (void) content_type;
-    (void) login; (void) password; (void) acl;
+    (void) login; (void) password;
     (void) cb; (void) data;
     assert (0);
 }
@@ -77,12 +76,11 @@ httpd_handler_sys_t *httpd_HandlerDelete (httpd_handler_t *handler)
 
 httpd_handler_t *httpd_HandlerNew (httpd_host_t *host, const char *url,
                                    const char *login, const char *password,
-                                   const vlc_acl_t *acl,
                                    httpd_handler_callback_t cb,
                                    httpd_handler_sys_t *data)
 {
     (void) host; (void) url;
-    (void) login; (void) password; (void) acl;
+    (void) login; (void) password;
     (void) cb; (void) data;
     assert (0);
 }
index 63351689729583d9d6259ca08aaffc393f03f28e..a79b52f246645d595b7ce645f32870f7e5275f36 100644 (file)
@@ -34,7 +34,6 @@
 
 #include <vlc_network.h>
 #include <vlc_tls.h>
-#include <vlc_acl.h>
 #include <vlc_strings.h>
 #include <vlc_rand.h>
 #include <vlc_charset.h>
@@ -68,9 +67,6 @@
 #endif
 
 static void httpd_ClientClean( httpd_client_t *cl );
-static httpd_url_t *httpd_UrlNewPrivate( httpd_host_t *, const char *,
-                                         const char *, const char *,
-                                         const vlc_acl_t * );
 
 /* each host run in his own thread */
 struct httpd_host_t
@@ -113,7 +109,6 @@ struct httpd_url_t
     char      *psz_url;
     char      *psz_user;
     char      *psz_password;
-    vlc_acl_t *p_acl;
 
     struct
     {
@@ -445,13 +440,12 @@ httpd_FileCallBack( httpd_callback_sys_t *p_sys, httpd_client_t *cl,
 httpd_file_t *httpd_FileNew( httpd_host_t *host,
                              const char *psz_url, const char *psz_mime,
                              const char *psz_user, const char *psz_password,
-                             const vlc_acl_t *p_acl, httpd_file_callback_t pf_fill,
+                             httpd_file_callback_t pf_fill,
                              httpd_file_sys_t *p_sys )
 {
     httpd_file_t *file = xmalloc( sizeof( httpd_file_t ) );
 
-    file->url = httpd_UrlNewPrivate( host, psz_url, psz_user, psz_password,
-                                     p_acl );
+    file->url = httpd_UrlNew( host, psz_url, psz_user, psz_password );
     if( file->url == NULL )
     {
         free( file );
@@ -592,14 +586,12 @@ httpd_HandlerCallBack( httpd_callback_sys_t *p_sys, httpd_client_t *cl,
 httpd_handler_t *httpd_HandlerNew( httpd_host_t *host, const char *psz_url,
                                    const char *psz_user,
                                    const char *psz_password,
-                                   const vlc_acl_t *p_acl,
                                    httpd_handler_callback_t pf_fill,
                                    httpd_handler_sys_t *p_sys )
 {
     httpd_handler_t *handler = xmalloc( sizeof( httpd_handler_t ) );
 
-    handler->url = httpd_UrlNewPrivate( host, psz_url, psz_user, psz_password,
-                                        p_acl );
+    handler->url = httpd_UrlNew( host, psz_url, psz_user, psz_password );
     if( handler->url == NULL )
     {
         free( handler );
@@ -852,8 +844,7 @@ httpd_stream_t *httpd_StreamNew( httpd_host_t *host,
 {
     httpd_stream_t *stream = xmalloc( sizeof( httpd_stream_t ) );
 
-    stream->url = httpd_UrlNewPrivate( host, psz_url, psz_user, psz_password,
-                                       NULL );
+    stream->url = httpd_UrlNew( host, psz_url, psz_user, psz_password );
     if( stream->url == NULL )
     {
         free( stream );
@@ -1199,9 +1190,8 @@ void httpd_HostDelete( httpd_host_t *host )
 }
 
 /* register a new url */
-static httpd_url_t *httpd_UrlNewPrivate( httpd_host_t *host, const char *psz_url,
-                                         const char *psz_user, const char *psz_password,
-                                         const vlc_acl_t *p_acl )
+httpd_url_t *httpd_UrlNew( httpd_host_t *host, const char *psz_url,
+                           const char *psz_user, const char *psz_password )
 {
     httpd_url_t *url;
 
@@ -1226,7 +1216,6 @@ static httpd_url_t *httpd_UrlNewPrivate( httpd_host_t *host, const char *psz_url
     url->psz_url = strdup( psz_url );
     url->psz_user = strdup( psz_user ? psz_user : "" );
     url->psz_password = strdup( psz_password ? psz_password : "" );
-    url->p_acl = ACL_Duplicate( host, p_acl );
     for( int i = 0; i < HTTPD_MSG_MAX; i++ )
     {
         url->catch[i].cb = NULL;
@@ -1240,12 +1229,6 @@ static httpd_url_t *httpd_UrlNewPrivate( httpd_host_t *host, const char *psz_url
     return url;
 }
 
-httpd_url_t *httpd_UrlNew( httpd_host_t *host, const char *psz_url,
-                           const char *psz_user, const char *psz_password )
-{
-    return httpd_UrlNewPrivate( host, psz_url, psz_user, psz_password, NULL );
-}
-
 /* register callback on a url */
 int httpd_UrlCatch( httpd_url_t *url, int i_msg, httpd_callback_t cb,
                     httpd_callback_sys_t *p_sys )
@@ -1271,7 +1254,6 @@ void httpd_UrlDelete( httpd_url_t *url )
     free( url->psz_url );
     free( url->psz_user );
     free( url->psz_password );
-    ACL_Destroy( url->p_acl );
 
     for( i = 0; i < host->i_client; i++ )
     {
@@ -2162,7 +2144,6 @@ static void* httpd_HostThread( void *data )
                 else
                 {
                     bool b_auth_failed = false;
-                    bool b_hosts_failed = false;
 
                     /* Search the url and trigger callbacks */
                     for(int i = 0; i < host->i_url; i++ )
@@ -2173,18 +2154,6 @@ static void* httpd_HostThread( void *data )
                         {
                             if( url->catch[i_msg].cb )
                             {
-                                if( answer && ( url->p_acl != NULL ) )
-                                {
-                                    char ip[NI_MAXNUMERICHOST];
-
-                                    if( ( httpd_ClientIP( cl, ip, NULL ) == NULL )
-                                     || ACL_Check( url->p_acl, ip ) )
-                                    {
-                                        b_hosts_failed = true;
-                                        break;
-                                    }
-                                }
-
                                 if( answer && ( *url->psz_user || *url->psz_password ) )
                                 {
                                     /* create the headers */
@@ -2252,11 +2221,7 @@ static void* httpd_HostThread( void *data )
                         answer->i_type   = HTTPD_MSG_ANSWER;
                         answer->i_version= 0;
 
-                        if( b_hosts_failed )
-                        {
-                            answer->i_status = 403;
-                        }
-                        else if( b_auth_failed )
+                        if( b_auth_failed )
                         {
                             answer->i_status = 401;
                         }