This commit is contained in:
Brad Arant committed 2022-06-29 13:34:49 -07:00
1 parent 37b5a5bf4e
commit 6c844983d9
27 files changed
+230 -272

No files matched your search

+37 -48
View File
@@ -4,63 +4,52 @@
namespace mail {
int __SMTP_AUTH::processCommand(coreutils::PString request, SMTPSession &session, SMTPServer &server, std::stringstream &data) {
switch(session.authState) {
int __SMTP_AUTH::processCommand(coreutils::ZString &request, core::TCPSession &session) {
SMTPSession &s = dynamic_cast<SMTPSession &>(session);
SMTPServer &server = session.server;
switch((SMTPSession &)session.authState) {
case USER_UNKNOWN:
if(request[1].str() == "LOGIN") {
data << "334 VXNlcm5hbWU6" << CRLF;
// setTimer(10.0f);
session.authState = USER_QUERY;
session.server.commands.grabInput(&session, *this);
}
else {
data << "504 AUTH method not supported." << CRLF;
}
return 1;
if(request[1].equals("LOGIN") {
data << "334 VXNlcm5hbWU6" << CRLF;
// setTimer(10.0f);
s.authState = USER_QUERY;
server.commands.grabInput(&session, *this);
}
else {
s.out << "504 AUTH method not supported." << CRLF;
}
return 1;
case USER_QUERY:
session.userName = request[0].str();
// setTimer(0.0f);
data << "334 UGFzc3dvcmQ6" << CRLF;
// setTimer(10.0f);
session.authState = USER_SECRET_QUERY;
return 1;
s.userName = request[0].str();
// setTimer(0.0f);
s.out << "334 UGFzc3dvcmQ6" << CRLF;
// setTimer(10.0f);
s.authState = USER_SECRET_QUERY;
return 1;
case USER_SECRET_QUERY:
session.password = request[0].str();
// setTimer(0.0f);
coreutils::Base64 base64;
if(authLogin(session.userName, session.password, server)) {
data << "235 2.7.0 Authentication successful" << CRLF;
session.relay = true;
session.authState = USER_KNOWN;
session.server.commands.clearGrab(&session);
}
else {
data << "530 Login was unsuccessful." << CRLF;
}
return 1;
}
s.password = request[0].str();
// setTimer(0.0f);
coreutils::Base64 base64;
if(authLogin(s.userName, s.password, server)) {
s.out << "235 2.7.0 Authentication successful" << CRLF;
s.relay = true;
s.authState = USER_KNOWN;
server.commands.clearGrab(&session);
}
else {
s.out << "530 Login was unsuccessful." << CRLF;
}
return 1;
}
return 0;
}
bool __SMTP_AUTH::authLogin(std::string userName, std::string password, SMTPServer &server) {
bool __SMTP_AUTH::authLogin(coreutils::ZString userName, coreutils::ZString password, SMTPServer &server) {
std::string secretPath = server.mailFileSystem.getMailBoxPath(userName) + "/.password";
coreutils::File secret(secretPath);
secret.read();