From owner-freebsd-questions@FreeBSD.ORG Fri Oct 19 21:15:02 2007 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DC8B016A41B for ; Fri, 19 Oct 2007 21:15:02 +0000 (UTC) (envelope-from erikt@midgard.homeip.net) Received: from ch-smtp01.sth.basefarm.net (ch-smtp01.sth.basefarm.net [80.76.149.212]) by mx1.freebsd.org (Postfix) with ESMTP id 53F5513C448 for ; Fri, 19 Oct 2007 21:15:02 +0000 (UTC) (envelope-from erikt@midgard.homeip.net) Received: from c83-253-25-183.bredband.comhem.se ([83.253.25.183]:51704 helo=falcon.midgard.homeip.net) by ch-smtp01.sth.basefarm.net with esmtp (Exim 4.68) (envelope-from ) id 1IizB8-0004rz-5v for freebsd-questions@freebsd.org; Fri, 19 Oct 2007 23:14:47 +0200 Received: (qmail 91671 invoked from network); 19 Oct 2007 23:14:34 +0200 Received: from owl.midgard.homeip.net (10.1.5.7) by falcon.midgard.homeip.net with ESMTP; 19 Oct 2007 23:14:34 +0200 Received: (qmail 76523 invoked by uid 1001); 19 Oct 2007 23:14:34 +0200 Date: Fri, 19 Oct 2007 23:14:34 +0200 From: Erik Trulsson To: "Aryeh M. Friedman" Message-ID: <20071019211433.GA76124@owl.midgard.homeip.net> Mail-Followup-To: "Aryeh M. Friedman" , freebsd-questions@freebsd.org References: <4718D7D4.2010604@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4718D7D4.2010604@gmail.com> User-Agent: Mutt/1.5.16 (2007-06-09) X-Originating-IP: 83.253.25.183 X-Scan-Result: No virus found in message 1IizB8-0004rz-5v. X-Scan-Signature: ch-smtp01.sth.basefarm.net 1IizB8-0004rz-5v 275f2fcbf9b2cba068c967ea61db91bf Cc: freebsd-questions@freebsd.org Subject: Re: [stupid question] setting env variables globally X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Oct 2007 21:15:02 -0000 On Fri, Oct 19, 2007 at 04:14:12PM +0000, 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 ertr1013@student.uu.se