Skip to content

Backport symlink fixes to rhel10-branch - #1523

Merged
brlane-rht merged 10 commits into
weldr:rhel10-branchfrom
brlane-rht:rhel10-RHEL-238020
Aug 12, 2026
Merged

Backport symlink fixes to rhel10-branch#1523
brlane-rht merged 10 commits into
weldr:rhel10-branchfrom
brlane-rht:rhel10-RHEL-238020

Conversation

@brlane-rht

Copy link
Copy Markdown
Contributor

Backport of #1522

Resolves: RHEL-238020

This tests to make sure that using remove on a symlink pointing to a
directory just removes the symlink, not the whole directory. Note that
shutil.rmtree has used a symlink resistant version since python 3.3 so
this test is purely to demonstrate that remove() uses unlink in that
case.

(cherry picked from commit 69245f6)

Related: RHEL-238020
Just in case they have already been created as symlinks, use remove
instead of shutil which will raise an error.

(cherry picked from commit dca1e79)

Related: RHEL-238020
Make sure that all the kernels returned are under the root directory.
This prevents potential issues with accessing files on the host system.

(cherry picked from commit 0db5798)

Related: RHEL-238020
If there is an existing module-info, and it is a symlink, remove it
before writing the new one.

(cherry picked from commit 6e4647e)

Related: RHEL-238020
This helps catch mistakes with hardlink, symlink, copy, move trying to
access paths outside of the outroot set in the template runner. Should
help prevent accidentally accessing host files and paths.

(cherry picked from commit 0bbb060)

Related: RHEL-238020
This function is similar to joinpaths, except that it will evaluate the
final path and raise a RuntimeError if it is outside of the first
argument passed.

This can be used to help prevent absolute symlinks and directory
traversals from pointing outside of a directory tree.

Includes tests.

(cherry picked from commit e5115e3)

Related: RHEL-238020
This will raise a RuntimeError if the real path points outside the
template runner's outroot.

NOTE: This does not guarantee the safety of the template -- this is
running as root, it has access to the whole system and is not safe to
pass unknown templates into. This change is meant to help prevent
accidentally accessing the host files.

(cherry picked from commit 36bfff1)

Related: RHEL-238020
This prevents absolute symlinks in the ostree boot path from pointing
outside the image's directory tree.

(cherry picked from commit aef9a50)

Related: RHEL-238020
This ensures that the path used for the config_files cannot point
outside of the mount_dir.

(cherry picked from commit 8d88b4c)

Related: RHEL-238020
This ensures that the boot directory from the image cannot be a symlink
pointing outside of the root_dir

(cherry picked from commit bfc9cff)

Resolves: RHEL-238020
@brlane-rht brlane-rht changed the title Rhel10 rhel 238020 Backport symlink fixes to rhel10-branch Aug 11, 2026
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 31524799405

Warning

No base build found for commit af7a466 on rhel10-branch.
Coverage changes can't be calculated without a base build.
If a base build is processing, this comment will update automatically when it completes.

Coverage: 44.052%

Details

  • Patch coverage: 11 uncovered changes across 4 files (38 of 49 lines covered, 77.55%).

Uncovered Changes

File Changed Covered %
src/pylorax/creator.py 6 2 33.33%
src/pylorax/installer.py 4 1 25.0%
src/pylorax/ltmpl.py 21 18 85.71%
src/pylorax/treebuilder.py 13 12 92.31%
Total (5 files) 49 38 77.55%

Coverage Regressions

Requires a base build to compare against. How to fix this →


Coverage Stats

Coverage Status
Relevant Lines: 3529
Covered Lines: 1638
Line Coverage: 46.42%
Relevant Branches: 1540
Covered Branches: 595
Branch Coverage: 38.64%
Branches in Coverage %: Yes
Coverage Strength: 0.46 hits per line

💛 - Coveralls

@brlane-rht
brlane-rht merged commit 7954c1c into weldr:rhel10-branch Aug 12, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants