Commit graph

928 commits

Author SHA1 Message Date
Carl Schwan
0262cc33d7
Fix psalm
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-01-24 13:34:48 +01:00
acsfer
ad5ea4eb06 [stable22] Check for disk_free_space
Backport of https://github.com/nextcloud/server/pull/29758
2022-01-17 19:56:35 +00:00
Jonas Meurer
5d1157c37c
updateEncryptedVersion: cleanup on target if cache already got renamed
When moving a file to trash with encryption enabled, the cache gets
moved before the actual file. According to @icewind1991 this is in order
to not break object storage.

When moving a file from an unencrypted storage (e.g. a collectives
storage) to the encrypted trashbin storage, this causes errors, see

This commit fixes it by doing `updateEncryptedVersion()` on the target
cache entry *if* the source cache entry doesn't exist anymore, but the
corresponding target cache entry does exist already.

Fixes: #26544

Signed-off-by: Jonas Meurer <jonas@freesources.org>
2022-01-15 13:40:01 +01:00
Carl Schwan
5c155d1e53 Fix psalm issues
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-01-14 14:17:04 +00:00
Carl Schwan
79289c55f2 Add helper method in Wrapper
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-01-14 14:17:01 +00:00
John Molakvoæ
295348446b
Implement multibucket shift for ObjectStore
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
2022-01-14 08:32:04 +01:00
Vincent Petry
e455b71ecd Fix fail when keys/files folder already exists
Fixes an issue with transfer ownership in move mode where the folder
"files_encryption/keys/files" already exists.

Instead of failing, its existence is checked before calling mkdir.

Signed-off-by: Vincent Petry <vincent@nextcloud.com>
2022-01-11 08:19:50 +00:00
Vincent Petry
76e5b1af7c Check resource before closing in encryption wrapper
In case of error there is no guarantee that $source or $target is set or
is a resource when handling an error.

Without this fix, there's a risk that fclose will fail and the actual
exception will not be thrown, making it impossible to find out about the
root cause.

Signed-off-by: Vincent Petry <vincent@nextcloud.com>
2021-12-10 00:07:49 +00:00
Robin Appelman
73a8ea2d4e background scan the source storage when a background scan on a storage jail is triggered
Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-12-06 01:11:44 +01:00
Joas Schilling
696e4f16a5
Check for invalid characters before trimming
Signed-off-by: Joas Schilling <coding@schilljs.com>
2021-11-25 15:39:19 +01:00
Robin Appelman
c4fa59c540 properly handle cases where cache wrappers block access
`CacheWrapper::formatCacheEntry` can return false for files that should be filtered out

Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-11-24 20:17:55 +01:00
Vincent Petry
a721d346b9 Normalize directory entries in Encoding wrapper
Directory entry file names are now normalized in getMetaData(),
getDirectoryContents() and opendir().

This makes the scanner work properly as it assumes pre-normalized names.

In case the names were not normalized, the scanner will now skip the
entries and display a warning when applicable.

Signed-off-by: Vincent Petry <vincent@nextcloud.com>
2021-11-19 14:51:40 +00:00
Vincent Petry
2b4badf768 Move storage encoding compatibility warning logic
The encoding check for file names is now happening the Scanner, and an
event will be emitted only if the storage doesn't contain the encoding
compatibility wrapper.

The event is listened to by the occ scan command to be able to display a
warning in case of file name mismatches when they have NFD encoding.

Signed-off-by: Vincent Petry <vincent@nextcloud.com>
2021-11-19 14:51:40 +00:00
Vincent Petry
787d7956cb Normalize file name before existence check in scanner
The scanner would not find a NFD-encoded file name in an
existing file list that is normalized.

This normalizes the file name before scanning.

Fixes issues where scanning repeatedly would make NFD files flicker in
and out of existence in the file cache.

Signed-off-by: Vincent Petry <vincent@nextcloud.com>
2021-11-19 14:51:39 +00:00
Sijmen Schoon
071eda7baa Move query outside the loop and reduce chunk size to 1000
This involved changing CacheQueryBuilder\whereParentIn to take a
parameter name, renaming the function accordingly.

Signed-off-by: Sijmen Schoon <me@sijmenschoon.nl>
2021-11-01 11:08:32 +00:00
Sijmen Schoon
ec3b1ccd91 Limit parameter count per query in Cache.removeChildren
Signed-off-by: Sijmen Schoon <me@sijmenschoon.nl>
2021-11-01 11:08:31 +00:00
Carl Schwan
8993cf86f1
Merge pull request #29475 from nextcloud/backport/29115/stable22
[stable22] Fix permissions when copying from ObjectStorage
2021-10-30 11:20:07 +02:00
MichaIng
5bd6a4fd29
Merge pull request #29415 from nextcloud/backport/27440/stable22
[stable22] Handle files with `is_file` instead of `file_exists`
2021-10-30 00:19:28 +02:00
Carl Schwan
7bf4a45f49 Fix permissions when copying from ObjectStorage
Make sure that when a user copy a file from a directory they don't have
all permissions to a directory where they have more permissions, the
permissions are correctly set to the one from the parent taget folder.

This was caused by the ObjectStoreStorage::copyFromStorage using
the jailed storage and cache entry instead of the unjailed one like other
storages (the local one).
Steps to reproduce

+ Use object storage
+ Create a groupfolder with one group having full permission and another one
  who can just read files.
+ With an user who is in the second group, copy a file from the groupfolder to
  the home folder of this user.
+ The file in the home folder of the user will be read only and can't be deleted
  even though it is in their home folder and they are the owner. In oc_filecache,
  the permissions stored for this file are 1 (READ)

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2021-10-30 00:18:26 +02:00
acsfer
3a5d1c1faf Handle files with is_file instead of file_exists
Should fix things like `fread(): read of 8192 bytes failed with errno=21 Is a directory`
2021-10-23 09:28:13 +00:00
Robin Appelman
5f438375a9 more reliable return value for Watcher::checkUpdate
Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-10-22 12:34:30 +00:00
Robin Appelman
a4a4097068 s3 external storage listing rework
Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-10-22 12:34:30 +00:00
Carl Schwan
887f4ba2fb Fix security issues when copying groupfolder with advanced ACL
Using advanced ACL, it is possible that an user has access to a
directory but not to a subdirectory, so the copying use
Common::copyFromStorage instead of Local::copyFromStorage.

Fix https://github.com/nextcloud/groupfolders/issues/1692

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2021-10-21 16:34:20 +00:00
acsfer
50791c61d3 Simplify :) 2021-10-18 07:59:00 +00:00
acsfer
269d9b5e0b Replace file_exists() method by is_file() 2021-10-18 07:58:59 +00:00
acsfer
698527d197 Get filesize() if file_exists()
Should make sense.
2021-10-18 07:58:59 +00:00
Julius Härtl
96abf31c3b
Merge pull request #29160 from nextcloud/backport/24185/stable22 2021-10-12 09:12:11 +02:00
Julius Härtl
9163894634
Merge pull request #29133 from nextcloud/backport/28907/stable22 2021-10-11 22:22:59 +02:00
Julius Härtl
3246eea0b6 Make sure that a empty directory can still be deleted when copied from another storage
Signed-off-by: Julius Härtl <jus@bitgrid.net>
2021-10-11 08:01:10 +00:00
Daniel Kesselberg
15417f3824 explicitly close source stream on encryption storage
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
2021-10-08 08:04:34 +00:00
Daniel Kesselberg
8ce2a320a1 explicitly close source stream on local storage
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
2021-10-08 08:04:34 +00:00
Robin Appelman
d4fb676dd7 generate a better optimized query for path prefix search filters
Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-10-07 15:19:58 +00:00
blizzz
9410141747
Merge pull request #28683 from nextcloud/backport/26463/stable22
[stable22] Fix S3 ObjectStore proxy option
2021-09-23 10:24:54 +02:00
Pauli Järvinen
11695164c6 Support seeking also from the end of file on S3 storage
The PR https://github.com/nextcloud/server/pull/20033 added support
for `fseek` for  the S3 storage backend. However, the seek mode SEEK_END
was left out that time. This PR fills this gap.

Signed-off-by: Pauli Järvinen <pauli.jarvinen@gmail.com>
2021-09-20 18:13:25 +00:00
Maxime Besson
d99a72b801 fix(proxy): use accessor
Signed-off-by: Maxime Besson <maxime.besson@worteks.com>
2021-09-01 08:23:18 +00:00
Maxime Besson
956bccc1c0 fix(proxy): reaching s3 storage behind some http proxy
Signed-off-by: Maxime Besson <maxime.besson@worteks.com>
2021-09-01 08:23:18 +00:00
Samuel
4c9e7e2d39 fix(proxy): reaching s3 storage behind some http proxy
Signed-off-by: Maxime Besson <maxime.besson@worteks.com>
2021-09-01 08:23:18 +00:00
Vincent Petry
eada9eaace
Unregister enc stream wrapper for any exception
This prevents side effects in tests by properly cleaning up
even with expected exceptions.

Signed-off-by: Vincent Petry <vincent@nextcloud.com>
2021-08-26 14:17:12 +02:00
Lukas Reschke
34b5d979ff
Merge pull request #28583 from nextcloud/backport/28566/stable22
[stable22] use getGetUnjailedRoot to determine if jailed search needs the path filter
2021-08-25 13:21:41 +02:00
Robin Appelman
9e5440abc3 use getGetUnjailedRoot to determine if jailed search needs the path filter
Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-08-24 12:52:27 +00:00
Robin Appelman
5444db1ebf use case insensitive like when limiting search to jail
Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-08-24 07:02:22 +00:00
Robin Appelman
8a6e3e6aca fix Folder->getById() when a single storage is mounted multiple times
Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-08-09 17:29:40 +00:00
Robin Appelman
1534b24e38 dont apply jail search filter is on the root
the extra '/' breaks things and the filter wouldn't do anything anyway except making the databases job harder

Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-07-29 07:30:21 +00:00
John Molakvoæ
c73070c19d
Merge pull request #27752 from nextcloud/backport/27586/stable22
[stable22] Reset checksum when writing files to object store
2021-07-05 17:27:07 +02:00
Robin Appelman
cb0e76105e dont include folder being search in in the results
Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-07-02 15:52:17 +00:00
Julius Härtl
226e0c4107 Reset checksum when writing files to object store
Signed-off-by: Julius Härtl <jus@bitgrid.net>
2021-07-01 15:33:47 +00:00
Pytal
9ed379da22
Merge pull request #27635 from nextcloud/fix/datetime-constants
Fix usage of DateTime constants
2021-06-23 09:56:28 -07:00
Christoph Wurst
6d5cfe0c66
Move DateTime::RFC2822 to DateTimeInterface::2822
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2021-06-23 15:30:43 +02:00
Lukas Reschke
a70fd1bad1
Merge pull request #26344 from J0WI/fs-early-root
Return early if path is root
2021-06-23 15:21:56 +02:00
Robin Appelman
8520717b4f
handle case where storage can't be created in getStorageRootId
Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-06-17 14:32:38 +02:00