| 11506 | } cli_update_activation_t; |
| 11507 | |
| 11508 | static int cli_update_activate_binary(void *opaque) { |
| 11509 | cli_update_activation_t *activation = opaque; |
| 11510 | if (!activation || !activation->bin_dest || !activation->binary_transaction) { |
| 11511 | return CLI_TRUE; |
| 11512 | } |
| 11513 | char previous_managed_binary[CLI_BUF_1K] = {0}; |
| 11514 | bool previous_managed_binary_exact = cbm_detect_self_path( |
| 11515 | previous_managed_binary, sizeof(previous_managed_binary), activation->home); |
| 11516 | if (cli_activation_transaction_commit_validated(activation->binary_transaction, |
| 11517 | &activation->binary_validator, |
| 11518 | CLI_OCTAL_PERM) != CLI_OK) { |
| 11519 | cli_activation_transaction_abort_or_fail_stop(&activation->binary_transaction, |
| 11520 | "update_transaction_publish_recovery"); |
| 11521 | (void)fprintf(stderr, "error: cannot publish staged update to %s\n", activation->bin_dest); |
| 11522 | return CLI_TRUE; |
| 11523 | } |
| 11524 | /* Agent configs must never observe a replacement binary outside the same |
| 11525 | * exact-build activation window. Otherwise another CBM process can start |
| 11526 | * after the binary swap but before its MCP/hook entries are refreshed. */ |
| 11527 | printf("Refreshing agent configurations...\n"); |
| 11528 | if (cbm_install_agent_configs_with_previous( |
| 11529 | activation->home, activation->bin_dest, |
| 11530 | previous_managed_binary_exact ? previous_managed_binary : NULL, true, |
| 11531 | false) != CLI_OK) { |
| 11532 | cli_activation_transaction_finalize_committed_or_fail_stop( |
| 11533 | &activation->binary_transaction, "update_transaction_config_failure_finalize"); |
| 11534 | (void)fprintf(stderr, "error: one or more agent configurations failed; the " |
| 11535 | "published update was kept. Review the errors above and " |
| 11536 | "rerun update\n"); |
| 11537 | return CLI_ACTIVATION_PARTIAL; |
| 11538 | } |
| 11539 | if (activation->delete_indexes) { |
| 11540 | int expected = count_db_indexes(activation->home); |
| 11541 | int removed = cbm_remove_indexes(activation->home); |
| 11542 | printf("Removed %d index(es).\n\n", removed); |
| 11543 | if (removed != expected) { |
| 11544 | cli_activation_transaction_finalize_committed_or_fail_stop( |
| 11545 | &activation->binary_transaction, "update_transaction_index_failure_finalize"); |
| 11546 | (void)fprintf(stderr, "error: only %d of %d indexes could be removed\n", removed, |
| 11547 | expected); |
| 11548 | return CLI_ACTIVATION_PARTIAL; |
| 11549 | } |
| 11550 | } |
| 11551 | cli_activation_transaction_finalize_committed_or_fail_stop(&activation->binary_transaction, |
| 11552 | "update_transaction_finalize"); |
| 11553 | return CLI_OK; |
| 11554 | } |
| 11555 | |
| 11556 | static int extract_and_install_binary(extract_install_args_t args) { |
| 11557 | const char *tmp_archive = args.tmp_archive; |
nothing calls this directly
no test coverage detected