Bug 23734

Summary: fopen function always failed
Product: Mageia Reporter: Yann Ciret <mageia>
Component: RPM PackagesAssignee: Marc Krämer <mageia>
Status: RESOLVED INVALID QA Contact:
Severity: normal    
Priority: Normal CC: mageia, marja11
Version: 6   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Source RPM: php-5.6.38-1.mga6.src.rpm CVE:
Status comment:

Description Yann Ciret 2018-10-19 08:56:47 CEST
Description of problem:
When I want update Matomo on my Mageia 6 server, I always have fopen php error:

WARNING: /var/www/html/suivi/core/Http.php(467): Warning - fopen(http://builds.matomo.org/piwik.zip?cb=3.6.1): failed to open stream: php_network_getaddresses: getaddrinfo failed: Nom ou service inconnu - Matomo 3.6.0

WARNING: /var/www/html/suivi/core/Http.php(467): Warning - fopen(): php_network_getaddresses: getaddrinfo failed: Nom ou service inconnu - Matomo 3.6.0

WARNING: /var/www/html/suivi/core/Http.php(467): Warning - fopen(https://builds.matomo.org/piwik.zip?cb=3.6.1): failed to open stream: php_network_getaddresses: getaddrinfo failed: Nom ou service inconnu - Matomo 3.6.0

WARNING: /var/www/html/suivi/core/Http.php(467): Warning - fopen(): php_network_getaddresses: getaddrinfo failed: Nom ou service inconnu - Matomo 3.6.0

I suspect a problem with mageia php package because url works well with wget or curl and fopen is allowed in php.ini file.




Version-Release number of selected component (if applicable):
5.6.38
Marja Van Waes 2018-10-20 13:43:44 CEST

Assignee: bugsquad => php
CC: (none) => marja11

Comment 1 Marc Krämer 2018-10-20 16:58:12 CEST
I can not confirm this.
Running the following test script:
<?php
$handle=fopen('http://builds.matomo.org/piwik.zip?cb=3.6.1','r');
echo  strlen(fread($handle,20));
fclose($handle);
?>

runs fine, and gives 20 bytes from the stream. No problem in name resolution. Looks more like a configuration problem of the network / name resolution to me.

Did you allow url opening in your php.ini???

; http://php.net/allow-url-fopen
allow_url_fopen = On

Assignee: php => mageia
CC: (none) => mageia

Comment 2 Yann Ciret 2018-10-22 00:06:55 CEST
(In reply to Marc Krämer from comment #1)
> I can not confirm this.
> Running the following test script:
> <?php
> $handle=fopen('http://builds.matomo.org/piwik.zip?cb=3.6.1','r');
> echo  strlen(fread($handle,20));
> fclose($handle);
> ?>
> 
> runs fine, and gives 20 bytes from the stream. No problem in name
> resolution. Looks more like a configuration problem of the network / name
> resolution to me.
> 
> Did you allow url opening in your php.ini???
> 
> ; http://php.net/allow-url-fopen
> allow_url_fopen = On

Hello Marc,

As I mention in my first message, allow_url_fopen is autorised in php.ini.
I tested your script and the result gives 0.

And wget works, so this is not a network configuration problem.

This is the result of your script in error logs:
[Sun Oct 21 23:47:34.797998 2018] [:error] [pid 24302] [client 82.235.164.210:49660] PHP Warning:  fopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/html/suivi/test.php on line 2
[Sun Oct 21 23:47:34.798079 2018] [:error] [pid 24302] [client 82.235.164.210:49660] PHP Warning:  fopen(http://builds.matomo.org/piwik.zip?cb=3.6.1): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/html/suivi/test.php on line 2
[Sun Oct 21 23:47:34.798109 2018] [:error] [pid 24302] [client 82.235.164.210:49660] PHP Warning:  fread() expects parameter 1 to be resource, boolean given in /var/www/html/suivi/test.php on line 3
[Sun Oct 21 23:47:34.798136 2018] [:error] [pid 24302] [client 82.235.164.210:49660] PHP Warning:  fclose() expects parameter 1 to be resource, boolean given in /var/www/html/suivi/test.php on line 4


phpinfo() confirm allow_url_fopen = On.

Regards
Yann
Comment 3 Yann Ciret 2018-10-22 00:24:59 CEST
For precision, my server is IPv4 only.
Comment 4 Yann Ciret 2018-10-22 00:56:33 CEST
It is weird.
When you go on https://mars.zamiz.net/suivi/test.php, the result is 0.
But if I launch the test with apache user in command line, the result is 20.

$ php html/suivi/test.php
20
Comment 5 Marc Krämer 2018-10-22 10:27:18 CEST
- do you run php as apache module or via cgi (php-fpm)?

can you replace the url in the script to
a) http://google.com
b) http://173.194.79.113

so, we can see, if this is a general network problem or only the name resolution.

- do you have a firewall running, which may prevent outgoing traffic?
Comment 6 Yann Ciret 2018-10-22 19:10:57 CEST
for me this is the apache module.
You can see phpinfo at https://mars.zamiz.net/suivi/test.php

with modification in script:
a/ it failed
b/ it failed

[Mon Oct 22 19:05:43.094730 2018] [:error] [pid 13878] [client 82.235.164.210:58554] PHP Warning:  fopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/html/suivi/test.php on line 3
[Mon Oct 22 19:05:43.094808 2018] [:error] [pid 13878] [client 82.235.164.210:58554] PHP Warning:  fopen(http://173.194.79.113): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/html/suivi/test.php on line 3
[Mon Oct 22 19:05:43.094835 2018] [:error] [pid 13878] [client 82.235.164.210:58554] PHP Warning:  fread() expects parameter 1 to be resource, boolean given in /var/www/html/suivi/test.php on line 4
[Mon Oct 22 19:05:43.094859 2018] [:error] [pid 13878] [client 82.235.164.210:58554] PHP Warning:  fclose() expects parameter 1 to be resource, boolean given in /var/www/html/suivi/test.php on line 5


About firewall, I don't think. If this is the case, the flow should never work. Only ongoing traffic is filtered.
Comment 7 Yann Ciret 2018-10-22 19:55:33 CEST
is it possible issue comes from bad hosts.allow and hosts.deny config?

hosts.allow:
http:   ALL
https:  ALL
sshd:   ALL EXCEPT /etc/hosts.evil
svn:    ALL

hosts.deny:
ALL:ALL EXCEPT 127.0.0.1:DENY
Comment 8 Yann Ciret 2018-10-24 01:00:15 CEST
I found!

The problem came from a bad configuration in the php.ini file. The option "always_populate_raw_post_post_data = -1" was enabled. A relic of an update certainly. After disabled it, all work fine.

Thank you for your time.

Status: NEW => RESOLVED
Resolution: (none) => INVALID