sudo-project/sudo

Asynchronous execution of sudo in parallel breaks terminal

sylv-io opened this issue · 6 comments

Regarding the issue addressed here: go-task/task#1369, it looks like there is a regression that causes the tty to break when sudo is running in parallel.
As mentioned in the above issue, it does not require a password prompt to break and can be reproduced by this simple go application:

package main

import (
       "log"
       "os"
       "os/exec"
       "sync"
)

const NumExecutions = 3

func main() {
       var wg sync.WaitGroup

       for i := 0; i < NumExecutions; i++ {
               wg.Add(1)

               go func() {
                       defer wg.Done()

                       cmd := exec.Command("sudo", "true")

                       cmd.Stdin = os.Stdin
                       cmd.Stdout = os.Stdout
                       cmd.Stderr = os.Stderr

                       err := cmd.Run()
                       if err != nil {
                               log.Fatal(err)
                       }
               }()
       }

       wg.Wait()
}

I'm pretty sure this didn't happen about 1 year ago, so I'm currently trying to bisect this bug.

I can confirm that this bug does not occur with sudo v1.9.0.

Can you check whether setting

Defaults !use_pty

in the sudoers file works around the problem?

Can you check whether setting

Defaults !use_pty

in the sudoers file works around the problem?

hi @millert
You are correct. This is indeed a workaround for the problem. 👍

I git bisected and as expected, this is the breaking commit:
Enable the use_pty option by default for sudo 1.9.14. 894daa8

Fixed by fabb626

Thanks 👍