password protection (currently disabled)

Added files and changes required for password protection
This commit is contained in:
mvoelkel 2015-09-03 14:32:02 +02:00
parent 860265e427
commit a1e04db6db
4 changed files with 149 additions and 11 deletions

View File

@ -0,0 +1,41 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>OctopusNet</title>
<link rel="stylesheet" type="text/css" href="/style.css">
<script type="text/javascript" src="/menu.js"></script>
<!-- Add included scripts here -->
<!-- Add page scripts here -->
<script type="text/javascript">
</script>
</head>
<body>
<table class="maintable" align="center">
<colgroup>
<col width="182px"/>
<col width="728px"/>
</colgroup>
<tr><td class="maintd" colspan="2">
<a href="http://www.digitaldevices.de"><img src="/BannerDD.jpg" alt="DD" width="910" height="130" /></a>
</td></tr>
<tr><td class="maintd" colspan="2">&nbsp;</td></tr>
<tr>
<td class="maintd"><script type="text/javascript">CreateMenu();</script></td>
<td class="content">
<div>
<!-- Begin Content -->
<H1>401: admin login required</H1>
<!-- End Content -->
</div>
</td>
</tr>
<tr><td colspan="2">&nbsp;</td></tr>
</table>
</body>
</html>

View File

@ -0,0 +1,52 @@
#!/usr/bin/lua
local host = os.getenv("HTTP_HOST")
local proto = os.getenv("SERVER_PROTOCOL")
local query = os.getenv("QUERY_STRING")
local method = os.getenv("REQUEST_METHOD")
local clength = os.getenv("CONTENT_LENGTH")
local ctype = os.getenv("CONTENT_TYPE")
function http_print(s)
if s then
io.stdout:write(tostring(s).."\r\n")
else
io.stdout:write("\r\n")
end
end
if #arg> 0 then
method="GET"
query="admin"
proto = "HTTP/1.0"
end
function SendError(err,desc)
http_print(proto.." "..err)
http_print()
local file = io.open("e404.html")
if file then
local tmp = file:read("*a")
tmp = string.gsub(tmp,"404 Not Found",err .. " " .. desc)
http_print(tmp)
file:close()
end
end
if method == "GET" then
file = io.open("/tmp/pw","w")
if file then
file:write(query.."\n")
file:write(query.."\n")
file:close()
os.execute('passwd admin </tmp/pw >/dev/null');
os.execute('rm -f /tmp/pw >/dev/null');
end
http_print(proto.." 204")
http_print()
return
else
SendError("500","What")
end

View File

@ -56,6 +56,21 @@ function Change()
document.getElementById("SetButton").disabled = false;
}
function SetPassword()
{
pwd1 = document.getElementById("pwd1").value;
pwd2 = document.getElementById("pwd2").value;
if( pwd1 != pwd2 )
{
document.getElementById("pwd1").value = "";
document.getElementById("pwd2").value = "";
document.getElementById("PwdError").style = "color:#F02000";
return 0;
}
document.getElementById("PwdError").style = "color:#FFFFFF";
location.replace('/setpasswd.lua?'+pwd1);
}
</script>
</head>
@ -83,7 +98,7 @@ function Change()
</form>
</td>
<td>See note below</td>
<tr>
</tr>
<tr>
<td>Telnet</td>
@ -93,7 +108,7 @@ function Change()
</form>
</td>
<td>Enable it at your own risk</td>
<tr>
</tr>
<tr>
<td>NODMS</td>
@ -103,9 +118,9 @@ function Change()
</form>
</td>
<td>Disable DMS announcement.</td>
<tr>
</tr>
<tr>
<tr>
<td>NODVBT</td>
<td>
<form action="">
@ -113,9 +128,9 @@ function Change()
</form>
</td>
<td>Disable DVBT announcement.</td>
<tr>
</tr>
<tr>
<tr>
<td>No DVB switch</td>
<td>
<form action="">
@ -123,7 +138,7 @@ function Change()
</form>
</td>
<td>Disable DVB switch emulation on S8.</td>
<tr>
</tr>
<tr>
<td colspan="2" align="right">
@ -137,6 +152,39 @@ function Change()
</td>
</tr>
</table>
<br/>
<!--
<table class="tableleft" align="center" cellspacing="2px">
<form action="">
<tr>
<td align="right">
New password
</td>
<td>
<input id="pwd1" type="Password" value="" size="30">
</td>
</tr>
<tr>
<td align="right">
Repeat new password
</td>
<td>
<input id="pwd2" type="Password" value="" size="30">
</td>
</tr>
<tr>
<td>
<div Id="PwdError" Style="color:#FFFFFF">
Repeated password doesn't match
</div>
</td>
<td align="right">
<input id="SetButton" type="Button" value="Set Password" onclick="SetPassword()" >
</td>
</tr>
</form>
</table>
-->
<div style="margin:20px; clear:both">
<h3>Layer 2 Quality of Service</h3>
This is defined in the <b>IEEE 802.1Q</b> VLAN standard, and provides QoS in a local network.<br/>

View File

@ -74,11 +74,8 @@ if query ~= "" then
os.rename("/etc/securetty","/etc/securetty.bak"); -- temp fix to allow root login on telnet
os.execute("/etc/init.d/S91telnet restart")
end
-- if name == "vlan" then os.execute("/etc/init.d/S99octo restartoctonet&") end
-- if name == "nodms" then os.execute("/etc/init.d/S99octo restartoctonet&") end
-- if name == "nodvbt" then os.execute("/etc/init.d/S99octo restartoctonet&") end
if name == "vlan" then restart = 1 end
if name == "nodms" then restart = 1 end
if name == "nodms" then restart = 1 end
if name == "nodvbt" then restart = 1 end
if name == "noswitch" then restart = 1 end
nextloc = "wait.html?5"