Skip to content

[core] Disable local level of gEnv#22775

Open
jblomer wants to merge 3 commits into
root-project:masterfrom
jblomer:restrict-rclogon-v2
Open

[core] Disable local level of gEnv#22775
jblomer wants to merge 3 commits into
root-project:masterfrom
jblomer:restrict-rclogon-v2

Conversation

@jblomer

@jblomer jblomer commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Add a new option for constructing TEnv that allows to disable the local
level. If disabled, configuration cannot be read anymore into the local
level, the local level cannot be saved and values cannot be set in the
local level. Effectively, the local level is always empty in this mode.

By default, new instances of TEnv have the local level enabled. Only
gEnv has it disabled to prevent environment poisoning.

The old behavior can be restored by setting the ROOTENV_UNSAFE_USE_LOCAL
environment variable to a non-empty string.

jblomer added 2 commits July 8, 2026 13:41
The previous fix for this made incorrect use of the PrependPathName()
API. Fixing.
@jblomer jblomer requested review from hageboeck and silverweed July 8, 2026 12:43
@jblomer jblomer self-assigned this Jul 8, 2026
@jblomer jblomer requested review from dpiparo and pcanal as code owners July 8, 2026 12:43
@jblomer jblomer force-pushed the restrict-rclogon-v2 branch from 6950a4d to b8076f5 Compare July 8, 2026 13:55
Add a new option for constructing TEnv that allows to disable the local
level. If disabled, configuration cannot be read anymore into the local
level, the local level cannot be saved and values cannot be set in the
local level. Effectively, the local level is always empty in this mode.

By default, new instances of TEnv have the local level _enabled_. Only
gEnv has it disabled to prevent environment poisoning.

The old behavior can be restored by setting the ROOTENV_UNSAFE_USE_LOCAL
environment variable to a non-empty string.
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

Test Results

    23 files      23 suites   3d 14h 24m 21s ⏱️
 3 875 tests  3 784 ✅   0 💤  91 ❌
78 826 runs  78 490 ✅ 214 💤 122 ❌

For more details on these failures, see this check.

Results for commit b8076f5.

Comment thread core/base/src/TEnv.cxx
global file is `$ROOTSYS/etc/system<name>` (or `ROOTETCDIR/system<name>`)
the user file is `$HOME/<name>` and the local file is `./<name>`.

For gEnv, the local level is disabled to prevent environment poisoning.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a bit obscure what we mean by "environment poisoning". Could we make this comment a little more explicit on why it is a safety measure?

Comment thread core/base/inc/TEnv.h
@@ -24,7 +24,7 @@ class TWriteEnvParser;
enum EEnvLevel {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to add a brief explanation of what each level means

Comment thread core/base/inc/TEnv.h
Bool_t fIgnoreDup; // ignore duplicates, don't issue warning
THashList *fTable; // hash table containing env records
TString fRcName; // resource file base name
Bool_t fIgnoreDup; // ignore duplicates, don't issue warning

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably initialize all these fields inline

Comment thread core/base/src/TEnv.cxx

For gEnv, the local level is disabled to prevent environment poisoning.
The behavior can be changed to be backwards-compatible by setting
`ROOTENV_UNSAFE_USE_LOCAL=1`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intuitively I would think that ROOTENV_UNSAFE_USE_LOCAL=0 would mean "explicitly disable local env". It would be beneficial to either make it that way or warn the user if we find a value 0 (or false) inside this variable that it's not doing what they think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants