Skip to content

utils: Clarify that ensure_file, ensure_dir intentionally follow symlinks#737

Merged
cgwalters merged 1 commit intocontainers:mainfrom
smcv:issue733
Mar 20, 2026
Merged

utils: Clarify that ensure_file, ensure_dir intentionally follow symlinks#737
cgwalters merged 1 commit intocontainers:mainfrom
smcv:issue733

Conversation

@smcv
Copy link
Collaborator

@smcv smcv commented Mar 20, 2026

In #733, the issue reporter thought that we'd intended to use lstat() in ensure_file(), because stat() doesn't normally result in S_ISLNK. In fact this was working as intended - we were checking for the one situation where stat() will produce S_ISLNK, which is a dangling symlink - but it wasn't as obvious as it could have been.

No functional change, comments only.

Fixes: #733


@dwahdany, if we had already had these comments, would that have avoided #733?

…inks

In containers#733, the issue reporter thought that we'd intended to use lstat()
in ensure_file(), because stat() doesn't normally result in S_ISLNK.
In fact this was working as intended - we were checking for the one
situation where stat() *will* produce S_ISLNK, which is a dangling
symlink - but it wasn't as obvious as it could have been.

No functional change, comments only.

Fixes: containers#733
Signed-off-by: Simon McVittie <smcv@collabora.com>
@dwahdany
Copy link

yes, perfect. thx @smcv !

@cgwalters cgwalters merged commit 5e8f408 into containers:main Mar 20, 2026
4 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.

ensure_file() uses stat() instead of lstat(), making S_ISLNK check dead code

3 participants