Make the no_access page work for blank admin_pw

This commit is contained in:
Ron Pedde 2006-06-01 06:17:26 +00:00
parent 4fb0b0035d
commit 6fd6a1c9bb
4 changed files with 36 additions and 11 deletions

View File

@ -9,7 +9,7 @@ adminroot_DATA = ftr.html linkOpaque.gif status.html aspl-license.txt \
gpl-license.html aspl-license.html thanks.html feedback.html \
playlist.html playlist.js smart.html smart.js DAAPApplet-0.1.jar \
smartpopup.html applet.html mt-daapd.js CREDITS status.js \
config.js config.xml spinner.gif util.js pngfix.js
config.js config.xml spinner.gif util.js pngfix.js no_access.html
EXTRA_DIST = ftr.html linkOpaque.gif status.html aspl-license.txt \
gpl-license.txt linkTransparent.gif config-update.html hdr.html \
@ -17,5 +17,5 @@ EXTRA_DIST = ftr.html linkOpaque.gif status.html aspl-license.txt \
gpl-license.html aspl-license.html thanks.html feedback.html \
playlist.html playlist.js smart.html smart.js DAAPApplet-0.1.jar \
smartpopup.html applet.html mt-daapd.js CREDITS status.js \
config.js config.xml spinner.gif util.js pngfix.js
config.js config.xml spinner.gif util.js pngfix.js no_access.html

View File

@ -1,24 +1,26 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<title>mt-daapd</title>
<title>Firefly Media Server</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>No access</title>
</head>
<body>
<h1>No access</h1>
You have no password set in you config file.<br />
Without a password access is only permitted from the computer were<br /> Firefly is running.<br />
You have no password set in your config file.<br />
Without a password access is only permitted from the computer where<br
/> Firefly Media Server is running.<br />
<br />
To enable Firefly remote administration open your config file:<br />
@CONFFILE@ <br />
Find the section mark <code>[general]</code> and add the following line after the mark: <br />
<br />
<tt>@CONFFILE@</tt> <br /><br />
Find the section marked <code>[general]</code> and add the following line after the mark: <br />
<br />
<code>
admin_pw = your_password
</code>
<br />
<br />
You need to restart Firefly for the change to take effect.
You will need to restart Firefly for the change to take effect.
</body>
</html>

View File

@ -103,7 +103,7 @@ static CONF_ELEMENTS conf_elements[] = {
{ 1, 0, CONF_T_STRING,"general","runas" },
{ 1, 0, CONF_T_EXISTPATH,"general","web_root" },
{ 0, 0, CONF_T_INT,"general","port" },
{ 1, 0, CONF_T_STRING,"general","admin_pw" },
{ 0, 0, CONF_T_STRING,"general","admin_pw" },
{ 1, 0, CONF_T_MULTICOMMA,"general","mp3_dir" },
{ 0, 1, CONF_T_EXISTPATH,"general","db_dir" },
{ 0, 0, CONF_T_STRING,"general","db_type" },

View File

@ -287,6 +287,26 @@ void config_handler(WS_CONNINFO *pwsc) {
char *pw;
int size;
if(!pwsc->hostname) { /* ?? */
ws_returnerror(pwsc,500,"Couldn't determine remote hostname");
pwsc->close=1;
return;
}
if(!os_islocaladdr(pwsc->hostname)) {
pw=conf_alloc_string("general","admin_pw",NULL);
if((!pw) || (strlen(pw) == 0)) {
if(pw) free(pw);
/* if we aren't getting the no_access.html page, we should */
if(strcmp(pwsc->uri,"/no_access.html") != 0) {
ws_addresponseheader(pwsc,"location","/no_access.html");
ws_returnerror(pwsc,302,"Moved Temporarily");
pwsc->close=1;
return;
}
}
}
size = sizeof(web_root);
if(conf_get_string("general","web_root",NULL,web_root,
&size) == CONF_E_NOTFOUND) {
@ -391,8 +411,11 @@ int config_auth(WS_CONNINFO *pwsc, char *user, char *password) {
return TRUE;
adminpassword=conf_alloc_string("general","admin_pw",NULL);
if(!adminpassword)
return FALSE;
if((!adminpassword) || (strlen(adminpassword)==0)) {
/* we'll handle this later */
if(adminpassword) free(adminpassword);
return TRUE;
}
if(!password)
return FALSE;