aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/zencore/filesystem.cpp12
-rw-r--r--src/zencore/include/zencore/filesystem.h1
-rw-r--r--src/zenserver/config/config.cpp21
-rw-r--r--src/zenserver/config/config.h17
-rw-r--r--src/zenserver/storage/projectstore/httpprojectstore.cpp29
-rw-r--r--src/zenserver/storage/projectstore/httpprojectstore.h16
-rw-r--r--src/zenserver/storage/storageconfig.cpp10
-rw-r--r--src/zenserver/storage/storageconfig.h2
-rw-r--r--src/zenserver/storage/zenstorageserver.cpp10
-rw-r--r--src/zenserver/zenserver.cpp5
10 files changed, 59 insertions, 64 deletions
diff --git a/src/zencore/filesystem.cpp b/src/zencore/filesystem.cpp
index 8adb66972..7f341818b 100644
--- a/src/zencore/filesystem.cpp
+++ b/src/zencore/filesystem.cpp
@@ -2756,18 +2756,6 @@ GetEnvVariable(std::string_view VariableName)
return "";
}
-bool
-SetEnvVariable(std::string Name, std::string Value)
-{
- ZEN_ASSERT(!Name.empty() && !Value.empty());
-#if ZEN_PLATFORM_WINDOWS
- return SetEnvironmentVariableA(Name.c_str(), Value.c_str());
-#endif
-#if ZEN_PLATFORM_LINUX || ZEN_PLATFORM_MAC
- return setenv(Name.c_str(), Value.c_str(), /* overwrite */ 1) == 0;
-#endif
-}
-
std::error_code
RotateFiles(const std::filesystem::path& Filename, std::size_t MaxFiles)
{
diff --git a/src/zencore/include/zencore/filesystem.h b/src/zencore/include/zencore/filesystem.h
index b7422d389..b4906aebf 100644
--- a/src/zencore/include/zencore/filesystem.h
+++ b/src/zencore/include/zencore/filesystem.h
@@ -378,7 +378,6 @@ void GetDirectoryContent(const std::filesystem::path& RootDir,
Latch& PendingWorkCount);
std::string GetEnvVariable(std::string_view VariableName);
-bool SetEnvVariable(std::string Name, std::string Value);
std::filesystem::path SearchPathForExecutable(std::string_view ExecutableName);
diff --git a/src/zenserver/config/config.cpp b/src/zenserver/config/config.cpp
index f5170add8..18187711b 100644
--- a/src/zenserver/config/config.cpp
+++ b/src/zenserver/config/config.cpp
@@ -182,7 +182,6 @@ struct ZenServerCmdLineOptions
std::string DataDir;
std::string AbsLogFile;
std::string BaseSnapshotDir;
- std::string OidcTokenExecutable;
void AddCliOptions(cxxopts::Options& options, ZenServerConfig& ServerOptions);
void ApplyOptions(cxxopts::Options& options, ZenServerConfig& ServerOptions);
@@ -375,13 +374,6 @@ ZenServerCmdLineOptions::AddCliOptions(cxxopts::Options& options, ZenServerConfi
"",
cxxopts::value<bool>(ServerOptions.StatsConfig.Enabled)->default_value("false"),
"Enable statsd reporter (localhost:8125)");
-
- options.add_option("auth",
- "",
- "oidctoken-exe-path",
- "Path to OidcToken executable",
- cxxopts::value<std::string>(OidcTokenExecutable)->default_value(""),
- "");
}
void
@@ -396,13 +388,12 @@ ZenServerCmdLineOptions::ApplyOptions(cxxopts::Options& options, ZenServerConfig
throw std::runtime_error(fmt::format("'--snapshot-dir' ('{}') must be a directory", ServerOptions.BaseSnapshotDir));
}
- ServerOptions.SystemRootDir = MakeSafeAbsolutePath(SystemRootDir);
- ServerOptions.DataDir = MakeSafeAbsolutePath(DataDir);
- ServerOptions.ContentDir = MakeSafeAbsolutePath(ContentDir);
- ServerOptions.AbsLogFile = MakeSafeAbsolutePath(AbsLogFile);
- ServerOptions.ConfigFile = MakeSafeAbsolutePath(ConfigFile);
- ServerOptions.BaseSnapshotDir = MakeSafeAbsolutePath(BaseSnapshotDir);
- ServerOptions.OidcTokenExecutable = MakeSafeAbsolutePath(OidcTokenExecutable);
+ ServerOptions.SystemRootDir = MakeSafeAbsolutePath(SystemRootDir);
+ ServerOptions.DataDir = MakeSafeAbsolutePath(DataDir);
+ ServerOptions.ContentDir = MakeSafeAbsolutePath(ContentDir);
+ ServerOptions.AbsLogFile = MakeSafeAbsolutePath(AbsLogFile);
+ ServerOptions.ConfigFile = MakeSafeAbsolutePath(ConfigFile);
+ ServerOptions.BaseSnapshotDir = MakeSafeAbsolutePath(BaseSnapshotDir);
}
//////////////////////////////////////////////////////////////////////////
diff --git a/src/zenserver/config/config.h b/src/zenserver/config/config.h
index 2d37697cd..40639da13 100644
--- a/src/zenserver/config/config.h
+++ b/src/zenserver/config/config.h
@@ -55,15 +55,14 @@ struct ZenServerConfig
bool IsDedicated = false; // Indicates a dedicated/shared instance, with larger resource requirements
bool ShouldCrash = false; // Option for testing crash handling
bool IsFirstRun = false;
- std::filesystem::path ConfigFile; // Path to Lua config file
- std::filesystem::path SystemRootDir; // System root directory (used for machine level config)
- std::filesystem::path ContentDir; // Root directory for serving frontend content (experimental)
- std::filesystem::path DataDir; // Root directory for state (used for testing)
- std::filesystem::path AbsLogFile; // Absolute path to main log file
- std::filesystem::path BaseSnapshotDir; // Path to server state snapshot (will be copied into data dir on start)
- std::filesystem::path OidcTokenExecutable; // Path to OidcToken executable to use for auth
- std::string ChildId; // Id assigned by parent process (used for lifetime management)
- std::string LogId; // Id for tagging log output
+ std::filesystem::path ConfigFile; // Path to Lua config file
+ std::filesystem::path SystemRootDir; // System root directory (used for machine level config)
+ std::filesystem::path ContentDir; // Root directory for serving frontend content (experimental)
+ std::filesystem::path DataDir; // Root directory for state (used for testing)
+ std::filesystem::path AbsLogFile; // Absolute path to main log file
+ std::filesystem::path BaseSnapshotDir; // Path to server state snapshot (will be copied into data dir on start)
+ std::string ChildId; // Id assigned by parent process (used for lifetime management)
+ std::string LogId; // Id for tagging log output
std::string Loggers[zen::logging::level::LogLevelCount];
#if ZEN_WITH_TRACE
bool HasTraceCommandlineOptions = false;
diff --git a/src/zenserver/storage/projectstore/httpprojectstore.cpp b/src/zenserver/storage/projectstore/httpprojectstore.cpp
index 3a48ef595..1e1899002 100644
--- a/src/zenserver/storage/projectstore/httpprojectstore.cpp
+++ b/src/zenserver/storage/projectstore/httpprojectstore.cpp
@@ -252,7 +252,8 @@ namespace {
size_t MaxBlockSize,
size_t MaxChunkEmbedSize,
size_t MaximumInMemoryDownloadSize,
- const std::filesystem::path& TempFilePath)
+ const std::filesystem::path& TempFilePath,
+ const std::filesystem::path& OidcTokenExePath)
{
ZEN_MEMSCOPE(GetProjectHttpTag());
@@ -318,7 +319,7 @@ namespace {
}
}
- std::filesystem::path OidcExePath = FindOidcTokenExePath("");
+ std::filesystem::path OidcExePath = FindOidcTokenExePath(OidcTokenExePath.string());
std::string_view KeyParam = Cloud["key"sv].AsString();
if (KeyParam.empty())
@@ -425,7 +426,7 @@ namespace {
AccessToken = GetEnvVariable(AccessTokenEnvVariable);
}
}
- std::filesystem::path OidcExePath = FindOidcTokenExePath("");
+ std::filesystem::path OidcExePath = FindOidcTokenExePath(OidcTokenExePath.string());
std::string_view BuildIdParam = Builds["buildsid"sv].AsString();
if (BuildIdParam.empty())
{
@@ -507,13 +508,14 @@ namespace {
//////////////////////////////////////////////////////////////////////////
-HttpProjectService::HttpProjectService(CidStore& Store,
- ProjectStore* Projects,
- HttpStatusService& StatusService,
- HttpStatsService& StatsService,
- AuthMgr& AuthMgr,
- OpenProcessCache& InOpenProcessCache,
- JobQueue& InJobQueue)
+HttpProjectService::HttpProjectService(CidStore& Store,
+ ProjectStore* Projects,
+ HttpStatusService& StatusService,
+ HttpStatsService& StatsService,
+ AuthMgr& AuthMgr,
+ OpenProcessCache& InOpenProcessCache,
+ JobQueue& InJobQueue,
+ const std::filesystem::path& InOidcTokenExePath)
: m_Log(logging::Get("project"))
, m_CidStore(Store)
, m_ProjectStore(Projects)
@@ -522,6 +524,7 @@ HttpProjectService::HttpProjectService(CidStore& Store,
, m_AuthMgr(AuthMgr)
, m_OpenProcessCache(InOpenProcessCache)
, m_JobQueue(InJobQueue)
+, m_OidcTokenExePath(InOidcTokenExePath)
{
ZEN_MEMSCOPE(GetProjectHttpTag());
@@ -2636,7 +2639,8 @@ HttpProjectService::HandleRpcRequest(HttpRouterRequest& Req)
MaxBlockSize,
MaxChunkEmbedSize,
GetMaxMemoryBufferSize(MaxBlockSize, BoostWorkerMemory),
- Oplog->TempPath());
+ Oplog->TempPath(),
+ m_OidcTokenExePath);
if (RemoteStoreResult.Store == nullptr)
{
@@ -2706,7 +2710,8 @@ HttpProjectService::HandleRpcRequest(HttpRouterRequest& Req)
MaxBlockSize,
MaxChunkEmbedSize,
GetMaxMemoryBufferSize(MaxBlockSize, BoostWorkerMemory),
- Oplog->TempPath());
+ Oplog->TempPath(),
+ m_OidcTokenExePath);
if (RemoteStoreResult.Store == nullptr)
{
diff --git a/src/zenserver/storage/projectstore/httpprojectstore.h b/src/zenserver/storage/projectstore/httpprojectstore.h
index b742102a5..5a8bd3c9b 100644
--- a/src/zenserver/storage/projectstore/httpprojectstore.h
+++ b/src/zenserver/storage/projectstore/httpprojectstore.h
@@ -38,13 +38,14 @@ class TransferThreadWorkers;
class HttpProjectService : public HttpService, public IHttpStatusProvider, public IHttpStatsProvider
{
public:
- HttpProjectService(CidStore& Store,
- ProjectStore* InProjectStore,
- HttpStatusService& StatusService,
- HttpStatsService& StatsService,
- AuthMgr& AuthMgr,
- OpenProcessCache& InOpenProcessCache,
- JobQueue& InJobQueue);
+ HttpProjectService(CidStore& Store,
+ ProjectStore* InProjectStore,
+ HttpStatusService& StatusService,
+ HttpStatsService& StatsService,
+ AuthMgr& AuthMgr,
+ OpenProcessCache& InOpenProcessCache,
+ JobQueue& InJobQueue,
+ const std::filesystem::path& InOidcTokenExePath);
~HttpProjectService();
virtual const char* BaseUri() const override;
@@ -109,6 +110,7 @@ private:
metrics::OperationTiming m_HttpRequests;
RwLock m_ThreadWorkersLock;
Ref<TransferThreadWorkers> m_ThreadWorkers;
+ std::filesystem::path m_OidcTokenExePath;
Ref<TransferThreadWorkers> GetThreadWorkers(bool BoostWorkers, bool SingleThreaded);
};
diff --git a/src/zenserver/storage/storageconfig.cpp b/src/zenserver/storage/storageconfig.cpp
index 0f8ab1e98..98167b4f6 100644
--- a/src/zenserver/storage/storageconfig.cpp
+++ b/src/zenserver/storage/storageconfig.cpp
@@ -496,6 +496,7 @@ ZenStorageServerConfigurator::AddConfigOptions(LuaConfig::Options& LuaOptions)
LuaOptions.AddOption("security.encryptionaeskey"sv, ServerOptions.EncryptionKey, "encryption-aes-key"sv);
LuaOptions.AddOption("security.encryptionaesiv"sv, ServerOptions.EncryptionIV, "encryption-aes-iv"sv);
LuaOptions.AddOption("security.openidproviders"sv, ServerOptions.AuthConfig);
+ LuaOptions.AddOption("security.oidctokenexecutable"sv, ServerOptions.OidcTokenExecutable, "oidctoken-exe-path"sv);
////// workspaces
LuaOptions.AddOption("workspaces.enabled"sv, ServerOptions.WorksSpacesConfig.Enabled, "workspaces-enabled"sv);
@@ -649,6 +650,12 @@ ZenStorageServerCmdLineOptions::AddSecurityOptions(cxxopts::Options& options, Ze
options.add_option("security", "", "openid-provider-url", "Open ID provider URL", cxxopts::value<std::string>(OpenIdProviderUrl), "");
options.add_option("security", "", "openid-client-id", "Open ID client ID", cxxopts::value<std::string>(OpenIdClientId), "");
+ options.add_option("security",
+ "",
+ "oidctoken-exe-path",
+ "Path to OidcToken executable",
+ cxxopts::value<std::string>(OidcTokenExecutable),
+ "");
}
void
@@ -1045,7 +1052,8 @@ ZenStorageServerCmdLineOptions::ApplyOptions(cxxopts::Options& options, ZenStora
{.Name = OpenIdProviderName, .Url = OpenIdProviderUrl, .ClientId = OpenIdClientId});
}
- ServerOptions.ObjectStoreConfig = ParseBucketConfigs(BucketConfigs);
+ ServerOptions.ObjectStoreConfig = ParseBucketConfigs(BucketConfigs);
+ ServerOptions.OidcTokenExecutable = MakeSafeAbsolutePath(OidcTokenExecutable);
}
} // namespace zen
diff --git a/src/zenserver/storage/storageconfig.h b/src/zenserver/storage/storageconfig.h
index d59d05cf6..b265572cc 100644
--- a/src/zenserver/storage/storageconfig.h
+++ b/src/zenserver/storage/storageconfig.h
@@ -157,6 +157,7 @@ struct ZenStorageServerConfig : public ZenServerConfig
std::filesystem::path PluginsConfigFile; // Path to plugins config file
bool ObjectStoreEnabled = false;
std::string ScrubOptions;
+ std::filesystem::path OidcTokenExecutable;
};
struct ZenStorageServerCmdLineOptions
@@ -174,6 +175,7 @@ struct ZenStorageServerCmdLineOptions
std::string OpenIdProviderName;
std::string OpenIdProviderUrl;
std::string OpenIdClientId;
+ std::string OidcTokenExecutable;
void AddSecurityOptions(cxxopts::Options& options, ZenStorageServerConfig& ServerOptions);
diff --git a/src/zenserver/storage/zenstorageserver.cpp b/src/zenserver/storage/zenstorageserver.cpp
index 559695a94..381ef028a 100644
--- a/src/zenserver/storage/zenstorageserver.cpp
+++ b/src/zenserver/storage/zenstorageserver.cpp
@@ -204,8 +204,14 @@ ZenStorageServer::InitializeServices(const ZenStorageServerConfig& ServerOptions
m_OpenProcessCache = std::make_unique<OpenProcessCache>();
m_ProjectStore = new ProjectStore(*m_CidStore, m_DataRoot / "projects", m_GcManager, ProjectStore::Configuration{});
- m_HttpProjectService.reset(
- new HttpProjectService{*m_CidStore, m_ProjectStore, m_StatusService, m_StatsService, *m_AuthMgr, *m_OpenProcessCache, *m_JobQueue});
+ m_HttpProjectService.reset(new HttpProjectService{*m_CidStore,
+ m_ProjectStore,
+ m_StatusService,
+ m_StatsService,
+ *m_AuthMgr,
+ *m_OpenProcessCache,
+ *m_JobQueue,
+ ServerOptions.OidcTokenExecutable});
if (ServerOptions.WorksSpacesConfig.Enabled)
{
diff --git a/src/zenserver/zenserver.cpp b/src/zenserver/zenserver.cpp
index d5c9558aa..08be5475a 100644
--- a/src/zenserver/zenserver.cpp
+++ b/src/zenserver/zenserver.cpp
@@ -128,11 +128,6 @@ ZenServerBase::Initialize(const ZenServerConfig& ServerOptions, ZenServerState::
EnqueueSigIntTimer();
- if (!ServerOptions.OidcTokenExecutable.empty())
- {
- SetEnvVariable(std::string(GetOidcTokenPathEnvVariableName()), ServerOptions.OidcTokenExecutable.string());
- }
-
m_Http = CreateHttpServer(ServerOptions.HttpConfig);
int EffectiveBasePort = m_Http->Initialize(ServerOptions.BasePort, ServerOptions.DataDir);
if (EffectiveBasePort == 0)