mirror of
https://github.com/nextcloud/server.git
synced 2026-04-21 06:08:46 -04:00
update icewind/smb to 3.5.2
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
0bed61f949
commit
a33e1dc5bb
6 changed files with 72 additions and 53 deletions
2
apps/files_external/3rdparty/composer.json
vendored
2
apps/files_external/3rdparty/composer.json
vendored
|
|
@ -9,6 +9,6 @@
|
|||
},
|
||||
"require": {
|
||||
"icewind/streams": "0.7.4",
|
||||
"icewind/smb": "3.5.1"
|
||||
"icewind/smb": "3.5.2"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
16
apps/files_external/3rdparty/composer.lock
generated
vendored
16
apps/files_external/3rdparty/composer.lock
generated
vendored
|
|
@ -4,20 +4,20 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "ed821b15824934fd2d245faca1f35aad",
|
||||
"content-hash": "524c99fd87297e01d004eb5a4e53b04c",
|
||||
"packages": [
|
||||
{
|
||||
"name": "icewind/smb",
|
||||
"version": "v3.5.1",
|
||||
"version": "v3.5.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/icewind1991/SMB.git",
|
||||
"reference": "c1ce4fbb2ff1786846d9d0b3850b395ca94cf563"
|
||||
"reference": "0a425bd21acf7ae112b135dca34640e1b1a825c3"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/icewind1991/SMB/zipball/c1ce4fbb2ff1786846d9d0b3850b395ca94cf563",
|
||||
"reference": "c1ce4fbb2ff1786846d9d0b3850b395ca94cf563",
|
||||
"url": "https://api.github.com/repos/icewind1991/SMB/zipball/0a425bd21acf7ae112b135dca34640e1b1a825c3",
|
||||
"reference": "0a425bd21acf7ae112b135dca34640e1b1a825c3",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -49,9 +49,9 @@
|
|||
"description": "php wrapper for smbclient and libsmbclient-php",
|
||||
"support": {
|
||||
"issues": "https://github.com/icewind1991/SMB/issues",
|
||||
"source": "https://github.com/icewind1991/SMB/tree/v3.5.1"
|
||||
"source": "https://github.com/icewind1991/SMB/tree/v3.5.2"
|
||||
},
|
||||
"time": "2021-11-04T14:28:18+00:00"
|
||||
"time": "2022-01-20T14:51:51+00:00"
|
||||
},
|
||||
{
|
||||
"name": "icewind/streams",
|
||||
|
|
@ -107,5 +107,5 @@
|
|||
"prefer-lowest": false,
|
||||
"platform": [],
|
||||
"platform-dev": [],
|
||||
"plugin-api-version": "2.1.0"
|
||||
"plugin-api-version": "2.2.0"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ class ClassLoader
|
|||
|
||||
/**
|
||||
* @return string[] Array of classname => path
|
||||
* @psalm-var array<string, string>
|
||||
* @psalm-return array<string, string>
|
||||
*/
|
||||
public function getClassMap()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,17 +2,17 @@
|
|||
"packages": [
|
||||
{
|
||||
"name": "icewind/smb",
|
||||
"version": "v3.5.1",
|
||||
"version_normalized": "3.5.1.0",
|
||||
"version": "v3.5.2",
|
||||
"version_normalized": "3.5.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/icewind1991/SMB.git",
|
||||
"reference": "c1ce4fbb2ff1786846d9d0b3850b395ca94cf563"
|
||||
"reference": "0a425bd21acf7ae112b135dca34640e1b1a825c3"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/icewind1991/SMB/zipball/c1ce4fbb2ff1786846d9d0b3850b395ca94cf563",
|
||||
"reference": "c1ce4fbb2ff1786846d9d0b3850b395ca94cf563",
|
||||
"url": "https://api.github.com/repos/icewind1991/SMB/zipball/0a425bd21acf7ae112b135dca34640e1b1a825c3",
|
||||
"reference": "0a425bd21acf7ae112b135dca34640e1b1a825c3",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
"phpunit/phpunit": "^8.5|^9.3.8",
|
||||
"psalm/phar": "^4.3"
|
||||
},
|
||||
"time": "2021-11-04T14:28:18+00:00",
|
||||
"time": "2022-01-20T14:51:51+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
|
|
@ -46,7 +46,7 @@
|
|||
"description": "php wrapper for smbclient and libsmbclient-php",
|
||||
"support": {
|
||||
"issues": "https://github.com/icewind1991/SMB/issues",
|
||||
"source": "https://github.com/icewind1991/SMB/tree/v3.5.1"
|
||||
"source": "https://github.com/icewind1991/SMB/tree/v3.5.2"
|
||||
},
|
||||
"install-path": "../icewind/smb"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../',
|
||||
'aliases' => array(),
|
||||
'reference' => 'cd72330b8f669e3dc81388be5a92171404f36fec',
|
||||
'reference' => '0bed61f949bc7a8c69cd154919e78b704e28c99e',
|
||||
'name' => 'files_external/3rdparty',
|
||||
'dev' => true,
|
||||
),
|
||||
|
|
@ -16,16 +16,16 @@
|
|||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../',
|
||||
'aliases' => array(),
|
||||
'reference' => 'cd72330b8f669e3dc81388be5a92171404f36fec',
|
||||
'reference' => '0bed61f949bc7a8c69cd154919e78b704e28c99e',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'icewind/smb' => array(
|
||||
'pretty_version' => 'v3.5.1',
|
||||
'version' => '3.5.1.0',
|
||||
'pretty_version' => 'v3.5.2',
|
||||
'version' => '3.5.2.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../icewind/smb',
|
||||
'aliases' => array(),
|
||||
'reference' => 'c1ce4fbb2ff1786846d9d0b3850b395ca94cf563',
|
||||
'reference' => '0a425bd21acf7ae112b135dca34640e1b1a825c3',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'icewind/streams' => array(
|
||||
|
|
|
|||
|
|
@ -31,35 +31,65 @@ class KerberosApacheAuth extends KerberosAuth implements IAuth {
|
|||
/** @var string */
|
||||
private $ticketPath = "";
|
||||
|
||||
// only working with specific library (mod_auth_kerb, krb5, smbclient) versions
|
||||
/** @var bool */
|
||||
private $saveTicketInMemory = false;
|
||||
|
||||
/** @var bool */
|
||||
private $init = false;
|
||||
|
||||
/** @var string|false */
|
||||
private $ticketName;
|
||||
|
||||
public function __construct() {
|
||||
$this->ticketName = getenv("KRB5CCNAME");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param bool $saveTicketInMemory
|
||||
* Copy the ticket to a temporary location and use that ticket for authentication
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(bool $saveTicketInMemory = false) {
|
||||
$this->saveTicketInMemory = $saveTicketInMemory;
|
||||
public function copyTicket(): void {
|
||||
if (!$this->checkTicket()) {
|
||||
return;
|
||||
}
|
||||
$krb5 = new \KRB5CCache();
|
||||
$krb5->open($this->ticketName);
|
||||
$tmpFilename = tempnam("/tmp", "krb5cc_php_");
|
||||
$tmpCacheFile = "FILE:" . $tmpFilename;
|
||||
$krb5->save($tmpCacheFile);
|
||||
$this->ticketPath = $tmpFilename;
|
||||
$this->ticketName = $tmpCacheFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pass the ticket to smbclient by memory instead of path
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function passTicketFromMemory(): void {
|
||||
if (!$this->checkTicket()) {
|
||||
return;
|
||||
}
|
||||
$krb5 = new \KRB5CCache();
|
||||
$krb5->open($this->ticketName);
|
||||
$this->ticketName = (string)$krb5->getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a valid kerberos ticket is present
|
||||
*
|
||||
* @return bool
|
||||
* @psalm-assert-if-true string $this->ticketName
|
||||
*/
|
||||
public function checkTicket(): bool {
|
||||
//read apache kerberos ticket cache
|
||||
$cacheFile = getenv("KRB5CCNAME");
|
||||
if (!$cacheFile) {
|
||||
if (!$this->ticketName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$krb5 = new \KRB5CCache();
|
||||
$krb5->open($cacheFile);
|
||||
return (bool)$krb5->isValid();
|
||||
$krb5->open($this->ticketName);
|
||||
/** @psalm-suppress MixedArgument */
|
||||
return count($krb5->getEntries()) > 0;
|
||||
}
|
||||
|
||||
private function init(): void {
|
||||
|
|
@ -75,28 +105,13 @@ class KerberosApacheAuth extends KerberosAuth implements IAuth {
|
|||
}
|
||||
|
||||
//read apache kerberos ticket cache
|
||||
$cacheFile = getenv("KRB5CCNAME");
|
||||
if (!$cacheFile) {
|
||||
if (!$this->checkTicket()) {
|
||||
throw new Exception('No kerberos ticket cache environment variable (KRB5CCNAME) found.');
|
||||
}
|
||||
|
||||
$krb5 = new \KRB5CCache();
|
||||
$krb5->open($cacheFile);
|
||||
if (!$krb5->isValid()) {
|
||||
throw new Exception('Kerberos ticket cache is not valid.');
|
||||
}
|
||||
|
||||
|
||||
if ($this->saveTicketInMemory) {
|
||||
putenv("KRB5CCNAME=" . (string)$krb5->getName());
|
||||
} else {
|
||||
//workaround: smbclient is not working with the original apache ticket cache.
|
||||
$tmpFilename = tempnam("/tmp", "krb5cc_php_");
|
||||
$tmpCacheFile = "FILE:" . $tmpFilename;
|
||||
$krb5->save($tmpCacheFile);
|
||||
$this->ticketPath = $tmpFilename;
|
||||
putenv("KRB5CCNAME=" . $tmpCacheFile);
|
||||
}
|
||||
// note that even if the ticketname is the value we got from `getenv("KRB5CCNAME")` we still need to set the env variable ourselves
|
||||
// this is because `getenv` also reads the variables passed from the SAPI (apache-php) and we need to set the variable in the OS's env
|
||||
putenv("KRB5CCNAME=" . $this->ticketName);
|
||||
}
|
||||
|
||||
public function getExtraCommandLineArguments(): string {
|
||||
|
|
@ -106,7 +121,11 @@ class KerberosApacheAuth extends KerberosAuth implements IAuth {
|
|||
|
||||
public function setExtraSmbClientOptions($smbClientState): void {
|
||||
$this->init();
|
||||
parent::setExtraSmbClientOptions($smbClientState);
|
||||
try {
|
||||
parent::setExtraSmbClientOptions($smbClientState);
|
||||
} catch (Exception $e) {
|
||||
// suppress
|
||||
}
|
||||
}
|
||||
|
||||
public function __destruct() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue