before this change, we rely on `using namespace seastar` to use
`seastar::format()` without qualifying the `format()` with its
namespace. this works fine until we changed the parameter type
of format string `seastar::format()` from `const char*` to
`fmt::format_string<...>`. this change practically invited
`seastar::format()` to the club of `std::format()` and `fmt::format()`,
where all members accept a templated parameter as its `fmt`
parameter. and `seastar::format()` is not the best candidate anymore.
despite that argument-dependent lookup (ADT for short) favors the
function which is in the same namespace as its parameter, but
`using namespace` makes `seastar::format()` more competitive,
so both `std::format()` and `seastar::format()` are considered
as the condidates.
that is what is happening scylladb in quite a few caller sites of
`format()`, hence ADT is not able to tell which function the winner
in the name lookup:
```
/__w/scylladb/scylladb/mutation/mutation_fragment_stream_validator.cc:265:12: error: call to 'format' is ambiguous
265 | return format("{} ({}.{} {})", _name_view, s.ks_name(), s.cf_name(), s.id());
| ^~~~~~
/usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/format:4290:5: note: candidate function [with _Args = <const std::basic_string_view<char> &, const seastar::basic_sstring<char, unsigned int, 15> &, const seastar::basic_sstring<char, unsigned int, 15> &, const utils::tagged_uuid<table_id_tag> &>]
4290 | format(format_string<_Args...> __fmt, _Args&&... __args)
| ^
/__w/scylladb/scylladb/seastar/include/seastar/core/print.hh:143:1: note: candidate function [with A = <const std::basic_string_view<char> &, const seastar::basic_sstring<char, unsigned int, 15> &, const seastar::basic_sstring<char, unsigned int, 15> &, const utils::tagged_uuid<table_id_tag> &>]
143 | format(fmt::format_string<A...> fmt, A&&... a) {
| ^
```
in this change, we
change all `format()` to either `fmt::format()` or `seastar::format()`
with following rules:
- if the caller expects an `sstring` or `std::string_view`, change to
`seastar::format()`
- if the caller expects an `std::string`, change to `fmt::format()`.
because, `sstring::operator std::basic_string` would incur a deep
copy.
we will need another change to enable scylladb to compile with the
latest seastar. namely, to pass the format string as a templated
parameter down to helper functions which format their parameters.
to miminize the scope of this change, let's include that change when
bumping up the seastar submodule. as that change will depend on
the seastar change.
Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
113 lines
4.1 KiB
C++
113 lines
4.1 KiB
C++
/*
|
|
* Copyright (C) 2023-present ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
#include "auth/maintenance_socket_role_manager.hh"
|
|
|
|
#include <seastar/core/future.hh>
|
|
#include <stdexcept>
|
|
#include <string_view>
|
|
#include "utils/class_registrator.hh"
|
|
|
|
namespace auth {
|
|
|
|
constexpr std::string_view maintenance_socket_role_manager_name = "com.scylladb.auth.MaintenanceSocketRoleManager";
|
|
|
|
static const class_registrator<
|
|
role_manager,
|
|
maintenance_socket_role_manager,
|
|
cql3::query_processor&,
|
|
::service::raft_group0_client&,
|
|
::service::migration_manager&> registration(sstring{maintenance_socket_role_manager_name});
|
|
|
|
|
|
std::string_view maintenance_socket_role_manager::qualified_java_name() const noexcept {
|
|
return maintenance_socket_role_manager_name;
|
|
}
|
|
|
|
const resource_set& maintenance_socket_role_manager::protected_resources() const {
|
|
static const resource_set resources{};
|
|
|
|
return resources;
|
|
}
|
|
|
|
future<> maintenance_socket_role_manager::start() {
|
|
return make_ready_future<>();
|
|
}
|
|
|
|
future<> maintenance_socket_role_manager::stop() {
|
|
return make_ready_future<>();
|
|
}
|
|
|
|
template<typename T = void>
|
|
future<T> operation_not_supported_exception(std::string_view operation) {
|
|
return make_exception_future<T>(
|
|
std::runtime_error(fmt::format("role manager: {} operation not supported through maintenance socket", operation)));
|
|
}
|
|
|
|
future<> maintenance_socket_role_manager::create(std::string_view role_name, const role_config&, ::service::group0_batch&) {
|
|
return operation_not_supported_exception("CREATE");
|
|
}
|
|
|
|
future<> maintenance_socket_role_manager::drop(std::string_view role_name, ::service::group0_batch& mc) {
|
|
return operation_not_supported_exception("DROP");
|
|
}
|
|
|
|
future<> maintenance_socket_role_manager::alter(std::string_view role_name, const role_config_update&, ::service::group0_batch&) {
|
|
return operation_not_supported_exception("ALTER");
|
|
}
|
|
|
|
future<> maintenance_socket_role_manager::grant(std::string_view grantee_name, std::string_view role_name, ::service::group0_batch& mc) {
|
|
return operation_not_supported_exception("GRANT");
|
|
}
|
|
|
|
future<> maintenance_socket_role_manager::revoke(std::string_view revokee_name, std::string_view role_name, ::service::group0_batch& mc) {
|
|
return operation_not_supported_exception("REVOKE");
|
|
}
|
|
|
|
future<role_set> maintenance_socket_role_manager::query_granted(std::string_view grantee_name, recursive_role_query) {
|
|
return operation_not_supported_exception<role_set>("QUERY GRANTED");
|
|
}
|
|
|
|
future<role_to_directly_granted_map> maintenance_socket_role_manager::query_all_directly_granted() {
|
|
return operation_not_supported_exception<role_to_directly_granted_map>("QUERY ALL DIRECTLY GRANTED");
|
|
}
|
|
|
|
future<role_set> maintenance_socket_role_manager::query_all() {
|
|
return operation_not_supported_exception<role_set>("QUERY ALL");
|
|
}
|
|
|
|
future<bool> maintenance_socket_role_manager::exists(std::string_view role_name) {
|
|
return operation_not_supported_exception<bool>("EXISTS");
|
|
}
|
|
|
|
future<bool> maintenance_socket_role_manager::is_superuser(std::string_view role_name) {
|
|
return make_ready_future<bool>(true);
|
|
}
|
|
|
|
future<bool> maintenance_socket_role_manager::can_login(std::string_view role_name) {
|
|
return make_ready_future<bool>(true);
|
|
}
|
|
|
|
future<std::optional<sstring>> maintenance_socket_role_manager::get_attribute(std::string_view role_name, std::string_view attribute_name) {
|
|
return operation_not_supported_exception<std::optional<sstring>>("GET ATTRIBUTE");
|
|
}
|
|
|
|
future<role_manager::attribute_vals> maintenance_socket_role_manager::query_attribute_for_all(std::string_view attribute_name) {
|
|
return operation_not_supported_exception<role_manager::attribute_vals>("QUERY ATTRIBUTE");
|
|
}
|
|
|
|
future<> maintenance_socket_role_manager::set_attribute(std::string_view role_name, std::string_view attribute_name, std::string_view attribute_value, ::service::group0_batch& mc) {
|
|
return operation_not_supported_exception("SET ATTRIBUTE");
|
|
}
|
|
|
|
future<> maintenance_socket_role_manager::remove_attribute(std::string_view role_name, std::string_view attribute_name, ::service::group0_batch& mc) {
|
|
return operation_not_supported_exception("REMOVE ATTRIBUTE");
|
|
}
|
|
|
|
}
|