Bug 1057 - [bisected] main: sudo eats newlines on stderr since 760c9c110
[bisected] main: sudo eats newlines on stderr since 760c9c110
Status: RESOLVED FIXED
Product: Sudo
Classification: Unclassified
Component: Sudo
1.9.14
PC Linux
: low normal
Assigned To: Todd C. Miller
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2023-08-12 10:13 MDT by Sergei Trofimovich
Modified: 2023-11-06 11:20 MST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sergei Trofimovich 2023-08-12 10:13:55 MDT
Initially observed the problem after `nixpkgs` update sudo to 1.9.14p3 with a backport of https://github.com/sudo-project/sudo/commit/760c9c11074cb921ecc0da9fbb5f0a12afd46233.patch commit:

    https://github.com/NixOS/nixpkgs/pull/240681

This exposed a recent regression in sudo/main. Reproducer:

Good: newlines look as expected:

    # 1.9.14p3, no patches:
    $ { sudo printf "a\nb\nc\n" >&2; } |& nl
         1  a
         2  b
         3  c

Bad: newlines are like staircase (as if '\r' has no effect):

    # main, no patches:
    $ { sudo printf "a\nb\nc\n" >&2; } |& nl
         1  a
                  2 b
                          3 c

Bisect says it started since the following commit:

commit 760c9c11074cb921ecc0da9fbb5f0a12afd46233
Date:   Wed Jul 26 19:43:49 2023 -0600

    Don't assume that if std{in,out,err} is a tty, it is the user's tty.

    Previously, sudo only checked that the fd was a terminal, not that
    it matched sudo's idea of the user's terminal.  This matters when
    input or output is redirected to a different terminal.  In that
    case we want to interpose the fd with a pipe even if it refers to
    a terminal.  Bug #1056.
Comment 1 Todd C. Miller 2023-08-12 10:42:30 MDT
Thanks for the report, this is now fixed by: https://www.sudo.ws/repos/sudo/rev/ac80d75699d1

Please let the nixpkgs folks know so they can update their patch.
Comment 2 Sergei Trofimovich 2023-08-12 11:17:21 MDT
(In reply to Todd C. Miller from comment #1)
> Thanks for the report, this is now fixed by:
> https://www.sudo.ws/repos/sudo/rev/ac80d75699d1
> 
> Please let the nixpkgs folks know so they can update their patch.

The fix works for me as well. Proposed backport downstream as https://github.com/NixOS/nixpkgs/pull/248742

Thank you!
Comment 3 Todd C. Miller 2023-11-06 11:20:56 MST
Closing now that sudo 1.9.15 is available.