Skip to content
2 changes: 1 addition & 1 deletion source/common/network/resolver_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ InstanceConstSharedPtr resolveProtoAddress(const envoy::config::core::v3::Addres
case envoy::config::core::v3::Address::AddressCase::kSocketAddress:
return resolveProtoSocketAddress(address.socket_address());
case envoy::config::core::v3::Address::AddressCase::kPipe:
return std::make_shared<PipeInstance>(address.pipe().path());
return std::make_shared<PipeInstance>(address.pipe().path(), address.pipe().mode());
case envoy::config::core::v3::Address::AddressCase::kEnvoyInternalAddress:
switch (address.envoy_internal_address().address_name_specifier_case()) {
case envoy::config::core::v3::EnvoyInternalAddress::AddressNameSpecifierCase::
Expand Down
31 changes: 29 additions & 2 deletions test/integration/uds_integration_test.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "uds_integration_test.h"

#include <unistd.h>

#include "envoy/config/bootstrap/v3/bootstrap.pb.h"

#include "common/event/dispatcher_impl.h"
Expand Down Expand Up @@ -47,14 +49,20 @@ TEST_P(UdsUpstreamIntegrationTest, RouterDownstreamDisconnectBeforeResponseCompl
INSTANTIATE_TEST_SUITE_P(
TestParameters, UdsListenerIntegrationTest,
testing::Combine(testing::ValuesIn(TestEnvironment::getIpVersionsForTest()),
testing::Values(false, true)));
testing::Values(false, true), testing::Values(0)));
#else
INSTANTIATE_TEST_SUITE_P(
TestParameters, UdsListenerIntegrationTest,
testing::Combine(testing::ValuesIn(TestEnvironment::getIpVersionsForTest()),
testing::Values(false)));
testing::Values(false, true), testing::Values(0)));
Comment thread
lizan marked this conversation as resolved.
Outdated
#endif

// Test the mode parameter, excluding abstract namespace enabled
INSTANTIATE_TEST_SUITE_P(
TestModeParameter, UdsListenerIntegrationTest,
testing::Combine(testing::ValuesIn(TestEnvironment::getIpVersionsForTest()),
testing::Values(false), testing::Values(0662)));

void UdsListenerIntegrationTest::initialize() {
config_helper_.addConfigModifier([&](envoy::config::bootstrap::v3::Bootstrap& bootstrap) -> void {
auto* admin_addr = bootstrap.mutable_admin()->mutable_address();
Expand All @@ -68,6 +76,7 @@ void UdsListenerIntegrationTest::initialize() {
auto* listener = listeners->Add();
listener->set_name("listener_0");
listener->mutable_address()->mutable_pipe()->set_path(getListenerSocketName());
listener->mutable_address()->mutable_pipe()->set_mode(getMode());
*(listener->mutable_filter_chains()) = filter_chains;
});
HttpIntegrationTest::initialize();
Expand All @@ -84,6 +93,24 @@ HttpIntegrationTest::ConnectionCreationFunction UdsListenerIntegrationTest::crea
};
}

TEST_P(UdsListenerIntegrationTest, TestSocketMode) {
if (abstract_namespace_) {
// stat(2) against sockets in abstract namespace is not possible
GTEST_SKIP();
}

initialize();
struct stat listener_stat;
EXPECT_EQ(::stat(getListenerSocketName().c_str(), &listener_stat), 0);
Comment thread
lizan marked this conversation as resolved.
Outdated
ENVOY_LOG_MISC(debug, "expectedmode={} mode={} uid={} gid={}", mode_, listener_stat.st_mode,
listener_stat.st_uid, listener_stat.st_gid);
if (mode_ == 0) {
EXPECT_NE(listener_stat.st_mode & 0777, 0);
} else {
EXPECT_EQ(listener_stat.st_mode & mode_, mode_);
}
}

TEST_P(UdsListenerIntegrationTest, TestPeerCredentials) {
fake_upstreams_count_ = 1;
initialize();
Expand Down
7 changes: 5 additions & 2 deletions test/integration/uds_integration_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ class UdsUpstreamIntegrationTest
};

class UdsListenerIntegrationTest
: public testing::TestWithParam<std::tuple<Network::Address::IpVersion, bool>>,
: public testing::TestWithParam<std::tuple<Network::Address::IpVersion, bool, mode_t>>,
public HttpIntegrationTest {
public:
UdsListenerIntegrationTest()
: HttpIntegrationTest(Http::CodecClient::Type::HTTP1, std::get<0>(GetParam())),
abstract_namespace_(std::get<1>(GetParam())) {}
abstract_namespace_(std::get<1>(GetParam())), mode_(std::get<2>(GetParam())) {}

void initialize() override;

Expand All @@ -71,10 +71,13 @@ class UdsListenerIntegrationTest
return TestEnvironment::unixDomainSocketPath("listener_0.sock", abstract_namespace_);
}

mode_t getMode() { return mode_; }

protected:
HttpIntegrationTest::ConnectionCreationFunction createConnectionFn();

const bool abstract_namespace_;
const mode_t mode_;
};

} // namespace Envoy