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
e8df1df9a2
commit
93b1f14b5d
2 changed files with 12 additions and 24 deletions
|
|
@ -24,22 +24,18 @@ namespace Icewind\SMB;
|
||||||
use Icewind\SMB\Exception\DependencyException;
|
use Icewind\SMB\Exception\DependencyException;
|
||||||
use Icewind\SMB\Exception\Exception;
|
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 {
|
||||||
|
|
||||||
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
|
||||||
private $saveTicketInMemory = false;
|
private $saveTicketInMemory = false;
|
||||||
|
|
||||||
public function __construct($saveTicketInMemory = false) {
|
public function __construct($saveTicketInMemory = false) {
|
||||||
|
|
||||||
$this->saveTicketInMemory = $saveTicketInMemory;
|
$this->saveTicketInMemory = $saveTicketInMemory;
|
||||||
$this->registerApacheKerberosTicket();
|
$this->registerApacheKerberosTicket();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function registerApacheKerberosTicket() {
|
private function registerApacheKerberosTicket() {
|
||||||
|
|
@ -55,9 +51,7 @@ class KerberosApacheAuth extends KerberosAuth implements IAuth {
|
||||||
//read apache kerberos ticket cache
|
//read apache kerberos ticket cache
|
||||||
$cacheFile = getenv("KRB5CCNAME");
|
$cacheFile = getenv("KRB5CCNAME");
|
||||||
if (!$cacheFile) {
|
if (!$cacheFile) {
|
||||||
|
|
||||||
throw new Exception('No kerberos ticket cache environment variable (KRB5CCNAME) found.');
|
throw new Exception('No kerberos ticket cache environment variable (KRB5CCNAME) found.');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$krb5 = new \KRB5CCache();
|
$krb5 = new \KRB5CCache();
|
||||||
|
|
@ -69,8 +63,7 @@ class KerberosApacheAuth extends KerberosAuth implements IAuth {
|
||||||
|
|
||||||
if ($this->saveTicketInMemory) {
|
if ($this->saveTicketInMemory) {
|
||||||
putenv("KRB5CCNAME=" . $krb5->getName());
|
putenv("KRB5CCNAME=" . $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_");
|
||||||
$tmpCacheFile = "FILE:" . $tmpFilename;
|
$tmpCacheFile = "FILE:" . $tmpFilename;
|
||||||
|
|
@ -78,17 +71,12 @@ class KerberosApacheAuth extends KerberosAuth implements IAuth {
|
||||||
$this->ticketPath = $tmpFilename;
|
$this->ticketPath = $tmpFilename;
|
||||||
putenv("KRB5CCNAME=" . $tmpCacheFile);
|
putenv("KRB5CCNAME=" . $tmpCacheFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function __destruct() {
|
public function __destruct() {
|
||||||
|
|
||||||
if (!empty($this->ticketPath) && file_exists($this->ticketPath) && is_file($this->ticketPath)) {
|
if (!empty($this->ticketPath) && file_exists($this->ticketPath) && is_file($this->ticketPath)) {
|
||||||
|
|
||||||
unlink($this->ticketPath);
|
unlink($this->ticketPath);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue