Skip to content
Commit 063d89ab authored by Pablo Correa Gómez's avatar Pablo Correa Gómez Committed by Robert Ancell
Browse files

user-accounts: run-passwd: Redirect stderr to stdout in the child

The previous code was prone to race conditions if the child already
started writing to stdout before the dup2 call happened. This has
been detected in postmarketOS[1] and I also reproduced it in Alpine
Linux. Since passwd writes to stderr and linux-pam to stdout, the
redirection was needed. However, linux-pam was failing with
"Conversation error" since an fprintf(stdout, ...) call wasn't
able to write to an already-closed stdout.

This problem is fixed by setting the redirection in the child setup
function and ignoring the stderr pipe. It also fixes a leak, where
the stderr fd was simply ignored and never closed.

[1] https://gitlab.com/postmarketOS/pmaports/-/issues/1449
parent 8e6b89db
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment