Skip to content

Commit

Permalink
Fixed PutRelative return codes when the user has no permission
Browse files Browse the repository at this point in the history
  • Loading branch information
glpatcern committed Nov 4, 2022
1 parent efa0935 commit 69d82c2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/core/wopi.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,9 @@ def putRelative(fileid, reqheaders, acctok):
newstat = st.statx(acctok['endpoint'], targetName, acctok['userid'])
_, newfileid = common.decodeinode(newstat['inode'])
except IOError as e:
if str(e) == common.ACCESS_ERROR:
# BAD_REQUEST may seem better but the WOPI validator tests explicitly expect NOT_IMPLEMENTED
return 'Unauthorized to perform PutRelative', http.client.NOT_IMPLEMENTED
utils.storeForRecovery(flask.request.get_data(), acctok['username'], targetName,
flask.request.args['access_token'][-20:], e)
return IO_ERROR, http.client.INTERNAL_SERVER_ERROR
Expand Down
3 changes: 3 additions & 0 deletions src/core/xrootiface.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,9 @@ def writefile(endpoint, filepath, userid, content, lockmd, islock=False):
if 'file has a valid extended attribute lock' in rc.message:
log.warning('msg="Lock mismatch when writing file" filepath="%s"' % filepath)
raise IOError(common.LOCK_MISMATCH_ERROR)
if common.ACCESS_ERROR in rc.message:
log.warning('msg="Access denied when writing file" filepath="%s"' % filepath)
raise IOError(common.ACCESS_ERROR)
# any other failure is reported as is
log.error('msg="Error opening the file for write" filepath="%s" elapsedTimems="%.1f" error="%s"' %
(filepath, (tend-tstart)*1000, rc.message.strip('\n')))
Expand Down

0 comments on commit 69d82c2

Please sign in to comment.