From: Casey Bodley Date: Wed, 25 Mar 2020 14:50:07 +0000 (-0400) Subject: rgw: remove unused librgw_admin_user X-Git-Tag: v17.0.0~2832^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=c89b59428e66ae6d89d1fd27a4280045c57251cb;p=ceph.git rgw: remove unused librgw_admin_user unused and not worth the effort to maintain Signed-off-by: Casey Bodley --- diff --git a/ceph.spec.in b/ceph.spec.in index c91472d4b1e55..20f8f87f9250f 100644 --- a/ceph.spec.in +++ b/ceph.spec.in @@ -2137,7 +2137,6 @@ fi %files -n librgw2 %{_libdir}/librgw.so.* -%{_libdir}/librgw_admin_user.so.* %if %{with lttng} %{_libdir}/librgw_op_tp.so.* %{_libdir}/librgw_rados_tp.so.* @@ -2150,10 +2149,8 @@ fi %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 diff --git a/debian/librgw-dev.install b/debian/librgw-dev.install index 1f4f1b190bad4..ed2a81dba5013 100644 --- a/debian/librgw-dev.install +++ b/debian/librgw-dev.install @@ -1,5 +1,3 @@ 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 diff --git a/debian/librgw2.install b/debian/librgw2.install index 725f341affa48..b86fb891e2c25 100644 --- a/debian/librgw2.install +++ b/debian/librgw2.install @@ -1,2 +1 @@ usr/lib/librgw.so.* -usr/lib/librgw_admin_user.so.* diff --git a/src/include/CMakeLists.txt b/src/include/CMakeLists.txt index 39cdc6b2bf42f..77eb4093a80aa 100644 --- a/src/include/CMakeLists.txt +++ b/src/include/CMakeLists.txt @@ -30,6 +30,5 @@ if(WITH_RADOSGW) 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() diff --git a/src/include/rgw/librgw_admin_user.h b/src/include/rgw/librgw_admin_user.h deleted file mode 100644 index e1dd5a29776a6..0000000000000 --- a/src/include/rgw/librgw_admin_user.h +++ /dev/null @@ -1,63 +0,0 @@ -// -*- 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 */ diff --git a/src/rgw/CMakeLists.txt b/src/rgw/CMakeLists.txt index 2dae1f2c81deb..bfacafc41e865 100644 --- a/src/rgw/CMakeLists.txt +++ b/src/rgw/CMakeLists.txt @@ -393,45 +393,6 @@ set_target_properties(rgw PROPERTIES OUTPUT_NAME rgw VERSION 2.0.0 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} - $) - -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) diff --git a/src/rgw/librgw_admin_user.cc b/src/rgw/librgw_admin_user.cc deleted file mode 100644 index 2c1f0ae2c705f..0000000000000 --- a/src/rgw/librgw_admin_user.cc +++ /dev/null @@ -1,184 +0,0 @@ -// -*- 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 -#include -#include -#include -#include -#include -#include - -#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 args; - return init(args); - } - - int RGWLibAdmin::init(vector& args) - { - /* alternative default for module */ - map 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 lg(librgw_admin_user_mtx); - if (! g_ceph_context) { - vector args; - std::vector 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(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(rgw_admin_user); - rgw_lib_admin.stop(); - cct->put(); -} - -} /* extern "C" */ - - diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index 82208219e7873..bc69f8e1e19bc 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -107,11 +107,6 @@ if(WITH_RADOSGW) 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) @@ -345,18 +340,6 @@ target_link_libraries(test_rgw_ldap ${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 diff --git a/src/test/test_librgw_admin_user.cc b/src/test/test_librgw_admin_user.cc deleted file mode 100644 index 6b9df1cc5f33c..0000000000000 --- a/src/test/test_librgw_admin_user.cc +++ /dev/null @@ -1,104 +0,0 @@ -// -*- 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 -#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 args; - - argv_to_vec(argc, const_cast(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(); -} -