blob: f23ae83783044a761ae8abaaa2df816dea945152 [file] [log] [blame]
Dimitry Ivanov4cabfaa2017-03-07 11:19:05 -08001/*
2 * Copyright (C) 2017 The Android Open Source Project
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
13 * distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#include "linker_config.h"
30
31#include "linker_globals.h"
32#include "linker_debug.h"
33#include "linker_utils.h"
34
35#include <android-base/file.h>
Justin Yun53ce7422017-11-27 16:28:07 +090036#include <android-base/properties.h>
Tom Cherryb8ab6182017-04-05 16:20:29 -070037#include <android-base/scopeguard.h>
Dimitry Ivanov4cabfaa2017-03-07 11:19:05 -080038#include <android-base/strings.h>
39
Christopher Ferris7a3681e2017-04-24 17:48:32 -070040#include <async_safe/log.h>
41
Inseob Kim216323b2018-06-18 15:30:18 +090042#include <limits.h>
Dimitry Ivanov4cabfaa2017-03-07 11:19:05 -080043#include <stdlib.h>
44
45#include <string>
46#include <unordered_map>
47
Sundong Ahn8fc50322017-10-10 14:12:40 +090048#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
49#include <sys/_system_properties.h>
50
Dimitry Ivanov4cabfaa2017-03-07 11:19:05 -080051class ConfigParser {
52 public:
53 enum {
Jiyong Park8b029512017-11-29 18:30:53 +090054 kPropertyAssign,
55 kPropertyAppend,
Dimitry Ivanov4cabfaa2017-03-07 11:19:05 -080056 kSection,
57 kEndOfFile,
58 kError,
59 };
60
61 explicit ConfigParser(std::string&& content)
62 : content_(content), p_(0), lineno_(0), was_end_of_file_(false) {}
63
64 /*
65 * Possible return values
Jiyong Park8b029512017-11-29 18:30:53 +090066 * kPropertyAssign: name is set to property name and value is set to property value
67 * kPropertyAppend: same as kPropertyAssign, but the value should be appended
Dimitry Ivanov4cabfaa2017-03-07 11:19:05 -080068 * kSection: name is set to section name.
69 * kEndOfFile: reached end of file.
70 * kError: error_msg is set.
71 */
72 int next_token(std::string* name, std::string* value, std::string* error_msg) {
73 std::string line;
74 while(NextLine(&line)) {
75 size_t found = line.find('#');
76 line = android::base::Trim(line.substr(0, found));
77
78 if (line.empty()) {
79 continue;
80 }
81
82 if (line[0] == '[' && line[line.size() - 1] == ']') {
83 *name = line.substr(1, line.size() - 2);
84 return kSection;
85 }
86
Jiyong Park8b029512017-11-29 18:30:53 +090087 size_t found_assign = line.find('=');
88 size_t found_append = line.find("+=");
89 if (found_assign != std::string::npos && found_append == std::string::npos) {
90 *name = android::base::Trim(line.substr(0, found_assign));
91 *value = android::base::Trim(line.substr(found_assign + 1));
92 return kPropertyAssign;
Dimitry Ivanov4cabfaa2017-03-07 11:19:05 -080093 }
94
Jiyong Park8b029512017-11-29 18:30:53 +090095 if (found_append != std::string::npos) {
96 *name = android::base::Trim(line.substr(0, found_append));
97 *value = android::base::Trim(line.substr(found_append + 2));
98 return kPropertyAppend;
99 }
100
101 *error_msg = std::string("invalid format: ") +
102 line +
103 ", expected \"name = property\", \"name += property\", or \"[section]\"";
104 return kError;
Dimitry Ivanov4cabfaa2017-03-07 11:19:05 -0800105 }
106
107 // to avoid infinite cycles when programmer makes a mistake
108 CHECK(!was_end_of_file_);
109 was_end_of_file_ = true;
110 return kEndOfFile;
111 }
112
113 size_t lineno() const {
114 return lineno_;
115 }
116
117 private:
118 bool NextLine(std::string* line) {
119 if (p_ == std::string::npos) {
120 return false;
121 }
122
123 size_t found = content_.find('\n', p_);
124 if (found != std::string::npos) {
125 *line = content_.substr(p_, found - p_);
126 p_ = found + 1;
127 } else {
128 *line = content_.substr(p_);
129 p_ = std::string::npos;
130 }
131
132 lineno_++;
133 return true;
134 }
135
136 std::string content_;
137 size_t p_;
138 size_t lineno_;
139 bool was_end_of_file_;
140
141 DISALLOW_IMPLICIT_CONSTRUCTORS(ConfigParser);
142};
143
144class PropertyValue {
145 public:
146 PropertyValue() = default;
147
148 PropertyValue(std::string&& value, size_t lineno)
149 : value_(value), lineno_(lineno) {}
150
151 const std::string& value() const {
152 return value_;
153 }
154
Jiyong Park8b029512017-11-29 18:30:53 +0900155 void append_value(std::string&& value) {
156 value_ = value_ + value;
157 // lineno isn't updated as we might have cases like this:
158 // property.x = blah
159 // property.y = blah
160 // property.x += blah
161 }
162
Dimitry Ivanov4cabfaa2017-03-07 11:19:05 -0800163 size_t lineno() const {
164 return lineno_;
165 }
166
167 private:
168 std::string value_;
169 size_t lineno_;
170};
171
172static std::string create_error_msg(const char* file,
173 size_t lineno,
174 const std::string& msg) {
175 char buf[1024];
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700176 async_safe_format_buffer(buf, sizeof(buf), "%s:%zu: error: %s", file, lineno, msg.c_str());
Dimitry Ivanov4cabfaa2017-03-07 11:19:05 -0800177
178 return std::string(buf);
179}
180
181static bool parse_config_file(const char* ld_config_file_path,
182 const char* binary_realpath,
183 std::unordered_map<std::string, PropertyValue>* properties,
184 std::string* error_msg) {
185 std::string content;
186 if (!android::base::ReadFileToString(ld_config_file_path, &content)) {
187 if (errno != ENOENT) {
188 *error_msg = std::string("error reading file \"") +
189 ld_config_file_path + "\": " + strerror(errno);
190 }
191 return false;
192 }
193
194 ConfigParser cp(std::move(content));
195
196 std::string section_name;
197
Elliott Hughes9076b0c2018-02-28 11:29:45 -0800198 while (true) {
Dimitry Ivanov4cabfaa2017-03-07 11:19:05 -0800199 std::string name;
200 std::string value;
201 std::string error;
202
203 int result = cp.next_token(&name, &value, &error);
204 if (result == ConfigParser::kError) {
Elliott Hughes9076b0c2018-02-28 11:29:45 -0800205 DL_WARN("%s:%zd: warning: couldn't parse %s (ignoring this line)",
Dimitry Ivanov4cabfaa2017-03-07 11:19:05 -0800206 ld_config_file_path,
207 cp.lineno(),
208 error.c_str());
209 continue;
210 }
211
212 if (result == ConfigParser::kSection || result == ConfigParser::kEndOfFile) {
213 return false;
214 }
215
Jiyong Park8b029512017-11-29 18:30:53 +0900216 if (result == ConfigParser::kPropertyAssign) {
Dimitry Ivanov4cabfaa2017-03-07 11:19:05 -0800217 if (!android::base::StartsWith(name, "dir.")) {
Elliott Hughes9076b0c2018-02-28 11:29:45 -0800218 DL_WARN("%s:%zd: warning: unexpected property name \"%s\", "
Dimitry Ivanov4cabfaa2017-03-07 11:19:05 -0800219 "expected format dir.<section_name> (ignoring this line)",
220 ld_config_file_path,
221 cp.lineno(),
222 name.c_str());
223 continue;
224 }
225
226 // remove trailing '/'
Inseob Kim216323b2018-06-18 15:30:18 +0900227 while (!value.empty() && value.back() == '/') {
228 value.pop_back();
Dimitry Ivanov4cabfaa2017-03-07 11:19:05 -0800229 }
230
231 if (value.empty()) {
Elliott Hughes9076b0c2018-02-28 11:29:45 -0800232 DL_WARN("%s:%zd: warning: property value is empty (ignoring this line)",
Dimitry Ivanov4cabfaa2017-03-07 11:19:05 -0800233 ld_config_file_path,
234 cp.lineno());
235 continue;
236 }
237
Inseob Kim216323b2018-06-18 15:30:18 +0900238 // If the path can be resolved, resolve it
239 char buf[PATH_MAX];
240 std::string resolved_path;
241 if (realpath(value.c_str(), buf)) {
242 resolved_path = buf;
243 } else {
244 DL_WARN("%s:%zd: warning: path \"%s\" couldn't be resolved: %s",
245 ld_config_file_path,
246 cp.lineno(),
247 value.c_str(),
248 strerror(errno));
249 resolved_path = value;
250 }
251
252 if (file_is_under_dir(binary_realpath, resolved_path)) {
Dimitry Ivanov4cabfaa2017-03-07 11:19:05 -0800253 section_name = name.substr(4);
254 break;
255 }
256 }
257 }
258
259 // skip everything until we meet a correct section
260 while (true) {
261 std::string name;
262 std::string value;
263 std::string error;
264
265 int result = cp.next_token(&name, &value, &error);
266
267 if (result == ConfigParser::kSection && name == section_name) {
268 break;
269 }
270
271 if (result == ConfigParser::kEndOfFile) {
272 *error_msg = create_error_msg(ld_config_file_path,
273 cp.lineno(),
274 std::string("section \"") + section_name + "\" not found");
275 return false;
276 }
277 }
278
279 // found the section - parse it
280 while (true) {
281 std::string name;
282 std::string value;
283 std::string error;
284
285 int result = cp.next_token(&name, &value, &error);
286
287 if (result == ConfigParser::kEndOfFile || result == ConfigParser::kSection) {
288 break;
289 }
290
Jiyong Park8b029512017-11-29 18:30:53 +0900291 if (result == ConfigParser::kPropertyAssign) {
Dimitry Ivanov4cabfaa2017-03-07 11:19:05 -0800292 if (properties->find(name) != properties->end()) {
Elliott Hughes9076b0c2018-02-28 11:29:45 -0800293 DL_WARN("%s:%zd: warning: redefining property \"%s\" (overriding previous value)",
Dimitry Ivanov4cabfaa2017-03-07 11:19:05 -0800294 ld_config_file_path,
295 cp.lineno(),
296 name.c_str());
297 }
298
299 (*properties)[name] = PropertyValue(std::move(value), cp.lineno());
Jiyong Park8b029512017-11-29 18:30:53 +0900300 } else if (result == ConfigParser::kPropertyAppend) {
301 if (properties->find(name) == properties->end()) {
Elliott Hughes9076b0c2018-02-28 11:29:45 -0800302 DL_WARN("%s:%zd: warning: appending to undefined property \"%s\" (treating as assignment)",
Jiyong Park8b029512017-11-29 18:30:53 +0900303 ld_config_file_path,
304 cp.lineno(),
305 name.c_str());
306 (*properties)[name] = PropertyValue(std::move(value), cp.lineno());
307 } else {
308 if (android::base::EndsWith(name, ".links") ||
309 android::base::EndsWith(name, ".namespaces")) {
310 value = "," + value;
311 (*properties)[name].append_value(std::move(value));
312 } else if (android::base::EndsWith(name, ".paths") ||
313 android::base::EndsWith(name, ".shared_libs")) {
314 value = ":" + value;
315 (*properties)[name].append_value(std::move(value));
316 } else {
Elliott Hughes9076b0c2018-02-28 11:29:45 -0800317 DL_WARN("%s:%zd: warning: += isn't allowed for property \"%s\" (ignoring)",
Jiyong Park8b029512017-11-29 18:30:53 +0900318 ld_config_file_path,
319 cp.lineno(),
320 name.c_str());
321 }
322 }
Dimitry Ivanov4cabfaa2017-03-07 11:19:05 -0800323 }
324
325 if (result == ConfigParser::kError) {
Elliott Hughes9076b0c2018-02-28 11:29:45 -0800326 DL_WARN("%s:%zd: warning: couldn't parse %s (ignoring this line)",
Dimitry Ivanov4cabfaa2017-03-07 11:19:05 -0800327 ld_config_file_path,
328 cp.lineno(),
329 error.c_str());
330 continue;
331 }
332 }
333
334 return true;
335}
336
337static Config g_config;
338
339static constexpr const char* kDefaultConfigName = "default";
340static constexpr const char* kPropertyAdditionalNamespaces = "additional.namespaces";
341#if defined(__LP64__)
342static constexpr const char* kLibParamValue = "lib64";
343#else
344static constexpr const char* kLibParamValue = "lib";
345#endif
346
347class Properties {
348 public:
349 explicit Properties(std::unordered_map<std::string, PropertyValue>&& properties)
350 : properties_(properties), target_sdk_version_(__ANDROID_API__) {}
351
352 std::vector<std::string> get_strings(const std::string& name, size_t* lineno = nullptr) const {
353 auto it = find_property(name, lineno);
354 if (it == properties_.end()) {
355 // return empty vector
356 return std::vector<std::string>();
357 }
358
359 std::vector<std::string> strings = android::base::Split(it->second.value(), ",");
360
361 for (size_t i = 0; i < strings.size(); ++i) {
362 strings[i] = android::base::Trim(strings[i]);
363 }
364
365 return strings;
366 }
367
368 bool get_bool(const std::string& name, size_t* lineno = nullptr) const {
369 auto it = find_property(name, lineno);
370 if (it == properties_.end()) {
371 return false;
372 }
373
374 return it->second.value() == "true";
375 }
376
377 std::string get_string(const std::string& name, size_t* lineno = nullptr) const {
378 auto it = find_property(name, lineno);
379 return (it == properties_.end()) ? "" : it->second.value();
380 }
381
Jiyong Park0f33f232017-09-21 10:27:36 +0900382 std::vector<std::string> get_paths(const std::string& name, bool resolve, size_t* lineno = nullptr) {
Dimitry Ivanov4cabfaa2017-03-07 11:19:05 -0800383 std::string paths_str = get_string(name, lineno);
384
385 std::vector<std::string> paths;
386 split_path(paths_str.c_str(), ":", &paths);
387
388 std::vector<std::pair<std::string, std::string>> params;
389 params.push_back({ "LIB", kLibParamValue });
390 if (target_sdk_version_ != 0) {
391 char buf[16];
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700392 async_safe_format_buffer(buf, sizeof(buf), "%d", target_sdk_version_);
Dimitry Ivanov4cabfaa2017-03-07 11:19:05 -0800393 params.push_back({ "SDK_VER", buf });
394 }
395
Justin Yun53ce7422017-11-27 16:28:07 +0900396 static std::string vndk = Config::get_vndk_version_string('-');
Sundong Ahn8fc50322017-10-10 14:12:40 +0900397 params.push_back({ "VNDK_VER", vndk });
398
Dimitry Ivanov4cabfaa2017-03-07 11:19:05 -0800399 for (auto&& path : paths) {
400 format_string(&path, params);
401 }
402
Jiyong Park0f33f232017-09-21 10:27:36 +0900403 if (resolve) {
404 std::vector<std::string> resolved_paths;
Dimitry Ivanov4cabfaa2017-03-07 11:19:05 -0800405
Jiyong Park0f33f232017-09-21 10:27:36 +0900406 // do not remove paths that do not exist
407 resolve_paths(paths, &resolved_paths);
Dimitry Ivanov4cabfaa2017-03-07 11:19:05 -0800408
Jiyong Park0f33f232017-09-21 10:27:36 +0900409 return resolved_paths;
410 } else {
411 return paths;
412 }
Dimitry Ivanov4cabfaa2017-03-07 11:19:05 -0800413 }
414
415 void set_target_sdk_version(int target_sdk_version) {
416 target_sdk_version_ = target_sdk_version;
417 }
418
419 private:
420 std::unordered_map<std::string, PropertyValue>::const_iterator
421 find_property(const std::string& name, size_t* lineno) const {
422 auto it = properties_.find(name);
423 if (it != properties_.end() && lineno != nullptr) {
424 *lineno = it->second.lineno();
425 }
426
427 return it;
428 }
429 std::unordered_map<std::string, PropertyValue> properties_;
430 int target_sdk_version_;
431
432 DISALLOW_IMPLICIT_CONSTRUCTORS(Properties);
433};
434
435bool Config::read_binary_config(const char* ld_config_file_path,
436 const char* binary_realpath,
437 bool is_asan,
438 const Config** config,
439 std::string* error_msg) {
440 g_config.clear();
441
442 std::unordered_map<std::string, PropertyValue> property_map;
443 if (!parse_config_file(ld_config_file_path, binary_realpath, &property_map, error_msg)) {
444 return false;
445 }
446
447 Properties properties(std::move(property_map));
448
Tom Cherryb8ab6182017-04-05 16:20:29 -0700449 auto failure_guard = android::base::make_scope_guard([] { g_config.clear(); });
Dimitry Ivanov4cabfaa2017-03-07 11:19:05 -0800450
451 std::unordered_map<std::string, NamespaceConfig*> namespace_configs;
452
453 namespace_configs[kDefaultConfigName] = g_config.create_namespace_config(kDefaultConfigName);
454
455 std::vector<std::string> additional_namespaces = properties.get_strings(kPropertyAdditionalNamespaces);
456 for (const auto& name : additional_namespaces) {
457 namespace_configs[name] = g_config.create_namespace_config(name);
458 }
459
460 bool versioning_enabled = properties.get_bool("enable.target.sdk.version");
461 int target_sdk_version = __ANDROID_API__;
462 if (versioning_enabled) {
463 std::string version_file = dirname(binary_realpath) + "/.version";
464 std::string content;
465 if (!android::base::ReadFileToString(version_file, &content)) {
466 if (errno != ENOENT) {
467 *error_msg = std::string("error reading version file \"") +
468 version_file + "\": " + strerror(errno);
469 return false;
470 }
471 } else {
472 content = android::base::Trim(content);
473 errno = 0;
474 char* end = nullptr;
475 const char* content_str = content.c_str();
476 int result = strtol(content_str, &end, 10);
477 if (errno == 0 && *end == '\0' && result > 0) {
478 target_sdk_version = result;
479 properties.set_target_sdk_version(target_sdk_version);
480 } else {
481 *error_msg = std::string("invalid version \"") + version_file + "\": \"" + content +"\"";
482 return false;
483 }
484 }
485 }
486
487 g_config.set_target_sdk_version(target_sdk_version);
488
489 for (auto ns_config_it : namespace_configs) {
490 auto& name = ns_config_it.first;
491 NamespaceConfig* ns_config = ns_config_it.second;
492
493 std::string property_name_prefix = std::string("namespace.") + name;
494
495 size_t lineno = 0;
496 std::vector<std::string> linked_namespaces =
497 properties.get_strings(property_name_prefix + ".links", &lineno);
498
499 for (const auto& linked_ns_name : linked_namespaces) {
500 if (namespace_configs.find(linked_ns_name) == namespace_configs.end()) {
501 *error_msg = create_error_msg(ld_config_file_path,
502 lineno,
503 std::string("undefined namespace: ") + linked_ns_name);
504 return false;
505 }
506
Logan Chien9ee45912018-01-18 12:05:09 +0800507 bool allow_all_shared_libs = properties.get_bool(property_name_prefix + ".link." +
508 linked_ns_name + ".allow_all_shared_libs");
509
Dimitry Ivanov4cabfaa2017-03-07 11:19:05 -0800510 std::string shared_libs = properties.get_string(property_name_prefix +
511 ".link." +
512 linked_ns_name +
513 ".shared_libs", &lineno);
514
Logan Chien9ee45912018-01-18 12:05:09 +0800515 if (!allow_all_shared_libs && shared_libs.empty()) {
Dimitry Ivanov4cabfaa2017-03-07 11:19:05 -0800516 *error_msg = create_error_msg(ld_config_file_path,
517 lineno,
518 std::string("list of shared_libs for ") +
519 name +
520 "->" +
521 linked_ns_name +
522 " link is not specified or is empty.");
523 return false;
524 }
525
Logan Chien9ee45912018-01-18 12:05:09 +0800526 if (allow_all_shared_libs && !shared_libs.empty()) {
527 *error_msg = create_error_msg(ld_config_file_path, lineno,
528 std::string("both shared_libs and allow_all_shared_libs "
529 "are set for ") +
530 name + "->" + linked_ns_name + " link.");
531 return false;
532 }
533
534 ns_config->add_namespace_link(linked_ns_name, shared_libs, allow_all_shared_libs);
Dimitry Ivanov4cabfaa2017-03-07 11:19:05 -0800535 }
536
537 ns_config->set_isolated(properties.get_bool(property_name_prefix + ".isolated"));
Jiyong Park01de74e2017-04-03 23:10:37 +0900538 ns_config->set_visible(properties.get_bool(property_name_prefix + ".visible"));
Dimitry Ivanov4cabfaa2017-03-07 11:19:05 -0800539
540 // these are affected by is_asan flag
541 if (is_asan) {
542 property_name_prefix += ".asan";
543 }
544
Jiyong Park0f33f232017-09-21 10:27:36 +0900545 // search paths are resolved (canonicalized). This is required mainly for
546 // the case when /vendor is a symlink to /system/vendor, which is true for
547 // non Treble-ized legacy devices.
548 ns_config->set_search_paths(properties.get_paths(property_name_prefix + ".search.paths", true));
549
550 // However, for permitted paths, we are not required to resolve the paths
551 // since they are only set for isolated namespaces, which implies the device
552 // is Treble-ized (= /vendor is not a symlink to /system/vendor).
553 // In fact, the resolving is causing an unexpected side effect of selinux
554 // denials on some executables which are not allowed to access some of the
555 // permitted paths.
556 ns_config->set_permitted_paths(properties.get_paths(property_name_prefix + ".permitted.paths", false));
Dimitry Ivanov4cabfaa2017-03-07 11:19:05 -0800557 }
558
Tom Cherryb8ab6182017-04-05 16:20:29 -0700559 failure_guard.Disable();
Dimitry Ivanov4cabfaa2017-03-07 11:19:05 -0800560 *config = &g_config;
561 return true;
562}
563
Justin Yun53ce7422017-11-27 16:28:07 +0900564std::string Config::get_vndk_version_string(const char delimiter) {
565 std::string version = android::base::GetProperty("ro.vndk.version", "");
566 if (version != "" && version != "current") {
567 //add the delimiter char in front of the string and return it.
568 return version.insert(0, 1, delimiter);
569 }
570 return "";
571}
572
Dimitry Ivanov4cabfaa2017-03-07 11:19:05 -0800573NamespaceConfig* Config::create_namespace_config(const std::string& name) {
574 namespace_configs_.push_back(std::unique_ptr<NamespaceConfig>(new NamespaceConfig(name)));
575 NamespaceConfig* ns_config_ptr = namespace_configs_.back().get();
576 namespace_configs_map_[name] = ns_config_ptr;
577 return ns_config_ptr;
578}
579
580void Config::clear() {
581 namespace_configs_.clear();
582 namespace_configs_map_.clear();
583}