Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#35946 closed defect (bug) (duplicate)

ssh2/sftp doesn't work in chrooted environments

Reported by: aberbenni's profile aberbenni Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.4.2
Component: Filesystem API Keywords:
Focuses: administration Cc:

Description

This is a follow-up to #32345 and #33919.

I'm using same (ssh2 chrooted environments) configuration on a new test server with php7 fpm and SSH2 support enabled, extension version 0.12+dev, libssh2 version 1.4.3, banner SSH-2.0-libssh2_1.4.3

Tested on 4.4.2 here is extra debug from WP_Filesystem_Base::$verbose when attempting an update to a plugin:

Looking for /var/www/www.mydomain.com/website/wp-content in /
The update process is starting. This process may take a while on some hosts, so please be patient.

Looking for /var/www/www.mydomain.com/website/wp-content in /
Updating plugin Akismet (1/1)
An error occurred while updating Akismet: Unable to locate WordPress Content directory (wp-content).
Looking for /var/www/www.mydomain.com/website in /
All updates have been completed.

I decided to install Wp FS Tester and run it but, it crashes with log:

PHP Fatal error:  Uncaught Error: Call to undefined function split() in /var/www/www.mydomain.com/website/wp-content/plugins/wp-filesystem-tester.php:42
			      Stack trace:
			      /var/www/www.mydomain.com/website/wp-content/plugins/wp-filesystem-tester.php(113): wpfs_get_base_dir('/', true)
			      /var/www/www.mydomain.com/website/wp-includes/plugin.php(525): wsts_page('')
			      /var/www/www.mydomain.com/website/wp-admin/admin.php(236): do_action('toplevel_page_w...')
			      {main}
			      thrown in /var/www/www.mydomain.com/website/wp-content/plugins/wp-filesystem-tester.php on line 42


I decided to fix lines 42 and 40 with this code:


if( strpos($abspath, $base) > 0)
		$arrPath = explode('/',substr($abspath,strpos($abspath, $base)));
	else
		$arrPath = explode('/',$abspath);

Then run fixed Wp FS Tester:

Connection Method	ssh2
ABSPATH	/var/www/www.mydomain.com/website/
PLUGINDIR	wp-content/plugins
FS Errors	None
FS CWD	/
FS WordPress Locator	Ricerca di /var/www/www.mydomain.com/website in /
FS WordPress Location	
FS0 WordPress Locator (Old code)	Modificando in /
FS0 WordPress Location (Old code)	
Tests Stopped; Error: WordPress could not be located	Files in folder

Change History (6)

#1 @dd32
8 years ago

This is quite possibly a faulty PHP extension, can you test if the patch on #35517 solves it for you?

#2 @aberbenni
8 years ago

  • Severity changed from normal to major

Ok, I'll test the patch on #35517.
In the meantime here is a follow up.

Installed and activated SSH SFTP Updater Support and then run fixed Wp FS Tester:

Connection Method	ssh2
ABSPATH	/var/www/www.mydomain.com/website/
PLUGINDIR	wp-content/plugins
FS Errors	None
FS CWD	This service allows sftp connections only. /
FS WordPress Locator	Ricerca di /var/www/www.mydomain.com/website in This service allows sftp connections only. /
Ricerca di /var/www/www.mydomain.com/website in /
Trovati /website
FS WordPress Location	/website/
FS0 WordPress Locator (Old code)


PHP Fatal error:  Uncaught Error: Call to a member function chdir() on null in /var/www/www.mydomain.com/website/wp-content/plugins/ssh-sftp-updater-support/class-wp-filesystem-ssh2.php:155
				  Stack trace:
				  /var/www/www.mydomain.com/website/wp-content/plugins/wp-filesystem-tester.php(112): WP_Filesystem_SSH2->chdir('This service al...')
				  /var/www/www.mydomain.com/website/wp-includes/plugin.php(525): wsts_page('')
				  /var/www/www.mydomain.com/website/wp-admin/admin.php(236): do_action('toplevel_page_w...')
				  {main}
				  thrown in /var/www/www.mydomain.com/website/wp-content/plugins/ssh-sftp-updater-support/class-wp-filesystem-ssh2.php on line 155
Version 0, edited 8 years ago by aberbenni (next)

#3 @ocean90
8 years ago

  • Severity changed from major to normal

#4 @aberbenni
8 years ago

  • Focuses administration added

Follow up.

Patch #35517 installed.

Run fixed Wp FS Tester:

Connection Method	ssh2
ABSPATH	/var/www/www.mydomain.com/website/
PLUGINDIR	wp-content/plugins
FS Errors	None
FS CWD	/
FS WordPress Locator	Looking for /var/www/www.mydomain.com/website in /
Found /website
FS WordPress Location	/website/
FS0 WordPress Locator (Old code)	Modified in /
Found website Modified in /website/
FS0 WordPress Location (Old code)	/website/
Plugin location:	/var/www/www.mydomain.com/website/wp-content/plugins/wp-filesystem-tester.php (Local)
/website/wp-content/plugins/wp-filesystem-tester.php (FTP)
Plugin Locations	
hello.php	/website/wp-content/plugins/	Delete file: /website/wp-content/plugins/hello.php
akismet/akismet.php	/website/wp-content/plugins/akismet/	Delete entire folder: /website/wp-content/plugins/akismet/
File IO Errors	All File IO tests passed.
Created /website/wp-content/plugins/super-long-name-not-to-conflict.php
Verified conents
Deleted /website/wp-content/plugins/super-long-name-not-to-conflict.php
Downloading a zip	Downloading http://downloads.wordpress.org/plugin/akismet.zip... Suceeded
Extracting Zip	Suceeded
Zip Contents	
akismet/	0	ok	binary
akismet/_inc/	0	ok	binary
akismet/_inc/img/	0	ok	binary
akismet/_inc/img/logo-full-2x.png	4970	ok	binary
akismet/_inc/akismet.js	6295	ok	binary
akismet/_inc/form.js	700	ok	binary
akismet/_inc/akismet.css	8748	ok	binary
akismet/class.akismet.php	43719	ok	<?php

class Akismet {
	const API_HOST = 'rest.aki...
akismet/LICENSE.txt	18092	ok	                    GNU GENERAL PUBLIC LICENSE
   ...
akismet/akismet.php	2381	ok	<?php
/**
 * @package Akismet
 */
/*
Plugin Name: ...
akismet/index.php	26	ok	<?php
# Silence is golden....
akismet/class.akismet-widget.php	2719	ok	<?php
/**
 * @package Akismet
 */
class Akismet_Wi...
akismet/views/	0	ok	binary
akismet/views/config.php	10682	ok	<div class="wrap">

	<h2><?php esc_html_e( 'Akisme...
akismet/views/strict.php	761	ok	<fieldset>
	<legend class="screen-reader-text">
		...
akismet/views/get.php	595	ok	<form name="akismet_activate" action="https://akis...
akismet/views/start.php	6547	ok	<div class="no-key config-wrap"><?php
	if ( $akism...
akismet/views/stats.php	551	ok	<div class="wrap">
	<h2><?php esc_html_e( 'Akismet...
akismet/views/notice.php	8697	ok	<?php if ( $type == 'plugin' ) :?>
<div class="upd...
akismet/readme.txt	12687	ok	=== Akismet ===
Contributors: matt, ryan, andy, md...
akismet/wrapper.php	6427	ok	<?php

global $wpcom_api_key, $akismet_api_host, $...
akismet/class.akismet-admin.php	39526	ok	<?php

class Akismet_Admin {
	const NONCE = 'akism...
akismet/.htaccess	616	ok	binary

#5 @dd32
8 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #35517.

I guess I should update my Filesystem tester plugin one of these days..

Looking at the debug output there, it's all working with the patch applied, so you do indeed have a faulty version of the PHP SSH2 extension installed (The PHP7 port was done incorrectly).

#6 @aberbenni
8 years ago

Yes but this time I cannot rely even on SSH SFTP Updater Support plugin.

Note: See TracTickets for help on using tickets.