Commit 9c7136cf authored by Asanka Herath's avatar Asanka Herath Committed by Commit Bot

[net/auth] Fix DLOPEN_KERBEROS flag propagation to net tests.

DLOPEN_KERBEROS is a flag used to control whether the GSSAPI library
should be loaded at runtime (via dlopen()) or linked to statically. The
latter is used by some Linux distributions. Unfortunately this flag was
not being passed to the net_unittests target, which resulted in the
corresponding tests to not be compiled all these years.

This CL moves DLOPEN_KERBEROS from being a compiler flag to being a
buildflag in net_buildflag.h. This increases the visibility of
DLOPEN_KERBEROS substantially, but is consistent with its sibling
USE_KERBEROS.

Ideally this buildflag should be called DLOPEN_GSSAPI which will happen
after an announcement on net-dev@.

Bug: 927182
Change-Id: I6d886595fcebabb222436113ea60f8879e08910d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1639345
Commit-Queue: Asanka Herath <asanka@chromium.org>
Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#665799}
parent 906024f5
...@@ -84,6 +84,7 @@ buildflag_header("buildflags") { ...@@ -84,6 +84,7 @@ buildflag_header("buildflags") {
"ENABLE_WEBSOCKETS=$enable_websockets", "ENABLE_WEBSOCKETS=$enable_websockets",
"INCLUDE_TRANSPORT_SECURITY_STATE_PRELOAD_LIST=$include_transport_security_state_preload_list", "INCLUDE_TRANSPORT_SECURITY_STATE_PRELOAD_LIST=$include_transport_security_state_preload_list",
"USE_KERBEROS=$use_kerberos", "USE_KERBEROS=$use_kerberos",
"DLOPEN_KERBEROS=$use_external_gssapi",
"TRIAL_COMPARISON_CERT_VERIFIER_SUPPORTED=$trial_comparison_cert_verifier_supported", "TRIAL_COMPARISON_CERT_VERIFIER_SUPPORTED=$trial_comparison_cert_verifier_supported",
] ]
} }
...@@ -98,10 +99,6 @@ config("net_internal_config") { ...@@ -98,10 +99,6 @@ config("net_internal_config") {
if (enable_built_in_dns) { if (enable_built_in_dns) {
defines += [ "ENABLE_BUILT_IN_DNS" ] defines += [ "ENABLE_BUILT_IN_DNS" ]
} }
if (use_external_gssapi) {
defines += [ "DLOPEN_KERBEROS" ]
}
} }
net_configs = [ net_configs = [
......
...@@ -16,7 +16,9 @@ ...@@ -16,7 +16,9 @@
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
#include "net/http/http_auth_gssapi_posix.h"
#include "net/http/http_auth_multi_round_parse.h" #include "net/http/http_auth_multi_round_parse.h"
#include "net/net_buildflags.h"
// These are defined for the GSSAPI library: // These are defined for the GSSAPI library:
// Paraphrasing the comments from gssapi.h: // Paraphrasing the comments from gssapi.h:
...@@ -422,11 +424,11 @@ bool GSSAPISharedLibrary::Init() { ...@@ -422,11 +424,11 @@ bool GSSAPISharedLibrary::Init() {
bool GSSAPISharedLibrary::InitImpl() { bool GSSAPISharedLibrary::InitImpl() {
DCHECK(!initialized_); DCHECK(!initialized_);
#if defined(DLOPEN_KERBEROS) #if BUILDFLAG(DLOPEN_KERBEROS)
gssapi_library_ = LoadSharedLibrary(); gssapi_library_ = LoadSharedLibrary();
if (gssapi_library_ == nullptr) if (gssapi_library_ == nullptr)
return false; return false;
#endif // defined(DLOPEN_KERBEROS) #endif // BUILDFLAG(DLOPEN_KERBEROS)
initialized_ = true; initialized_ = true;
return true; return true;
} }
...@@ -479,7 +481,7 @@ base::NativeLibrary GSSAPISharedLibrary::LoadSharedLibrary() { ...@@ -479,7 +481,7 @@ base::NativeLibrary GSSAPISharedLibrary::LoadSharedLibrary() {
return nullptr; return nullptr;
} }
#if defined(DLOPEN_KERBEROS) #if BUILDFLAG(DLOPEN_KERBEROS)
#define BIND(lib, x) \ #define BIND(lib, x) \
DCHECK(lib); \ DCHECK(lib); \
gss_##x##_type x = reinterpret_cast<gss_##x##_type>( \ gss_##x##_type x = reinterpret_cast<gss_##x##_type>( \
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
#include "net/http/http_auth_challenge_tokenizer.h" #include "net/http/http_auth_challenge_tokenizer.h"
#include "net/http/mock_gssapi_library_posix.h" #include "net/http/mock_gssapi_library_posix.h"
#include "net/net_buildflags.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace net { namespace net {
...@@ -90,13 +91,13 @@ TEST(HttpAuthGSSAPIPOSIXTest, GSSAPIStartup) { ...@@ -90,13 +91,13 @@ TEST(HttpAuthGSSAPIPOSIXTest, GSSAPIStartup) {
EXPECT_TRUE(gssapi.get()->Init()); EXPECT_TRUE(gssapi.get()->Init());
} }
#if defined(DLOPEN_KERBEROS) #if BUILDFLAG(DLOPEN_KERBEROS)
TEST(HttpAuthGSSAPIPOSIXTest, GSSAPILoadCustomLibrary) { TEST(HttpAuthGSSAPIPOSIXTest, GSSAPILoadCustomLibrary) {
std::unique_ptr<GSSAPILibrary> gssapi( std::unique_ptr<GSSAPILibrary> gssapi(
new GSSAPISharedLibrary("/this/library/does/not/exist")); new GSSAPISharedLibrary("/this/library/does/not/exist"));
EXPECT_FALSE(gssapi.get()->Init()); EXPECT_FALSE(gssapi.get()->Init());
} }
#endif // defined(DLOPEN_KERBEROS) #endif // DLOPEN_KERBEROS
TEST(HttpAuthGSSAPIPOSIXTest, GSSAPICycle) { TEST(HttpAuthGSSAPIPOSIXTest, GSSAPICycle) {
std::unique_ptr<test::MockGSSAPILibrary> mock_library( std::unique_ptr<test::MockGSSAPILibrary> mock_library(
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "net/http/http_request_info.h" #include "net/http/http_request_info.h"
#include "net/http/mock_allow_http_auth_preferences.h" #include "net/http/mock_allow_http_auth_preferences.h"
#include "net/log/net_log_with_source.h" #include "net/log/net_log_with_source.h"
#include "net/net_buildflags.h"
#include "net/ssl/ssl_info.h" #include "net/ssl/ssl_info.h"
#include "net/test/gtest_util.h" #include "net/test/gtest_util.h"
#include "net/test/test_with_scoped_task_environment.h" #include "net/test/test_with_scoped_task_environment.h"
...@@ -382,14 +383,12 @@ TEST_F(HttpAuthHandlerNegotiateTest, NoKerberosCredentials) { ...@@ -382,14 +383,12 @@ TEST_F(HttpAuthHandlerNegotiateTest, NoKerberosCredentials) {
EXPECT_THAT(callback.WaitForResult(), IsError(ERR_MISSING_AUTH_CREDENTIALS)); EXPECT_THAT(callback.WaitForResult(), IsError(ERR_MISSING_AUTH_CREDENTIALS));
} }
#if defined(DLOPEN_KERBEROS) #if BUILDFLAG(DLOPEN_KERBEROS)
TEST_F(HttpAuthHandlerNegotiateTest, MissingGSSAPI) { TEST_F(HttpAuthHandlerNegotiateTest, MissingGSSAPI) {
std::unique_ptr<HostResolver> host_resolver(new MockHostResolver());
MockAllowHttpAuthPreferences http_auth_preferences; MockAllowHttpAuthPreferences http_auth_preferences;
std::unique_ptr<HttpAuthHandlerNegotiate::Factory> negotiate_factory( std::unique_ptr<HttpAuthHandlerNegotiate::Factory> negotiate_factory(
new HttpAuthHandlerNegotiate::Factory( new HttpAuthHandlerNegotiate::Factory(
net::HttpAuthHandlerFactory::NegotiateAuthSystemFactory())); net::HttpAuthHandlerFactory::NegotiateAuthSystemFactory()));
negotiate_factory->set_host_resolver(host_resolver);
negotiate_factory->set_http_auth_preferences(&http_auth_preferences); negotiate_factory->set_http_auth_preferences(&http_auth_preferences);
negotiate_factory->set_library( negotiate_factory->set_library(
std::make_unique<GSSAPISharedLibrary>("/this/library/does/not/exist")); std::make_unique<GSSAPISharedLibrary>("/this/library/does/not/exist"));
...@@ -397,12 +396,12 @@ TEST_F(HttpAuthHandlerNegotiateTest, MissingGSSAPI) { ...@@ -397,12 +396,12 @@ TEST_F(HttpAuthHandlerNegotiateTest, MissingGSSAPI) {
GURL gurl("http://www.example.com"); GURL gurl("http://www.example.com");
std::unique_ptr<HttpAuthHandler> generic_handler; std::unique_ptr<HttpAuthHandler> generic_handler;
int rv = negotiate_factory->CreateAuthHandlerFromString( int rv = negotiate_factory->CreateAuthHandlerFromString(
"Negotiate", HttpAuth::AUTH_SERVER, gurl, NetLogWithSource(), "Negotiate", HttpAuth::AUTH_SERVER, SSLInfo(), gurl, NetLogWithSource(),
&generic_handler); resolver(), &generic_handler);
EXPECT_THAT(rv, IsError(ERR_UNSUPPORTED_AUTH_SCHEME)); EXPECT_THAT(rv, IsError(ERR_UNSUPPORTED_AUTH_SCHEME));
EXPECT_TRUE(generic_handler.get() == nullptr); EXPECT_TRUE(generic_handler.get() == nullptr);
} }
#endif // defined(DLOPEN_KERBEROS) #endif // BUILDFLAG(DLOPEN_KERBEROS)
// AllowGssapiLibraryLoad() is only supported on Chrome OS. // AllowGssapiLibraryLoad() is only supported on Chrome OS.
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment