| 11592 | } cli_update_activation_t; |
| 11593 | |
| 11594 | static int cli_update_activate_binary(void *opaque) { |
| 11595 | cli_update_activation_t *activation = opaque; |
| 11596 | if (!activation || !activation->bin_dest || !activation->binary_transaction) { |
| 11597 | return CLI_TRUE; |
| 11598 | } |
| 11599 | char previous_managed_binary[CLI_BUF_1K] = {0}; |
| 11600 | bool previous_managed_binary_exact = cbm_detect_self_path( |
| 11601 | previous_managed_binary, sizeof(previous_managed_binary), activation->home); |
| 11602 | if (cli_activation_transaction_commit_validated(activation->binary_transaction, |
| 11603 | &activation->binary_validator, |
| 11604 | CLI_OCTAL_PERM) != CLI_OK) { |
| 11605 | cli_activation_transaction_abort_or_fail_stop(&activation->binary_transaction, |
| 11606 | "update_transaction_publish_recovery"); |
| 11607 | (void)fprintf(stderr, "error: cannot publish staged update to %s\n", activation->bin_dest); |
| 11608 | return CLI_TRUE; |
| 11609 | } |
| 11610 | /* Agent configs must never observe a replacement binary outside the same |
| 11611 | * exact-build activation window. Otherwise another CBM process can start |
| 11612 | * after the binary swap but before its MCP/hook entries are refreshed. */ |
| 11613 | printf("Refreshing agent configurations...\n"); |
| 11614 | if (cbm_install_agent_configs_with_previous( |
| 11615 | activation->home, activation->bin_dest, |
| 11616 | previous_managed_binary_exact ? previous_managed_binary : NULL, true, |
| 11617 | false) != CLI_OK) { |
| 11618 | cli_activation_transaction_finalize_committed_or_fail_stop( |
| 11619 | &activation->binary_transaction, "update_transaction_config_failure_finalize"); |
| 11620 | (void)fprintf(stderr, "error: one or more agent configurations failed; the " |
| 11621 | "published update was kept. Review the errors above and " |
| 11622 | "rerun update\n"); |
| 11623 | return CLI_ACTIVATION_PARTIAL; |
| 11624 | } |
| 11625 | if (activation->delete_indexes) { |
| 11626 | int expected = count_db_indexes(activation->home); |
| 11627 | int removed = cbm_remove_indexes(activation->home); |
| 11628 | printf("Removed %d index(es).\n\n", removed); |
| 11629 | if (removed != expected) { |
| 11630 | cli_activation_transaction_finalize_committed_or_fail_stop( |
| 11631 | &activation->binary_transaction, "update_transaction_index_failure_finalize"); |
| 11632 | (void)fprintf(stderr, "error: only %d of %d indexes could be removed\n", removed, |
| 11633 | expected); |
| 11634 | return CLI_ACTIVATION_PARTIAL; |
| 11635 | } |
| 11636 | } |
| 11637 | cli_activation_transaction_finalize_committed_or_fail_stop(&activation->binary_transaction, |
| 11638 | "update_transaction_finalize"); |
| 11639 | return CLI_OK; |
| 11640 | } |
| 11641 | |
| 11642 | static int extract_and_install_binary(extract_install_args_t args) { |
| 11643 | const char *tmp_archive = args.tmp_archive; |
nothing calls this directly
no test coverage detected