WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#42345 closed defect (bug) (invalid)

file_put_contents: failed to open stream

Reported by: eduardbosch Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.8.2
Component: Plugins Keywords:
Focuses: Cc:

Description

Hi,

I've started having problems accessing some pages in my Admin dashboard.

First, I was unable to enter settings page and also some other plugin pages. When I tried to enter those pages, I saw in chrome 'ERROR_EMPTY_RESPONSE' and in my apache error.log I was seeing this errors

AH00051: child pid 11660 exit signal Segmentation fault (11), possible coredump in /var/cache/apache2/

After enabling coredump, I've noticed that this was causing the problem:

...
#0  __strstr_sse2_unaligned () at ../sysdeps/x86_64/multiarch/strstr-sse2-unaligned.S:22
22	../sysdeps/x86_64/multiarch/strstr-sse2-unaligned.S: No such file or directory.
(gdb) bt full
#0  __strstr_sse2_unaligned () at ../sysdeps/x86_64/multiarch/strstr-sse2-unaligned.S:22
No locals.
#1  0x00007fe0b756e2d8 in php_ssh2_fopen_wraper_parse_path () from /usr/lib/php5/20121212/ssh2.so
No symbol table info available.
#2  0x00007fe0b757225c in ?? () from /usr/lib/php5/20121212/ssh2.so
No symbol table info available.
#3  0x00007fe0c1e4ae07 in _php_stream_stat_path () from /usr/lib/apache2/modules/libphp5.so
No symbol table info available.
#4  0x00007fe0c1dc6a95 in ?? () from /usr/lib/apache2/modules/libphp5.so
No symbol table info available.
#5  0x00007fe0c1dc8d8b in zif_file_exists () from /usr/lib/apache2/modules/libphp5.so
No symbol table info available.
#6  0x00007fe0c1cff8c6 in phar_file_exists () from /usr/lib/apache2/modules/libphp5.so
No symbol table info available.
...

After some research, I finally installed ssh2 with pecl. Since then I can access all admin pages without problem, but now I cannot update any plugins or manage some plugins (like backup one backup plugin). I receive this message 'Update Failed: Unable to locate WordPress content directory (wp-content).'

Also in apache error.log file I receive this errors when I try to update a plugin

PHP Warning:  file_put_contents(ssh2.sftp://Resource id #1144/.maintenance): failed to open stream: operation failed in /var/www/html/wp-admin/includes/class-wp-filesystem-ssh2.php on line 253, referer: http://mywebpage.com/wp-admin/plugins.php

My config:
PHP 5.5.9-1ubuntu4.22
ssh2 extension 0.13
libssh2 version 1.4.3
ssh2 SSH-2.0-libssh2_1.4.3

Change History (8)

#1 @dd32
4 years ago

It appears that this is caused by a PHP Security update when running with an incompatible version of the PHP SSH2 extension - unfortunately the latest version of the extension (for PHP 5: 0.13) is incompatible. Some versions (such as 0.13-3 from the REMI repo's) are compatible though.

Some reading:
https://bugs.php.net/bug.php?id=73597
https://forum.remirepo.net/viewtopic.php?id=3509

I'm guessing the reason you had segfaults previously is you were most likely running a much further outdated version of the ssh2 extension, updating it fixed the segfaults, but didn't help with the incompatibility.

The workaround provided in the above php.net link to use intval() is an option for core, however is only required in the scenario that someone is using an updated PHP version without updating the ssh2 extension.

@eduardbosch in the short term - either update the ssh2 extension to a fixed one, disable ssh updating (remove the extension) and/or use the PHP-based SSH updater plugin which doesn't need the extension and IMHO is far more reliable than the extension breaks.

Last edited 4 years ago by dd32 (previous) (diff)

#2 @eduardbosch
4 years ago

Thanks a lot @dd32

I managed to update my plugins with SSH updater plugin

The problem is that my backup plugin is still having trouble.

I would like to update the ssh2 lib to 0.13-3, but I think I cannot install the REMI packages to Ubuntu, right?
Is there any way to compile the sources or find a package for Ubuntu?

Thanks again

#3 @eduardbosch
4 years ago

Hi @dd32,

I've tried to install without the ssh2 for php5 without success.

Do you know any fixed ssh2 version for php5 that I can install on ubuntu? This error makes some parts of my Wordpress admin unusable.

Is there any workaround to fix this, like downgrading php5 to a certain version?

Thanks

#4 @dd32
4 years ago

Sorry, I can't help with regard to the extension at all, I've not used it in several years and don't recommend it's use.

#5 @eduardbosch
4 years ago

So, how can Wordpress can be configured to use ssh2 keys without this extension?

If I disable this extension, my Wordpress will lose its security, right?

My Wordpress configuration uses public and private keys. I think this are used by this extension, right?

...

define('FTP_PUBKEY','/home/wp-user/wp_rsa.pub');
define('FTP_PRIKEY','/home/wp-user/wp_rsa');
define('FTP_USER','user');
define('FTP_PASS','');
define('FTP_HOST','127.0.0.1:22');

...

I'm a little bit confused on how to fix my admin problems.

#6 @dd32
4 years ago

If I disable this extension, my Wordpress will lose its security, right?

A properly configured server should not require the usage of ssh2 to access it's own files, and in general by storing the keys on the server you're loosing most of the security which the usage of keys would provide in the first place.

Unfortunately, Trac is not a location for server support or PHP configuration. We support the ssh2 extension if it works with your Server/PHP environment, unfortunately the widely deployed packages are out of date and haven't been updated in quite some time for PHP5, all recent development is focused on the PHP7 package (which is also not yet stable AFAIK)

#7 @eduardbosch
4 years ago

  • Resolution set to invalid
  • Status changed from new to closed

#8 @netweb
4 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.