diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2023-11-20 17:07:11 -0500 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2023-11-20 17:07:11 -0500 |
commit | 43bcd36bb31c1ab117b54f21746b119db2448449 (patch) | |
tree | 12e69ecb6c84a8b99ae8df3bbf65642152d21bcc /src/conda.c | |
parent | 8b3f862c59f7866f67f1da349efd5e3d931e1eae (diff) | |
download | stasis-43bcd36bb31c1ab117b54f21746b119db2448449.tar.gz |
Use TMPDIR, and fail when script cannot be executed within that filesystem
Diffstat (limited to 'src/conda.c')
-rw-r--r-- | src/conda.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/conda.c b/src/conda.c index a361267..9575c25 100644 --- a/src/conda.c +++ b/src/conda.c @@ -73,7 +73,7 @@ int conda_activate(const char *root, const char *env_name) { // Set the path to our stdout log // Emulate mktemp()'s behavior. Give us a unique file name, but don't use // the file handle at all. We'll open it as a FILE stream soon enough. - strcpy(logfile, "/tmp/shell_XXXXXX"); + sprintf(logfile, "%s/%s", globals.tmpdir, "shell_XXXXXX"); fd = mkstemp(logfile); if (fd < 0) { perror(logfile); @@ -87,11 +87,13 @@ int conda_activate(const char *root, const char *env_name) { // Verify conda's init scripts are available if (access(path_conda, F_OK) < 0) { perror(path_conda); + remove(logfile); return -1; } if (access(path_mamba, F_OK) < 0) { perror(path_mamba); + remove(logfile); return -1; } @@ -101,6 +103,7 @@ int conda_activate(const char *root, const char *env_name) { int retval = shell2(&proc, command); if (retval) { // it didn't work; drop out for cleanup + remove(logfile); return retval; } |