Environment handling broken in /bin/sh with changes to {get,set,put}env()

Andrey Chernov ache at nagual.pp.ru
Fri Jul 13 20:39:17 UTC 2007


On Sat, Jul 14, 2007 at 12:24:33AM +0400, Andrey Chernov wrote:
> 1) I care in first hand about unsetenv() as my example states. There 
> nowhere said in the specs that unsetenv() may modify environ _content_, 
> manpage says about pointers only.

Moreover, they directly states (at least for some cases) that environment 
should be left completely untouched, like that:

"If the named variable does not exist in the current environment, the 
environment shall be unchanged and the function is considered to have 
completed successfully."

> 2) That example not fail under FreeBSD 6 but fail under new code:
> 
> nenv[0] = "PATH=/bin";
> nenv[1] = NULL;
> environ = nenv;
> setenv("HOME", "/xxx", 1);

Similar thing to the setenv example: 

nenv[0] = "PATH=/bin";
setenv("PATH", "/bin", 0);

"If the environment variable named by envname already exists and the value 
of overwrite is zero, the function shall return success and the 
environment shall remain unchanged."

-- 
http://ache.pp.ru/


More information about the freebsd-current mailing list