From 19fcec84d8d7d21e796c7624e521b60d28ee21ed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:45:59 +0200 Subject: Adding upstream version 16.2.11+ds. Signed-off-by: Daniel Baumann --- src/rgw/rgw_lua.h | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/rgw/rgw_lua.h (limited to 'src/rgw/rgw_lua.h') diff --git a/src/rgw/rgw_lua.h b/src/rgw/rgw_lua.h new file mode 100644 index 000000000..4e135a763 --- /dev/null +++ b/src/rgw/rgw_lua.h @@ -0,0 +1,56 @@ +#pragma once + +#include +#include "common/async/yield_context.h" + +class lua_State; +class rgw_user; +namespace rgw::sal { + class RGWRadosStore; +} + +namespace rgw::lua { + +enum class context { + preRequest, + postRequest, + none +}; + +// get context enum from string +// the expected string the same as the enum (case insensitive) +// return "none" if not matched +context to_context(const std::string& s); + +// verify a lua script +bool verify(const std::string& script, std::string& err_msg); + +// store a lua script in a context +int write_script(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore* store, const std::string& tenant, optional_yield y, context ctx, const std::string& script); + +// read the stored lua script from a context +int read_script(rgw::sal::RGWRadosStore* store, const std::string& tenant, optional_yield y, context ctx, std::string& script); + +// delete the stored lua script from a context +int delete_script(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore* store, const std::string& tenant, optional_yield y, context ctx); + +#ifdef WITH_RADOSGW_LUA_PACKAGES +#include + +using packages_t = std::set; + +// add a lua package to the allowlist +int add_package(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore* store, optional_yield y, const std::string& package_name, bool allow_compilation); + +// remove a lua package from the allowlist +int remove_package(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore* store, optional_yield y, const std::string& package_name); + +// list lua packages in the allowlist +int list_packages(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore* store, optional_yield y, packages_t& packages); + +// install all packages from the allowlist +// return the list of packages that failed to install and the output of the install command +int install_packages(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore* store, optional_yield y, packages_t& failed_packages, std::string& output); +#endif +} + -- cgit v1.2.3