Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SMB-with OC-login not working in 8.10 #17480

Closed
htwsaaraub opened this issue Jul 8, 2015 · 13 comments · Fixed by #18473
Closed

SMB-with OC-login not working in 8.10 #17480

htwsaaraub opened this issue Jul 8, 2015 · 13 comments · Fixed by #18473

Comments

@htwsaaraub
Copy link

Hi,

System Information: Debian 8.1
uname -a
Linux aub-cloud 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt11-1 (2015-05-24) x86_64 GNU/Linux

We are using owncloud as a frontend for our internal Windows Servers. When a user logs in, owncloud automaticaly connect the Shares set in the admin panel with the OC-Login. The users authenticate with there Microsoft Active-Directory Account.

Till Version 8.04 I could do this by adding our domain in the Script smb_oc.php

public function __construct($params) {
        if (isset($params['host']) && \OC::$server->getSession()->exists('smb-credentials')) {
            $host=$params['host'];
            $this->username_as_share = ($params['username_as_share'] === 'true');

            $params_auth = json_decode(\OC::$server->getCrypto()->decrypt(\OC::$server->getSession()->get('smb-credentials')), true);

            $domain = "ourdomain.local\\";
            $user = \OC::$server->getSession()->get('loginname');
            $userincldomain = $domain . $user;
            $password = $params_auth['password'];

            $root=isset($params['root'])?$params['root']:'/';
            $share = '';

            if ($this->username_as_share) {
                $share = '/'.$user;
            } elseif (isset($params['share'])) {
                $share = $params['share'];
            } else {
                throw new \Exception();
            }
            parent::__construct(array(
                "user" => $userincldomain,
                "password" => $password,
                "host" => $host,
                "share" => $share,
                "root" => $root
            ));
        } else {
            throw new \Exception();
        }
    }

Till 8.04 the App files_external use smb4php to connect to smb shares.
In owncloud 8.1 the App files_external now use icewind to connect to smb shares.
I tried to edit the smb_oc in the same way.

public function __construct($params) {
        if (isset($params['host'])) {
            $host = $params['host'];
            $this->username_as_share = ($params['username_as_share'] === 'true');

            // dummy credentials, unused, to satisfy constructor
            $user = 'foo';
            $password = 'bar';
            if (\OC::$server->getSession()->exists('smb-credentials')) {
                $params_auth = json_decode(\OC::$server->getCrypto()->decrypt(\OC::$server->getSession()->get('smb-credentials')), true);
                $domain = "ourdomain.local\\";
                $user = \OC::$server->getSession()->get('loginname');
                $userincldomain = $domain . $user;
                $password = $params_auth['password'];
            } else {
                // assume we are testing from the admin section
            }

            $root = isset($params['root']) ? $params['root'] : '/';
            $share = '';

            if ($this->username_as_share) {
                $share = '/' . $user;
            } elseif (isset($params['share'])) {
                $share = $params['share'];
            } else {
                throw new \Exception();
            }
            parent::__construct(array(
                "user" => $userincldomain,
                "password" => $password,
                "host" => $host,
                "share" => $share,
                "root" => $root
            ));
        } else {
            throw new \Exception();
        }
    }

Login with this script gives heavy load on the apache process and many processes from smbclient

in Top for each mounted share one process is displayed.

smbclient -authentication-file=/proc/self/fd/3 //IP-to-smb-server-Share

Can't someone add a input field "domain" to the admin panel for external_files and add some stuff to the scripts? That would be great.

@RobinMcCorkell
Copy link
Member

ref #13407

@jospoortvliet
Copy link

@icewind1991 your thing?

@PVince81
Copy link
Contributor

PVince81 commented Jul 9, 2015

Duplicate of #17499 ?

@htwsaaraub
Copy link
Author

Today I tested the authentication with smb-oc on our backup-server.

When you join the machine with the ads domain and configure the system to also use winbind, the smbclient command, which comes from owncloud, also works without adding the domain to the user.

I followed this tutorial to bind the machine to our ads domain: http://wiki.ubuntuusers.de/samba_winbind

The smbclient command keeps running a while after the first connect to the shares but stops after about a minute. The performace in owncloud browsing external smb shares is great. There must be a performance improvement in 8.1 for external_files.

I keep testing for permance issues and if it's running well I also join our live server to the ads domain.
No script hacks necessary any more. Keeps the upgrade process much more simple.

@htwsaaraub
Copy link
Author

I Also joined our live Server to our ads domain. The Users login to our owncloud instance, connecting with there OC-Login, can see the external shares without changeing domain or chanching code in a script. The Shares are mapped automatic after login.

The Point is: Since 8.10 the smbclient process eats about 70% CPU performance with only one user logged in. There is one process starting for each Share.

smbclient --authentication-file=/proc/self/fd3 //IP-of-SMB-Server/Share
smbclient: Version 4.1.17-Debian

The process stops when the User log out.

Here is the owncloud.log

{"reqId":"UTjZ5qQPTaYIyYCLJlv1","remoteAddr":"134.96.211.82","app":"index","message":"Exception: {\"Exception\":\"Icewind\SMB\Exception\NotFoundException\",\"Message\":\"Invalid request for /GDE 2015/\u00dc1/Michelle Wei\u00df\",\"Code\":0,\"Trace\":\"
n#0 /var/www/owncloud-test/apps/files_external/3rdparty/icewind/smb/src/Share.php(365): Icewind\SMB\Parser->checkForError(Array, '/GDE 2015/\xC3\x9C1/M...')\
n#1 /var/www/owncloud-test/apps/files_external/3rdparty/icewind/smb/src/Share.php(109): Icewind\SMB\Share->parseOutput(Array, '/GDE 2015/\xC3\x9C1/M...')\
n#2 /var/www/owncloud-test/apps/files_external/lib/smb.php(110): Icewind\SMB\Share->dir('/GDE 2015/\xC3\x9C1/M...')\
n#3 /var/www/owncloud-test/apps/files_external/lib/smb.php(259): OC\Files\Storage\SMB->getFolderContents('GDE 2015/\xC3\x9C1/Mi...')\
n#4 /var/www/owncloud-test/lib/private/files/storage/wrapper/wrapper.php(88): OC\Files\Storage\SMB->opendir('GDE 2015/\xC3\x9C1/Mi...')\
n#5 /var/www/owncloud-test/lib/private/files/storage/wrapper/wrapper.php(88): OC\Files\Storage\Wrapper\Wrapper->opendir('GDE 2015/\xC3\x9C1/Mi...')\
n#6 /var/www/owncloud-test/lib/private/files/cache/scanner.php(299): OC\Files\Storage\Wrapper\Wrapper->opendir('GDE 2015/\xC3\x9C1/Mi...')\
n#7 /var/www/owncloud-test/lib/private/files/cache/scanner.php(334): OC\Files\Cache\Scanner->getNewChildren('GDE 2015/\xC3\x9C1/Mi...')\
n#8 /var/www/owncloud-test/lib/private/files/cache/scanner.php(384): OC\Files\Cache\Scanner->scanChildren('GDE 2015/\xC3\x9C1/Mi...', true, 1, Array, true)\
n#9 /var/www/owncloud-test/lib/private/files/cache/scanner.php(384): OC\Files\Cache\Scanner->scanChildren('GDE 2015/\xC3\x9C1', true, 1, Array, true)\
n#10 /var/www/owncloud-test/lib/private/files/cache/scanner.php(384): OC\Files\Cache\Scanner->scanChildren('GDE 2015', true, 1, Array, true)\
n#11 /var/www/owncloud-test/lib/private/files/cache/scanner.php(267): OC\Files\Cache\Scanner->scanChildren('', true, 1, Array, true)\
n#12 /var/www/owncloud-test/lib/private/files/cache/scanner.php(419): OC\Files\Cache\Scanner->scan('', true, 1)\
n#13 /var/www/owncloud-test/lib/private/files/utils/scanner.php(125): OC\Files\Cache\Scanner->backgroundScan()\
n#14 /var/www/owncloud-test/apps/files/ajax/scan.php(55): OC\Files\Utils\Scanner->backgroundScan('')\
n#15 /var/www/owncloud-test/lib/private/route/route.php(154) : runtime-created function(1): require_once('/var/www/ownclo...')\
n#16 [internal function]: __lambda_func(Array)\
n#17 /var/www/owncloud-test/lib/private/route/router.php(274): call_user_func('\x00lambda_11', Array)\
n#18 /var/www/owncloud-test/lib/base.php(867): OC\Route\Router->match('/apps/files/aja...')\
n#19 /var/www/owncloud-test/index.php(40): OC::handleRequest()\
n#20 {main}\",\"File\":\"/var/www/owncloud-test/apps/files_external/3rdparty/icewind/smb/src/Parser.php\",\"Line\":49}","level":4,"time":"2015-07-14T08:32:20+00:00"}
``

@jospoortvliet
Copy link

@htwsaaraub see #17499 (comment) - could you see if your issue is the same and provide the test results @icewind1991 is looking for? tnx

@htwsaaraub
Copy link
Author

sudo git clone https://github.com/icewind1991/SMB
cd SMB
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
sudo composer install
sudo vi tests/config.json
sudo apt-get install phpunit
cd tests
sudo phpunit

Configuration read from /home/sven.schneider/SMB/tests/phpunit.xml

SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS 63 / 300 ( 21%)
SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS 126 / 300 ( 42%)
SSSSSSSSSSSSSSSSSSSS...........S............................... 189 / 300 ( 63%)
....................................................F.......... 252 / 300 ( 84%)
................................................

Time: 34.2 seconds, Memory: 9.25Mb

There was 1 failure:

  1. Icewind\SMB\Test\Share::testModifiedDate
    Modified time differs by 543 seconds
    Failed asserting that false is true.

/home/sven.schneider/SMB/tests/AbstractShare.php:334

FAILURES!
Tests: 300, Assertions: 426, Failures: 1, Skipped: 147.

@jospoortvliet
Copy link

@icewind1991 see above. that what you were looking for?

@icewind1991
Copy link
Contributor

Those results look good

@htwsaaraub what is the config used (excluding password ofc)

@htwsaaraub
Copy link
Author

{
        "host": "172.17.8.2",
        "user": "Sven.Schneider",
        "password": "",
        "share": "Tausch",
        "root": "/"
}

@htwsaaraub
Copy link
Author

Today I installed the latest libsmbclient from github on our Testserver.
After the Installation I restarted apache and cleared the oc_filecache table to make sure there is no false result.
When I logged in the first time the shares take a time to get connected. After a few seconds the shares are present and the directories can be accessed. On a htop command there is no more smbclient workload, only the apache2 process. The second time I logged in and accessing the share the Listing was faster due to the oc_filecache.
The problem is solved. For our production server I wait for the next Version and keep testing bevor I upgrade.

@htwsaaraub
Copy link
Author

Can someone confirm owncloud 8.0X with installed and activated libsmbclient from github working fine?
In 8.0 there is a different files_external component than 8.1.

@DeepDiver1975 DeepDiver1975 added this to the 8.2-current milestone Aug 21, 2015
@DeepDiver1975
Copy link
Member

@icewind1991 fixed? need more info? THX

@lock lock bot locked as resolved and limited conversation to collaborators Aug 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants