Allow entry of no password
This commit is contained in:
parent
9ff2d9410b
commit
b75254220c
|
@ -130,8 +130,8 @@
|
|||
|
||||
const int FirmwareRevision = 32;
|
||||
const int FirmwareSubRevision = 0;
|
||||
const int FirmwareMinorRevision = 5;
|
||||
const char* FirmwareDate = "11 Apr 2020";
|
||||
const int FirmwareMinorRevision = 6;
|
||||
const char* FirmwareDate = "26 Apr 2020";
|
||||
|
||||
|
||||
#ifdef ESP32
|
||||
|
@ -838,10 +838,6 @@ bool isWebClientConnected()
|
|||
|
||||
void checkDebugCommands()
|
||||
{
|
||||
static uint8_t nGetString = 0;
|
||||
static uint8_t nGetConf = 0;
|
||||
static String pw1;
|
||||
static String pw2;
|
||||
static CGetLine line;
|
||||
|
||||
// check for test commands received over Debug serial port or telnet
|
||||
|
@ -870,229 +866,6 @@ void checkDebugCommands()
|
|||
return;
|
||||
}
|
||||
|
||||
if(nGetConf) {
|
||||
DebugPort.print(rxVal);
|
||||
bool bSave = (rxVal == 'y') || (rxVal == 'Y');
|
||||
DebugPort.println("");
|
||||
if(!bSave) {
|
||||
DebugPort.println(" ABORTED!");
|
||||
nGetConf = 0;
|
||||
return;
|
||||
}
|
||||
switch(nGetConf) {
|
||||
case 1:
|
||||
setName(line.getString(), 0);
|
||||
break;
|
||||
case 2:
|
||||
setPassword(pw2.c_str(), 0);
|
||||
break;
|
||||
case 3:
|
||||
setName(line.getString(), 1);
|
||||
break;
|
||||
case 4:
|
||||
setPassword(pw2.c_str(), 1);
|
||||
break;
|
||||
case 5:
|
||||
setName(line.getString(), 2);
|
||||
break;
|
||||
case 6:
|
||||
setPassword(pw2.c_str(), 2);
|
||||
break;
|
||||
}
|
||||
nGetConf = 0;
|
||||
return;
|
||||
}
|
||||
else if(nGetString) {
|
||||
DebugPort.enable(true);
|
||||
|
||||
if(rxVal == 0x1b) { // ESCAPE
|
||||
nGetString = 0;
|
||||
DebugPort.println("\r\nABORTED!");
|
||||
return;
|
||||
}
|
||||
|
||||
if(line.handle(rxVal)) {
|
||||
switch(nGetString) {
|
||||
case 1:
|
||||
if(line.getLen() <= 31) {
|
||||
nGetConf = 1;
|
||||
DebugPort.printf("\r\nSet AP SSID to %s? (y/n) - ", line.getString());
|
||||
}
|
||||
else {
|
||||
DebugPort.println("\r\nNew name is longer than 31 characters - ABORTING");
|
||||
}
|
||||
nGetString = 0;
|
||||
return;
|
||||
case 2:
|
||||
pw1 = line.getString();
|
||||
pw2 = NVstore.getCredentials().APpassword;
|
||||
if(pw1 != pw2) {
|
||||
DebugPort.println("\r\nPassword does not match existing - ABORTING");
|
||||
nGetString = 0;
|
||||
}
|
||||
else {
|
||||
nGetString = 3;
|
||||
DebugPort.print("\r\nPlease enter new password - ");
|
||||
DebugPort.enable(false); // block other debug msgs whilst we get the password
|
||||
}
|
||||
line.reset();
|
||||
line.maskEntry();
|
||||
return;
|
||||
case 3:
|
||||
pw1 = line.getString();
|
||||
if(line.getLen() < 8) {
|
||||
// ABORT - too short
|
||||
DebugPort.println("\r\nNew password must be at least 8 characters - ABORTING");
|
||||
nGetString = 0;
|
||||
}
|
||||
else if(line.getLen() > 31) {
|
||||
// ABORT - too long!
|
||||
DebugPort.println("\r\nNew password is longer than 31 characters - ABORTING");
|
||||
nGetString = 0;
|
||||
}
|
||||
else {
|
||||
nGetString = 4;
|
||||
DebugPort.print("\r\nPlease confirm new password - ");
|
||||
DebugPort.enable(false); // block other debug msgs whilst we get the password
|
||||
}
|
||||
line.reset();
|
||||
line.maskEntry();
|
||||
return;
|
||||
case 4:
|
||||
pw2 = line.getString();
|
||||
line.reset();
|
||||
if(pw1 != pw2) {
|
||||
DebugPort.println("\r\nNew passwords do not match - ABORTING");
|
||||
}
|
||||
else {
|
||||
nGetConf = 2;
|
||||
DebugPort.print("\r\nSet new password (y/n) - ");
|
||||
}
|
||||
nGetString = 0;
|
||||
return;
|
||||
case 10:
|
||||
if(line.getLen() <= 31) {
|
||||
nGetConf = 3;
|
||||
DebugPort.printf("\r\nSet Web page username to %s? (y/n) - ", line.getString());
|
||||
}
|
||||
else {
|
||||
DebugPort.println("\r\nNew username is longer than 31 characters - ABORTING");
|
||||
}
|
||||
nGetString = 0;
|
||||
return;
|
||||
case 11:
|
||||
pw1 = line.getString();
|
||||
pw2 = NVstore.getCredentials().webPassword;
|
||||
if(pw1 != pw2) {
|
||||
DebugPort.println("\r\nPassword does not match existing - ABORTING");
|
||||
nGetString = 0;
|
||||
}
|
||||
else {
|
||||
nGetString = 12;
|
||||
DebugPort.print("\r\nPlease enter new password - ");
|
||||
DebugPort.enable(false); // block other debug msgs whilst we get the password
|
||||
}
|
||||
line.reset();
|
||||
line.maskEntry();
|
||||
return;
|
||||
case 12:
|
||||
pw1 = line.getString();
|
||||
if(line.getLen() < 8) {
|
||||
// ABORT - too short
|
||||
DebugPort.println("\r\nNew password must be at least 8 characters - ABORTING");
|
||||
nGetString = 0;
|
||||
}
|
||||
else if(line.getLen() > 31) {
|
||||
// ABORT - too long!
|
||||
DebugPort.println("\r\nNew password is longer than 31 characters - ABORTING");
|
||||
nGetString = 0;
|
||||
}
|
||||
else {
|
||||
nGetString = 13;
|
||||
DebugPort.print("\r\nPlease confirm new password - ");
|
||||
DebugPort.enable(false); // block other debug msgs whilst we get the password
|
||||
}
|
||||
line.reset();
|
||||
line.maskEntry();
|
||||
return;
|
||||
case 13:
|
||||
pw2 = line.getString();
|
||||
line.reset();
|
||||
if(pw1 != pw2) {
|
||||
DebugPort.println("\r\nNew passwords do not match - ABORTING");
|
||||
}
|
||||
else {
|
||||
nGetConf = 4;
|
||||
DebugPort.print("\r\nSet new password (y/n) - ");
|
||||
}
|
||||
nGetString = 0;
|
||||
return;
|
||||
|
||||
case 20:
|
||||
if(line.getLen() <= 31) {
|
||||
nGetConf = 5;
|
||||
DebugPort.printf("\r\nSet Web /update username to %s? (y/n) - ", line.getString());
|
||||
}
|
||||
else {
|
||||
DebugPort.println("\r\nNew username is longer than 31 characters - ABORTING");
|
||||
}
|
||||
nGetString = 0;
|
||||
return;
|
||||
|
||||
case 21:
|
||||
pw1 = line.getString();
|
||||
pw2 = NVstore.getCredentials().webUpdatePassword;
|
||||
if(pw1 != pw2) {
|
||||
DebugPort.println("\r\nPassword does not match existing - ABORTING");
|
||||
nGetString = 0;
|
||||
}
|
||||
else {
|
||||
nGetString = 22;
|
||||
DebugPort.print("\r\nPlease enter new password - ");
|
||||
DebugPort.enable(false); // block other debug msgs whilst we get the password
|
||||
}
|
||||
line.reset();
|
||||
line.maskEntry();
|
||||
return;
|
||||
case 22:
|
||||
pw1 = line.getString();
|
||||
if(line.getLen() < 8) {
|
||||
// ABORT - too short
|
||||
DebugPort.println("\r\nNew password must be at least 8 characters - ABORTING");
|
||||
nGetString = 0;
|
||||
}
|
||||
else if(line.getLen() > 31) {
|
||||
// ABORT - too long!
|
||||
DebugPort.println("\r\nNew password is longer than 31 characters - ABORTING");
|
||||
nGetString = 0;
|
||||
}
|
||||
else {
|
||||
nGetString = 23;
|
||||
DebugPort.print("\r\nPlease confirm new password - ");
|
||||
DebugPort.enable(false); // block other debug msgs whilst we get the password
|
||||
}
|
||||
line.reset();
|
||||
line.maskEntry();
|
||||
return;
|
||||
case 23:
|
||||
pw2 = line.getString();
|
||||
line.reset();
|
||||
if(pw1 != pw2) {
|
||||
DebugPort.println("\r\nNew passwords do not match - ABORTING");
|
||||
}
|
||||
else {
|
||||
nGetConf = 6;
|
||||
DebugPort.print("\r\nSet new password (y/n) - ");
|
||||
}
|
||||
nGetString = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
DebugPort.enable(false);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
rxVal = toLowerCase(rxVal);
|
||||
|
||||
#ifdef PROTOCOL_INVESTIGATION
|
||||
|
@ -1163,12 +936,6 @@ void checkDebugCommands()
|
|||
bReportRecyleEvents = false;
|
||||
DebugPort.printf("Toggled blue wire recycling event reporting %s\r\n", bReportRecyleEvents ? "ON" : "OFF");
|
||||
}
|
||||
else if(rxVal == 'n') {
|
||||
DebugPort.print("Please enter new SSID name for Access Point - ");
|
||||
line.reset();
|
||||
nGetString = 1;
|
||||
DebugPort.enable(false); // block other debug msgs whilst we get strings
|
||||
}
|
||||
else if(rxVal == 'm') {
|
||||
MQTTmenu.setActive();
|
||||
}
|
||||
|
@ -1179,37 +946,6 @@ void checkDebugCommands()
|
|||
bReportOEMresync = !bReportOEMresync;
|
||||
DebugPort.printf("Toggled OEM resync event reporting %s\r\n", bReportOEMresync ? "ON" : "OFF");
|
||||
}
|
||||
else if(rxVal == 'p') {
|
||||
DebugPort.print("Please enter current AP password - ");
|
||||
line.reset();
|
||||
line.maskEntry();
|
||||
nGetString = 2;
|
||||
DebugPort.enable(false); // block other debug msgs whilst we get strings
|
||||
}
|
||||
else if(rxVal == 'u') {
|
||||
DebugPort.print("Please enter username for Web page access (CTRL-X to disable) - ");
|
||||
line.reset();
|
||||
nGetString = 10;
|
||||
DebugPort.enable(false); // block other debug msgs whilst we get strings
|
||||
}
|
||||
else if(rxVal == 'w') {
|
||||
DebugPort.print("Please enter current Web page password - ");
|
||||
line.reset();
|
||||
nGetString = 11;
|
||||
DebugPort.enable(false); // block other debug msgs whilst we get strings
|
||||
}
|
||||
else if(rxVal == 'y') {
|
||||
DebugPort.print("Please enter username for /update Web page access - ");
|
||||
line.reset();
|
||||
nGetString = 20;
|
||||
DebugPort.enable(false); // block other debug msgs whilst we get strings
|
||||
}
|
||||
else if(rxVal == 'z') {
|
||||
DebugPort.print("Please enter current /update Web page password - ");
|
||||
line.reset();
|
||||
nGetString = 21;
|
||||
DebugPort.enable(false); // block other debug msgs whilst we get strings
|
||||
}
|
||||
else if(rxVal == ('c' & 0x1f)) {
|
||||
CommState.toggleReporting();
|
||||
}
|
||||
|
@ -1222,7 +958,7 @@ void checkDebugCommands()
|
|||
else if(rxVal == 'h') {
|
||||
getWebContent(true);
|
||||
}
|
||||
else if(rxVal == ('b' & 0x1f)) { // CTRL-B Tst Mdoe: bluetooth module route
|
||||
else if(rxVal == ('b' & 0x1f)) { // CTRL-B Tst Mode: bluetooth module route
|
||||
bTestBTModule = !bTestBTModule;
|
||||
Bluetooth.test(bTestBTModule ? 0xff : 0x00); // special enter or leave BT test commands
|
||||
}
|
||||
|
|
|
@ -220,33 +220,21 @@ CSecuritySetup::_showMenu(bool init)
|
|||
DebugPort.printf(" <1> - set SSID, currently \"%s\"\r\n", _credsSetup.APSSID);
|
||||
DebugPort.print(" <2> - set password");
|
||||
len = strlen(_credsSetup.APpassword);
|
||||
if(len == 0)
|
||||
DebugPort.print(", currently UNRESTRICTED\r\n");
|
||||
else {
|
||||
insertDummy(len);
|
||||
}
|
||||
insertDummy(len);
|
||||
DebugPort.println("");
|
||||
|
||||
DebugPort.println(" Web page credentials");
|
||||
DebugPort.printf(" <3> - set username, currently \"%s\"\r\n", _credsSetup.webUsername);
|
||||
DebugPort.print(" <4> - set password");
|
||||
len = strlen(_credsSetup.webPassword);
|
||||
if(len == 0)
|
||||
DebugPort.printf(", currently UNRESTRICTED\r\n");
|
||||
else {
|
||||
insertDummy(len);
|
||||
}
|
||||
insertDummy(len);
|
||||
DebugPort.println("");
|
||||
|
||||
DebugPort.println(" /update web page credentials");
|
||||
DebugPort.printf(" <5> - set username, currently \"%s\"\r\n", _credsSetup.webUpdateUsername);
|
||||
DebugPort.printf(" <6> - set password");
|
||||
len = strlen(_credsSetup.webUpdatePassword);
|
||||
if(len == 0)
|
||||
DebugPort.printf(", UNRESTRICTED!\r\n");
|
||||
else {
|
||||
insertDummy(len);
|
||||
}
|
||||
insertDummy(len);
|
||||
DebugPort.println("");
|
||||
DebugPort.printf(" <ENTER> - save and exit\r\n");
|
||||
DebugPort.printf(" <ESC> - abort\r\n");
|
||||
|
@ -255,13 +243,17 @@ CSecuritySetup::_showMenu(bool init)
|
|||
}
|
||||
|
||||
void insertDummy(int len) {
|
||||
char dummy[32];
|
||||
memset(dummy, 0, 32);
|
||||
if(len > 31)
|
||||
len = 31;
|
||||
for(int i = 0; i < len; i++)
|
||||
dummy[i] = '*';
|
||||
DebugPort.printf(" (%s)\r\n", dummy);
|
||||
if(len == 0)
|
||||
DebugPort.println(", NOT REQUIRED!");
|
||||
else {
|
||||
char dummy[32];
|
||||
memset(dummy, 0, 32);
|
||||
if(len > 31)
|
||||
len = 31;
|
||||
for(int i = 0; i < len; i++)
|
||||
dummy[i] = '*';
|
||||
DebugPort.printf(" (%s)\r\n", dummy);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -312,7 +304,7 @@ CSecuritySetup::_handle(char rxVal)
|
|||
break;
|
||||
case 2:
|
||||
DebugPort.print("Enter current AP password");
|
||||
_initPassword(0);
|
||||
_initPassword(0, "inbuilt Access Point");
|
||||
break;
|
||||
case 3:
|
||||
DebugPort.printf("Enter new Web page access username (currently '%s', CTRL-X to erase)", _credsSetup.webUsername);
|
||||
|
@ -320,7 +312,7 @@ CSecuritySetup::_handle(char rxVal)
|
|||
break;
|
||||
case 4:
|
||||
DebugPort.print("Enter current web page access password");
|
||||
_initPassword(1);
|
||||
_initPassword(1, "web page access");
|
||||
break;
|
||||
case 5:
|
||||
DebugPort.printf("Enter new /update web page access username (currently '%s', CTRL-X to erase)", _credsSetup.webUpdateUsername);
|
||||
|
@ -328,7 +320,7 @@ CSecuritySetup::_handle(char rxVal)
|
|||
break;
|
||||
case 6:
|
||||
DebugPort.print("Enter current /update web page access password");
|
||||
_initPassword(2);
|
||||
_initPassword(2, "/update web page access");
|
||||
break;
|
||||
}
|
||||
DebugPort.print("... ");
|
||||
|
@ -355,12 +347,16 @@ CSecuritySetup::_handle(char rxVal)
|
|||
}
|
||||
|
||||
void
|
||||
CSecuritySetup::_initPassword(int idx)
|
||||
CSecuritySetup::_initPassword(int idx, const char* prompt)
|
||||
{
|
||||
_lineInput.reset();
|
||||
_lineInput.maskEntry();
|
||||
_password.Idx = idx;
|
||||
_password.State = 1;
|
||||
if(strlen(_getCurrentPassword()) == 0) {
|
||||
DebugPort.printf("\rEnter password for %s (CTRL-X for no password) - ", prompt);
|
||||
_password.State = 2;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -373,7 +369,7 @@ bool
|
|||
CSecuritySetup::_handlePassword(char rxVal)
|
||||
{
|
||||
switch(_password.State) {
|
||||
case 1:
|
||||
case 1: // collect, then test existing password
|
||||
if(_lineInput.handle(rxVal)) {
|
||||
_password.str1 = _lineInput.getString();
|
||||
_password.str2 = _getCurrentPassword();
|
||||
|
@ -383,7 +379,7 @@ CSecuritySetup::_handlePassword(char rxVal)
|
|||
}
|
||||
else {
|
||||
_password.State = 2;
|
||||
DebugPort.print("\r\nPlease enter new password - ");
|
||||
DebugPort.print("\r\nPlease enter new password (CTRL-X for no password) - ");
|
||||
DebugPort.enable(false); // block other debug msgs whilst we get the password
|
||||
}
|
||||
_lineInput.reset();
|
||||
|
@ -391,6 +387,12 @@ CSecuritySetup::_handlePassword(char rxVal)
|
|||
}
|
||||
return true;
|
||||
case 2:
|
||||
if(rxVal == ('x' & 0x1f)) { // special handling for CTRL-X - erase password
|
||||
_password.State = 4;
|
||||
DebugPort.print("\r\nConfirm no password required? (y/n) - ");
|
||||
_password.str2 = "";
|
||||
return true;
|
||||
}
|
||||
if(_lineInput.handle(rxVal)) {
|
||||
_password.str1 = _lineInput.getString();
|
||||
if(_lineInput.getLen() < 8) {
|
||||
|
|
|
@ -48,7 +48,7 @@ class CSecuritySetup {
|
|||
sCredentials _credsSetup;
|
||||
bool _handle(char rxVal);
|
||||
void _showMenu(bool init = false);
|
||||
void _initPassword(int idx);
|
||||
void _initPassword(int idx, const char*prompt);
|
||||
bool _getPassword();
|
||||
bool _handlePassword(char rxVal);
|
||||
const char* _getCurrentPassword();
|
||||
|
|
Loading…
Reference in New Issue