os.chown() operations will fail for non-root users #10

Open
opened 2025-11-15 03:44:13 +00:00 by snegov · 0 comments
Owner

os.chown() operations will fail for non-root users

Priority: High
Component: fs.py
Type: Bug

Description

Multiple locations in the code call os.chown() without error handling. On Unix systems, only root can change file ownership, so these operations will fail for normal users.

Locations

  • curateipsum/fs.py:225-227
  • curateipsum/fs.py:377
  • curateipsum/fs.py:460

Problem

Normal users running backups will encounter PermissionError when trying to preserve ownership of files, causing backup to fail.

Proposed Solution

Either:

  1. Wrap in try/except and log warning
  2. Check if running as root before attempting
  3. Add a flag to skip ownership preservation
try:
    os.chown(dst_path, src_stat.st_uid, src_stat.st_gid)
except PermissionError:
    _lg.debug("Cannot change ownership (not root): %s", dst_path)

Impact

High - Makes tool unusable for non-root users in current form.

# os.chown() operations will fail for non-root users **Priority:** High **Component:** fs.py **Type:** Bug ## Description Multiple locations in the code call `os.chown()` without error handling. On Unix systems, only root can change file ownership, so these operations will fail for normal users. ## Locations - `curateipsum/fs.py:225-227` - `curateipsum/fs.py:377` - `curateipsum/fs.py:460` ## Problem Normal users running backups will encounter `PermissionError` when trying to preserve ownership of files, causing backup to fail. ## Proposed Solution Either: 1. Wrap in try/except and log warning 2. Check if running as root before attempting 3. Add a flag to skip ownership preservation ```python try: os.chown(dst_path, src_stat.st_uid, src_stat.st_gid) except PermissionError: _lg.debug("Cannot change ownership (not root): %s", dst_path) ``` ## Impact **High** - Makes tool unusable for non-root users in current form.
Sign in to join this conversation.
No Label
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: snegov/cura-te-ipsum#10
No description provided.