Re: [stupid question] setting env variables globally
On Fri, Oct 19, 2007 at 04:14:12PM +, Aryeh M. Friedman wrote: Is there any way to set the default value of a enviromental variable globally. Specifically I want JAVA_VERSION to default to "1.6" unless the user sets it other wise. By global I mean no matter how something is invoked (command line, script, GUI, IPC trigger, etc.) if it checks the value of the var it gets the same value (and I want to do this system wide) For userland stuff that is invoked after a login (i.e. In some user's login context), I have a master profile I keep in /usr/local/etc/.myprofile. I then source this from the .profile or .bashrc in a given user's account. If you need this for cron jobs, there is a way to set environment variables in the crontab entry IIRC... HTH, Tim Daneliuk [EMAIL PROTECTED] PGP Key: http://www.tundraware.com/PGP/ ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: [stupid question] setting env variables globally
On Fri, Oct 19, 2007 at 04:14:12PM +, Aryeh M. Friedman wrote: > Is there any way to set the default value of a enviromental variable > globally. Specifically I want JAVA_VERSION to default to "1.6" unless > the user sets it other wise. By global I mean no matter how something > is invoked (command line, script, GUI, IPC trigger, etc.) if it checks > the value of the var it gets the same value (and I want to do this > system wide) You can take a look at login.conf(5) which probably can provide what you want. Depending on exactly how and when (and from where) a process is started this might not work, but is probably the best that can be done without hacking the kernel source code. A process normally inherits the environment from its parent process. When a process calls some of the exec(3) functions to start a new program it can also provide a completely new environment which can be completely independent of the parent's. The settings in login.conf(5) only (AFAICT) affects processes whose ancestry can be traced back to a login(1) instance, and where the environment hasn't been changed along the way. This should cover most of the processes you are interested in but perhaps not quite all of them. If you really want *all* processes to have a certain environment variable set to a given value you will have to modify the execve(2) system call. I don't recommend doing this unless you know *exactly* what you are doing and the possible consequences thereof. -- Erik Trulsson [EMAIL PROTECTED] ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: [stupid question] setting env variables globally
On Oct 19, 2007, at 9:14 AM, Aryeh M. Friedman wrote: Is there any way to set the default value of a enviromental variable globally. Specifically I want JAVA_VERSION to default to "1.6" unless the user sets it other wise. By global I mean no matter how something is invoked (command line, script, GUI, IPC trigger, etc.) if it checks the value of the var it gets the same value (and I want to do this system wide) Setting variables in /etc/profile and /etc/csh.cshrc (respectively) will do it for the common shells; or perhaps you might look at /etc/ login.conf... -- -Chuck ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"