From owner-freebsd-java Mon Mar 24 6:26:46 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 8B43F37B401 for ; Mon, 24 Mar 2003 06:26:42 -0800 (PST) Received: from habanero.hesketh.net (habanero.hesketh.net [66.45.6.196]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6782243F93 for ; Mon, 24 Mar 2003 06:26:41 -0800 (PST) (envelope-from brent@mutt.rcfile.org) X-Received-From: brent@mutt.rcfile.org X-Delivered-To: freebsd-java@FreeBSD.ORG X-Originating-IP: [66.57.229.60] Received: from mutt.rcfile.org (rdu57-229-060.nc.rr.com [66.57.229.60]) by habanero.hesketh.net (8.12.8/8.12.8) with ESMTP id h2OEQSVC008985; Mon, 24 Mar 2003 09:26:29 -0500 X-Spam-Filter: check_local@habanero.hesketh.net by digitalanswers.org Received: from mutt.rcfile.org (localhost [127.0.0.1]) by mutt.rcfile.org (8.12.8/8.12.7) with ESMTP id h2OEQWa3036743; Mon, 24 Mar 2003 09:26:32 -0500 (EST) (envelope-from brent@mutt.rcfile.org) Received: (from brent@localhost) by mutt.rcfile.org (8.12.8/8.12.8/Submit) id h2OEQWJA036742; Mon, 24 Mar 2003 09:26:32 -0500 (EST) Date: Mon, 24 Mar 2003 09:26:32 -0500 From: Brent Verner To: Ernst de Haan Cc: Greg Lewis , freebsd-java@FreeBSD.ORG Subject: Re: [patch] daemonctl.c modified to use JAVA_HOME environment variable Message-ID: <20030324142632.GA36430@rcfile.org> References: <20030207163217.GA99329@rcfile.org> <20030208055654.A20219@misty.eyesbeyond.com> <20030208002946.GA4681@rcfile.org> <200303241032.54982.ernst.dehaan@nl.wanadoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200303241032.54982.ernst.dehaan@nl.wanadoo.com> X-muttrc: $Id: .muttrc,v 1.10 2003/02/08 08:35:24 brent Exp $ X-uname: FreeBSD 4.8-RC #6: Thu Mar 20 02:22:17 EST 2003 root@mutt.rcfile.org:/usr/obj/usr/src/sys/MUTTS User-Agent: Mutt/1.5.3i X-Spam-Status: No, hits=-14.5 required=5.0 tests=IN_REP_TO,RCVD_IN_RFCI,REFERENCES,USER_AGENT_MUTT 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 [2003-03-24 10:32] Ernst de Haan said: | 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. This has turned into a little more than a patch at this point... :-) http://docs.freebsd.org/cgi/getmsg.cgi?fetch=146473+0+archive/2003/freebsd-java/20030323.freebsd-java I've competed the setuid/setgid, setenv, chdir and (non-forking) execv bits. I still have logs, forked execv, and pidfile handling to complete, and hope to find time by mid-week to wrap those up. If anyone wants to help the cause, the code is in cvs... sh$ cvs -d :pserver:anoncvs@rcfile.org:/var/cvs login [empty password, just press key] sh$ cvs -d :pserver:anoncvs@rcfile.org:/var/cvs co daemonctl This should probably be a separate port, and just have each dependent package install its xml config into /usr/local/etc/daemonct.d/ and create its symlink to the daemonctl binary. cheers. b | 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 -- "Develop your talent, man, and leave the world something. Records are really gifts from people. To think that an artist would love you enough to share his music with anyone is a beautiful thing." -- Duane Allman To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-java" in the body of the message