diff options
author | Jannis M. Hoffmann <jannis@fehcom.de> | 2023-10-07 22:33:50 +0200 |
---|---|---|
committer | Jannis M. Hoffmann <jannis@fehcom.de> | 2023-10-08 11:35:51 +0200 |
commit | 1978c49bea5b439d993067c055cec47e70db8fd6 (patch) | |
tree | 255caea96a13f95564e6b631be9a4ac55ce33cd9 /src/authenticate.cc | |
parent | 3b1278f5459514a6d6364f068ff97b8a0432057b (diff) |
minor refactoring
Diffstat (limited to 'src/authenticate.cc')
-rw-r--r-- | src/authenticate.cc | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/authenticate.cc b/src/authenticate.cc index 88bfa63..63a8b3a 100644 --- a/src/authenticate.cc +++ b/src/authenticate.cc @@ -1,9 +1,10 @@ -/** -------------------------------------------------------------------- +/** * @file authenticate.cc * @brief Implementation of the common (C/R) authentication mechanism. * @author Andreas Aardal Hanssen, Erwin Hoffmann * @date 2002-2005, 2023 - * ----------------------------------------------------------------- **/ + */ + #include <string> #include <vector> @@ -28,15 +29,16 @@ #include "iofactory.h" #include "session.h" -using namespace ::std; using namespace Binc; +using std::endl; +using std::string; // 0 = ok // 1 = internal error // 2 = failed // 3 = timeout // -1 = abort -//------------------------------------------------------------------------ + int Binc::authenticate(Depot &depot, const string &username, const string &password, @@ -46,7 +48,7 @@ int Binc::authenticate(Depot &depot, session.setUserID(username); // check if checkpassword is present - if (::access(session.unparsedArgs[0], X_OK) != 0) { // x is enough + if (access(session.unparsedArgs[0], X_OK) != 0) { // x is enough bincError << "unable to start authenticator " << session.unparsedArgs[0] << ": " << strerror(errno) << endl; return 1; @@ -84,15 +86,16 @@ int Binc::authenticate(Depot &depot, } string timestamp; - time_t t = time(0); + time_t t = time(nullptr); char *c; - if ((c = ctime(&t)) != 0) { + if ((c = ctime(&t)) != nullptr) { timestamp = c; trim(timestamp); - } else + } else { timestamp = "unknown timestamp"; + } - string pid = to_string(session.getPid()); + string pid = std::to_string(session.getPid()); // execute authentication module int result; @@ -128,7 +131,7 @@ int Binc::authenticate(Depot &depot, exit(111); } - if (session.unparsedArgs[0] != 0) { + if (session.unparsedArgs[0] != nullptr) { execvp(session.unparsedArgs[0], &session.unparsedArgs[0]); bincDebug << "bincimap-up: pid " << pid << " authenticate(), [auth module] invocation of " << session.unparsedArgs[0] << " failed: " << strerror(errno) << endl; @@ -212,7 +215,7 @@ int Binc::authenticate(Depot &depot, // EINTR. int n; do { - n = select(maxfd + 1, &rtmp, 0, 0, &timeout); + n = select(maxfd + 1, &rtmp, nullptr, nullptr, &timeout); } while (n < 0 && errno == EINTR); if (n < 0) { @@ -295,8 +298,7 @@ int Binc::authenticate(Depot &depot, return -1; } - // if the server died because we closed the sockets after a timeout, - // exit 3. + // if the server died because we closed the sockets after a timeout, exit 3. if (timedout) return 3; if (disconnected) return 0; |