Skip to content

runcon: report a stdout write error instead of panicking#13380

Open
leeewee wants to merge 1 commit into
uutils:mainfrom
leeewee:runcon-fix-write-error
Open

runcon: report a stdout write error instead of panicking#13380
leeewee wants to merge 1 commit into
uutils:mainfrom
leeewee:runcon-fix-write-error

Conversation

@leeewee

@leeewee leeewee commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Fixes #13379

runcon with no arguments prints the current SELinux context with println!, which aborts (exit 134) when the stdout write fails — e.g. output redirected to a full device. GNU reports the write error and exits 1.

print_current_context now writes to a locked stdout and propagates the io::Error as a new Error::Write, so a write failure is reported as write error: <reason> (exit 1), matching GNU.

Before:

$ runcon > /dev/full
thread 'main' panicked at library/std/src/io/stdio.rs:...:
failed printing to stdout: No space left on device (os error 28)
Aborted (core dumped)          # exit 134

After:

$ runcon > /dev/full
runcon: write error: No space left on device        # exit 1

This matches GNU byte-for-byte (/usr/bin/runcon: write error: No space left on device, exit 1) and is the same write-error class as chcon (#13061) and kill (#13297). A regression test is added (/dev/full, Linux-gated).

@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

Skipping an intermittent issue tests/cut/bounded-memory (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/misc/tty-eof (passes in this run but fails in the 'main' branch)
Note: The gnu test tests/env/env-signal-handler was skipped on 'main' but is now failing.

Comment thread src/uu/runcon/src/errors.rs Outdated
source: io::Error,
},

#[error("{}", translate!("runcon-error-write-error", "error" => .0))]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
#[error("{}", translate!("runcon-error-write-error", "error" => .0))]
#[error("{}", translate!("runcon-error-write", "error" => strip_errno(.0)))]
Write(io::Error),

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.

Applied, thanks!

`print_current_context` printed the current context with `println!`, which
aborts (exit 134) when the write fails, e.g. stdout redirected to a full
device. Write to a locked stdout and propagate the io::Error as a new
`Error::Write`, so a write failure is reported as `write error: <reason>`
with exit 1, matching GNU.
@leeewee
leeewee force-pushed the runcon-fix-write-error branch from 4492832 to 77d6148 Compare July 15, 2026 04:38
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.

runcon panics (aborts) on a stdout write error when output to /dev/full

2 participants