uutils/coreutils · error · uucore::error::Error

Modifying root path

Error message

Modifying root path

What it means

Error "Modifying root path" thrown in uutils/coreutils.

Source

Thrown at src/uu/chcon/src/chcon.rs:557

            ));
        };

        let mut result = Ok(());

        match entry.flags() {
            fts_sys::FTS_D if options.recursive_mode.is_recursive() => {
                if root_dev_ino_check(root_dev_ino, file_dev_ino) {
                    // This happens e.g., with "chcon -R --preserve-root ... /"
                    // and with "chcon -RH --preserve-root ... symlink-to-root".
                    root_dev_ino_warn(&file_full_name);

                    // Tell fts not to traverse into this hierarchy.
                    let _ignored = fts.set(fts_sys::FTS_SKIP);

                    // Ensure that we do not process "/" on the second visit.
                    let _ignored = fts.read_next_entry();

                    return Err(err(
                        translate!("chcon-op-modifying-root-path"),
                        io::ErrorKind::PermissionDenied,
                    ));
                }

                return Ok(());
            }

            fts_sys::FTS_DP if !options.recursive_mode.is_recursive() => {
                return Ok(());
            }

            fts_sys::FTS_NS => {
                // For a top-level file or directory, this FTS_NS (stat failed) indicator is determined
                // at the time of the initial fts_open call. With programs like chmod, chown, and chgrp,
                // that modify permissions, it is possible that the file in question is accessible when
                // control reaches this point. So, if this is the first time we've seen the FTS_NS for
                // this file, tell fts_read to stat it "again".

View on GitHub (pinned to 0b77ced485)

Solutions

  1. Run chcon with sufficient privileges (root or appropriate SELinux permissions) when modifying the root path.
  2. Avoid changing contexts on / unless explicitly intended; target the correct path.

When it happens

Trigger: Occurs when chcon fails to modify the security context of the root path of a recursive operation.

Common situations: Insufficient privileges or SELinux policy denying the context change on the top-level path.


AI-assisted analysis of uutils/coreutils@0b77ced485 (2026-08-19). Data as JSON: /api/errors/a8d54506ccef627d. Report an issue: GitHub.