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

Function single_plugin_init

src/proxy/Plugin.cc:136–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134}
135
136static bool
137single_plugin_init(int argc, char *argv[], bool validateOnly)
138{
139 char path[PATH_NAME_MAX];
140 init_func_t init;
141
142 if (argc < 1) {
143 return true;
144 }
145 ink_filepath_make(path, sizeof(path), plugin_dir, argv[0]);
146
147 Note("loading plugin '%s'", path);
148
149 for (PluginRegInfo *plugin_reg_temp = plugin_reg_list.head; plugin_reg_temp != nullptr;
150 plugin_reg_temp = (plugin_reg_temp->link).next) {
151 if (strcmp(plugin_reg_temp->plugin_path, path) == 0) {
152 Warning("multiple loading of plugin %s", path);
153 break;
154 }
155 }
156
157 // elevate the access to read files as root if compiled with capabilities, if not
158 // change the effective user to root
159 {
160 uint32_t elevate_access = 0;
161 REC_ReadConfigInteger(elevate_access, "proxy.config.plugin.load_elevated");
162 ElevateAccess access(elevate_access ? ElevateAccess::FILE_PRIVILEGE : 0);
163
164 void *handle, *initptr = nullptr;
165 std::string error;
166 bool loaded = plugin_dso_load(path, handle, initptr, error);
167 init = reinterpret_cast<init_func_t>(initptr);
168
169 if (!loaded) {
170 if (validateOnly) {
171 return false;
172 }
173 Fatal("%s", error.c_str());
174 return false; // this line won't get called since Fatal brings down ATS
175 }
176
177 // Allocate a new registration structure for the
178 // plugin we're starting up
179 ink_assert(plugin_reg_current == nullptr);
180 plugin_reg_current = new PluginRegInfo;
181 plugin_reg_current->plugin_path = ats_strdup(path);
182 plugin_reg_current->dlh = handle;
183
184#if (!defined(kfreebsd) && defined(freebsd)) || defined(darwin)
185 optreset = 1;
186#endif
187#if defined(__GLIBC__)
188 optind = 0;
189#else
190 optind = 1;
191#endif
192 opterr = 0;
193 optarg = nullptr;

Callers 1

plugin_initFunction · 0.85

Calls 6

ink_filepath_makeFunction · 0.85
strcmpFunction · 0.85
plugin_dso_loadFunction · 0.85
initFunction · 0.50
c_strMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected