Hacker News new | past | comments | ask | show | jobs | submit login

unset ? Inheriting env variables from the shell is a good idea ( or else you need all your dot files).



Not when you're running system daemons, and those daemons respond differently when you invoke them with commonly different env vars, like LANG.


Normally, system daemons are run by root. There is no reason to change the LANG env variable for system daemons.


You’ve missed the point. Back in the SysV days, you would log in to the system with SSH. You were logged in as hulitu, with all of your personalized environment variables, most of which were actually copied by ssh from your personal computer. This includes LANG and TERM and almost everything else (ssh has a blacklist, so it won’t copy SSH_AUTH_SOCK and PATH over).

Then you would use `su` or `sudo` to become root so that you could do admin stuff on the machine. When you started a service by running `/etc/rc.d/init.d/foo`, it would inherit those things from your shell. Today that service is running with LANG=en_US, but then next week someone from the EU does an upgrade and suddenly it is running with LANG=fr_FR. Oops! The error messages are still in English because you never localized this daemon program, but now when it converts numbers into strings it uses the wrong thousands and decimal separators. I hope that isn’t breaking anything, or silently corrupting any data.

This is a problem that systemd explicitly solves. All daemons launched by systemd are started in a fresh environment that inherits nothing from either the user who asked for it to be launched or from systemd itself.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

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

Search: