mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-03 17:24:07 +02:00
code style
This commit is contained in:
parent
e5340170a8
commit
306ec135c8
3 changed files with 45 additions and 30 deletions
46
.github/workflows/ci.yaml
vendored
46
.github/workflows/ci.yaml
vendored
|
|
@ -18,23 +18,6 @@ jobs:
|
||||||
with:
|
with:
|
||||||
args: --diff --dry-run --allow-risky yes --stop-on-violation --using-cache=no --path-mode=intersection
|
args: --diff --dry-run --allow-risky yes --stop-on-violation --using-cache=no --path-mode=intersection
|
||||||
|
|
||||||
phpstan:
|
|
||||||
name: PHPStan Static Analysis
|
|
||||||
runs-on: ubuntu-20.04
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Setup PHP
|
|
||||||
uses: shivammathur/setup-php@v2
|
|
||||||
with:
|
|
||||||
php-version: '8.0'
|
|
||||||
extensions: apcu, smbclient
|
|
||||||
- name: Composer
|
|
||||||
run: composer install
|
|
||||||
- env:
|
|
||||||
BACKEND: smbclient
|
|
||||||
run: php ./vendor/bin/phpstan analyse --level 6 src
|
|
||||||
|
|
||||||
php-versions:
|
php-versions:
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
name: Unit tests
|
name: Unit tests
|
||||||
|
|
@ -200,6 +183,8 @@ jobs:
|
||||||
- "8.0"
|
- "8.0"
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- name: krb5-dev
|
||||||
|
run: sudo apt-get install -y libkrb5-dev
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@master
|
uses: actions/checkout@master
|
||||||
- name: Set up php
|
- name: Set up php
|
||||||
|
|
@ -208,8 +193,31 @@ jobs:
|
||||||
php-version: "${{ matrix.php-version }}"
|
php-version: "${{ matrix.php-version }}"
|
||||||
tools: composer:v1
|
tools: composer:v1
|
||||||
coverage: none
|
coverage: none
|
||||||
extensions: apcu, smbclient
|
extensions: apcu, smbclient, krb5
|
||||||
|
env:
|
||||||
|
fail-fast: true
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: composer i
|
run: composer i
|
||||||
- name: Run coding standards check
|
- name: Run coding standards check
|
||||||
run: composer run psalm
|
run: composer run psalm
|
||||||
|
|
||||||
|
phpstan:
|
||||||
|
name: PHPStan Static Analysis
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: krb5-dev
|
||||||
|
run: sudo apt-get install -y libkrb5-dev
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Setup PHP
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: '8.0'
|
||||||
|
extensions: apcu, smbclient, krb5
|
||||||
|
env:
|
||||||
|
fail-fast: true
|
||||||
|
- name: Composer
|
||||||
|
run: composer install
|
||||||
|
- env:
|
||||||
|
BACKEND: smbclient
|
||||||
|
run: php ./vendor/bin/phpstan analyse --level 6 src
|
||||||
|
|
@ -28,22 +28,25 @@ use Icewind\SMB\Exception\Exception;
|
||||||
* Use existing kerberos ticket to authenticate and reuse the apache ticket cache (mod_auth_kerb)
|
* Use existing kerberos ticket to authenticate and reuse the apache ticket cache (mod_auth_kerb)
|
||||||
*/
|
*/
|
||||||
class KerberosApacheAuth extends KerberosAuth implements IAuth {
|
class KerberosApacheAuth extends KerberosAuth implements IAuth {
|
||||||
|
/** @var string */
|
||||||
private $ticketPath = "";
|
private $ticketPath = "";
|
||||||
|
|
||||||
//only working with specific library (mod_auth_kerb, krb5, smbclient) versions
|
// only working with specific library (mod_auth_kerb, krb5, smbclient) versions
|
||||||
|
/** @var bool */
|
||||||
private $saveTicketInMemory = false;
|
private $saveTicketInMemory = false;
|
||||||
|
|
||||||
public function __construct($saveTicketInMemory = false) {
|
/**
|
||||||
|
* @param bool $saveTicketInMemory
|
||||||
|
*/
|
||||||
|
public function __construct(bool $saveTicketInMemory = false) {
|
||||||
$this->saveTicketInMemory = $saveTicketInMemory;
|
$this->saveTicketInMemory = $saveTicketInMemory;
|
||||||
$this->registerApacheKerberosTicket();
|
$this->registerApacheKerberosTicket();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function registerApacheKerberosTicket() {
|
private function registerApacheKerberosTicket(): void {
|
||||||
|
|
||||||
// inspired by https://git.typo3.org/TYPO3CMS/Extensions/fal_cifs.git
|
// inspired by https://git.typo3.org/TYPO3CMS/Extensions/fal_cifs.git
|
||||||
|
|
||||||
if (!extension_loaded("krb5")) {
|
if (!extension_loaded("krb5")) {
|
||||||
|
|
||||||
// https://pecl.php.net/package/krb5
|
// https://pecl.php.net/package/krb5
|
||||||
throw new DependencyException('Ensure php-krb5 is installed.');
|
throw new DependencyException('Ensure php-krb5 is installed.');
|
||||||
}
|
}
|
||||||
|
|
@ -62,7 +65,7 @@ class KerberosApacheAuth extends KerberosAuth implements IAuth {
|
||||||
|
|
||||||
|
|
||||||
if ($this->saveTicketInMemory) {
|
if ($this->saveTicketInMemory) {
|
||||||
putenv("KRB5CCNAME=" . $krb5->getName());
|
putenv("KRB5CCNAME=" . (string)$krb5->getName());
|
||||||
} else {
|
} else {
|
||||||
//workaround: smbclient is not working with the original apache ticket cache.
|
//workaround: smbclient is not working with the original apache ticket cache.
|
||||||
$tmpFilename = tempnam("/tmp", "krb5cc_php_");
|
$tmpFilename = tempnam("/tmp", "krb5cc_php_");
|
||||||
|
|
|
||||||
|
|
@ -38,9 +38,13 @@ class NativeState {
|
||||||
/** @var bool */
|
/** @var bool */
|
||||||
protected $connected = false;
|
protected $connected = false;
|
||||||
|
|
||||||
// sync the garbage collection cycle
|
/**
|
||||||
// __deconstruct() of KerberosAuth should not called too soon
|
* sync the garbage collection cycle
|
||||||
protected $auth;
|
* __deconstruct() of KerberosAuth should not called too soon
|
||||||
|
*
|
||||||
|
* @var IAuth|null $auth
|
||||||
|
*/
|
||||||
|
protected $auth = null;
|
||||||
|
|
||||||
// see error.h
|
// see error.h
|
||||||
const EXCEPTION_MAP = [
|
const EXCEPTION_MAP = [
|
||||||
|
|
@ -111,12 +115,12 @@ class NativeState {
|
||||||
}
|
}
|
||||||
|
|
||||||
$auth->setExtraSmbClientOptions($this->state);
|
$auth->setExtraSmbClientOptions($this->state);
|
||||||
/** @var bool $result */
|
|
||||||
|
|
||||||
// sync the garbage collection cycle
|
// sync the garbage collection cycle
|
||||||
// __deconstruct() of KerberosAuth should not called too soon
|
// __deconstruct() of KerberosAuth should not caled too soon
|
||||||
$this->auth = $auth;
|
$this->auth = $auth;
|
||||||
|
|
||||||
|
/** @var bool $result */
|
||||||
$result = @smbclient_state_init($this->state, $auth->getWorkgroup(), $auth->getUsername(), $auth->getPassword());
|
$result = @smbclient_state_init($this->state, $auth->getWorkgroup(), $auth->getUsername(), $auth->getPassword());
|
||||||
|
|
||||||
$this->testResult($result, '');
|
$this->testResult($result, '');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue