From 81f12ab7c97055a9493f79fc601453ebad96e62a Mon Sep 17 00:00:00 2001 From: RonaldReagan Date: Wed, 21 Apr 2021 17:48:06 -0600 Subject: [PATCH] Enable passwordless authentication through the vita config. --- source/src/clientgame.cpp | 2 ++ source/src/server.cpp | 26 +++++++++++++++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 99123e1b..026f7d89 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -1665,6 +1665,8 @@ void setadmin(int *claim, char *password) } else if(*claim != 0 && *password) addmsg(SV_SETADMIN, "ris", *claim, genpwdhash(player1->name, password, sessionid)); + else if(*claim != 0) + addmsg(SV_SETADMIN, "ri", *claim); } COMMAND(setadmin, "is"); diff --git a/source/src/server.cpp b/source/src/server.cpp index f7129f75..ff8ff504 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -2627,19 +2627,35 @@ void callvotepacket (int cn, voteinfo *v = curvote) void changeclientrole(int client, int role, char *pwd, bool force) { pwddetail pd; + bool success = false; if(!isdedicated || !valid_client(client)) return; pd.line = -1; - if(force || role == CR_DEFAULT || (role == CR_ADMIN && pwd && pwd[0] && passwords.check(clients[client]->name, pwd, clients[client]->salt, &pd) && !pd.denyadmin)) - { - if(role == clients[client]->role) return; + + if(role == clients[client]->role) return; + + if(force) success = true; + + if(role == CR_ADMIN + && pwd + && pwd[0] + && passwords.check(clients[client]->name, pwd, clients[client]->salt, &pd) + && !pd.denyadmin) { + mlog(ACLOG_INFO,"[%s] player %s used admin password in line %d", clients[client]->hostname, clients[client]->name[0] ? clients[client]->name : "[unnamed]", pd.line); + success = true; + } + + if(clients[client]->checkvitadate(VS_ADMIN)) { + mlog(ACLOG_INFO,"[%s] player %s claimed admin through valid vita claim (pubkey: %s)", clients[client]->hostname, clients[client]->name[0] ? clients[client]->name : "[unnamed]", clients[client]->pubkeyhex); + success = true; + } + + if(success) { if(role > CR_DEFAULT) { loopv(clients) clients[i]->role = CR_DEFAULT; } clients[client]->role = role; sendserveropinfo(-1); - if(pd.line > -1) - mlog(ACLOG_INFO,"[%s] player %s used admin password in line %d", clients[client]->hostname, clients[client]->name[0] ? clients[client]->name : "[unnamed]", pd.line); mlog(ACLOG_INFO,"[%s] set role of player %s to %s", clients[client]->hostname, clients[client]->name[0] ? clients[client]->name : "[unnamed]", role == CR_ADMIN ? "admin" : "normal player"); // flowtron : connecting players haven't got a name yet (connectadmin) if(role > CR_DEFAULT) sendiplist(client); }