| 11047 | } cli_update_activation_t; |
| 11048 | |
| 11049 | static int cli_update_activate_binary(void *opaque) { |
| 11050 | cli_update_activation_t *activation = opaque; |
| 11051 | if (!activation || !activation->bin_dest || !activation->binary_transaction) { |
| 11052 | return CLI_TRUE; |
| 11053 | } |
| 11054 | char previous_managed_binary[CLI_BUF_1K] = {0}; |
| 11055 | bool previous_managed_binary_exact = cbm_detect_self_path( |
| 11056 | previous_managed_binary, sizeof(previous_managed_binary), activation->home); |
| 11057 | if (cli_activation_transaction_commit_validated(activation->binary_transaction, |
| 11058 | &activation->binary_validator, |
| 11059 | CLI_OCTAL_PERM) != CLI_OK) { |
| 11060 | cli_activation_transaction_abort_or_fail_stop(&activation->binary_transaction, |
| 11061 | "update_transaction_publish_recovery"); |
| 11062 | (void)fprintf(stderr, "error: cannot publish staged update to %s\n", activation->bin_dest); |
| 11063 | return CLI_TRUE; |
| 11064 | } |
| 11065 | /* Agent configs must never observe a replacement binary outside the same |
| 11066 | * exact-build activation window. Otherwise another CBM process can start |
| 11067 | * after the binary swap but before its MCP/hook entries are refreshed. */ |
| 11068 | printf("Refreshing agent configurations...\n"); |
| 11069 | if (cbm_install_agent_configs_with_previous( |
| 11070 | activation->home, activation->bin_dest, |
| 11071 | previous_managed_binary_exact ? previous_managed_binary : NULL, true, |
| 11072 | false) != CLI_OK) { |
| 11073 | cli_activation_transaction_finalize_committed_or_fail_stop( |
| 11074 | &activation->binary_transaction, "update_transaction_config_failure_finalize"); |
| 11075 | (void)fprintf(stderr, "error: one or more agent configurations failed; the " |
| 11076 | "published update was kept. Review the errors above and " |
| 11077 | "rerun update\n"); |
| 11078 | return CLI_ACTIVATION_PARTIAL; |
| 11079 | } |
| 11080 | if (activation->delete_indexes) { |
| 11081 | int expected = count_db_indexes(activation->home); |
| 11082 | int removed = cbm_remove_indexes(activation->home); |
| 11083 | printf("Removed %d index(es).\n\n", removed); |
| 11084 | if (removed != expected) { |
| 11085 | cli_activation_transaction_finalize_committed_or_fail_stop( |
| 11086 | &activation->binary_transaction, "update_transaction_index_failure_finalize"); |
| 11087 | (void)fprintf(stderr, "error: only %d of %d indexes could be removed\n", removed, |
| 11088 | expected); |
| 11089 | return CLI_ACTIVATION_PARTIAL; |
| 11090 | } |
| 11091 | } |
| 11092 | cli_activation_transaction_finalize_committed_or_fail_stop(&activation->binary_transaction, |
| 11093 | "update_transaction_finalize"); |
| 11094 | return CLI_OK; |
| 11095 | } |
| 11096 | |
| 11097 | static int extract_and_install_binary(extract_install_args_t args) { |
| 11098 | const char *tmp_archive = args.tmp_archive; |
nothing calls this directly
no test coverage detected