%files -n librgw2
%{_libdir}/librgw.so.*
-%{_libdir}/librgw_admin_user.so.*
%if %{with lttng}
%{_libdir}/librgw_op_tp.so.*
%{_libdir}/librgw_rados_tp.so.*
%files -n librgw-devel
%dir %{_includedir}/rados
%{_includedir}/rados/librgw.h
-%{_includedir}/rados/librgw_admin_user.h
%{_includedir}/rados/rgw_file.h
%{_libdir}/librgw.so
-%{_libdir}/librgw_admin_user.so
%if %{with lttng}
%{_libdir}/librgw_op_tp.so
%{_libdir}/librgw_rados_tp.so
usr/include/rados/librgw.h
-usr/include/rados/librgw_admin_user.h
usr/include/rados/rgw_file.h
usr/lib/librgw.so
-usr/lib/librgw_admin_user.so
usr/lib/librgw.so.*
-usr/lib/librgw_admin_user.so.*
install(FILES
rados/librgw.h
rados/rgw_file.h
- rgw/librgw_admin_user.h
- DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rados)
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rados)
endif()
+++ /dev/null
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-/*
- * create rgw admin user
- *
- * Copyright (C) 2015 Red Hat, Inc.
- *
- * This is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software
- * Foundation. See file COPYING.
- *
- */
-
-#ifndef LIB_RGW_ADMIN_USER_H
-#define LIB_RGW_ADMIN_USER_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define LIBRGW_ADMIN_USER_VER_MAJOR 1
-#define LIBRGW_ADMIN_USER_VER_MINOR 0
-#define LIBRGW_ADMIN_USER_VER_EXTRA 0
-
-#define LIBRGW_ADMIN_USER_VERSION(maj, min, extra) ((maj << 16) + (min << 8) + extra)
-#define LIBRGW_ADMIN_USER_VERSION_CODE LIBRGW_ADMIN_USER_VERSION(LIBRGW_ADMIN_USER_VER_MAJOR, LIBRGW_ADMIN_USER_VER_MINOR, LIBRGW_ADMIN_USER_VER_EXTRA)
-
-typedef void* librgw_admin_user_t;
-int librgw_admin_user_create(librgw_admin_user_t *rgw_admin_user, int argc, char **argv);
-void librgw_admin_user_shutdown(librgw_admin_user_t rgw_admin_user);
-
-struct rgw_user_info
-{
- const char *uid;
- const char *display_name;
- const char *access_key;
- const char* secret_key;
- const char* email;
- const char *caps;
- const char *access;
- bool admin;
- bool system;
-};
-
- /*
- * create a new rgw user
- */
-int rgw_admin_create_user(librgw_admin_user_t rgw_admin_user, const char *uid,
- const char *display_name, const char *access_key, const char* secret_key,
- const char *email, const char *caps,
- const char *access, bool admin, bool system);
-
-/*
- * get rgw user info
- */
-int rgw_admin_user_info(librgw_admin_user_t rgw_admin_user,const char * uid, rgw_user_info* user_info);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* LIBRGW_ADMIN_USER */
SOVERSION 2)
install(TARGETS rgw DESTINATION ${CMAKE_INSTALL_LIBDIR})
-set(librgw_admin_user_srcs
- librgw_admin_user.cc
- rgw_admin_user.cc
-)
-add_library(rgw_admin_user SHARED
- ${librgw_admin_user_srcs}
- $<TARGET_OBJECTS:rgw_common>)
-
-add_dependencies(rgw_admin_user civetweb_h)
-
-target_link_libraries(rgw_admin_user PRIVATE
- librados
- cls_rgw_client
- cls_otp_client
- cls_lock_client
- cls_refcount_client
- cls_log_client
- cls_timeindex_client
- cls_version_client
- cls_user_client
- cls_rgw_gc_client
- global
- ${CURL_LIBRARIES}
- ${EXPAT_LIBRARIES}
- ${OPENLDAP_LIBRARIES}
- dmclock::dmclock)
-set_target_properties(rgw_admin_user PROPERTIES OUTPUT_NAME rgw_admin_user VERSION 1.0.0
- SOVERSION 0)
-install(TARGETS rgw_admin_user DESTINATION ${CMAKE_INSTALL_LIBDIR})
-if(WITH_RADOSGW_AMQP_ENDPOINT)
- target_link_libraries(rgw_admin_user PRIVATE RabbitMQ::RabbitMQ)
-endif()
-if(WITH_RADOSGW_KAFKA_ENDPOINT)
- target_link_libraries(rgw_admin_user PRIVATE RDKafka::RDKafka)
-endif()
-if(WITH_BOOST_CONTEXT)
- target_link_libraries(rgw_admin_user PRIVATE spawn)
-endif()
-
if(WITH_TESTS)
add_executable(ceph_rgw_jsonparser
rgw_jsonparser.cc)
+++ /dev/null
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab ft=cpp
-
-/*
- * create rgw admin user
- *
- * Copyright (C) 2015 Red Hat, Inc.
- *
- * This is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software
- * Foundation. See file COPYING.
- *
- */
-
-#include "include/compat.h"
-#include <sys/types.h>
-#include <string.h>
-#include <chrono>
-#include <errno.h>
-#include <thread>
-#include <string>
-#include <mutex>
-
-#include "include/types.h"
-#include "include/rgw/librgw_admin_user.h"
-#include "include/str_list.h"
-#include "include/stringify.h"
-#include "global/global_init.h"
-#include "global/signal_handler.h"
-#include "common/config.h"
-#include "common/errno.h"
-#include "common/Timer.h"
-#include "common/Throttle.h"
-#include "common/WorkQueue.h"
-#include "common/ceph_argparse.h"
-#include "common/ceph_context.h"
-#include "common/common_init.h"
-#include "common/dout.h"
-
-#include "rgw_admin_user.h"
-#include "rgw_rados.h"
-#include "rgw_os_lib.h"
-#include "rgw_auth.h"
-#include "rgw_auth_s3.h"
-
-#define dout_subsys ceph_subsys_rgw
-
-bool global_stop = false;
-
-static void handle_sigterm(int signum)
-{
- dout(20) << __func__ << " SIGUSR1 ignored" << dendl;
-}
-
-namespace rgw {
-
- using std::string;
-
- static std::mutex librgw_admin_user_mtx;
-
- RGWLibAdmin rgw_lib_admin;
-
- class C_InitTimeout : public Context {
- public:
- C_InitTimeout() {}
- void finish(int r) override {
- derr << "Initialization timeout, failed to initialize" << dendl;
- exit(1);
- }
- };
-
- int RGWLibAdmin::init()
- {
- vector<const char*> args;
- return init(args);
- }
-
- int RGWLibAdmin::init(vector<const char*>& args)
- {
- /* alternative default for module */
- map<string,string> defaults = {
- { "debug_rgw", "1/5" },
- { "keyring", "$rgw_data/keyring" },
- { "log_file", "/var/log/radosgw/$cluster-$name.log" }
- };
-
- cct = global_init(&defaults, args,
- CEPH_ENTITY_TYPE_CLIENT,
- CODE_ENVIRONMENT_UTILITY, 0);
-
- ceph::mutex mutex = ceph::make_mutex("main");
- SafeTimer init_timer(g_ceph_context, mutex);
- init_timer.init();
- mutex.lock();
- init_timer.add_event_after(g_conf()->rgw_init_timeout, new C_InitTimeout);
- mutex.unlock();
-
- common_init_finish(g_ceph_context);
-
- store = RGWStoreManager::get_storage(g_ceph_context, false, false, false, false, false);
-
- if (!store) {
- mutex.lock();
- init_timer.cancel_all_events();
- init_timer.shutdown();
- mutex.unlock();
-
- derr << "Couldn't init storage provider (RADOS)" << dendl;
- return -EIO;
- }
-
- mutex.lock();
- init_timer.cancel_all_events();
- init_timer.shutdown();
- mutex.unlock();
-
- init_async_signal_handler();
- register_async_signal_handler(SIGUSR1, handle_sigterm);
-
- return 0;
- } /* RGWLibAdmin::init() */
-
- int RGWLibAdmin::stop()
- {
- derr << "shutting down" << dendl;
-
- unregister_async_signal_handler(SIGUSR1, handle_sigterm);
- shutdown_async_signal_handler();
-
- RGWStoreManager::close_storage(store);
-
- dout(1) << "final shutdown" << dendl;
- cct.reset();
-
- return 0;
- } /* RGWLibAdmin::stop() */
-
-} /* namespace rgw */
-
-extern "C" {
-
-int librgw_admin_user_create(librgw_admin_user_t* rgw_admin_user, int argc, char **argv)
-{
- using namespace rgw;
-
- int rc = -EINVAL;
-
- if (! g_ceph_context) {
- std::lock_guard<std::mutex> lg(librgw_admin_user_mtx);
- if (! g_ceph_context) {
- vector<const char*> args;
- std::vector<std::string> spl_args;
- // last non-0 argument will be split and consumed
- if (argc > 1) {
- const std::string spl_arg{argv[(--argc)]};
- get_str_vec(spl_arg, " \t", spl_args);
- }
- argv_to_vec(argc, const_cast<const char**>(argv), args);
- // append split args, if any
- for (const auto& elt : spl_args) {
- args.push_back(elt.c_str());
- }
- rc = rgw_lib_admin.init(args);
- }
- }
-
- *rgw_admin_user = g_ceph_context->get();
-
- return rc;
-}
-
-void librgw_admin_user_shutdown(librgw_admin_user_t rgw_admin_user)
-{
- using namespace rgw;
-
- CephContext* cct = static_cast<CephContext*>(rgw_admin_user);
- rgw_lib_admin.stop();
- cct->put();
-}
-
-} /* extern "C" */
-
-
target_link_libraries(test_build_librgw rgw_a pthread ${CRYPTO_LIBS} ${EXTRALIBS})
endif(WITH_RADOSGW)
-if(WITH_RADOSGW)
- add_executable(test_build_librgw_admin_user buildtest_skeleton.cc)
- target_link_libraries(test_build_librgw_admin_user pthread ${CRYPTO_LIBS} ${EXTRALIBS})
-endif(WITH_RADOSGW)
-
if(WITH_LIBCEPHFS)
# From src/test/Makefile-client.am: I dont get this one... testing the osdc build but link in libcephfs?
add_executable(test_build_libcephfs buildtest_skeleton.cc)
${OPENLDAP_LIBRARIES}
${UNITTEST_LIBS}
)
-
-# unittest_librgw_admin_user
-add_executable(ceph_test_librgw_admin_user test_librgw_admin_user.cc)
-target_link_libraries(ceph_test_librgw_admin_user
- rgw_admin_user
- cls_otp_client
- librados
- ceph-common
- ${UNITTEST_LIBS}
- ${EXTRALIBS}
- )
-
endif(${WITH_RADOSGW})
# ceph_multi_stress_watch
+++ /dev/null
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-/*
- * Ceph - scalable distributed file system
- *
- * Copyright (C) 2015 Red Hat, Inc.
- *
- * This is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software
- * Foundation. See file COPYING.
- *
- */
-
-#include <string.h>
-#include "gtest/gtest.h"
-#include "common/ceph_argparse.h"
-
-#include "include/rgw/librgw_admin_user.h"
-
-#define dout_subsys ceph_subsys_rgw
-
-namespace {
- librgw_admin_user_t rgw = nullptr;
- std::string uid("testuser");
- std::string display_name("testuser");
- std::string access_key("");
- std::string secret_key("");
- std::string email;
- std::string caps;
- std::string access_str;
- bool admin;
- bool system_user;
-
- struct {
- int argc;
- char **argv;
- } saved_args;
-}
-
-TEST(RGWLibAdmin, INIT) {
- int ret = librgw_admin_user_create(&rgw, saved_args.argc, saved_args.argv);
- ASSERT_EQ(ret, 0);
- ASSERT_NE(rgw, nullptr);
-}
-
-TEST(RGWLibAdmin, CREATE) {
- int ret = rgw_admin_create_user(rgw, uid.c_str(), display_name.c_str(),
- access_key.c_str(), secret_key.c_str(), caps.c_str(), access_str.c_str(), email.c_str(),
- admin, system_user);
- ASSERT_EQ(ret, 0);
-}
-
-TEST(RGWLibAdmin, INFO) {
- struct rgw_user_info user_info;
- int ret = rgw_admin_user_info(rgw, uid.c_str(), &user_info);
- ASSERT_EQ(ret, 0);
-}
-
-TEST(RGWLibAdmin, SHUTDOWN) {
- librgw_admin_user_shutdown(rgw);
-}
-
-int main(int argc, char *argv[])
-{
- char *v{nullptr};
- std::string val;
- std::vector<const char*> args;
-
- argv_to_vec(argc, const_cast<const char**>(argv), args);
- env_to_vec(args);
-
- v = getenv("AWS_ACCESS_KEY_ID");
- if (v) {
- access_key = v;
- }
-
- v = getenv("AWS_SECRET_ACCESS_KEY");
- if (v) {
- secret_key = v;
- }
-
- for (auto arg_iter = args.begin(); arg_iter != args.end();) {
- if (ceph_argparse_witharg(args, arg_iter, &val, "--access",
- (char*) nullptr)) {
- access_key = val;
- } else if (ceph_argparse_witharg(args, arg_iter, &val, "--secret",
- (char*) nullptr)) {
- secret_key = val;
- } else if (ceph_argparse_witharg(args, arg_iter, &val, "--uid",
- (char*) nullptr)) {
- uid = val;
- } else {
- ++arg_iter;
- }
- }
-
- saved_args.argc = argc;
- saved_args.argv = argv;
-
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
-