Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-2-2
Commits
d45f4c0a
Commit
d45f4c0a
authored
May 14, 2013
by
Rafaël Carré
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lua HTTPd: inform user that password has not been set
parent
ccd89407
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
1 deletion
+33
-1
modules/lua/libs/httpd.c
modules/lua/libs/httpd.c
+33
-0
share/lua/intf/http.lua
share/lua/intf/http.lua
+0
-1
No files found.
modules/lua/libs/httpd.c
View file @
d45f4c0a
...
...
@@ -61,6 +61,18 @@ static const luaL_Reg vlclua_httpd_reg[] = {
{
NULL
,
NULL
}
};
static
const
char
no_password
[]
=
N_
(
"<!DOCTYPE html PUBLIC
\"
-//W3C//DTD XHTML 1.0 Strict//EN
\"
\"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd
\"
>
\n
"
"<html xmlns=
\"
http://www.w3.org/1999/xhtml
\"
>"
"<head>"
"<meta http-equiv=
\"
Content-Type
\"
content=
\"
text/html;charset=utf-8
\"
/>"
"<title>VLC media player</title>"
"</head>"
"<body>"
"<p>Password for Web interface has not been set.</p>"
"<p>Please use --http-password, or set a password in </p>"
"<p>Preferences > All > Main interfaces > Lua > Lua HTTP > Password.</p>"
"<!-- VLC_PASSWORD_NOT_SET --></body></html>"
);
static
int
vlclua_httpd_tls_host_new
(
lua_State
*
L
)
{
vlc_object_t
*
p_this
=
vlclua_get_this
(
L
);
...
...
@@ -97,6 +109,7 @@ static int vlclua_httpd_host_delete( lua_State *L )
struct
httpd_handler_sys_t
{
lua_State
*
L
;
bool
password
;
int
ref
;
};
...
...
@@ -138,6 +151,17 @@ static int vlclua_httpd_handler_callback(
}
/* function data outdata */
*
pp_data
=
vlclua_todata
(
L
,
-
1
,
pi_data
);
if
(
!
p_sys
->
password
)
{
free
(
*
pp_data
);
size_t
s
=
strlen
(
_
(
no_password
));
if
(
asprintf
((
char
**
)
pp_data
,
"Status: 403
\n
"
"Content-Length: %zu
\n
"
"Content-Type: text/html
\n\n
%s"
,
s
,
_
(
no_password
))
<
0
)
*
pi_data
=
0
;
else
*
pi_data
=
strlen
((
char
*
)
*
pp_data
);
}
lua_pop
(
L
,
1
);
/* function data */
return
VLC_SUCCESS
;
...
...
@@ -159,6 +183,7 @@ static int vlclua_httpd_handler_new( lua_State * L )
return
luaL_error
(
L
,
"Failed to allocate private buffer."
);
p_sys
->
L
=
lua_newthread
(
L
);
p_sys
->
ref
=
luaL_ref
(
L
,
LUA_REGISTRYINDEX
);
/* pops the object too */
p_sys
->
password
=
psz_password
&&
*
psz_password
;
/* use lua_xmove to move the lua callback function and data to
* the callback's stack. */
lua_xmove
(
L
,
p_sys
->
L
,
2
);
...
...
@@ -200,6 +225,7 @@ struct httpd_file_sys_t
{
lua_State
*
L
;
int
ref
;
bool
password
;
};
static
int
vlclua_httpd_file_callback
(
...
...
@@ -228,6 +254,12 @@ static int vlclua_httpd_file_callback(
}
/* function data outdata */
*
pp_data
=
vlclua_todata
(
L
,
-
1
,
pi_data
);
if
(
!
p_sys
->
password
)
{
free
(
*
pp_data
);
*
pp_data
=
(
uint8_t
*
)
strdup
(
_
(
no_password
));
*
pi_data
=
strlen
((
char
*
)
*
pp_data
);
}
lua_pop
(
L
,
1
);
/* function data */
return
VLC_SUCCESS
;
...
...
@@ -248,6 +280,7 @@ static int vlclua_httpd_file_new( lua_State *L )
if
(
!
p_sys
)
return
luaL_error
(
L
,
"Failed to allocate private buffer."
);
p_sys
->
L
=
lua_newthread
(
L
);
p_sys
->
password
=
psz_password
&&
*
psz_password
;
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
,
...
...
share/lua/intf/http.lua
View file @
d45f4c0a
...
...
@@ -320,7 +320,6 @@ if config.host then
end
password
=
vlc
.
var
.
inherit
(
nil
,
"http-password"
)
assert
(
password
~=
""
,
"password not defined"
)
h
=
vlc
.
httpd
()
load_dir
(
http_dir
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment