Skip to content

snagflash: ums: switch from shutil.copy to shutil.copyfile#82

Closed
Taumille wants to merge 1 commit intobootlin:mainfrom
Taumille:fix_ums_shutilcopy
Closed

snagflash: ums: switch from shutil.copy to shutil.copyfile#82
Taumille wants to merge 1 commit intobootlin:mainfrom
Taumille:fix_ums_shutilcopy

Conversation

@Taumille
Copy link
Copy Markdown

@Taumille Taumille commented Mar 3, 2026

shutil.copy attempts to preserve file permissions after the copy operation.
When the destination is a device node, this triggers a PermissionError because chmod operations on device nodes typically require root privileges, even if the user has write access to the device.

Switching to shutil.copyfile ensures only the data is copied to the destination, avoiding unnecessary privileged operations.

shutil.copy attempts to preserve file permissions after the copy
operation.
When the destination is a device node, this triggers a PermissionError
because chmod operations on device nodes typically require root
privileges, even if the user has write access to the device.

Switching to shutil.copyfile ensures only the data is copied to the
destination, avoiding unnecessary privileged operations.

Signed-off-by: Thomas Bonnefille <thomas.bonnefille@bootlin.com>
@rgantois
Copy link
Copy Markdown
Collaborator

rgantois commented Mar 3, 2026

Hi, you shouldn't be using -d when copying to a raw block device, you should be using -b instead. Moreover, using copyfile will break cases where a destination directory is passed instead of a file path.

@rgantois rgantois closed this Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants