Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

We're almost rid of dotfiles in $HOME. Can we please also get rid of the abuse of environment variables for configuration? There is no reason your program needs to muck up the environment table of every process by defining MY_PROGRAM_API_KEY instead of taking a command line argument or reading a configuration file. It's not "secure" just because it's not on the command line. And it will mess up for users because it's nigh impossible to ensure you have the same environment variables over all login types. The variable might be there when you run locally, but not in an ssh session or cron. Some ephemeral configuration such as LD_LIBRARY_PATH and PWD is difficult to handle without environment variables, but those are rare exceptions and not the norm.

Contribute to a clean environment! Don't use environment variables for configuration! </rant>



This problem is also removed by just not exporting the variables. Also you can just pass an envp to execvE.


"MY_APP_SECRET_KEY=bla myapp" hardly accomplishes anything substantial over "myapp --secret-key=blah" It's just a less robust and less well-supported command-line interface. It's not supported by most gui launchers, PowerShell, nor many cron implementations, for example.


The command line can be read by any user on the host (with `ps auxww` for example) while the environment cannot.

You should never pass secrets on the command line.


Environment variables are not more secure than command line parameters! It's such a common misconception that because environment variables are "not seen" they can serve as a secure channel. They emphatically cannot.


Secrets being hidden ("not seen") is really their main quality...


Depending on your system, passing secrets via environment can be more secure than passing secrets via a command line. Command line arguments of all running processes can be visible to other users of the system, environment variables are usually not.


They're the standard for Docker container configuration tho. Otherwise I do agree.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: