[vlc-commits] Lua http: add a configurable password

Rémi Denis-Courmont git at videolan.org
Sun Apr 1 21:37:43 CEST 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Apr  1 22:36:11 2012 +0300| [3a4e084c4da5e7a2e8dbe7cabca2fd875b290517] | committer: Rémi Denis-Courmont

Lua http: add a configurable password

This is way more flexible than ACL:
 - does not need admin rights to edit,
 - does not assume the clients have fixed IP addresses,
 - does not assume the clients are single user systems,
 - is a better understood concept than access control lists.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3a4e084c4da5e7a2e8dbe7cabca2fd875b290517
---

 modules/lua/vlc.c       |    4 ++++
 share/lua/intf/http.lua |    9 +++++----
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/modules/lua/vlc.c b/modules/lua/vlc.c
index 8ac0466..0c43e07 100644
--- a/modules/lua/vlc.c
+++ b/modules/lua/vlc.c
@@ -50,6 +50,9 @@
 
 #define CONFIG_TEXT N_("Lua interface configuration")
 #define CONFIG_LONGTEXT N_("Lua interface configuration string. Format is: '[\"<interface module name>\"] = { <option> = <value>, ...}, ...'.")
+#define PASS_TEXT N_( "Password" )
+#define PASS_LONGTEXT N_( "A single password restricts access " \
+    "to this interface." )
 #define SRC_TEXT N_( "Source directory" )
 #define SRC_LONGTEXT N_( "Source directory" )
 #define INDEX_TEXT N_( "Directory index" )
@@ -91,6 +94,7 @@ vlc_module_begin ()
 
     add_submodule ()
         set_section( N_("Lua HTTP"), 0 )
+            add_password ( "http-password", NULL, PASS_TEXT, PASS_LONGTEXT, false )
             add_string ( "http-src",  NULL, SRC_TEXT,  SRC_LONGTEXT,  true )
             add_bool   ( "http-index", false, INDEX_TEXT, INDEX_LONGTEXT, true )
         set_capability( "interface", 0 )
diff --git a/share/lua/intf/http.lua b/share/lua/intf/http.lua
index fe6716a..aa0f156 100644
--- a/share/lua/intf/http.lua
+++ b/share/lua/intf/http.lua
@@ -134,7 +134,7 @@ function dirlisting(url,listing,acl_)
 </body>
 </html>]]
     end
-    return h:file(url,"text/html",nil,nil,acl_,callback,nil)
+    return h:file(url,"text/html",nil,password,acl_,callback,nil)
 end
 
 -- FIXME: Experimental art support. Needs some cleaning up.
@@ -207,7 +207,7 @@ function file(h,path,url,acl_,mime)
         end
         return table.concat(page)
     end
-    return h:file(url or path,mime,nil,nil,acl_,callback,nil)
+    return h:file(url or path,mime,nil,password,acl_,callback,nil)
 end
 
 function rawfile(h,path,url,acl_)
@@ -228,7 +228,7 @@ function rawfile(h,path,url,acl_)
         end
         return page
     end
-    return h:file(url or path,nil,nil,nil,acl_,callback,nil)
+    return h:file(url or path,nil,nil,password,acl_,callback,nil)
 end
 
 function parse_url_request(request)
@@ -329,6 +329,7 @@ if config.host then
     vlc.msg.info("Pass --http-host=IP "..(port and "and --http-port="..port.." " or "").."on the command line instead.")
 end
 
+password = vlc.var.inherit(nil,"http-password")
 h = vlc.httpd()
 local root_acl = load_dir( http_dir )
-local a = h:handler("/art",nil,nil,root_acl,callback_art,nil)
+local a = h:handler("/art",nil,password,root_acl,callback_art,nil)



More information about the vlc-commits mailing list