diff options
| author | 2024-05-16 12:29:32 +0100 | |
|---|---|---|
| committer | 2024-05-16 12:29:32 +0100 | |
| commit | c3cff63dca560d0edacc05de37b4495c930d2187 (patch) | |
| tree | e17396c0482ed46063f98953777265072fb23278 /src/users.cpp | |
| parent | Don't allow users to opt-in to older versions of Argon2. (diff) | |
Make passwords for oper accounts optional.
This allows restricting an oper account based on other data such
as TLS fingerprint or services account but without logging them in
automatically like autologin.
Diffstat (limited to 'src/users.cpp')
| -rw-r--r-- | src/users.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/users.cpp b/src/users.cpp index 8a67ddf13..e8a2b7a42 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -1294,8 +1294,9 @@ void OperType::MergeTag(const std::shared_ptr<ConfigTag>& tag) OperAccount::OperAccount(const std::string& n, const std::shared_ptr<OperType>& o, const std::shared_ptr<ConfigTag>& t) : OperType(n, nullptr) - , password(t->getString("password")) - , passwordhash(t->getString("hash", "plaintext", 1)) + , nopassword(t->getBool("nopassword")) + , password(nopassword ? "" : t->getString("password")) + , passwordhash(nopassword ? "" : t->getString("hash", "plaintext", 1)) , type(o ? o->GetName() : n) { autologin = t->getEnum("autologin", AutoLogin::NEVER, { @@ -1336,5 +1337,8 @@ bool OperAccount::CanAutoLogin(LocalUser* user) const bool OperAccount::CheckPassword(const std::string& pw) const { - return InspIRCd::CheckPassword(password, passwordhash, pw); + if (nopassword) + return true; // <oper nopassword="yes"> + + return !password.empty() && InspIRCd::CheckPassword(password, passwordhash, pw); } |
