Bug 15627 - PermissionError in systemd_preset_all when using systemd
Summary: PermissionError in systemd_preset_all when using systemd
Status: RESOLVED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: core (show other bugs)
Version: 5.0.4
Hardware: All Multiple
: Medium+ major
Target Milestone: 5.2 M3
Assignee: Ross Burton
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2024-10-17 12:40 UTC by Christian Charreyre
Modified: 2025-03-25 20:25 UTC (History)
4 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: Don't know


Attachments
Log of do_image step for core-image-minimal (2.25 KB, text/plain)
2024-10-17 12:40 UTC, Christian Charreyre
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Charreyre 2024-10-17 12:40:14 UTC
Created attachment 5076 [details]
Log of do_image step for core-image-minimal

When DISTRO_FEATURES contains systemd, systemd_preset_all is added to IMAGE_PREPROCESS_COMMAND.

This function uses recipe-sysroot-native/usr/bin/systemctl to create links in etc/systemd/system/, but in the rootfs of the image the processed files can point on nothing (depending on the host distro, mine is Ubunut 20.04). In fact it points to a file in /usr/lib/, that will be OK on the target but can not exist on the dev environment.

In my case /dd/test-scarthgap-bug/build/tmp/work/qemux86_64-poky-linux/core-image-minimal/1.0/rootfs/etc/systemd/system/default.target -> /usr/lib/systemd/system/multi-user.target, which triggers the error.

This leads to an error in path.is_dir() test of systemctl, due to self.stat() test in python3.12 pathlib.py :

    def stat(self, *, follow_symlinks=True):
        """
        Return the result of the stat() system call on this path, like
        os.stat() does.
        """
        return os.stat(self, follow_symlinks=follow_symlinks)

Same image with dunfell, using python3.8, worked fine, with different code in pathlib.py :

    def stat(self):
        """
        Return the result of the stat() system call on this path, like
        os.stat() does.
        """
        return self._accessor.stat(self)


Tests conditions: build core-image-minimal with just poky layer activated.
Comment 1 Ross Burton 2025-02-12 18:15:24 UTC
We're potentially going to remove the systemctl reimplmentation shortly which hopefully will fix this.
Comment 2 Ross Burton 2025-02-20 15:20:56 UTC
I've verified that the proper systemctl does the right thing, and that is queued for master.
Comment 3 Ross Burton 2025-03-25 20:25:44 UTC
This should be fixed in oe-core 7a580800db391891a3a0f838c4ae6e1513c710a2.