-
Notifications
You must be signed in to change notification settings - Fork 113
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 remove/update share permissions when the file is locked #4534
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to check the PermissionSet when updating a share.
return s.checkShareLock(ctx, getShareRes.Share) | ||
} | ||
|
||
func (s *svc) checkShareLock(ctx context.Context, share *collaboration.Share) (*rpc.Status, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is tooo restrictive. AFAIU we can
A) allow adding new users to a file
B) increase the permissions of a share, e.g. add edit permission for a viewer.
The current check disallows any sharing changes when a file is locked.
People often open a file in onlyoffice and then need to ADD new participants.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, we would have to send the lock in the creat/update share opaque... 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, I see now that share creation is unaffected. So new users can be added when a file is locked. That is good enough for me. IMO extending share permissions can be implemented in a followup PR.
Status: status, | ||
}, nil | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know I am a bit late to the party. But isn't this racy? The file lock can be created after this check, before updating the share. Classical TOCTOU problem, isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it could happen besides that the s.updateGrant failure can lead to an inconsistent state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, we would have to send the lock in the opaque of the sharing requests to make this (more) atomic.
} | ||
|
||
if sRes.GetInfo().GetLock() != nil { | ||
msg := "can not chane grants, the shared resource is locked" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a workaround that should prevent removing or changing the share permissions when the file is locked.
These limitations have to be removed after the wopi server will be able to unlock the file properly.
These limitations are not spread on the files inside the shared folder.
Related issue owncloud/ocis#8273