]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_lua.h
8241622b246cab8ab4f0a4e7dafc5650797f2387
[ceph.git] / ceph / src / rgw / rgw_lua.h
1 #pragma once
2
3 #include <string>
4 #include "common/async/yield_context.h"
5
6 class lua_State;
7 class rgw_user;
8 namespace rgw::sal {
9 class RGWRadosStore;
10 }
11
12 namespace rgw::lua {
13
14 enum class context {
15 preRequest,
16 postRequest,
17 none
18 };
19
20 // get context enum from string
21 // the expected string the same as the enum (case insensitive)
22 // return "none" if not matched
23 context to_context(const std::string& s);
24
25 // verify a lua script
26 bool verify(const std::string& script, std::string& err_msg);
27
28 // store a lua script in a context
29 int write_script(rgw::sal::RGWRadosStore* store, const std::string& tenant, optional_yield y, context ctx, const std::string& script);
30
31 // read the stored lua script from a context
32 int read_script(rgw::sal::RGWRadosStore* store, const std::string& tenant, optional_yield y, context ctx, std::string& script);
33
34 // delete the stored lua script from a context
35 int delete_script(rgw::sal::RGWRadosStore* store, const std::string& tenant, optional_yield y, context ctx);
36
37 #ifdef WITH_RADOSGW_LUA_PACKAGES
38 #include <set>
39
40 using packages_t = std::set<std::string>;
41
42 // add a lua package to the allowlist
43 int add_package(rgw::sal::RGWRadosStore* store, optional_yield y, const std::string& package_name, bool allow_compilation);
44
45 // remove a lua package from the allowlist
46 int remove_package(rgw::sal::RGWRadosStore* store, optional_yield y, const std::string& package_name);
47
48 // list lua packages in the allowlist
49 int list_packages(rgw::sal::RGWRadosStore* store, optional_yield y, packages_t& packages);
50
51 // install all packages from the allowlist
52 // return the list of packages that failed to install and the output of the install command
53 int install_packages(rgw::sal::RGWRadosStore* store, optional_yield y, packages_t& failed_packages, std::string& output);
54 #endif
55 }
56