}
auto svc = env.store->svc()->config_key;
- int r = svc->get(name, pbl);
+ int r = svc->get(name, true, pbl);
if (r < 0) {
lderr(ctx()) << type << " was not found: " << name << dendl;
return r;
return r;
}
+ r = config_key_rados->start();
+ if (r < 0) {
+ ldout(cct, 0) << "ERROR: failed to start config_key service (" << cpp_strerror(-r) << dendl;
+ return r;
+ }
+
r = zone_utils->start();
if (r < 0) {
ldout(cct, 0) << "ERROR: failed to start zone_utils service (" << cpp_strerror(-r) << dendl;
RGWSI_ConfigKey(CephContext *cct) : RGWServiceInstance(cct) {}
virtual ~RGWSI_ConfigKey() {}
- virtual int get(const string& key, bufferlist *result) = 0;
+ virtual int get(const string& key, bool secure, bufferlist *result) = 0;
};
#include "svc_rados.h"
#include "svc_config_key_rados.h"
-int RGWSI_ConfigKey_RADOS::get(const string& key, bufferlist *result)
+int RGWSI_ConfigKey_RADOS::do_start()
+{
+ maybe_insecure_mon_conn = !svc.rados->check_secure_mon_conn();
+
+ return 0;
+}
+
+void RGWSI_ConfigKey_RADOS::warn_if_insecure()
+{
+ if (!maybe_insecure_mon_conn ||
+ warned_insecure.test_and_set()) {
+ return;
+ }
+
+ string s = "rgw is configured to optionally allow insecure connections to the monitors (auth_supported, ms_mon_client_mode), ssl certificates stored at the monitor configuration could leak";
+
+ svc.rados->clog_warn(s);
+
+ lderr(ctx()) << __func__ << "(): WARNING: " << s << dendl;
+}
+
+int RGWSI_ConfigKey_RADOS::get(const string& key, bool secure, bufferlist *result)
{
string cmd =
"{"
bufferlist inbl;
auto handle = svc.rados->handle();
- return handle.mon_command(cmd, inbl, result, nullptr);
+ int ret = handle.mon_command(cmd, inbl, result, nullptr);
+ if (ret < 0) {
+ return ret;
+ }
+
+ if (secure) {
+ warn_if_insecure();
+ }
+
+ return 0;
}
#pragma once
+#include <atomic>
+
#include "rgw/rgw_service.h"
#include "svc_config_key.h"
class RGWSI_ConfigKey_RADOS : public RGWSI_ConfigKey
{
+ bool maybe_insecure_mon_conn{false};
+ std::atomic_flag warned_insecure{ATOMIC_FLAG_INIT};
+
+ int do_start() override;
+
+ void warn_if_insecure();
+
public:
struct Svc {
RGWSI_RADOS *rados{nullptr};
RGWSI_ConfigKey_RADOS(CephContext *cct) : RGWSI_ConfigKey(cct) {}
- int get(const string& key, bufferlist *result) override;
+ int get(const string& key, bool secure, bufferlist *result) override;
};
#include "rgw/rgw_tools.h"
#include "rgw/rgw_cr_rados.h"
+#include "auth/AuthRegistry.h"
+
#define dout_subsys ceph_subsys_rgw
RGWSI_RADOS::RGWSI_RADOS(CephContext *cct) : RGWServiceInstance(cct)
return h.mon_command(cmd, inbl, nullptr, nullptr);
}
+bool RGWSI_RADOS::check_secure_mon_conn() const
+{
+ AuthRegistry reg(cct);
+
+ reg.refresh_config();
+
+ std::vector<uint32_t> methods;
+ std::vector<uint32_t> modes;
+
+ reg.get_supported_methods(CEPH_ENTITY_TYPE_MON, &methods, &modes);
+ ldout(cct, 20) << __func__ << "(): auth registy supported: methods=" << methods << " modes=" << modes << dendl;
+
+ for (auto method : methods) {
+ if (!reg.is_secure_method(method)) {
+ ldout(cct, 20) << __func__ << "(): method " << method << " is insecure" << dendl;
+ return false;
+ }
+ }
+
+ for (auto mode : modes) {
+ if (!reg.is_secure_mode(mode)) {
+ ldout(cct, 20) << __func__ << "(): mode " << mode << " is insecure" << dendl;
+ return false;
+ }
+ }
+
+ return true;
+}
+
void shutdown() override;
uint64_t instance_id();
+ bool check_secure_mon_conn() const;
RGWAsyncRadosProcessor *get_async_processor() {
return async_processor.get();