adding space between) and {
This commit is contained in:
10
lib/ftp.php
10
lib/ftp.php
@@ -11,11 +11,11 @@ class OC_User_FTP extends OC_User_Backend{
|
|||||||
private $secure;
|
private $secure;
|
||||||
private $protocol;
|
private $protocol;
|
||||||
|
|
||||||
public function __construct($host,$secure=false){
|
public function __construct($host,$secure=false) {
|
||||||
$this->host=$host;
|
$this->host=$host;
|
||||||
$this->secure=$secure;
|
$this->secure=$secure;
|
||||||
$this->protocol='ftp';
|
$this->protocol='ftp';
|
||||||
if($this->secure){
|
if($this->secure) {
|
||||||
$this->protocol.='s';
|
$this->protocol.='s';
|
||||||
}
|
}
|
||||||
$this->protocol.='://';
|
$this->protocol.='://';
|
||||||
@@ -29,17 +29,17 @@ class OC_User_FTP extends OC_User_Backend{
|
|||||||
*
|
*
|
||||||
* Check if the password is correct without logging in the user
|
* Check if the password is correct without logging in the user
|
||||||
*/
|
*/
|
||||||
public function checkPassword($uid, $password){
|
public function checkPassword($uid, $password) {
|
||||||
$url=$this->protocol.$uid.':'.$password.'@'.$this->host.'/';
|
$url=$this->protocol.$uid.':'.$password.'@'.$this->host.'/';
|
||||||
$result=@opendir($url);
|
$result=@opendir($url);
|
||||||
if(is_resource($result)){
|
if(is_resource($result)) {
|
||||||
return $uid;
|
return $uid;
|
||||||
}else{
|
}else{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function userExists($uid){
|
public function userExists($uid) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
class OC_User_IMAP extends OC_User_Backend{
|
class OC_User_IMAP extends OC_User_Backend{
|
||||||
private $mailbox;
|
private $mailbox;
|
||||||
|
|
||||||
public function __construct($mailbox){
|
public function __construct($mailbox) {
|
||||||
$this->mailbox=$mailbox;
|
$this->mailbox=$mailbox;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -21,11 +21,11 @@ class OC_User_IMAP extends OC_User_Backend{
|
|||||||
*
|
*
|
||||||
* Check if the password is correct without logging in the user
|
* Check if the password is correct without logging in the user
|
||||||
*/
|
*/
|
||||||
public function checkPassword($uid, $password){
|
public function checkPassword($uid, $password) {
|
||||||
$mbox = @imap_open($this->mailbox, $uid, $password);
|
$mbox = @imap_open($this->mailbox, $uid, $password);
|
||||||
imap_errors();
|
imap_errors();
|
||||||
imap_alerts();
|
imap_alerts();
|
||||||
if($mbox){
|
if($mbox) {
|
||||||
imap_close($mbox);
|
imap_close($mbox);
|
||||||
return $uid;
|
return $uid;
|
||||||
}else{
|
}else{
|
||||||
@@ -33,7 +33,7 @@ class OC_User_IMAP extends OC_User_Backend{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function userExists($uid){
|
public function userExists($uid) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class OC_User_SMB extends OC_User_Backend{
|
|||||||
const smbclient='smbclient';
|
const smbclient='smbclient';
|
||||||
const loginError='NT_STATUS_LOGON_FAILURE';
|
const loginError='NT_STATUS_LOGON_FAILURE';
|
||||||
|
|
||||||
public function __construct($host){
|
public function __construct($host) {
|
||||||
$this->host=$host;
|
$this->host=$host;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,20 +24,20 @@ class OC_User_SMB extends OC_User_Backend{
|
|||||||
*
|
*
|
||||||
* Check if the password is correct without logging in the user
|
* Check if the password is correct without logging in the user
|
||||||
*/
|
*/
|
||||||
public function checkPassword($uid, $password){
|
public function checkPassword($uid, $password) {
|
||||||
$uidEscaped=escapeshellarg($uid);
|
$uidEscaped=escapeshellarg($uid);
|
||||||
$password=escapeshellarg($password);
|
$password=escapeshellarg($password);
|
||||||
$result=array();
|
$result=array();
|
||||||
$command=self::smbclient.' //'.$this->host.'/dummy -U'.$uidEscaped.'%'.$password;
|
$command=self::smbclient.' //'.$this->host.'/dummy -U'.$uidEscaped.'%'.$password;
|
||||||
$result=exec($command,$result);
|
$result=exec($command,$result);
|
||||||
if(substr($result,-strlen(self::loginError))==self::loginError){
|
if(substr($result,-strlen(self::loginError))==self::loginError) {
|
||||||
return false;
|
return false;
|
||||||
}else{
|
}else{
|
||||||
return $uid;
|
return $uid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function userExists($uid){
|
public function userExists($uid) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,21 +12,21 @@ class Test_User_FTP extends UnitTestCase{
|
|||||||
*/
|
*/
|
||||||
private $instance;
|
private $instance;
|
||||||
|
|
||||||
private function getConfig(){
|
private function getConfig() {
|
||||||
return include(__DIR__.'/config.php');
|
return include(__DIR__.'/config.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
function skip(){
|
function skip() {
|
||||||
$config=$this->getConfig();
|
$config=$this->getConfig();
|
||||||
$this->skipUnless($config['ftp']['run']);
|
$this->skipUnless($config['ftp']['run']);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUp(){
|
function setUp() {
|
||||||
$config=$this->getConfig();
|
$config=$this->getConfig();
|
||||||
$this->instance=new OC_User_FTP($config['ftp']['host']);
|
$this->instance=new OC_User_FTP($config['ftp']['host']);
|
||||||
}
|
}
|
||||||
|
|
||||||
function testLogin(){
|
function testLogin() {
|
||||||
$config=$this->getConfig();
|
$config=$this->getConfig();
|
||||||
$this->assertEqual($config['ftp']['user'],$this->instance->checkPassword($config['ftp']['user'],$config['ftp']['password']));
|
$this->assertEqual($config['ftp']['user'],$this->instance->checkPassword($config['ftp']['user'],$config['ftp']['password']));
|
||||||
$this->assertFalse($this->instance->checkPassword($config['ftp']['user'],$config['ftp']['password'].'foo'));
|
$this->assertFalse($this->instance->checkPassword($config['ftp']['user'],$config['ftp']['password'].'foo'));
|
||||||
|
|||||||
@@ -12,21 +12,21 @@ class Test_User_Imap extends UnitTestCase{
|
|||||||
*/
|
*/
|
||||||
private $instance;
|
private $instance;
|
||||||
|
|
||||||
private function getConfig(){
|
private function getConfig() {
|
||||||
return include(__DIR__.'/config.php');
|
return include(__DIR__.'/config.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
function skip(){
|
function skip() {
|
||||||
$config=$this->getConfig();
|
$config=$this->getConfig();
|
||||||
$this->skipUnless($config['imap']['run']);
|
$this->skipUnless($config['imap']['run']);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUp(){
|
function setUp() {
|
||||||
$config=$this->getConfig();
|
$config=$this->getConfig();
|
||||||
$this->instance=new OC_User_IMAP($config['imap']['mailbox']);
|
$this->instance=new OC_User_IMAP($config['imap']['mailbox']);
|
||||||
}
|
}
|
||||||
|
|
||||||
function testLogin(){
|
function testLogin() {
|
||||||
$config=$this->getConfig();
|
$config=$this->getConfig();
|
||||||
$this->assertEqual($config['imap']['user'],$this->instance->checkPassword($config['imap']['user'],$config['imap']['password']));
|
$this->assertEqual($config['imap']['user'],$this->instance->checkPassword($config['imap']['user'],$config['imap']['password']));
|
||||||
$this->assertFalse($this->instance->checkPassword($config['imap']['user'],$config['imap']['password'].'foo'));
|
$this->assertFalse($this->instance->checkPassword($config['imap']['user'],$config['imap']['password'].'foo'));
|
||||||
|
|||||||
@@ -12,21 +12,21 @@ class Test_User_SMB extends UnitTestCase{
|
|||||||
*/
|
*/
|
||||||
private $instance;
|
private $instance;
|
||||||
|
|
||||||
private function getConfig(){
|
private function getConfig() {
|
||||||
return include(__DIR__.'/config.php');
|
return include(__DIR__.'/config.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
function skip(){
|
function skip() {
|
||||||
$config=$this->getConfig();
|
$config=$this->getConfig();
|
||||||
$this->skipUnless($config['smb']['run']);
|
$this->skipUnless($config['smb']['run']);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUp(){
|
function setUp() {
|
||||||
$config=$this->getConfig();
|
$config=$this->getConfig();
|
||||||
$this->instance=new OC_User_SMB($config['smb']['host']);
|
$this->instance=new OC_User_SMB($config['smb']['host']);
|
||||||
}
|
}
|
||||||
|
|
||||||
function testLogin(){
|
function testLogin() {
|
||||||
$config=$this->getConfig();
|
$config=$this->getConfig();
|
||||||
$this->assertEqual($config['smb']['user'],$this->instance->checkPassword($config['smb']['user'],$config['smb']['password']));
|
$this->assertEqual($config['smb']['user'],$this->instance->checkPassword($config['smb']['user'],$config['smb']['password']));
|
||||||
$this->assertFalse($this->instance->checkPassword($config['smb']['user'],$config['smb']['password'].'foo'));
|
$this->assertFalse($this->instance->checkPassword($config['smb']['user'],$config['smb']['password'].'foo'));
|
||||||
|
|||||||
Reference in New Issue
Block a user