From fbef6f009fb869f1c78b3d7dfb95ef92eedf586a Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sat, 1 Dec 2018 22:41:45 -0600 Subject: [PATCH] System/SSH/Agent: add parameter to constructor --- phpseclib/System/SSH/Agent.php | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/phpseclib/System/SSH/Agent.php b/phpseclib/System/SSH/Agent.php index e7c76782..e751b4d9 100644 --- a/phpseclib/System/SSH/Agent.php +++ b/phpseclib/System/SSH/Agent.php @@ -352,18 +352,20 @@ class System_SSH_Agent * @return System_SSH_Agent * @access public */ - function __construct() + function __construct($address = null) { - switch (true) { - case isset($_SERVER['SSH_AUTH_SOCK']): - $address = $_SERVER['SSH_AUTH_SOCK']; - break; - case isset($_ENV['SSH_AUTH_SOCK']): - $address = $_ENV['SSH_AUTH_SOCK']; - break; - default: - user_error('SSH_AUTH_SOCK not found'); - return false; + if (!$address) { + switch (true) { + case isset($_SERVER['SSH_AUTH_SOCK']): + $address = $_SERVER['SSH_AUTH_SOCK']; + break; + case isset($_ENV['SSH_AUTH_SOCK']): + $address = $_ENV['SSH_AUTH_SOCK']; + break; + default: + user_error('SSH_AUTH_SOCK not found'); + return false; + } } $this->fsock = fsockopen('unix://' . $address, 0, $errno, $errstr); @@ -378,9 +380,9 @@ class System_SSH_Agent * @see self::__construct() * @access public */ - function System_SSH_Agent() + function System_SSH_Agent($address = null) { - $this->__construct(); + $this->__construct($address); } /**