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

Fix permissions when copying from ObjectStorage #29115

Merged
merged 1 commit into from
Oct 28, 2021

Conversation

CarlSchwan
Copy link
Member

@CarlSchwan CarlSchwan commented Oct 7, 2021

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

  1. Use object storage
  2. Create a groupfolder with one group having full permission and another one
    who can just read files.
  3. With an user who is in the second group, copy a file from the groupfolder to
    the home folder of this user.
  4. 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

@CarlSchwan CarlSchwan added the 3. to review Waiting for reviews label Oct 7, 2021
@CarlSchwan CarlSchwan force-pushed the work/carl/correct-permissions-when-copying branch from 3338b71 to 17b5d9a Compare October 7, 2021 11:00
@PVince81
Copy link
Member

PVince81 commented Oct 7, 2021

@CarlSchwan can you clarify the explanation as it's easy to get confused ? maybe use some example to illustrate what is happening

@PVince81
Copy link
Member

PVince81 commented Oct 7, 2021

maybe add some "steps to reproduce" might help to understand better (since we don't have a ticket)

@CarlSchwan CarlSchwan force-pushed the work/carl/correct-permissions-when-copying branch from 17b5d9a to a2a89d6 Compare October 7, 2021 12:04
@CarlSchwan
Copy link
Member Author

maybe add some "steps to reproduce" might help to understand better (since we don't have a ticket)

I added steps to reproduce section, I hope this makes it more clear

@artonge
Copy link
Contributor

artonge commented Oct 7, 2021

Wouldn't it make more sense to create a new scanner dedicated to object storage?

@PVince81
Copy link
Member

PVince81 commented Oct 7, 2021

Wouldn't it make more sense to create a new scanner dedicated to object storage?

There is nothing to scan in a primary object storage, so having one would semantically mismatch.

Strange that conceptually it's usually the Scanner that sets the permission.

@CarlSchwan
Copy link
Member Author

Wouldn't it make more sense to create a new scanner dedicated to object storage?

There is nothing to scan in a primary object storage, so having one would semantically mismatch.

Strange that conceptually it's usually the Scanner that sets the permission.

I just tested adding the normal Scanner to the ObjectStoreStorage. Since the normal Scanner will still be able to scan one file successfully by using the path. Problem is that this still doesn't solve the problem since the Scanner will ask the Storage for the permissions and the ObjectStoreStorage storage will just returns the permissions from the filecache (this isn't the case for the Local Storage).

I used the debugger a bit more and I ended up finding why it put 1 as permission in the filecache. In the ObjectStoreStorage::copyFromStorage when looking for the sourceEntry cache there is a permission mask changing the permissions and these permission are simply copied to the target cache.

I pushed a commit that now uses the unjailedStorage to get the sourceEntry, This is that is also done in the Local storage and this seems more correct to me than modifying the Cache class.

Copy link
Member

@icewind1991 icewind1991 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of unwrapping the Jail wrappers it should unwrap the PermissionsMask

alternatively you can check for $cacheEntry['scan_permissions'], (not available trough a getter on ICacheEntry only trough array access) which is used already used to set the proper permissions while scanner a permissions masked storage

@CarlSchwan CarlSchwan force-pushed the work/carl/correct-permissions-when-copying branch 3 times, most recently from f507a35 to d26b3d9 Compare October 7, 2021 15:52
@CarlSchwan CarlSchwan force-pushed the work/carl/correct-permissions-when-copying branch from d26b3d9 to 4edbb8a Compare October 8, 2021 11:10
Copy link
Member

@PVince81 PVince81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@CarlSchwan CarlSchwan force-pushed the work/carl/correct-permissions-when-copying branch from 80a8c05 to e1e846f Compare October 14, 2021 08:18
@CarlSchwan
Copy link
Member Author

friendly ping :D

@PVince81
Copy link
Member

@icewind1991 can you approve ? it follows your suggestion from last time about "scan_permissions"

@CarlSchwan
Copy link
Member Author

Ping?

Copy link
Member

@juliusknorr juliusknorr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some code comment would be nice as @skjnldsv suggested, otherwise seems fine 👍

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>
@CarlSchwan CarlSchwan force-pushed the work/carl/correct-permissions-when-copying branch from e1e846f to bfa60aa Compare October 28, 2021 11:30
@CarlSchwan CarlSchwan merged commit df4e6ba into master Oct 28, 2021
@CarlSchwan CarlSchwan deleted the work/carl/correct-permissions-when-copying branch October 28, 2021 12:38
@CarlSchwan
Copy link
Member Author

/backport to stable22

@CarlSchwan
Copy link
Member Author

/backport to stable21

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

Successfully merging this pull request may close these issues.

7 participants