diff options
| author | Joseph Hunkeler <jhunkeler@users.noreply.github.com> | 2026-05-12 13:34:13 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-12 13:34:13 -0400 |
| commit | d8ee8c27444a56bb98dd8bd67a019a1e9efbcc10 (patch) | |
| tree | 6ae1275a5f8e5794b917aac95c6cb1ab3f4cb6c5 /src/cli/stasis | |
| parent | 4649a889a916aa377ebd3ca8f3daa9ac703baa34 (diff) | |
| parent | 1d91efc28e30c8501428fec8ff6cd7b13dcdfb95 (diff) | |
| download | stasis-d8ee8c27444a56bb98dd8bd67a019a1e9efbcc10.tar.gz | |
Bughunt 0x1002
Diffstat (limited to 'src/cli/stasis')
| -rw-r--r-- | src/cli/stasis/args.c | 2 | ||||
| -rw-r--r-- | src/cli/stasis/stasis_main.c | 35 | ||||
| -rw-r--r-- | src/cli/stasis/system_requirements.c | 91 |
3 files changed, 78 insertions, 50 deletions
diff --git a/src/cli/stasis/args.c b/src/cli/stasis/args.c index e1c49fe..eb096bc 100644 --- a/src/cli/stasis/args.c +++ b/src/cli/stasis/args.c @@ -59,7 +59,7 @@ static int get_option_max_width(struct option option[]) { int i = 0; int max = 0; const int indent = 4; - while (option[i].name != 0) { + while (option[i].name != NULL) { int len = (int) strlen(option[i].name); if (option[i].has_arg) { len += indent; diff --git a/src/cli/stasis/stasis_main.c b/src/cli/stasis/stasis_main.c index b902a8a..fb4ed80 100644 --- a/src/cli/stasis/stasis_main.c +++ b/src/cli/stasis/stasis_main.c @@ -522,41 +522,6 @@ static void transfer_artifacts(struct Delivery *ctx) { } } -static char *center_text(const char *s, const size_t maxwidth) { - if (maxwidth < 2) { - SYSERROR("maximum width must be greater than 0"); - return NULL; - } - - if (maxwidth % 2 != 0) { - SYSERROR("maximum width (%zu) must be even", maxwidth); - return NULL; - } - - const size_t s_len = strlen(s); - if (s_len + 1 > maxwidth) { - SYSERROR("length of input string (%zu) exceeds maximum width (%zu)", s_len, maxwidth); - return NULL; - } - - char *result = calloc(maxwidth + 1, sizeof(*result)); - if (!result) { - SYSERROR("unable to allocate bytes for centered text string"); - return NULL; - } - const size_t middle = (maxwidth / 2) - s_len / 2; - size_t i = 0; - for (; i < middle; i++) { - result[i] = ' '; - } - result[i++] = 'v'; - strncpy(&result[i], s, maxwidth - middle - 1); - result[maxwidth - 1] = '\0'; - - return result; -} - - int main(int argc, char *argv[]) { struct Delivery ctx; struct Process proc = { diff --git a/src/cli/stasis/system_requirements.c b/src/cli/stasis/system_requirements.c index 02889da..a48c113 100644 --- a/src/cli/stasis/system_requirements.c +++ b/src/cli/stasis/system_requirements.c @@ -3,20 +3,83 @@ void check_system_env_requirements() { msg(STASIS_MSG_L1, "Checking environment\n"); globals.envctl = envctl_init(); - envctl_register(&globals.envctl, STASIS_ENVCTL_PASSTHRU, NULL, "TMPDIR"); - envctl_register(&globals.envctl, STASIS_ENVCTL_PASSTHRU, NULL, "STASIS_ROOT"); - envctl_register(&globals.envctl, STASIS_ENVCTL_PASSTHRU, NULL, "STASIS_SYSCONFDIR"); - envctl_register(&globals.envctl, STASIS_ENVCTL_PASSTHRU, NULL, "STASIS_CPU_COUNT"); - envctl_register(&globals.envctl, STASIS_ENVCTL_REQUIRED | STASIS_ENVCTL_REDACT, callback_except_gh, "STASIS_GH_TOKEN"); - envctl_register(&globals.envctl, STASIS_ENVCTL_REQUIRED, callback_except_jf, "STASIS_JF_ARTIFACTORY_URL"); - envctl_register(&globals.envctl, STASIS_ENVCTL_REDACT, NULL, "STASIS_JF_ACCESS_TOKEN"); - envctl_register(&globals.envctl, STASIS_ENVCTL_PASSTHRU, NULL, "STASIS_JF_USER"); - envctl_register(&globals.envctl, STASIS_ENVCTL_REDACT, NULL, "STASIS_JF_PASSWORD"); - envctl_register(&globals.envctl, STASIS_ENVCTL_REDACT, NULL, "STASIS_JF_SSH_KEY_PATH"); - envctl_register(&globals.envctl, STASIS_ENVCTL_REDACT, NULL, "STASIS_JF_SSH_PASSPHRASE"); - envctl_register(&globals.envctl, STASIS_ENVCTL_REDACT, NULL, "STASIS_JF_CLIENT_CERT_CERT_PATH"); - envctl_register(&globals.envctl, STASIS_ENVCTL_REDACT, NULL, "STASIS_JF_CLIENT_CERT_KEY_PATH"); - envctl_register(&globals.envctl, STASIS_ENVCTL_REQUIRED, callback_except_jf, "STASIS_JF_REPO"); + if (!globals.envctl) { + SYSERROR("envctl_init failed"); + exit(1); + } + + int status = 0; + status = envctl_register(&globals.envctl, STASIS_ENVCTL_PASSTHRU, NULL, "TMPDIR"); + if (status) { + SYSERROR("envctl_register failed"); + exit(1); + } + status = envctl_register(&globals.envctl, STASIS_ENVCTL_PASSTHRU, NULL, "STASIS_ROOT"); + if (status) { + SYSERROR("envctl_register failed"); + exit(1); + } + status = envctl_register(&globals.envctl, STASIS_ENVCTL_PASSTHRU, NULL, "STASIS_SYSCONFDIR"); + if (status) { + SYSERROR("envctl_register failed"); + exit(1); + } + status = envctl_register(&globals.envctl, STASIS_ENVCTL_PASSTHRU, NULL, "STASIS_CPU_COUNT"); + if (status) { + SYSERROR("envctl_register failed"); + exit(1); + } + status = envctl_register(&globals.envctl, STASIS_ENVCTL_REQUIRED | STASIS_ENVCTL_REDACT, callback_except_gh, "STASIS_GH_TOKEN"); + if (status) { + SYSERROR("envctl_register failed"); + exit(1); + } + status = envctl_register(&globals.envctl, STASIS_ENVCTL_REQUIRED, callback_except_jf, "STASIS_JF_ARTIFACTORY_URL"); + if (status) { + SYSERROR("envctl_register failed"); + exit(1); + } + status = envctl_register(&globals.envctl, STASIS_ENVCTL_REDACT, NULL, "STASIS_JF_ACCESS_TOKEN"); + if (status) { + SYSERROR("envctl_register failed"); + exit(1); + } + status = envctl_register(&globals.envctl, STASIS_ENVCTL_PASSTHRU, NULL, "STASIS_JF_USER"); + if (status) { + SYSERROR("envctl_register failed"); + exit(1); + } + status = envctl_register(&globals.envctl, STASIS_ENVCTL_REDACT, NULL, "STASIS_JF_PASSWORD"); + if (status) { + SYSERROR("envctl_register failed"); + exit(1); + } + status = envctl_register(&globals.envctl, STASIS_ENVCTL_REDACT, NULL, "STASIS_JF_SSH_KEY_PATH"); + if (status) { + SYSERROR("envctl_register failed"); + exit(1); + } + status = envctl_register(&globals.envctl, STASIS_ENVCTL_REDACT, NULL, "STASIS_JF_SSH_PASSPHRASE"); + if (status) { + SYSERROR("envctl_register failed"); + exit(1); + } + status = envctl_register(&globals.envctl, STASIS_ENVCTL_REDACT, NULL, "STASIS_JF_CLIENT_CERT_CERT_PATH"); + if (status) { + SYSERROR("envctl_register failed"); + exit(1); + } + status = envctl_register(&globals.envctl, STASIS_ENVCTL_REDACT, NULL, "STASIS_JF_CLIENT_CERT_KEY_PATH"); + if (status) { + SYSERROR("envctl_register failed"); + exit(1); + } + status = envctl_register(&globals.envctl, STASIS_ENVCTL_REQUIRED, callback_except_jf, "STASIS_JF_REPO"); + if (status) { + SYSERROR("envctl_register failed"); + exit(1); + } + envctl_do_required(globals.envctl, globals.verbose); } |
