mirror of https://github.com/winsw/winsw
[FIXED JENKINS-42744] - Do not inject ps.EnvironmentVariables explicitly
parent
9cfdcf4ae7
commit
f81f5d3c57
|
@ -147,15 +147,11 @@ namespace winsw.Util
|
||||||
foreach (string key in envVars.Keys)
|
foreach (string key in envVars.Keys)
|
||||||
{
|
{
|
||||||
Environment.SetEnvironmentVariable(key, envVars[key]);
|
Environment.SetEnvironmentVariable(key, envVars[key]);
|
||||||
// ps.EnvironmentVariables[key] = envs[key]; // bugged (lower cases all variable names due to StringDictionary being used, see http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=326163)
|
// DONTDO: ps.EnvironmentVariables[key] = envs[key];
|
||||||
|
// bugged (lower cases all variable names due to StringDictionary being used, see http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=326163)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: move outside, stubbed to reproduce the issue
|
|
||||||
// TODO: Make it generic via extension points. The issue mentioned above should be ideally worked around somehow
|
|
||||||
ps.EnvironmentVariables[WinSWSystem.ENVVAR_NAME_SERVICE_ID.ToLower()] = "myapp";// _descriptor.Id;
|
|
||||||
// Environment.SetEnvironmentVariable(WinSWSystem.ENVVAR_NAME_SERVICE_ID.ToLower(), _descriptor.Id);
|
|
||||||
|
|
||||||
processToStart.Start();
|
processToStart.Start();
|
||||||
Logger.Info("Started process " + processToStart.Id);
|
Logger.Info("Started process " + processToStart.Id);
|
||||||
|
|
||||||
|
|
|
@ -118,9 +118,10 @@ namespace winsw.Plugins.RunawayProcessKiller
|
||||||
// TODO: This method is not ideal since it works only for vars explicitly mentioned in the start info
|
// TODO: This method is not ideal since it works only for vars explicitly mentioned in the start info
|
||||||
// No Windows 10- compatible solution for EnvVars retrieval, see https://blog.gapotchenko.com/eazfuscator.net/reading-environment-variables
|
// No Windows 10- compatible solution for EnvVars retrieval, see https://blog.gapotchenko.com/eazfuscator.net/reading-environment-variables
|
||||||
StringDictionary previousProcessEnvVars = proc.StartInfo.EnvironmentVariables;
|
StringDictionary previousProcessEnvVars = proc.StartInfo.EnvironmentVariables;
|
||||||
String expectedEnvVarName = WinSWSystem.ENVVAR_NAME_SERVICE_ID.ToLower();
|
String expectedEnvVarName = WinSWSystem.ENVVAR_NAME_SERVICE_ID;
|
||||||
if (previousProcessEnvVars.ContainsKey(expectedEnvVarName))
|
if (previousProcessEnvVars.ContainsKey(expectedEnvVarName))
|
||||||
{
|
{
|
||||||
|
// StringDictionary is case-insensitive, hence it will fetch variable definitions in any case
|
||||||
affiliatedServiceId = previousProcessEnvVars[expectedEnvVarName];
|
affiliatedServiceId = previousProcessEnvVars[expectedEnvVarName];
|
||||||
}
|
}
|
||||||
else if (CheckWinSWEnvironmentVariable)
|
else if (CheckWinSWEnvironmentVariable)
|
||||||
|
|
Loading…
Reference in New Issue