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

occ files:scan does not invalidate checksums if file changed on disk. #23783

Closed
dragotin opened this issue Apr 4, 2016 · 13 comments
Closed

occ files:scan does not invalidate checksums if file changed on disk. #23783

dragotin opened this issue Apr 4, 2016 · 13 comments

Comments

@dragotin
Copy link
Contributor

dragotin commented Apr 4, 2016

Steps to reproduce

  1. Create a file on client
  2. Wait until it is synced.
  3. Check that it has a checksum in the database, which was sent from the client.
  4. Edit the file on the server file system, which is not supported and forbidden as you should know.
  5. Feel bad about yourself and think occ files:scan --all will fix it.
  6. Start occ files:scan --all as you are an experienced admin for ownCloud
  7. See that the checksum of the file has not changed and was not invalidated 👎

Expected behaviour

When a files mtime on disk is changed, the checksum on the server needs to be recalculated. If that can not be done, it needs at least to be invalidated. The occ file scan must compare the mtime of the file and the one stored in the db and wipe the checksum if they do not match. In addition there should be a switch to wipe all checksums, if they can not be recalculated.

Having a wrong checksum for a file is a critical problem as the client will complain about a corrupted file on download .

Server configuration

Operating system:
Linux
Web server:
apache
Database:
mysql
PHP version:
5.5.14
ownCloud version: (see ownCloud admin page)
9.0.x, master branch, 15833d9
Updated from an older ownCloud or fresh install:

Where did you install ownCloud from:
git
Are you using external storage, if yes which one: local/smb/sftp/...
no external storage
Are you using encryption: yes/no
no encryption
Are you using an external user-backend, if yes which one: LDAP/ActiveDirectory/Webdav/...
no user-backend.

@rullzer
Copy link
Contributor

rullzer commented Apr 4, 2016

Yes agreed this must be handled properly.
I think the safest thing would even be to just invalidate all checksums on file scan. As we have (without recalculating) no guarantees the data is unchanged...

@danimo
Copy link
Contributor

danimo commented Apr 4, 2016

<sysadmin_hat>Safe? Yes. Expected: no. Scanning has become the default solution when something is wrong. Invalidating checksums by default makes this impossible, as it means resynch with all clients. Not something you want with a considerable amount of users and devices.</sysadmin_hat>

@rullzer
Copy link
Contributor

rullzer commented Apr 4, 2016

@danimo well if we don't want to calculate checksums on the server this is kind of playing with fire...

I guess the 'second' safest thing to do it compare mtime + size...

@rullzer rullzer added this to the 9.0.2-next-maintenance milestone Apr 4, 2016
@rullzer
Copy link
Contributor

rullzer commented Apr 4, 2016

Raised to sev2 as this has to be fixed for 9.0.2 from my POV. @cmonteroluque

@dragotin
Copy link
Contributor Author

dragotin commented Apr 4, 2016

@danimo no, invalidating the checksums would not mean to resync to all clients, as we use the ETags to decide upon syncing as you remember.

I think that there is no alternative to invalidating all checksums on rescan as, with this bug, we can not trust any checksum that is stored in the server db, as long as it is not validated.

@danimo
Copy link
Contributor

danimo commented Apr 4, 2016

@dragotin you are right, of course.

@ghost
Copy link

ghost commented Apr 7, 2016

@rullzer agreed

@moscicki
Copy link

You should NOT to send any checksums in the reply headers (GET) if you are unable to guarantee that these checksums are correct. So only send checksums if you are sure they are correct by design. So I think you should disable sending any checksums until you fix this issue in the server.

@PVince81
Copy link
Contributor

CC @icewind1991 since it's related to scanning.

rullzer added a commit that referenced this issue Apr 19, 2016
Fixes #23782 and #23783

If the file scanner detects a changed file we clear the checksum while
we update the cache.

* Unit test added
@rullzer
Copy link
Contributor

rullzer commented Apr 19, 2016

PR that fixes this in #24098

rullzer added a commit that referenced this issue Apr 20, 2016
Fixes #23782 and #23783

If the file scanner detects a changed file we clear the checksum while
we update the cache.

* Unit test added
@rullzer
Copy link
Contributor

rullzer commented Apr 20, 2016

Stable 9 backport in #24129

@rullzer
Copy link
Contributor

rullzer commented Apr 21, 2016

Merged. Closing.

@rullzer rullzer closed this as completed Apr 21, 2016
@MorrisJobke MorrisJobke modified the milestones: 9.1-current, 9.0.2-current-maintenance Apr 21, 2016
@lock
Copy link

lock bot commented Aug 4, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

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

No branches or pull requests

7 participants