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:
|
||||
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:
|
||||
runs-on: ubuntu-20.04
|
||||
name: Unit tests
|
||||
|
|
@ -200,6 +183,8 @@ jobs:
|
|||
- "8.0"
|
||||
|
||||
steps:
|
||||
- name: krb5-dev
|
||||
run: sudo apt-get install -y libkrb5-dev
|
||||
- name: Checkout
|
||||
uses: actions/checkout@master
|
||||
- name: Set up php
|
||||
|
|
@ -208,8 +193,31 @@ jobs:
|
|||
php-version: "${{ matrix.php-version }}"
|
||||
tools: composer:v1
|
||||
coverage: none
|
||||
extensions: apcu, smbclient
|
||||
extensions: apcu, smbclient, krb5
|
||||
env:
|
||||
fail-fast: true
|
||||
- name: Install dependencies
|
||||
run: composer i
|
||||
- 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)
|
||||
*/
|
||||
class KerberosApacheAuth extends KerberosAuth implements IAuth {
|
||||
/** @var string */
|
||||
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;
|
||||
|
||||
public function __construct($saveTicketInMemory = false) {
|
||||
/**
|
||||
* @param bool $saveTicketInMemory
|
||||
*/
|
||||
public function __construct(bool $saveTicketInMemory = false) {
|
||||
$this->saveTicketInMemory = $saveTicketInMemory;
|
||||
$this->registerApacheKerberosTicket();
|
||||
}
|
||||
|
||||
private function registerApacheKerberosTicket() {
|
||||
|
||||
private function registerApacheKerberosTicket(): void {
|
||||
// inspired by https://git.typo3.org/TYPO3CMS/Extensions/fal_cifs.git
|
||||
|
||||
if (!extension_loaded("krb5")) {
|
||||
|
||||
// https://pecl.php.net/package/krb5
|
||||
throw new DependencyException('Ensure php-krb5 is installed.');
|
||||
}
|
||||
|
|
@ -62,7 +65,7 @@ class KerberosApacheAuth extends KerberosAuth implements IAuth {
|
|||
|
||||
|
||||
if ($this->saveTicketInMemory) {
|
||||
putenv("KRB5CCNAME=" . $krb5->getName());
|
||||
putenv("KRB5CCNAME=" . (string)$krb5->getName());
|
||||
} else {
|
||||
//workaround: smbclient is not working with the original apache ticket cache.
|
||||
$tmpFilename = tempnam("/tmp", "krb5cc_php_");
|
||||
|
|
|
|||
|
|
@ -38,9 +38,13 @@ class NativeState {
|
|||
/** @var bool */
|
||||
protected $connected = false;
|
||||
|
||||
// sync the garbage collection cycle
|
||||
// __deconstruct() of KerberosAuth should not called too soon
|
||||
protected $auth;
|
||||
/**
|
||||
* sync the garbage collection cycle
|
||||
* __deconstruct() of KerberosAuth should not called too soon
|
||||
*
|
||||
* @var IAuth|null $auth
|
||||
*/
|
||||
protected $auth = null;
|
||||
|
||||
// see error.h
|
||||
const EXCEPTION_MAP = [
|
||||
|
|
@ -111,12 +115,12 @@ class NativeState {
|
|||
}
|
||||
|
||||
$auth->setExtraSmbClientOptions($this->state);
|
||||
/** @var bool $result */
|
||||
|
||||
// sync the garbage collection cycle
|
||||
// __deconstruct() of KerberosAuth should not called too soon
|
||||
// __deconstruct() of KerberosAuth should not caled too soon
|
||||
$this->auth = $auth;
|
||||
|
||||
/** @var bool $result */
|
||||
$result = @smbclient_state_init($this->state, $auth->getWorkgroup(), $auth->getUsername(), $auth->getPassword());
|
||||
|
||||
$this->testResult($result, '');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue