From owner-freebsd-current@FreeBSD.ORG Sat Jul 14 02:26:40 2007 Return-Path: X-Original-To: freebsd-current@FreeBSD.org Delivered-To: freebsd-current@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id BCCB316A402; Sat, 14 Jul 2007 02:26:40 +0000 (UTC) (envelope-from ache@nagual.pp.ru) Received: from nagual.pp.ru (nagual.pp.ru [194.87.13.69]) by mx1.freebsd.org (Postfix) with ESMTP id 1F4CE13C46B; Sat, 14 Jul 2007 02:26:39 +0000 (UTC) (envelope-from ache@nagual.pp.ru) Received: from nagual.pp.ru (ache@localhost [127.0.0.1]) by nagual.pp.ru (8.14.1/8.14.1) with ESMTP id l6E2QceW025383; Sat, 14 Jul 2007 06:26:38 +0400 (MSD) (envelope-from ache@nagual.pp.ru) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nagual.pp.ru; s=default; t=1184379998; bh=qVlicmtJX+jDeIXBZSMMPTUMslhZ0RUuWYbH7BS frok=; l=1222; h=Received:Date:From:To:Subject:Message-ID: Mail-Followup-To:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To:User-Agent; b=sN1Kkts7QCYDWBj0ahQW PuTBK9i2XUcCKWqKY5M/Ckh0QitMRZQaCL7BBZnP0wZZbVvQYneydjyf74dtId4CW7A vX3i5sj9MHqbVDlmMrzqYs+T9mwmx73B1J9RqLUhMdAWOt61Aop7KgGg6CdqFa/r31J cYURlIiFz79k1bcxQ= Received: (from ache@localhost) by nagual.pp.ru (8.14.1/8.14.1/Submit) id l6E2QcRU025382; Sat, 14 Jul 2007 06:26:38 +0400 (MSD) (envelope-from ache) Date: Sat, 14 Jul 2007 06:26:38 +0400 From: Andrey Chernov To: "Sean C. Farley" , freebsd-current Message-ID: <20070714022638.GA25256@nagual.pp.ru> Mail-Followup-To: Andrey Chernov , "Sean C. Farley" , freebsd-current References: <20070713162742.GA16260@nagual.pp.ru> <20070713142545.K26096@thor.farley.org> <20070713202433.GA19856@nagual.pp.ru> <20070713203915.GA20270@nagual.pp.ru> <20070713171942.Q26096@thor.farley.org> <20070713224608.GB21695@nagual.pp.ru> <20070713184543.A26096@thor.farley.org> <20070714004116.GA22909@nagual.pp.ru> <20070713200048.X26971@thor.farley.org> <20070714014319.GA24701@nagual.pp.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20070714014319.GA24701@nagual.pp.ru> User-Agent: Mutt/1.5.16 (2007-06-09) Cc: Subject: Re: Environment handling broken in /bin/sh with changes to t,set,put}env() X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Jul 2007 02:26:40 -0000 On Sat, Jul 14, 2007 at 05:43:20AM +0400, Andrey Chernov wrote: > On Fri, Jul 13, 2007 at 08:10:33PM -0500, Sean C. Farley wrote: > >> It ends up with environ = NULL; because envVarsTotal initialized to 0 > >> i.e. makes from "environ[0] == NULL" case "environ == NULL" case > >> which is different thing. > > > > I changed it to return (0) if either environ or environ[0] equal NULL. > > The SaveEnviron label is removed as well as the (envVarsTotal > 0) > > check. > > Looks OK. BTW, I fear about another place on this matter, merge_environ(). Look at this example: ... some setenv's called before nenv[0] = NULL; environ = nenv; unsetenv("NONEXISTEN"); What happens to environ pointer _after_ that? unsetenv() leads to environ = watchEnviron; in the merge_environ() but this environ is never rebuilded because no single setenv() is called from merge_environ() and no rebuild_environ() is called from unsetenv() due to "NONEXISTENT" value not found. It means reassigned environ inherits stale pointers from non-rebuilded watchEnviron which not equals to environ[0] == NULL Did I miss something? The same about environ = NULL; unsetenv("NONEXISTEN"); -- http://ache.pp.ru/