MCPcopy Create free account
hub / github.com/apache/trafficserver / Create

Method Create

src/cripts/Plugins.cc:37–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35}
36
37Plugin::Remap
38Plugin::Remap::Create(const std::string &tag, const std::string &plugin, const cripts::string &from_url,
39 const cripts::string &to_url, const Plugin::Options &options)
40{
41 Plugin::Remap inst;
42 int argc = options.size() + 1;
43 const char **argv = new const char *[argc];
44 const swoc::file::path path(plugin);
45
46 // Remap plugins expect the first two arguments to be the from and to URLs.
47 argv[0] = from_url.c_str();
48 argv[1] = to_url.c_str();
49
50 for (unsigned i = 0; i < options.size(); ++i) {
51 argv[i + 2] = options[i].c_str();
52 }
53
54 std::string error;
55
56 // We have to escalate access while loading these plugins, just as done when loading remap.config
57 {
58 uint32_t elevate_access = 0;
59
60 REC_ReadConfigInteger(elevate_access, "proxy.config.plugin.load_elevated");
61 ElevateAccess access(elevate_access ? ElevateAccess::FILE_PRIVILEGE : 0);
62
63 inst._plugin = gPluginFactory.getRemapPlugin(path, argc, const_cast<char **>(argv), error, isPluginDynamicReloadEnabled());
64 } // done elevating access
65
66 delete[] argv;
67
68 if (!inst._plugin) {
69 TSError("[%s] Unable to load plugin '%s': %s", tag.c_str(), plugin.c_str(), error.c_str());
70 inst._valid = false;
71 } else {
72 inst._valid = true;
73 }
74
75 return inst; // RVO
76}
77
78void
79Plugin::Remap::Cleanup()

Callers

nothing calls this directly

Calls 5

getRemapPluginMethod · 0.80
TSErrorFunction · 0.50
sizeMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected