Skip to content

Commit acabd6f

Browse files
committed
cvd: Handle broken symlinks in default custom action config
When launching older Android trees, the host tools might contain a broken symlink for cuttlefish_example_action_config.json (pointing to a non-existent /usr/lib/cuttlefish-common/... path on the host). Previously, DefaultCustomActionConfig() only checked if the parent directory existed and returned the first .json file found, without verifying if the file itself was accessible. This caused assemble_cvd to abort when trying to read the broken symlink. This change adds a FileExists() check before returning the detected config path. If the file is not accessible (e.g., a broken symlink), it logs a warning and safely ignores it, falling back to an empty custom action configuration and allowing the launch to proceed. Test: Local launch of older tree (simulated with broken symlink) TAG=agy CONV=9c0d5aa1-08b9-492f-a8dd-54472559c2d3
1 parent 22ba0c8 commit acabd6f

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

base/cvd/cuttlefish/host/libs/config/custom_actions.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,13 @@ std::string DefaultCustomActionConfig() {
192192
} else if (custom_action_configs.size() == 1) {
193193
for (const auto& config : custom_action_configs) {
194194
if (absl::EndsWithIgnoreCase(config, ".json")) {
195-
return custom_action_config_dir + "/" + config;
195+
auto full_path = custom_action_config_dir + "/" + config;
196+
if (FileExists(full_path)) {
197+
return full_path;
198+
}
199+
LOG(WARNING)
200+
<< "Default custom action config " << full_path
201+
<< " exists in directory but is not accessible (broken symlink?)";
196202
}
197203
}
198204
}

0 commit comments

Comments
 (0)