From: Alex Ainscow Date: Mon, 24 Nov 2025 16:49:19 +0000 (+0000) Subject: cls: Remove legacy ACL/Crypto class calls. X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0d2be63a30535ee0e76e90830d91177927a5efbf;p=ceph-ci.git cls: Remove legacy ACL/Crypto class calls. The osd code was not present, the radosacl tool did nothing useful and the scratchtoolpp was testing something that doesn't exist. Signed-off-by: Alex Ainscow --- diff --git a/src/cls_acl.cc b/src/cls_acl.cc deleted file mode 100644 index a9b2e8ae411..00000000000 --- a/src/cls_acl.cc +++ /dev/null @@ -1,58 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:nil -*- -// vim: ts=8 sw=2 sts=2 expandtab - -#include -#include -#include -#include - -#include -#include - -#include "include/types.h" -#include "objclass/objclass.h" - -CLS_VER(1,0) -CLS_NAME(acl) - -int get_method(cls_method_context_t ctx, char *indata, int datalen, - char **outdata, int *outdatalen) -{ - MD5_CTX c; - - cls_log("acl test method"); - cls_log("indata=%.*s data_len=%d", datalen, indata, datalen); - - cls_getxattr(ctx, "acls", outdata, outdatalen); - - return 0; -} - -int set_method(cls_method_context_t ctx, char *indata, int datalen, - char **outdata, int *outdatalen) -{ - MD5_CTX c; - - cls_log("acl test method"); - cls_log("indata=%.*s data_len=%d", datalen, indata, datalen); - - cls_setxattr(ctx, "acls", indata, datalen); - - return 0; -} - -CLS_INIT(acl) -{ - cls_log("Loaded acl class!"); - - cls_handle_t h_class; - cls_method_handle_t h_get; - cls_method_handle_t h_set; - - cls_register("acl", &h_class); - cls_register_method(h_class, "get", CLS_METHOD_RD, get_method, &h_get); - cls_register_method(h_class, "set", CLS_METHOD_WR, set_method, &h_set); - - return; -} - diff --git a/src/cls_crypto.cc b/src/cls_crypto.cc deleted file mode 100644 index 21252d88dbd..00000000000 --- a/src/cls_crypto.cc +++ /dev/null @@ -1,78 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:nil -*- -// vim: ts=8 sw=2 sts=2 expandtab - -#include -#include -#include -#include - -#include -#include - -#include "include/types.h" -#include "objclass/objclass.h" - -CLS_VER(1,0) -CLS_NAME(crypto) - -int md5_method(cls_method_context_t ctx, char *indata, int datalen, - char **outdata, int *outdatalen) -{ - MD5_CTX c; - unsigned char *md; - - cls_log("md5 method"); - cls_log("indata=%.*s data_len=%d", datalen, indata, datalen); - - md = (unsigned char *)cls_alloc(MD5_DIGEST_LENGTH); - if (!md) - return -ENOMEM; - - MD5_Init(&c); - MD5_Update(&c, indata, (unsigned long)datalen); - MD5_Final(md,&c); - - *outdata = (char *)md; - *outdatalen = MD5_DIGEST_LENGTH; - - return 0; -} - -int sha1_method(cls_method_context_t ctx, char *indata, int datalen, - char **outdata, int *outdatalen) -{ - SHA_CTX c; - unsigned char *md; - - cls_log("sha1 method"); - cls_log("indata=%.*s data_len=%d", datalen, indata, datalen); - - md = (unsigned char *)cls_alloc(SHA_DIGEST_LENGTH); - if (!md) - return -ENOMEM; - - SHA1_Init(&c); - SHA1_Update(&c, indata, (unsigned long)datalen); - SHA1_Final(md,&c); - - *outdata = (char *)md; - *outdatalen = SHA_DIGEST_LENGTH; - - return 0; -} - -CLS_INIT(crypto) -{ - cls_log("Loaded crypto class!"); - - cls_handle_t h_class; - cls_method_handle_t h_md5; - cls_method_handle_t h_sha1; - - cls_register("crypto", &h_class); - cls_register_method(h_class, "md5", CLS_METHOD_RD, md5_method, &h_md5); - cls_register_method(h_class, "sha1", CLS_METHOD_RD, sha1_method, &h_sha1); - - return; -} - diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt index ee8ff3f24bc..c4eb9218c07 100644 --- a/src/tools/CMakeLists.txt +++ b/src/tools/CMakeLists.txt @@ -37,10 +37,6 @@ add_executable(ceph_scratchtoolpp scratchtoolpp.cc) target_link_libraries(ceph_scratchtoolpp librados global) install(TARGETS ceph_scratchtoolpp DESTINATION bin) -add_executable(ceph_radosacl radosacl.cc) -target_link_libraries(ceph_radosacl librados global) -install(TARGETS ceph_radosacl DESTINATION bin) - install(PROGRAMS ceph-monstore-update-crush.sh DESTINATION ${CMAKE_INSTALL_LIBDIR}/ceph) diff --git a/src/tools/radosacl.cc b/src/tools/radosacl.cc deleted file mode 100644 index e6eb5805b53..00000000000 --- a/src/tools/radosacl.cc +++ /dev/null @@ -1,192 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:nil -*- -// vim: ts=8 sw=2 sts=2 expandtab - -/* - * Ceph - scalable distributed file system - * - * Copyright (C) 2004-2006 Sage Weil - * - * 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 -#include - -#include // for std::cerr - -#include "include/encoding.h" -#include "include/int_types.h" // for __u32 -#include "include/types.h" -#include "include/rados/librados.hpp" - -using namespace std; -using namespace librados; - -void buf_to_hex(const unsigned char *buf, int len, char *str) -{ - str[0] = '\0'; - for (int i = 0; i < len; i++) { - sprintf(&str[i*2], "%02x", (int)buf[i]); - } -} - - -#define ID_SIZE 8 - -#define ACL_RD 0x1 -#define ACL_WR 0x2 - -struct ACLID { - char id[ID_SIZE + 1]; - - void encode(bufferlist& bl) const { - bl.append((const char *)id, ID_SIZE); - } - void decode(bufferlist::const_iterator& iter) { - iter.copy(ID_SIZE, (char *)id); - } -}; -WRITE_CLASS_ENCODER(ACLID) - -typedef __u32 ACLFlags; - - -inline bool operator<(const ACLID& l, const ACLID& r) -{ - return (memcmp(&l, &r, ID_SIZE) < 0); -} - -struct ACLPair { - ACLID id; - ACLFlags flags; -}; - -class ObjectACLs { - map acls_map; - -public: - - void encode(bufferlist& bl) const { - using ceph::encode; - encode(acls_map, bl); - } - void decode(bufferlist::const_iterator& bl) { - using ceph::decode; - decode(acls_map, bl); - } - - int read_acl(ACLID& id, ACLFlags *flags); - void set_acl(ACLID& id, ACLFlags flags); -}; -WRITE_CLASS_ENCODER(ObjectACLs) - -int ObjectACLs::read_acl(ACLID& id, ACLFlags *flags) -{ - if (!flags) - return -EINVAL; - - map::iterator iter = acls_map.find(id); - - if (iter == acls_map.end()) - return -ENOENT; - - *flags = iter->second; - - return 0; -} - -void ObjectACLs::set_acl(ACLID& id, ACLFlags flags) -{ - acls_map[id] = flags; -} - - - -class ACLEntity -{ - string name; - map groups; -}; - -typedef map tACLIDEntityMap; - -static map users; -static map groups; - -void get_user(ACLID& aclid, ACLEntity *entity) -{ - //users.find(aclid); -} - - - - - -int main(int argc, const char **argv) -{ - Rados rados; - if (rados.init(NULL) < 0) { - cerr << "couldn't initialize rados!" << std::endl; - exit(1); - } - if (rados.conf_read_file(NULL)) { - cerr << "couldn't read Ceph configuration file!" << std::endl; - exit(1); - } - if (rados.connect() < 0) { - cerr << "couldn't connect to cluster!" << std::endl; - exit(1); - } - - time_t tm; - bufferlist bl, bl2; - char buf[128]; - - time(&tm); - snprintf(buf, 128, "%s", ctime(&tm)); - bl.append(buf, strlen(buf)); - - const char *oid = "bar"; - - IoCtx io_ctx; - int r = rados.ioctx_create("data", io_ctx); - cout << "open io_ctx result = " << r << " pool = " << io_ctx.get_pool_name() << std::endl; - - ACLID id; - - snprintf(id.id, sizeof(id.id), "%.8x", 0x1234); - cout << "id=" << id.id << std::endl; - - r = io_ctx.exec(oid, "acl", "get", bl, bl2); - cout << "exec(acl get) returned " << r - << " len=" << bl2.length() << std::endl; - ObjectACLs oa; - if (r >= 0) { - auto iter = bl2.cbegin(); - oa.decode(iter); - } - - oa.set_acl(id, ACL_RD); - bl.clear(); - oa.encode(bl); - r = io_ctx.exec(oid, "acl", "set", bl, bl2); - cout << "exec(acl set) returned " << r - << " len=" << bl2.length() << std::endl; - - const unsigned char *md5 = (const unsigned char *)bl2.c_str(); - char md5_str[bl2.length()*2 + 1]; - buf_to_hex(md5, bl2.length(), md5_str); - cout << "md5 result=" << md5_str << std::endl; - - int size = io_ctx.read(oid, bl2, 128, 0); - cout << "read result=" << bl2.c_str() << std::endl; - cout << "size=" << size << std::endl; - - return 0; -} - diff --git a/src/tools/scratchtoolpp.cc b/src/tools/scratchtoolpp.cc index 076667f18ea..1c84632cd63 100644 --- a/src/tools/scratchtoolpp.cc +++ b/src/tools/scratchtoolpp.cc @@ -170,12 +170,6 @@ int main(int argc, const char **argv) cout << "rados.trunc returned " << r << std::endl; r = io_ctx.read(oid, bl, bl.length(), 0); cout << "rados.read returned " << r << std::endl; - r = io_ctx.exec(oid, "crypto", "md5", bl, bl2); - cout << "exec returned " << r << " buf size=" << bl2.length() << std::endl; - const unsigned char *md5 = (const unsigned char *)bl2.c_str(); - char md5_str[bl2.length()*2 + 1]; - buf_to_hex(md5, bl2.length(), md5_str); - cout << "md5 result=" << md5_str << std::endl; // test assert_version r = io_ctx.read(oid, bl, 0, 1); @@ -193,21 +187,6 @@ int main(int argc, const char **argv) r = io_ctx.read(oid, bl, 0, 1); ceph_assert(r == -EOVERFLOW); - r = io_ctx.exec(oid, "crypto", "sha1", bl, bl2); - cout << "exec returned " << r << std::endl; - const unsigned char *sha1 = (const unsigned char *)bl2.c_str(); - char sha1_str[bl2.length()*2 + 1]; - buf_to_hex(sha1, bl2.length(), sha1_str); - cout << "sha1 result=" << sha1_str << std::endl; - - r = io_ctx.exec(oid, "acl", "set", bl, bl2); - cout << "exec (set) returned " << r << std::endl; - r = io_ctx.exec(oid, "acl", "get", bl, bl2); - cout << "exec (get) returned " << r << std::endl; - if (bl2.length() > 0) { - cout << "attr=" << bl2.c_str() << std::endl; - } - int size = io_ctx.read(oid, bl2, 128, 0); if (size <= 0) { cout << "failed to read oid " << oid << "." << std::endl;