Skip to content

Help users with incorrect / permission bits - #41431

Merged
poettering merged 3 commits into
systemd:mainfrom
sc0ttV6:protectDummies
Apr 10, 2026
Merged

poettering merged 3 commits into
systemd:mainfrom
sc0ttV6:protectDummies

Conversation

@sc0ttV6

@sc0ttV6 sc0ttV6 commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

This error causes the computer to pass the emergency.target and go to graphical.target.
Then, your window manager will have problems because it cant access any directories, your network manager wont startup the network. In my case, the screen just goes black. Ideally, you'd get an error message explaining this edge scenario that's occuring to you, and an emergency shell that makes it easy to run the necessary chmod 0755 / to proceed with booting. IDK not sure if this is the correct way to implement this, sorry it's my first contribution.

I ran
meson test -C build
and got

Ok: 1806
Fail: 26
Skipped: 25
on my cloned systemd repo before any changes, and got the same result after my commit ¯_(ツ)_/¯
So I hope I did that right.
Thanks

@github-actions github-actions Bot added the please-review PR is ready for (re-)review by a maintainer label Mar 31, 2026
@poettering

Copy link
Copy Markdown
Member

This is so random... yes, the root dir is an important inode, but it's really not the only relevant inode to keep the system running, hence why give it special treatment?

also, why not instead use a tmpfiles.d/ snippet to adjust it?

@bluca bluca added needs-reporter-feedback ❓ There's an unanswered question, the reporter needs to answer and removed please-review PR is ready for (re-)review by a maintainer labels Apr 1, 2026
@sc0ttV6
sc0ttV6 force-pushed the protectDummies branch 2 times, most recently from 351f29b to a16068f Compare April 2, 2026 19:48
@sc0ttV6

sc0ttV6 commented Apr 2, 2026

Copy link
Copy Markdown
Contributor Author

Yeah I thought about that, but I was worried there was some reason people really would want a 0700 / and be upset if it was changed silently. That was silly of me in hindsight, would adding this to tmpfiles.d/home.conf be appropriate?
I just changed the pr (I think, im not good with github) to do just that.
Thanks

@github-actions github-actions Bot added the please-review PR is ready for (re-)review by a maintainer label Apr 2, 2026
Comment thread tmpfiles.d/home.conf Outdated

# See tmpfiles.d(5) for details.

z / 0755 - - -

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so i am inclined to merge something like this, for the reason that it's quite common that the root inode is provided/created by a different component than the component that populates it. e.g. people might mount a tmpfs as a future root fs, where the inode is initialized by the kernel, and then they unpack a rootfs into it where the inodes are created by them. hence, there's a good chance that what is right for the rootfs doesn't match with what is right for the original unpopulated dir created for it.

but please, let's do this in a separate .conf file, so that people can easily override/mask it. i.e. rootfs.conf?

also, it should be 555 i think. (i.e. if some code runs as root with all caps dropped it shouldn't still get write access to the root inode)

@sc0ttV6 sc0ttV6 Apr 8, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

" for the reason that it's quite common that the root inode is provided/created by a different component than the component that populates it."
Yes that was the exact problem that got me. I formated a drive, mkfs, then mounted it. Then used a different tool to fill the rootfs with all the fhs stuff. The crazy thing was that somehow the mounted filesystem got its bits set to 700 without me noticing, then the system obviously failed.

A quick question though, if its perm bits are set to 555, that means the root (user) will be unable to mkdir /mnt2 or write anything to the root dir right?

@poettering poettering added tmpfiles and removed please-review PR is ready for (re-)review by a maintainer labels Apr 8, 2026
@poettering

Copy link
Copy Markdown
Member

might be good to already add an entry to NEWS for this, since this is not just a feature addition, it might break certain (broken, if you ask me) setups. Hence, we should mention this so that downstreams are aware of this change, and can reconsider it.

@github-actions github-actions Bot added please-review PR is ready for (re-)review by a maintainer documentation labels Apr 8, 2026
@poettering poettering added good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed and removed needs-reporter-feedback ❓ There's an unanswered question, the reporter needs to answer please-review PR is ready for (re-)review by a maintainer labels Apr 9, 2026
@poettering

Copy link
Copy Markdown
Member

you also need to register the file in meson.build, or otherwise it's not going to be installed

@poettering poettering added reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks and removed good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed labels Apr 9, 2026
@sc0ttV6

sc0ttV6 commented Apr 9, 2026

Copy link
Copy Markdown
Contributor Author

you also need to register the file in meson.build, or otherwise it's not going to be installed

done!

@github-actions github-actions Bot added please-review PR is ready for (re-)review by a maintainer and removed reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks labels Apr 9, 2026
@poettering poettering added good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed and removed please-review PR is ready for (re-)review by a maintainer labels Apr 10, 2026
@poettering
poettering merged commit 58b9e40 into systemd:main Apr 10, 2026
52 of 55 checks passed
@github-actions github-actions Bot removed the good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed label Apr 10, 2026
@keszybz

keszybz commented Apr 10, 2026

Copy link
Copy Markdown
Member

This should have been squashed into a single commit.

@cgwalters

Copy link
Copy Markdown
Contributor

Hi, this change caused...a fair bit of work for some folks. I think the change is well intentioned but TL;DR I have two recommendations:

First: I think we should have a flag for systemd-tmpfiles (z? or so?) that has it ignore the case where the filesystem is mounted readonly.

it might break certain (broken, if you ask me) setups.

Well...what's broken here? It's not like the difference between 0o755 or 0o555 really matters at all right?

I think alternatively (or in addition): A variant like z+ that acts like a required mask so it'd be z+ / 0555 or so? This one would accept 0755 without error.

Or we make z- work for this?

Backing up though I'm not so sure it should really systemd's job to define this stuff by default. I mean, on a traditional mutable system one can mess up the permissions of literally any arbitrary dir (messing up /usr, /etc, /usr/lib, ...) would all be fatal. Why is it more likely to be /? Not clear at all to me.

Or at least...anyone adding systemd to their OS/distro would for sure need to ensure these tmpfiles.d snippets are in sync with whatever other source of truth they had before (like filesystem RPM).

Probably what would make sense for mutable OS's is to have a little bit of code that runs in the initramfs and does these fixups instead? Or really have a "run repair" boot option?

The general case of course needs a USB key or at least completely separate fallback partition etc.


BTW, this led into a whole side quest in "actually, how are the perms of / defined and checked across package/build systems" and whooo boy is that a mess! Look at bootc-dev/bootc#2571 (comment) and below, gems like Debian still using md5 and I was really surprised to find that dpkg doesn't have any builtin way to repair the metadata for directories at all, and in OpenSUSE their filesystem rpm doesn't own / (nothing does!) etc.

debarshiray pushed a commit to debarshiray/toolbox that referenced this pull request Nov 12, 2026
As of systemd 261, bare 'systemd-tmpfiles --create' calls now attempt to
set permissions on / on systems which are not set to 0555 [1]. This
currently fails on Fedora CoreOS systems due to them having the
incorrect permissions (i.e., 0755) set while also having a read-only
root file system [2].  This leads to the following error:

  fchmod() of / failed: Read-only file system
  Traceback (most recent call last):
    File "toolbox/meson_post_install.py", line 26, in <module>
      subprocess.run(['systemd-tmpfiles', '--create'], check=True)
      ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib64/python3.15/subprocess.py", line 692, in run
      raise CalledProcessError(retcode, process.args,
                               output=stdout, stderr=stderr)
  subprocess.CalledProcessError: Command '['systemd-tmpfiles',
      '--create']'

Since both entries in data/tmpfiles.d/toolbox.conf are under /run, it's
safe to restrict these calls to this directory with '--prefix /run' in
order to avoid that issue on Fedora CoreOS.

[1] systemd commit 7b2a10b594d7ed0f
    systemd/systemd@7b2a10b594d7ed0f
    systemd/systemd#41431

[2] coreos/fedora-coreos-tracker#2238

containers#1847
containers#1857

Signed-off-by: Rolv Apneseth <[email protected]>
debarshiray pushed a commit to debarshiray/toolbox that referenced this pull request Nov 12, 2026
As of systemd 261, bare 'systemd-tmpfiles --create' calls now attempt to
set permissions on / on systems which are not set to 0555 [1]. This
currently fails on Fedora CoreOS systems due to them having the
incorrect permissions (i.e., 0755) set while also having a read-only
root file system [2].  This leads to the following error:
  fchmod() of / failed: Read-only file system
  Traceback (most recent call last):
    File "toolbox/meson_post_install.py", line 26, in <module>
      subprocess.run(['systemd-tmpfiles', '--create'], check=True)
      ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib64/python3.15/subprocess.py", line 692, in run
      raise CalledProcessError(retcode, process.args,
                               output=stdout, stderr=stderr)
  subprocess.CalledProcessError: Command '['systemd-tmpfiles',
      '--create']' returned non-zero exit status 73.

Since both entries in data/tmpfiles.d/toolbox.conf are under /run, it's
safe to restrict these calls to this directory with '--prefix /run' in
order to avoid that issue on Fedora CoreOS.

[1] systemd commit 7b2a10b594d7ed0f
    systemd/systemd@7b2a10b594d7ed0f
    systemd/systemd#41431

[2] coreos/fedora-coreos-tracker#2238

containers#1847
containers#1857

Signed-off-by: Rolv Apneseth <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

5 participants