| 35 | } |
| 36 | |
| 37 | Plugin::Remap |
| 38 | Plugin::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 | |
| 78 | void |
| 79 | Plugin::Remap::Cleanup() |
nothing calls this directly
no test coverage detected