diff options
| author | Joseph Hunkeler <jhunkeler@gmail.com> | 2025-06-10 12:48:50 -0400 | 
|---|---|---|
| committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2025-06-10 12:49:05 -0400 | 
| commit | 8fe9306c1655baa6f6b57edd56c9504132cb8232 (patch) | |
| tree | c6cf3bc0f033d12ae1549601cb3fc4852895868e /src/lib | |
| parent | b99daf7d16227f9dc9197699d7b24d2373fa5219 (diff) | |
| download | stasis-8fe9306c1655baa6f6b57edd56c9504132cb8232.tar.gz | |
Dynamic python_exec()
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/core/conda.c | 17 | 
1 files changed, 14 insertions, 3 deletions
diff --git a/src/lib/core/conda.c b/src/lib/core/conda.c index c81e6cc..62a81ef 100644 --- a/src/lib/core/conda.c +++ b/src/lib/core/conda.c @@ -62,10 +62,21 @@ int micromamba(struct MicromambaInfo *info, char *command, ...) {  }  int python_exec(const char *args) { -    char command[PATH_MAX] = {0}; -    snprintf(command, sizeof(command) - 1, "python %s", args); +    int result = -1; +    const char *command_base = "python "; +    const size_t required_len = strlen(command_base) + strlen(args) + 1; + +    char *command = calloc(required_len, sizeof(*command)); +    if (!command) { +        SYSERROR("Unable to allocate %zu bytes for command string", required_len); +        return result; +    } +    snprintf(command, required_len, "%s%s", command_base, args);      msg(STASIS_MSG_L3, "Executing: %s\n", command); -    return system(command); + +    result = system(command); +    guard_free(command); +    return result;  }  int pip_exec(const char *args) {  | 
