+bool UsersImpl::Authorize(const std::string & login, uint32_t ip,
+ uint32_t enabledDirs, const Auth * auth)
+{
+user_iter iter;
+std::lock_guard<std::mutex> lock(m_mutex);
+if (FindByNameNonLock(login, &iter))
+ {
+ WriteServLog("Attempt to authorize non-existant user '%s'", login.c_str());
+ return false;
+ }
+
+if (FindByIPIdx(ip, iter))
+ {
+ if (iter->GetLogin() != login)
+ {
+ WriteServLog("Attempt to authorize user '%s' from ip %s which already occupied by '%s'",
+ login.c_str(), inet_ntostring(ip).c_str(),
+ iter->GetLogin().c_str());
+ return false;
+ }
+ if (iter->Authorize(ip, enabledDirs, auth))
+ return false;
+ return true;
+ }
+
+if (iter->Authorize(ip, enabledDirs, auth))
+ return false;
+
+AddToIPIdx(iter);
+return true;
+}
+//-----------------------------------------------------------------------------
+bool UsersImpl::Unauthorize(const std::string & login,
+ const Auth * auth,
+ const std::string & reason)
+{
+user_iter iter;
+std::lock_guard<std::mutex> lock(m_mutex);
+if (FindByNameNonLock(login, &iter))
+ {
+ WriteServLog("Attempt to unauthorize non-existant user '%s'", login.c_str());
+ printfd(__FILE__, "Attempt to unauthorize non-existant user '%s'", login.c_str());
+ return false;
+ }
+
+uint32_t ip = iter->GetCurrIP();
+
+iter->Unauthorize(auth, reason);
+
+if (!iter->GetAuthorized())
+ DelFromIPIdx(ip);
+
+return true;
+}
+//-----------------------------------------------------------------------------
+int UsersImpl::ReadUsers()