From 264576bddd4627f533025a0338ff2a057cd018a8 Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Fri, 14 Aug 2026 22:12:08 +0200 Subject: [PATCH] Check a download target that already exists on its own A writable directory only says the user could have created a file there, and /tmp lets anyone do that. If the target exists, it has to be writable by the requesting user too, or confluent would overwrite it as root. --- confluent_server/confluent/messages.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/confluent_server/confluent/messages.py b/confluent_server/confluent/messages.py index 2733853f..1ed1c158 100644 --- a/confluent_server/confluent/messages.py +++ b/confluent_server/confluent/messages.py @@ -687,6 +687,15 @@ class InputFirmwareUpdate(ConfluentMessage): '{0} is not writable by {1}, check the ' 'directory and parent directory ownership ' 'and permissions'.format(target, curruser)) + if target != value and os.path.exists(value): + # /tmp lets anyone create a file, which says + # nothing about one already sitting there + if not checkaccess(curruser, value, pwent, + os.W_OK): + raise Exception( + '{0} already exists and is not writable ' + 'by {1}, check the file ownership and ' + 'permissions'.format(value, curruser)) elif not checkaccess(curruser, value, pwent): errstr = '{0} is not readable by {1}, check the file and parent directory ownership and permissions'.format( value, curruser)