Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Module regression from 1.4.1 to 1.5.0

Chiusa
#99 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

@transcendtient ci sta già lavorando.

Dal 28/8/2026.

  • #107 di @transcendtient — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
c, centos, php

Direzione di ricerca

Run the provided PHP reproduction script against the ssh2.sftp:// wrapper on versions 1.4.1 and 1.5.0, focusing on the opendir() entry point. Trace the stream-wrapper implementation and changes between those versions; done means opendir() succeeds and directory entries can be read on 1.5.0.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Updated a CentOS server, from pecl ssh2 version 1.4.1 to 1.5.0, and completely changed/broke the existing ssh/sftp connectivity we had built.

Below is a short example showing the issue at hand.

<?php
/**
 * Minimal reproduction: ssh2.sftp:// stream wrapper opendir() failure
 *
 * Tests whether opendir() works via the ssh2.sftp:// stream wrapper.
 * Known behavior:
 *   php-pecl-ssh2 1.4.1 -- opendir() returns a valid handle
 *   php-pecl-ssh2 1.5.0 -- opendir() returns false (regression)
 *
 * Usage:
 *   php ssh2_stream_wrapper_repro.php <host> <port> <user> <password> [<dir>]
 *
 * Example:
 *   php ssh2_stream_wrapper_repro.php sftp.example.com 22 myuser mypassword /
 */

if ($argc < 5) {
    fprintf(STDERR, "Usage: %s <host> <port> <user> <password> [<dir>]\n", $argv[0]);
    exit(1);
}

$host = $argv[1];
$port = (int)$argv[2];
$user = $argv[3];
$pwd  = $argv[4];
$dir  = isset($argv[5]) ? $argv[5] : "/";

echo "ssh2 extension version : " . phpversion("ssh2") . "\n";
echo "PHP version            : " . PHP_VERSION . "\n";
echo "Host                   : {$host}:{$port}\n";
echo "User                   : {$user}\n";
echo "Directory              : {$dir}\n";
echo str_repeat("-", 50) . "\n";

// Step 1: connect
echo "ssh2_connect()         : ";
$conn = ssh2_connect($host, $port);
var_dump($conn);
if (!$conn) { echo "FAIL: could not connect\n"; exit(1); }

// Step 2: authenticate
echo "ssh2_auth_password()   : ";
$auth = ssh2_auth_password($conn, $user, $pwd);
var_dump($auth);
if (!$auth) { echo "FAIL: authentication failed\n"; exit(1); }

// Step 3: open SFTP subsystem
echo "ssh2_sftp()            : ";
$sftp = ssh2_sftp($conn);
var_dump($sftp);
if (!$sftp) { echo "FAIL: could not open SFTP subsystem\n"; exit(1); }

// Step 4: show how the resource looks and what intval() gives
echo "intval(\$sftp)          : ";
var_dump(intval($sftp));

// Step 5: build the stream wrapper URL
$url = "ssh2.sftp://" . intval($sftp) . $dir;
echo "Stream wrapper URL     : {$url}\n";

// Step 6: the actual test — opendir via stream wrapper
echo "opendir()              : ";
$handle = opendir($url);
var_dump($handle);

if ($handle === false) {
    echo "FAIL: opendir() returned false — stream wrapper is broken\n";
    exit(1);
}

// Step 7: list a few entries to confirm it actually works
echo "Directory listing      :\n";
$count = 0;
while (false !== ($entry = readdir($handle))) {
    if ($entry === "." || $entry === "..") continue;
    echo "  {$entry}\n";
    if (++$count >= 10) { echo "  (truncated after 10 entries)\n"; break; }
}
closedir($handle);

echo str_repeat("-", 50) . "\n";
echo "PASS: stream wrapper opendir() works correctly\n";

Examples of each:

v1.4.1:

php tmp.php host.com 22 user REDACTED /
ssh2 extension version : 1.4.1
PHP version            : 8.4.20
Host                   : host.com:22
User                   : user
Directory              : /
--------------------------------------------------
ssh2_connect()         : resource(4) of type (SSH2 Session)
ssh2_auth_password()   : bool(true)
ssh2_sftp()            : resource(5) of type (SSH2 SFTP)
intval($sftp)          : int(5)
Stream wrapper URL     : ssh2.sftp://5/
opendir()              : resource(7) of type (stream)
Directory listing      :
  boot
  dev
  home
  proc
  run
  sys
  tmp
  etc
  root
  var
  (truncated after 10 entries)

v1.5.0

php tmp.php host.com 22 user REDACTED /
ssh2 extension version : 1.5.0
PHP version            : 8.4.20
Host                   : host.com:22
User                   : user
Directory              : /
--------------------------------------------------
ssh2_connect()         : resource(4) of type (SSH2 Session)
ssh2_auth_password()   : bool(true)
ssh2_sftp()            : resource(5) of type (SSH2 SFTP)
intval($sftp)          : int(5)
Stream wrapper URL     : ssh2.sftp://5/
opendir()              : bool(false)
FAIL: opendir() returned false — stream wrapper is broken
Lingua principale
C
Stelle
55
Fork
67
Merge medio
3h 8m
PR unite (30g)
1

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di php/pecl-networking-ssh2

Tutte le issue di php/pecl-networking-ssh2

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.