Skip to content

Conversation

@karalabe
Copy link
Member

One catch with env vars is that they might silently change Geth's behavior, in both directions:

  • A set config var might be unexpected to the user and they might not know where it originates from (since it's not specified on the CLI).
  • An old / mistyped env var might be present that is not actually consumed by Geth because a name mismatch, which would lead to a silent ignore.

Both cases would be quite tricky to debug. Further it would be a PITA for us to debug user issues when they don't share their env list, and sharing them may not be best security practice.

This PR tries to solve all 3 issues, by listing all the consumed env vars, as well as all the env vars that "seem" like GETH ones, but that are not consumed in the end.

TL;DR:

Screenshot 2023-09-14 at 17 24 26

@karalabe karalabe added this to the 1.13.1 milestone Sep 14, 2023
if err := debug.Setup(ctx); err != nil {
return err
}
flags.CheckEnvVars(ctx, app.Flags, "GETH")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
flags.CheckEnvVars(ctx, app.Flags, "GETH")
flags.CheckEnvVars(ctx, app.Flags, "GETH_")

maybe?

Copy link
Member Author

Choose a reason for hiding this comment

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

Unsure. I deliberately left it as GETH only so that if you forget the underscore or use a minus or something it still gets caught. That said, it's mostly a heuristic for now.

if ctx.Count(flag) > 0 {
log.Info("Config environment variable found", "envvar", key, "shadowedby", "--"+flag)
} else {
log.Info("Config environment variable found", "envvar", key)
Copy link
Contributor

Choose a reason for hiding this comment

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

In some cases. cmd line params are sensitive (password for remote influxdb databases, password for --unlock), but this will echo them in logs, right?

Might not be the best idea -- so far, we've been kind rightfully lax about asking people for their logs, because we know they contain nothing interesting.

Ah wait, it's only the key, not the value? If so it's all good!

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, only key for the exact reason.

Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

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

LGTM

@karalabe karalabe merged commit 16cd1a7 into ethereum:master Sep 15, 2023
devopsbo3 pushed a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
devopsbo3 added a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
devopsbo3 added a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants