Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 8 Feb 2003 03:20:23 +0100
From:      <k.j.koster@telecom.tno.nl>
To:        <brent@rcfile.org>
Cc:        <freebsd-java@FreeBSD.ORG>
Subject:   RE: [patch] daemonctl.c modified to use JAVA_HOME environment variable
Message-ID:  <0DD8055E0FECF744B5FF8053F80C4A2D194F69@l07.oase.research.kpn.com>

next in thread | raw e-mail | index | archive | help
Dear Brent,

I would prefer daemonctl to fail if the JAVA_HOME is pointing off into =
lala land. I really dislike solutions that are helpfully filling in =
information. If I set JAVA_HOME to something odd, I expect my programs =
to fail. Please consider this.

    Kees Jan

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
 You can't have everything.  Where would you put it?
                                     [Steven Wright]



> -----Original Message-----
> From: Brent Verner [mailto:brent@rcfile.org]
> Sent: zaterdag 8 februari 2003 1:30
> To: Greg Lewis
> Cc: freebsd-java@FreeBSD.ORG
> Subject: Re: [patch] daemonctl.c modified to use JAVA_HOME environment
> variable
>=20
>=20
> [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=20
> use JAVA_HOME
> | > if set in the environment.
> | >=20
> | > @@ -71,7 +75,16 @@
> | > =20
> | >  	/* Declare variables, like all other good ANSI C=20
> programs do :) */
> | >  	char *argument;
> | > -
> | > +   =20
> | > +    /* use JAVA_HOME environemt variable if set */
> | > +    char* _java_home =3D getenv("JAVA_HOME");
> | > +    if( _java_home !=3D NULL && strcmp("",_java_home) !=3D 0 ){
> | > +      /* TODO: verify that java_prog would exist before=20
> overriding the default */
> | > +      strncpy(java_home,_java_home,PATH_MAX-1);
> | > +     =20
> snprintf(java_prog,PATH_MAX-1,"%s/%%JAVA_CMD%%",_java_home);
> | > +      using_java_home_env =3D 1;
> | > +    }
> | > +   =20
> |=20
> | Just some minor feedback.
> |=20
> | 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).
>=20
>   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.
>=20
> cheers.
>   b
>=20
> --=20
> "Develop your talent, man, and leave the world something. Records are=20
> really gifts from people. To think that an artist would love=20
> you enough
> to share his music with anyone is a beautiful thing."  -- Duane Allman
>=20

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-java" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?0DD8055E0FECF744B5FF8053F80C4A2D194F69>