From 1978c49bea5b439d993067c055cec47e70db8fd6 Mon Sep 17 00:00:00 2001 From: "Jannis M. Hoffmann" Date: Sat, 7 Oct 2023 22:33:50 +0200 Subject: minor refactoring --- src/authenticate.cc | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'src/authenticate.cc') 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 #include @@ -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; -- cgit v1.2.3