2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-09-21 16:39:32 +00:00

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.
This commit is contained in:
Markus Hilger
2026-08-14 22:12:08 +02:00
parent 93a6ee554b
commit 264576bddd
+9
View File
@@ -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)