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
Please register or sign in to comment