Skip to content

Commit 761cddb

Browse files
committed
Merge #7703: tor: Change auth order to only use password auth if -torpassword
2e49448 tor: Change auth order to only use HASHEDPASSWORD if -torpassword (Wladimir J. van der Laan)
2 parents 67c91f8 + 2e49448 commit 761cddb

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/torcontrol.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,15 @@ void TorController::protocolinfo_cb(TorControlConnection& conn, const TorControl
574574
* password: "password"
575575
*/
576576
std::string torpassword = GetArg("-torpassword", "");
577-
if (methods.count("NULL")) {
577+
if (!torpassword.empty()) {
578+
if (methods.count("HASHEDPASSWORD")) {
579+
LogPrint("tor", "tor: Using HASHEDPASSWORD authentication\n");
580+
boost::replace_all(torpassword, "\"", "\\\"");
581+
conn.Command("AUTHENTICATE \"" + torpassword + "\"", boost::bind(&TorController::auth_cb, this, _1, _2));
582+
} else {
583+
LogPrintf("tor: Password provided with -torpassword, but HASHEDPASSWORD authentication is not available\n");
584+
}
585+
} else if (methods.count("NULL")) {
578586
LogPrint("tor", "tor: Using NULL authentication\n");
579587
conn.Command("AUTHENTICATE", boost::bind(&TorController::auth_cb, this, _1, _2));
580588
} else if (methods.count("SAFECOOKIE")) {
@@ -595,13 +603,7 @@ void TorController::protocolinfo_cb(TorControlConnection& conn, const TorControl
595603
}
596604
}
597605
} else if (methods.count("HASHEDPASSWORD")) {
598-
if (!torpassword.empty()) {
599-
LogPrint("tor", "tor: Using HASHEDPASSWORD authentication\n");
600-
boost::replace_all(torpassword, "\"", "\\\"");
601-
conn.Command("AUTHENTICATE \"" + torpassword + "\"", boost::bind(&TorController::auth_cb, this, _1, _2));
602-
} else {
603-
LogPrintf("tor: Password authentication required, but no password provided with -torpassword\n");
604-
}
606+
LogPrintf("tor: The only supported authentication mechanism left is password, but no password provided with -torpassword\n");
605607
} else {
606608
LogPrintf("tor: No supported authentication method\n");
607609
}

0 commit comments

Comments
 (0)