Skip to content
Snippets Groups Projects
Commit b3589802 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

backend: Use utils.IsBelowDir instead of local code


utils.IsBelowDir is actually tested and doesn't allow writes to
“…/queue*”, like the old code here did.

Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 4fdedd09
No related branches found
No related tags found
No related merge requests found
......@@ -2808,12 +2808,9 @@ def _EnsureJobQueueFile(file_name):
@raises RPCFail: if the file is not valid
"""
queue_dir = os.path.normpath(pathutils.QUEUE_DIR)
result = (os.path.commonprefix([queue_dir, file_name]) == queue_dir)
if not result:
if not utils.IsBelowDir(pathutils.QUEUE_DIR, file_name):
_Fail("Passed job queue file '%s' does not belong to"
" the queue directory '%s'", file_name, queue_dir)
" the queue directory '%s'", file_name, pathutils.QUEUE_DIR)
def JobQueueUpdate(file_name, content):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment