Bug #79051 [Asn->Ver]: putenv variables not accessible to dependent functions in Windows CLI

From: Date: Thu, 02 Jan 2020 15:04:21 +0000
Subject: Bug #79051 [Asn->Ver]: putenv variables not accessible to dependent functions in Windows CLI
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-224668@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79051&edit=1

 ID:                 79051
 Updated by:         cmb@php.net
 Reported by:        danielklein at airpost dot net
 Summary:            putenv variables not accessible to dependent
                     functions in Windows CLI
-Status:             Assigned
+Status:             Verified
 Type:               Bug
 Package:            PHP options/info functions
 Operating System:   Windows 10
 PHP Version:        7.3.13
 Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

Thanks for the further information!  I just tried with a ZTS
build, and now I could reproduce.  Apparently, I didn't test
a ZTS build before, even though I thought I did.  Sorry.

Anyhow, the problem is actually the missing part of bug #66265 for
ZTS, which has never been addressed (the other ticket had been
closed inadvertently).

TL;DR: libcurl() currently calls getenv() to retrieve the
environment variable, but in ZTS builds it is only set with
SetEnvironmentVariable(), so is not available to libcurl.

I'm afraid, though, that we can't do anything here without
coordination with libraries using getenv() to retrieve environment
variables.  I just wrote to the curl library mailing list[1];
let's see how that goes.

[1] <https://curl.haxx.se/mail/lib-2020-01/0006.html>


Previous Comments:
------------------------------------------------------------------------
[2020-01-02 12:10:42] danielklein at airpost dot net

This is what I've downloaded and installed today (in different directories):
- php-7.3.12-Win32-VC15-x64.zip
- php-7.3.13-Win32-VC15-x64.zip
- php-7.4.0-Win32-vc15-x64.zip
- php-7.4.1-Win32-vc15-x64.zip

------------------------------------------------------------------------
[2020-01-02 12:08:18] danielklein at airpost dot net

I've tried with 7.3.9-7.3.13, & 7.4.0-7.4.1 (fresh downloads and installations of PHP >=
7.3.12).
7.3.13 & 7.4.1 both with Xdebug disabled still have the same behaviour as I reported before.

------------------------------------------------------------------------
[2020-01-02 10:51:11] cmb@php.net

Yes, I tested on Windows (PHP 7.3.13 x64 NTS and ZTS).

Obviously, in your case putenv() signals success, and getenv()
returns what it is supposed to.

Could you please try with PHP 7.3.13 and Xdebug disabled?

Thanks.

------------------------------------------------------------------------
[2020-01-02 10:32:24] danielklein at airpost dot net

The first var_dump(getenv('all_proxy')); returns bool(false).
var_dump(putenv('all_proxy=localhost:5678')); returns bool(true).
The second var_dump(getenv('all_proxy')); returns string(14) "localhost:5678".

It's the thread safe build:

PHP 7.3.9 (cli) (built: Aug 28 2019 09:28:48) ( ZTS MSVC15 (Visual C++ 2017) x64 )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.9, Copyright (c) 1998-2018 Zend Technologies
    with Xdebug v2.7.2, Copyright (c) 2002-2019, by Derick Rethans

Just to confirm, you did run this on Windows? The bug is not present on Ubuntu, and I assume other
Linux varieties.

------------------------------------------------------------------------
[2020-01-01 12:39:00] cmb@php.net

I cannot reproduce the reported behavior.  What do the putenv()
and getenv() calls return (use var_dump instead of echo or
ignoring the return value)?  Also, are you using NTS or ZTS
builds?

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=79051


--
Edit this bug report at https://bugs.php.net/bug.php?id=79051&edit=1


Thread (10 messages)

« previous php.bugs (#224668) next »