From owner-freebsd-java Mon Mar 24 1:33:10 2003 Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B042437B401 for ; Mon, 24 Mar 2003 01:33:07 -0800 (PST) Received: from zaphod.euronet.nl (zaphod.euronet.nl [194.134.168.213]) by mx1.FreeBSD.org (Postfix) with ESMTP id A9CB343FD7 for ; Mon, 24 Mar 2003 01:33:06 -0800 (PST) (envelope-from ernst@zaphod.euronet.nl) Received: from zaphod.euronet.nl (localhost [127.0.0.1]) by zaphod.euronet.nl (8.12.8/8.12.6) with ESMTP id h2O9WuHt061990; Mon, 24 Mar 2003 10:32:56 +0100 (CET) (envelope-from ernst@zaphod.euronet.nl) Received: from localhost (localhost [[UNIX: localhost]]) by zaphod.euronet.nl (8.12.8/8.12.6/Submit) id h2O9Wtqk061989; Mon, 24 Mar 2003 10:32:55 +0100 (CET) From: Ernst de Haan Organization: Wanadoo Nederland B.V. To: Brent Verner , Greg Lewis Subject: Re: [patch] daemonctl.c modified to use JAVA_HOME environment variable Date: Mon, 24 Mar 2003 10:32:54 +0100 User-Agent: KMail/1.5 Cc: freebsd-java@FreeBSD.ORG References: <20030207163217.GA99329@rcfile.org> <20030208055654.A20219@misty.eyesbeyond.com> <20030208002946.GA4681@rcfile.org> In-Reply-To: <20030208002946.GA4681@rcfile.org> X-Address: Muiderstraat 1, Amsterdam, Netherlands MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200303241032.54982.ernst.dehaan@nl.wanadoo.com> X-Spam-Status: No, hits=-26.1 required=5.0 tests=EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) Sender: owner-freebsd-java@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org Brent, How's your daemonctl.c patch coming along? I'm really interested in this. Now that the initial FreeBSD 4.8-RELEASE tag is done, we can consider committing patches like these. Ernst On Saturday 08 February 2003 01:29, Brent Verner wrote: > [2003-02-08 05:56] Greg Lewis said: > | On Fri, Feb 07, 2003 at 11:32:17AM -0500, Brent Verner wrote: > | > The attached patch modified the daemonctl.c program to use JAVA_HOME > | > if set in the environment. > | > > | > @@ -71,7 +75,16 @@ > | > > | > /* Declare variables, like all other good ANSI C programs do :) */ > | > char *argument; > | > - > | > + > | > + /* use JAVA_HOME environemt variable if set */ > | > + char* _java_home = getenv("JAVA_HOME"); > | > + if( _java_home != NULL && strcmp("",_java_home) != 0 ){ > | > + /* TODO: verify that java_prog would exist before overriding > | > the default */ + strncpy(java_home,_java_home,PATH_MAX-1); > | > + snprintf(java_prog,PATH_MAX-1,"%s/%%JAVA_CMD%%",_java_home); > | > + using_java_home_env = 1; > | > + } > | > + > | > | Just some minor feedback. > | > | I don't think this change is safe. If _java_home is too long to fit > | then java_home won't get null terminated. I suggest trying strlcpy > | instead. You might want to think about using strlcat instead of > | snprintf too, and adding some checking for overflow (and appropriate > | error handling if it occurs). > > Here's a better version (thanks for the pointer to strlcat). If > JAVA_HOME is set (and not empty) in the environment, try to use it > to find a usable JAVA_HOME/bin/java executable. Use this executable > if found, otherwise the default compile-time executable will be used. > In any case, if JAVA_HOME was checked, an 'info' message is printed, > alerting the user of the attempted command override. > > cheers. > b To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-java" in the body of the message