From 02aeb7ef4a3bfe437034667d6e54e5c419120b79 Mon Sep 17 00:00:00 2001 From: Francesco Chemolli Date: Fri, 4 Sep 2015 15:26:59 +0200 Subject: [PATCH] Auth::User::userKey now returns SBuf --- src/auth/Gadgets.cc | 2 +- src/auth/User.h | 4 +--- src/auth/UserNameCache.cc | 4 ++-- src/auth/basic/Config.cc | 2 +- src/auth/negotiate/UserRequest.cc | 2 +- src/auth/ntlm/UserRequest.cc | 2 +- 6 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/auth/Gadgets.cc b/src/auth/Gadgets.cc index 402aae7fff..8a91934af8 100644 --- a/src/auth/Gadgets.cc +++ b/src/auth/Gadgets.cc @@ -109,7 +109,7 @@ std::vector authenticateCachedUsersList() { auto aucp_compare = [=](const Auth::User::Pointer lhs, const Auth::User::Pointer rhs) { - return lhs->SBufUserKey() < rhs->SBufUserKey(); + return lhs->userKey() < rhs->userKey(); }; std::vector v1, v2, rv, u1, u2; if (Auth::Config::Find("basic") != nullptr) diff --git a/src/auth/User.h b/src/auth/User.h index 579048a42c..8ff1af048c 100644 --- a/src/auth/User.h +++ b/src/auth/User.h @@ -65,9 +65,7 @@ public: void username(char const *); ///< set stored username and userKey // NP: key is set at the same time as username_. Until then both are empty/NULL. - const char *userKey() {return !userKey_.isEmpty() ? userKey_.c_str() : NULL;} - // user key as a SBuf - const SBuf SBufUserKey() const {return userKey_;} + const SBuf userKey() const {return userKey_;} /** * How long these credentials are still valid for. diff --git a/src/auth/UserNameCache.cc b/src/auth/UserNameCache.cc index 6ae6f05d3e..870be26da6 100644 --- a/src/auth/UserNameCache.cc +++ b/src/auth/UserNameCache.cc @@ -69,8 +69,8 @@ UserNameCache::Cleanup(void *data) void UserNameCache::insert(Auth::User::Pointer anAuth_user) { - debugs(29, 6, "adding " << anAuth_user->SBufUserKey()); - store_[anAuth_user->SBufUserKey()] = anAuth_user; + debugs(29, 6, "adding " << anAuth_user->userKey()); + store_[anAuth_user->userKey()] = anAuth_user; } // generates the list of cached usernames in a format that is convenient diff --git a/src/auth/basic/Config.cc b/src/auth/basic/Config.cc index 41876a2593..321e69907e 100644 --- a/src/auth/basic/Config.cc +++ b/src/auth/basic/Config.cc @@ -247,7 +247,7 @@ Auth::Basic::Config::decode(char const *proxy_auth, const char *aRequestRealm) /* now lookup and see if we have a matching auth_user structure in memory. */ Auth::User::Pointer auth_user; - if (!(auth_user = Auth::Basic::User::Cache()->lookup(lb->SBufUserKey()))) { + if (!(auth_user = Auth::Basic::User::Cache()->lookup(lb->userKey()))) { /* the user doesn't exist in the username cache yet */ /* save the credentials */ debugs(29, 9, HERE << "Creating new user '" << lb->username() << "'"); diff --git a/src/auth/negotiate/UserRequest.cc b/src/auth/negotiate/UserRequest.cc index eb9b736b30..b5d418a445 100644 --- a/src/auth/negotiate/UserRequest.cc +++ b/src/auth/negotiate/UserRequest.cc @@ -334,7 +334,7 @@ Auth::Negotiate::UserRequest::HandleReply(void *data, const Helper::Reply &reply /* connection is authenticated */ debugs(29, 4, HERE << "authenticated user " << auth_user_request->user()->username()); auto local_auth_user = lm_request->user(); - auto cached_user = Auth::Negotiate::User::Cache()->lookup(auth_user_request->user()->SBufUserKey()); + auto cached_user = Auth::Negotiate::User::Cache()->lookup(auth_user_request->user()->userKey()); if (!cached_user) { local_auth_user->addToNameCache(); } else { diff --git a/src/auth/ntlm/UserRequest.cc b/src/auth/ntlm/UserRequest.cc index 9d9f380435..cc3b79eb4e 100644 --- a/src/auth/ntlm/UserRequest.cc +++ b/src/auth/ntlm/UserRequest.cc @@ -329,7 +329,7 @@ Auth::Ntlm::UserRequest::HandleReply(void *data, const Helper::Reply &reply) debugs(29, 4, HERE << "authenticated user " << auth_user_request->user()->username()); /* see if this is an existing user */ auto local_auth_user = lm_request->user(); - auto cached_user = Auth::Ntlm::User::Cache()->lookup(auth_user_request->user()->SBufUserKey()); + auto cached_user = Auth::Ntlm::User::Cache()->lookup(auth_user_request->user()->userKey()); if (!cached_user) { local_auth_user->addToNameCache(); } else { -- 2.47.2