Skip to content

Handle permissions better #76

@supakeen

Description

@supakeen

Image Builder requires root permissions for many tasks (but not all). This is due to needing root permissions to do any disk mounting.

However, image-builder-cli always needs root permissions due to trying to create a directory in /var/cache.

If we're going down that route then perhaps we should add a geteuid() check and exit earlier. Right now it takes (on my system) 10-15 seconds before we get to the point of error:

user@muja ~ € image-builder build iot-commit
No distro name specified, selecting "fedora-41" based on host, use --distro to overrideWARN[0000] Failed to load consumer certs: no consumer key found 
Traceback (most recent call last):
  File "/usr/bin/osbuild", line 33, in <module>
    sys.exit(load_entry_point('osbuild==138', 'console_scripts', 'osbuild')())
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/lib/python3.13/site-packages/osbuild/main_cli.py", line 171, in osbuild_cli
    with ObjectStore(args.store) as object_store:
         ~~~~~~~~~~~^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/osbuild/objectstore.py", line 325, in __init__
    os.makedirs(self.store, exist_ok=True)
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen os>", line 217, in makedirs
  File "<frozen os>", line 227, in makedirs
PermissionError: [Errno 13] Permission denied: '/var/cache/image-builder'
error: running osbuild failed: exit status 1

Alternatively, we might want to tag the various image types with if they require root permissions and handle the cache differently.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions