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

Accept remote share on notification failed #3455

Closed
apg1980 opened this issue Feb 11, 2017 · 30 comments
Closed

Accept remote share on notification failed #3455

apg1980 opened this issue Feb 11, 2017 · 30 comments

Comments

@apg1980
Copy link

apg1980 commented Feb 11, 2017

Steps to reproduce

  1. Accept remote share on notification
  2. Failed to perform action appears
  3. Following entrys in the log:
    Error PHP Call to a member function file_exists() on null at /OWNCLOUD-DATA/opt/bitnami/apps/owncloud/htdocs/lib/private/legacy/helper.php#346 2017-02-11T08:45:52+0100
    Error PHP Argument 3 passed to OC_Helper::buildNotExistingFileNameForView() must be an instance of OC\Files\View, null given, called in /OWNCLOUD-DATA/opt/bitnami/apps/owncloud/htdocs/lib/private/legacy/helper.php on line 323 and defined at /OWNCLOUD-DATA/opt/bitnami/apps/owncloud/htdocs/lib/private/legacy/helper.php#333

Expected behaviour

Remote share should be accepted

Actual behaviour

Share is not accepted, is still appearing on notification.

Server configuration

Operating system: Linux linux 4.4.0-34-generic #53~14.04.1-Ubuntu SMP Wed Jul 27 16:56:40 UTC 2016 x86_64

Web server: Apache (apache2handler)

Database: mysql 5.6.29

PHP version: 5.6.19
Modules loaded: Core, date, ereg, libxml, openssl, pcre, sqlite3, zlib, bcmath, bz2, calendar, ctype, curl, dom, hash, fileinfo, filter, ftp, gd, gettext, gmp, SPL, iconv, session, intl, json, ldap, mbstring, mcrypt, standard, mysqlnd, mysqli, mysql, PDO, pdo_mysql, pdo_sqlite, Phar, posix, Reflection, imap, SimpleXML, soap, sockets, exif, tidy, tokenizer, xml, xmlreader, xmlrpc, xmlwriter, xsl, zip, apache2handler, redis, Zend OPcache

Nextcloud version: 11.0.1 (stable) - 11.0.1.2

Updated from an older Nextcloud/ownCloud or fresh install:

Where did you install Nextcloud from:

Signing status:

Signing status
"Integrity checker has been disabled. Integrity cannot be verified."

List of activated apps:

App list ``` Enabled: - activity: 2.4.1 - admin_audit: 1.1.0 - announcementcenter: 3.0.0 - audioplayer: 1.4.1 - bookmarks: 0.9.1 - calendar: 1.5.0 - comments: 1.1.0 - contacts: 1.5.3 - dav: 1.1.1 - direct_menu: 0.10.0 - federatedfilesharing: 1.1.1 - federation: 1.1.1 - files: 1.6.1 - files_downloadactivity: 1.0.0 - files_external: 1.1.2 - files_pdfviewer: 1.0.1 - files_reader: 0.8.4 - files_sharing: 1.1.1 - files_texteditor: 2.2 - files_trashbin: 1.1.0 - files_versions: 1.4.0 - files_videoplayer: 1.0.0 - firstrunwizard: 2.0 - gallery: 16.0.0 - issuetemplate: 0.2.0 - logreader: 2.0.0 - lookup_server_connector: 1.0.0 - mozilla_sync: 1 - news: 10.1.0 - nextcloud_announcements: 1.0 - notifications: 1.0.1 - ownnote: 1.08 - password_policy: 1.1.0 - previewgenerator: 1.0.1 - provisioning_api: 1.1.0 - rainloop: 4.27 - serverinfo: 1.1.1 - sharebymail: 1.0.1 - survey_client: 0.1.5 - systemtags: 1.1.3 - tasks: 0.9.4 - templateeditor: 0.2 - theming: 1.1.1 - twofactor_backupcodes: 1.0.0 - updatenotification: 1.1.1 - user_ldap: 1.1.1 - workflowengine: 1.1.1

Disabled:

  • documents
  • encryption
  • external
  • files_accesscontrol
  • files_automatedtagging
  • files_retention
  • keeweb
  • nextant
  • passwords
  • user_external
  • user_saml
</details>

**The content of config/config.php:**
<details>
	<summary>Config report</summary>

{
"instanceid": "oca32fe9a93f",
"trusted_domains": [
"127.0.0.1",
"10.10.20.22",
"cloud.xxxx.de",
"cloud.xxxx24.de"
],
"datadirectory": "/OWNCLOUD-DATA/opt/data",
"tempdirectory": "/OWNCLOUD-DATA/opt/tmp/nextcloud",
"dbtype": "mysql",
"version": "11.0.1.2",
"dbname": "bitnami_owncloud",
"dbhost": "127.0.0.1",
"dbtableprefix": "oc_",
"dbuser": "REMOVED SENSITIVE VALUE",
"dbpassword": "REMOVED SENSITIVE VALUE",
"installed": true,
"log_authfailip": false,
"cron_log": true,
"check_for_working_webdav": false,
"check_for_working_htaccess": false,
"appcodechecker": false,
"updatechecker": true,
"appstoreenabled": true,
"appstore.experimental.enabled": true,
"knowledgebaseenabled": true,
"loglevel": 2,
"asset-pipeline.enabled": false,
"mail_smtpmode": "smtp",
"mail_smtphost": "xxxxxxxx",
"mail_smtpport": "4425",
"mail_from_address": "owncloud",
"mail_domain": "cloud.xxxd.de",
"mail_smtpdebug": false,
"theme": "",
"maintenance": false,
"preview_libreoffice_path": "/usr/bin/libreoffice",
"ldapIgnoreNamingRules": false,
"logtimezone": "Europe/Berlin",
"log_rotate_size": 902400,
"forcessl": false,
"secret": "REMOVED SENSITIVE VALUE",
"xframe_restriction": false,
"allow_user_to_change_display_name": false,
"memcache.local": "\OC\Memcache\Redis",
"filelocking.enabled": "false",
"memcache.distributed": "\OC\Memcache\Redis",
"memcache.locking": "\OC\Memcache\Redis",
"redis": {
"host": "/var/run/redis/redis.sock",
"port": 0,
"timeout": 0,
"dbindex": 0
},
"trashbin_retention_obligation": "auto, 30",
"defaultapp": "files",
"activity_expire_days": 30,
"enable_previews": true,
"lost_password_link": "https://mail.xxxxd.de/ecp/?rfr=owa&p=PersonalSettings/Password.aspx",
"versions_retention_obligation": "auto, 30",
"htaccess.RewriteBase": "/",
"ldapProviderFactory": "\OCA\User_LDAP\LDAPProviderFactory",
"auth.bruteforce.protection.enabled": false,
"token_auth_enforced": false,
"integrity.check.disabled": true
}

</details>

**Are you using external storage, if yes which one:** Array
(
    [0] => \OC\Files\Storage\Local
    [1] => \OCA\Files_External\Lib\Storage\FTP
    [2] => \OC\Files\Storage\DAV
    [3] => \OCA\Files_External\Lib\Storage\OwnCloud
    [4] => \OCA\Files_External\Lib\Storage\SFTP
    [5] => \OCA\Files_External\Lib\Storage\AmazonS3
    [6] => \OCA\Files_External\Lib\Storage\Dropbox
    [7] => \OCA\Files_External\Lib\Storage\Google
    [8] => \OCA\Files_External\Lib\Storage\Swift
    [9] => \OCA\Files_External\Lib\Storage\SFTP
    [10] => \OCA\Files_External\Lib\Storage\SMB
    [11] => \OCA\Files_External\Lib\Storage\SMB
)


**Are you using encryption:** no

**Are you using an external user-backend, if yes which one:** LDAP/ActiveDirectory/Webdav/...

#### LDAP configuration (delete this part if not used)
<details>
	<summary>LDAP config</summary>

	```
	With access to your command line run e.g.:
	sudo -u www-data php occ ldap:show-config
	from within your Nextcloud installation folder

	Without access to your command line download the data/owncloud.db to your local
	computer or access your SQL server remotely and run the select query:
	SELECT * FROM `oc_appconfig` WHERE `appid` = 'user_ldap';


	Eventually replace sensitive data as the name/IP-address of your LDAP server or groups.
	```
</details>
### Client configuration
**Browser:** Mozilla/5.0 (Windows NT 10.0; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0

**Operating system:**

### Logs
#### Web server error log
<details>
	<summary>Web server error log</summary>
	```
	Insert your webserver log here
	```
</details>

#### Nextcloud log (data/nextcloud.log)
<details>
	<summary>Nextcloud log</summary>
	```
	Insert your Nextcloud log here
	```
</details>

#### Browser log
<details>
	<summary>Browser log</summary>
	```
	Insert your browser log here, this could for example include:

	a) The javascript console log
	b) The network log
	c) ...
	```
</details>
@MorrisJobke
Copy link
Member

cc @nickvergessen @schiessle

@coderobe
Copy link

coderobe commented Feb 16, 2017

This bug seems to occur when a previously remotely unshared remote share is reshared to you

@mattronix
Copy link

mattronix commented Mar 1, 2017

We at weho.st have the same issue what we have noticed accepting shares gives us similar errors when we try to accept shares.

Here are the errors we get:

"Argument 3 passed to OC_Helper::buildNotExistingFileNameForView() must be an instance of OC\Files\View, null given, called in /var/www/nextcloud/lib/private/legacy/helper.php on line 323 and defined at /var/www/nextcloud/lib/private/legacy/helper.php#333"

Call to a member function file_exists() on null at /var/www/nextcloud/lib/private/legacy/helper.php#346

Comments starting with '#' are deprecated in Unknown on line 1 at Unknown#0

On a test server with identical settings and PHP we do not have this issue or these errors another interesting thing from the server that cannot accept shares it can still share with other servers with no issue.

Let me know if i can give any useful information or test anything :)

Expected behaviour

Remote share should be accepted

Actual behaviour

Share is not accepted, is still appearing on notification.

Server configuration

Operating system: Linux 3.13.0 BrandZ virtual linux x86_64 GNU/Linux (Debian Container)

Web server: Ngnix

Database: mysql 5.6.22

PHP version: 5.6.30-0+deb8u1

[PHP Modules]
apc
apcu
bcmath
bz2
calendar
Core
ctype
curl
date
dba
dom
ereg
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
json
ldap
libxml
mbstring
mcrypt
mhash
mysql
mysqli
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
posix
readline
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlwriter
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache

Nextcloud version: 11.0.2 (stable) - 11.0.2

Updated from an older Nextcloud/ownCloud or fresh install:

Where did you install Nextcloud from:

@mattronix
Copy link

@coderobe i seem to have it with new or unshared/reshared files.

@mattronix
Copy link

Another interesting note it seems like link sharing no longer works on the top level directory but it does work on sub directories for shares i tried to federate and unshared.
screen shot 2017-03-01 at 4 39 12 pm

@nickvergessen
Copy link
Member

@schiessle and me both tested this on friday and couldn't reproduce

Maybe it's some proxy settings that are not working as expected?

@mattronix
Copy link

mattronix commented Mar 6, 2017 via email

@drycoffee
Copy link

I have the same issue and there is no proxy involved.

I dug a bit in the code and found out, that the problem is, that $view = \OC\Files\Filesystem::getView(); yields null for some reason.

I changed the function buildNotExistingFileName in lib/private/legacy/helper.php as follows:

public static function buildNotExistingFileName($path, $filename) {
                $view = \OC\Files\Filesystem::getView();
                if ($view === null) {
                 if ($pos = strrpos($filename, '.')) {
                        $name = substr($filename, 0, $pos);
                        $ext = substr($filename, $pos);
                } else {
                        $name = $filename;
                        $ext = '';
                }

                return $path . '/' . $name . '_' . time() . '_' . $ext; 
                }
                return self::buildNotExistingFileNameForView($path, $filename, $view);
        }

With this dirty hack I can accept the incoming shares without any problem, so this seems to be a bug and no networking issue.

I'm running nextcloud 11.0.2.7 on ubuntu 16.04.2 LTS with PHP 7.0.15

@Huster-at-github
Copy link

Huster-at-github commented Mar 18, 2017

I changed the function buildNotExistingFileName in lib/private/legacy/helper.php as follows:

@drycoffee 👍

Thanks, that works for me too!

Server configuration

Operating system: Linux owncloud 4.4.0-64-generic #85-Ubuntu SMP Mon Feb 20 11:50:30 UTC 2017 x86_64

Web server: Apache/2.4.18 (Ubuntu) (apache2handler)

Database: mysql 5.7.17

PHP version: 7.0.15-0ubuntu0.16.04.4
Modules loaded: Core, date, libxml, openssl, pcre, zlib, filter, hash, Reflection, SPL, session, standard, apache2handler, mysqlnd, PDO, xml, calendar, ctype, curl, dom, mbstring, fileinfo, ftp, gd, gettext, iconv, imap, intl, json, ldap, exif, mcrypt, mysqli, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, Phar, posix, readline, redis, shmop, SimpleXML, smbclient, sockets, sqlite3, sysvmsg, sysvsem, sysvshm, tokenizer, wddx, xmlreader, xmlwriter, xsl, zip, libsmbclient, Zend OPcache

Nextcloud version: 11.0.2 (stable) - 11.0.2.7

List of activated apps:

App list ``` Enabled: - activity: 2.4.1 - activitylog: 0.0.1 - admin_audit: 1.1.0 - admin_notifications: 1.0.0 - announcementcenter: 3.0.0 - apporder: 0.3.3 - audioplayer: 1.5.0-beta.4 - bookmarks: 0.9.1 - calendar: 1.5.1 - comments: 1.1.0 - contacts: 1.5.3 - dav: 1.1.1 - external: 1.2 - federatedfilesharing: 1.1.1 - federation: 1.1.1 - files: 1.6.1 - files_accesscontrol: 1.1.2 - files_automatedtagging: 1.1.1 - files_downloadactivity: 1.0.1 - files_external: 1.1.2 - files_markdown: 1.0.1 - files_pdfviewer: 1.0.1 - files_reader: 1.0.0 - files_retention: 1.0.1 - files_sharing: 1.1.1 - files_texteditor: 2.2 - files_trashbin: 1.1.0 - files_versions: 1.4.0 - files_videoplayer: 1.0.0 - firstrunwizard: 2.0 - gallery: 16.0.0 - issuetemplate: 0.2.1 - keeweb: 0.3.0 - logreader: 2.0.0 - lookup_server_connector: 1.0.0 - mail: 0.6.2 - nextcloud_announcements: 1.0 - notes: 2.2.0 - notifications: 1.0.1 - passman: 2.1.1 - password_policy: 1.1.0 - previewgenerator: 1.0.3 - provisioning_api: 1.1.0 - qownnotesapi: 17.3.0 - rainloop: 4.27.0 - serverinfo: 1.1.1 - sharebymail: 1.0.1 - spreed: 1.2.0 - spreedme: 0.3.8 - survey_client: 0.1.5 - systemtags: 1.1.3 - tasks: 0.9.5 - templateeditor: 0.2 - theming: 1.1.1 - twofactor_backupcodes: 1.0.0 - twofactor_totp: 1.1.0 - twofactor_u2f: 1.1.0 - updatenotification: 1.1.1 - weather: 1.3.5 - workflowengine: 1.1.1

@Huster-at-github
Copy link

Huster-at-github commented Mar 18, 2017

But now have this 👎

Shared file Test_Dokument FederatedSharing.odt for [email protected]:
Renamed to Test_Dokument FederatedSharing_1489841591_.odt at [email protected]:

Info	admin_audit	File accessed: "/Test_Dokument FederatedSharing_1489841591_.odt"
Debug	files_sharing	shareWith after, Myuser
Debug	files_sharing	shareWith before, Myuser
  • Folders are also renamed
  • In NC 10.0.2 everything works fine.

@dafrodo
Copy link

dafrodo commented Mar 26, 2017

Same here.
the little hack helped, federation share is working now but the name of the shared folger got extended with _145683829.
i renamed the shared folder to the original name. now seems to work fine.

anyone got an idea why the renaming?

running NC 10.0.2.7

@nickvergessen
Copy link
Member

Please update to 10.0.4

@dafrodo
Copy link

dafrodo commented Mar 26, 2017

sorry i wrote the wrong version...
i am running 11.0.2 not 10.0.2

@drycoffee
Copy link

@Huster-at-github @dafrodo

That's why I called it a hack and not a fix. My function does not address the root cause, it's just a workaround to be able to accept shares. The renaming happens on purpose, it's a security measure.

Whenever you receive a shared file or folder the server usually checks if a file with the same name already exists and renames the file if necessary.
As the bug prevents the server from checking if a file by the name already exists, I added a unix timstamp into the filename to make sure that there are no collisions with pre-existing files (actually there still could be collisions, but it is less likely with the added timestamp).

If the timestamp bothers you, you have two options:

  1. Simply rename the file back to it's original name after accepting it.

or

  1. Change the function as follows:
    public static function buildNotExistingFileName($path, $filename) { $view = \OC\Files\Filesystem::getView(); if ($view === null) { return $path . '/' . $filename; } return self::buildNotExistingFileNameForView($path, $filename, $view); }

This will prevent the renaming, however collisions may occur. If so, you can rename the received file/folder manually to resolve the collision. It may be necessary to occ file:scan to retrieve the original files.

@Huster-at-github
Copy link

@drycoffee

Thanks a lot for your explenation!

"As the bug prevents the server from checking if a file by the name already exists,"

Is there any progress on this bug?

@drycoffee
Copy link

@Huster-at-github

I don't have any more information on this than this ticket itself provides - there is nobody assigned yet, so I guess for now there's not much progress.

@runout-at
Copy link

runout-at commented Mar 29, 2017

I can confirm this bug here between 2 instances of NC 11.0.2
The workaround does partly work. I can accept the share but not access it: 'Storage is temporarily not available'. Renaming the folder does not work: 'Could not rename...'
This is also true if the folder is not renamed on accepting (workaround of the workaround like above)

For both, access and renaming i get following in the log:

Sabre\DAV\Exception\ServiceUnavailable: HTTP/1.1 503 Storage is temporarily not available
/var/lib/nextcloud/nextcloud/apps/dav/lib/Connector/Sabre/FilesPlugin.php - line 194: OCA\DAV\Connector\Sabre\ObjectTree->getNodeForPath('old_name_149080...')
[internal function] OCA\DAV\Connector\Sabre\FilesPlugin->checkMove('old_name_149080...', 'new_name')
/var/lib/nextcloud/nextcloud/3rdparty/sabre/event/lib/EventEmitterTrait.php - line 105: call_user_func_array(Array, Array)
/var/lib/nextcloud/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php - line 633: Sabre\Event\EventEmitter->emit('beforeMove', Array)
[internal function] Sabre\DAV\CorePlugin->httpMove(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response))
/var/lib/nextcloud/nextcloud/3rdparty/sabre/event/lib/EventEmitterTrait.php - line 105: call_user_func_array(Array, Array)
/var/lib/nextcloud/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 479: Sabre\Event\EventEmitter->emit('method MOVE', Array)
/var/lib/nextcloud/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 254: Sabre\DAV\Server->invokeMethod(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response))
/var/lib/nextcloud/nextcloud/apps/dav/appinfo/v1/webdav.php - line 60: Sabre\DAV\Server->exec()
/var/lib/nextcloud/nextcloud/remote.php - line 165: require_once('/var/lib/nextcl...')
{main}

@Huster-at-github
Copy link

The workaround does partly work. I can accept the share but not access it (i think) because of the renamed folder: 'Storage is temporarily not available'.

Same here.

So for read only access the hack from @drycoffee works.

@nickvergessen
Copy link
Member

Anyone willing to turn the "workaround" into a PR with descriptive reproduction steps?
Then we can have a look how to extend it.

@LEDfan
Copy link
Member

LEDfan commented Apr 2, 2017

I experienced the same problem yesterday, but for now I'm unable to reproduce it on my test instances. What happened yesterday is:

  1. I created a directory and shared with one person on another nextcloud instance
  2. Shared it with the problematic user
  3. user says he didn't receive a notification
  4. I removed the user from the share and re-shared
  5. when clicking accept on the notification, the notification disappears but nothing happens and the error is logged.

I'll re-try to reproduce this.

@ghost
Copy link

ghost commented Apr 7, 2017

This bug seems to occur when a previously remotely unshared remote share is reshared to you

It also affects files that are shared for the first time.

TypeError: Argument 3 passed to OC_Helper::buildNotExistingFileNameForView() must be an instance of OC\Files\View, null given, called in /home/www/lib/private/legacy/helper.php on line 323 at /home/www/lib/private/legacy/helper.php#333

@nickvergessen
Copy link
Member

@schiessle did we change something here for NC 11.0.3?

@schiessle
Copy link
Member

not on purpose but maybe by accident?

@enoch85
Copy link
Member

enoch85 commented May 19, 2017

I'm also affected on 11.0.3, any update here?

@LEDfan
Copy link
Member

LEDfan commented May 20, 2017

I'm now running NC 12 beta3 on my server, and I'm experiencing the same problem with the specific other server.

@nickvergessen
Copy link
Member

Can you test: apps/files_sharing/lib/External/Manager.php
find:

$mountPoint = Files::buildNotExistingFileName('/', $share['name']);

before add:

\OC_Util::setupFS($this->uid);

cc @juliushaertl

@juliusknorr
Copy link
Member

juliusknorr commented May 20, 2017

@nickvergessen Yes that fixes it for me. 👍

@nickvergessen
Copy link
Member

Now the question is, why is the filesystem for some already loaded, but not for others.

I compared the app list, and I only have lesser apps than you. No additional app.

Anyway, can you turn this into a patch for 12 and master please?

@juliusknorr
Copy link
Member

@nickvergessen just checked if it starts working by disabling apps. After disabling the previewgenerator app it started working again without any changes in code.

cc @rullzer

@enoch85
Copy link
Member

enoch85 commented May 20, 2017

Your fix fixed it for me as well @nickvergessen

Did not try to disable the app that @juliushaertl mentioned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests