Skip to content

Report actual exit status when nsenter exits unsuccessfully #675

@mdryaan

Description

@mdryaan

Description

In cmd/urunc/create.go, the function that handles the nsenter reexec result checks whether reexec.Process.Wait() returned an error, then separately checks whether the exit status was successful. The second branch — reached only when err is nil — wraps err into an error message using %w. At that point err is guaranteed to be nil because the first check already handled the non-nil case. The resulting error message reads "nsenter unsuccessful exit: <nil>", which hides the actual exit code and is meaningless to anyone reading logs or error output.

Expected behavior: When the nsenter process exits unsuccessfully, the error message includes the actual exit status (e.g. "nsenter unsuccessful exit: exit status 1").

Current behavior: The error message reads "nsenter unsuccessful exit: <nil>" because err is nil at the point it is formatted.

Proposed solution: Replace the fmt.Errorf call that wraps err with one that formats the exit status from the status value instead, so the real exit code appears in the error string.

Metadata

Metadata

Assignees

Labels

CoreRelated to urunc's internals

Type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions