aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2025-06-09 12:00:41 +0200
committerGitHub Enterprise <[email protected]>2025-06-09 12:00:41 +0200
commit6f87665745cd432f025215bb259a974dc434964e (patch)
tree6d2592c05d9f66283bf79e74550f3d14f66921d3
parentfix namespace picking up wrong argument (#425) (diff)
downloadzen-6f87665745cd432f025215bb259a974dc434964e.tar.xz
zen-6f87665745cd432f025215bb259a974dc434964e.zip
use unique tmp name for auth token file (#426)
* use Oid to generate unique name since std::tmpnam is not good practice
-rw-r--r--CHANGELOG.md1
-rw-r--r--src/zenhttp/httpclientauth.cpp6
2 files changed, 4 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b35eb650d..b9fb237fc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,7 @@
- Improvement: Optimized check for modified files when verifying state of scavenged paths
- Improvement: Process report now indicates if it is pausing or aborting
- Improvement: Don't report OOD or OOM errors to Sentry when running `zen builds` commands
+- Improvement: Use unique temporary file name when calling OidcToken executable to generate auth token
- Bugfix: Zen CLI now initializes Sentry after command line options parsing, so that the options can be propetly taken into account during init
- Bugfix: Revert: `zen builds upload` now use the system temp directory for temporary files leaving the source folder untouched
- Bugfix: Use selected subcommand when displaying help for failed command line options in zen builds
diff --git a/src/zenhttp/httpclientauth.cpp b/src/zenhttp/httpclientauth.cpp
index 916b25bff..39efe1d0c 100644
--- a/src/zenhttp/httpclientauth.cpp
+++ b/src/zenhttp/httpclientauth.cpp
@@ -7,6 +7,7 @@
#include <zencore/process.h>
#include <zencore/scopeguard.h>
#include <zencore/timer.h>
+#include <zencore/uid.h>
#include <zenhttp/auth/authmgr.h>
#include <ctime>
@@ -94,9 +95,8 @@ namespace zen { namespace httpclientauth {
CreateProcOptions ProcOptions;
- const std::string AuthTokenPath = ".zen-auth-oidctoken";
-
- auto _ = MakeGuard([AuthTokenPath]() { RemoveFile(AuthTokenPath); });
+ const std::filesystem::path AuthTokenPath(std::filesystem::temp_directory_path() / fmt::format(".zen-auth-{}", Oid::NewOid()));
+ auto _ = MakeGuard([AuthTokenPath]() { RemoveFile(AuthTokenPath); });
const std::string ProcArgs = fmt::format("{} --AuthConfigUrl {} --OutFile {} --Unattended={}",
OidcExecutablePath,