Live data from Hacker News

Don’t use environment variables for configuration

nibblestew.blogspot.com

291–296 of 296 posts

Re: Don’t use environment variables for configuration

#291

sure env vars are overused. some values simply do not belong in the environment, for example - credentials. however, i havent seen a more convenient method of injecting configuration dynamically without some error prone file watching mechanics

Why don't credentials belong in the environment? They're definitely not visible to other users there, as opposed to on the command line where they definitely are, or in a file where they can be if you don't set the permissions correctly.

Because with credentials in environment we now have to distinguish between private and public environment vars so we don’t accidentally log something we should not or expose security sensitive info in another way

Re: Don’t use environment variables for configuration

#292
post #132

Earlier quoted context omitted.

Bold of you to assume my third party code runs with the same UID and SELinux label as my credentials-handling code. (I wish, it's April 1 after all!)

If the third party code runs with a different UID, then it can't read the environment either.

Unless it has DAC override or other capabilities. Belt and braces!

Re: Don’t use environment variables for configuration

#294
post #292

Earlier quoted context omitted.

If the third party code runs with a different UID, then it can't read the environment either.

Unless it has DAC override or other capabilities. Belt and braces!

If it has DAC override, then it can read your credentials file just as easily as it can the environment.

Re: Don’t use environment variables for configuration

#295
post #292

Earlier quoted context omitted.

Unless it has DAC override or other capabilities. Belt and braces!

If it has DAC override, then it can read your credentials file just as easily as it can the environment.

Not if SELinux policy prevents it.

Re: Don’t use environment variables for configuration

#296
The most common problem that I've encountered with using environment variables for configuration is that developers often add them ad-hoc, in the module where the configuration is needed, making it impossible to have a clear idea of all the configurable options in a program.

The solution is not to get rid of env vars, but to have a mechanism that centralises the confirguration in one place; this way all the options are easy to locate, and they can be defined in multiple ways.

Shameless plug, FWIW: figga is my humble contribution to this area for Python: https://github.com/berislavlopac/figga

Post reply on HN