From owner-freebsd-ports@FreeBSD.ORG Sun Nov 19 20:36:34 2006 Return-Path: X-Original-To: ports@freebsd.org Delivered-To: freebsd-ports@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DDF4E16A416 for ; Sun, 19 Nov 2006 20:36:34 +0000 (UTC) (envelope-from marcus@marcuscom.com) Received: from creme-brulee.marcuscom.com (creme-brulee.marcuscom.com [24.172.16.118]) by mx1.FreeBSD.org (Postfix) with ESMTP id A56FF43D8A for ; Sun, 19 Nov 2006 20:36:18 +0000 (GMT) (envelope-from marcus@marcuscom.com) Received: from [192.168.1.4] (shumai.marcuscom.com [192.168.1.4]) by creme-brulee.marcuscom.com (8.13.8/8.13.8) with ESMTP id kAJKaT8r001427; Sun, 19 Nov 2006 15:36:29 -0500 (EST) (envelope-from marcus@marcuscom.com) From: Joe Marcus Clarke To: Sevan / Venture37 In-Reply-To: <4560BEA2.3070809@hotmail.com> References: <4560BEA2.3070809@hotmail.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-0NaArx14r80BhX5VLGDr" Organization: MarcusCom, Inc. Date: Sun, 19 Nov 2006 15:36:24 -0500 Message-Id: <1163968584.85615.3.camel@shumai.marcuscom.com> Mime-Version: 1.0 X-Mailer: Evolution 2.8.1.1 FreeBSD GNOME Team Port Cc: ports@freebsd.org Subject: Re: Dealing with clearenv() X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Nov 2006 20:36:34 -0000 --=-0NaArx14r80BhX5VLGDr Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Sun, 2006-11-19 at 20:29 +0000, Sevan / Venture37 wrote: > Chillispot 1.1 uses clearenv() which is not available in FreeBSD. What's > the best way for dealing with this, atm I'm using the following patch to > the source code which seems to work & none of the testers have reported > back with any problems. Is there a better way to deal with the issue?? > +#ifdef HAVE_CLEARENV > if (clearenv() !=3D 0) { > sys_err(LOG_ERR, __FILE__, __LINE__, errno, > "clearenv() did not return 0!"); > exit(0); > } > +#else > + extern char **environ; > + environ[0] =3D NULL; > + if (environ[0] !=3D NULL) { > + sys_err(LOG_ERR, __FILE__, __LINE__, errno, > + "Venture37 doesn't know what he's doing!!!"); > + exit(0); > + } > +#endif This will work, but you do not need the check to make sure environ[0] is NULL. And you should declare extern char **environ at the top of a block so that the code compiles on non-C99 compilers. This might make things a bit cleaner: int my_cleanenv (void) { #ifdef HAVE_CLEARENV return cleanenv(); #else extern char **environ; environ[0] =3D NULL; return 0; #endif } ... if (my_cleanenv() !=3D 0) { ... Joe --=20 PGP Key : http://www.marcuscom.com/pgp.asc --=-0NaArx14r80BhX5VLGDr Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (FreeBSD) iD8DBQBFYMBIb2iPiv4Uz4cRAgpfAJ94fMMQkMX2MN8GA/I2KeD9jg12NACfa6YM Yew22bANCm764kzGobcxtKs= =m1yf -----END PGP SIGNATURE----- --=-0NaArx14r80BhX5VLGDr--