diff options
author | Glenn Kasten | 2016-10-06 14:58:46 -0500 |
---|---|---|
committer | Glenn Kasten | 2016-10-07 15:56:37 -0500 |
commit | 2de796491aed1c5c40af94d9c9b08a385a309e1f (patch) | |
tree | 2a5dc2bc9d2c78a7104cfd27d98c763ffe1fae6a | |
parent | 62c9101646a10138ce66d2614dad451109ae7f48 (diff) | |
download | platform-system-core-2de796491aed1c5c40af94d9c9b08a385a309e1f.tar.gz platform-system-core-2de796491aed1c5c40af94d9c9b08a385a309e1f.tar.xz platform-system-core-2de796491aed1c5c40af94d9c9b08a385a309e1f.zip |
Traverse /etc/init in a well-defined order
Bug: 31996208
Test: will need a CTS, not yet done
Change-Id: I5ecc7f0519d42a83065b7b97a31cdb5b33549cda
-rw-r--r-- | init/init_parser.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/init/init_parser.cpp b/init/init_parser.cpp index 9ec26afb5..d017390ce 100644 --- a/init/init_parser.cpp +++ b/init/init_parser.cpp | |||
@@ -122,14 +122,20 @@ bool Parser::ParseConfigDir(const std::string& path) { | |||
122 | return false; | 122 | return false; |
123 | } | 123 | } |
124 | dirent* current_file; | 124 | dirent* current_file; |
125 | std::vector<std::string> files; | ||
125 | while ((current_file = readdir(config_dir.get()))) { | 126 | while ((current_file = readdir(config_dir.get()))) { |
126 | std::string current_path = | ||
127 | android::base::StringPrintf("%s/%s", path.c_str(), current_file->d_name); | ||
128 | // Ignore directories and only process regular files. | 127 | // Ignore directories and only process regular files. |
129 | if (current_file->d_type == DT_REG) { | 128 | if (current_file->d_type == DT_REG) { |
130 | if (!ParseConfigFile(current_path)) { | 129 | std::string current_path = |
131 | LOG(ERROR) << "could not import file '" << current_path << "'"; | 130 | android::base::StringPrintf("%s/%s", path.c_str(), current_file->d_name); |
132 | } | 131 | files.emplace_back(current_path); |
132 | } | ||
133 | } | ||
134 | // Sort first so we load files in a consistent order (bug 31996208) | ||
135 | std::sort(files.begin(), files.end()); | ||
136 | for (const auto& file : files) { | ||
137 | if (!ParseConfigFile(file)) { | ||
138 | LOG(ERROR) << "could not import file '" << file << "'"; | ||
133 | } | 139 | } |
134 | } | 140 | } |
135 | return true; | 141 | return true; |