Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asynchronous execution of sudo in parallel breaks terminal #1369

Closed
sylv-io opened this issue Oct 8, 2023 · 2 comments
Closed

Asynchronous execution of sudo in parallel breaks terminal #1369

sylv-io opened this issue Oct 8, 2023 · 2 comments

Comments

@sylv-io
Copy link
Contributor

sylv-io commented Oct 8, 2023

After running an old taskfile I wrote about a year ago, I realized that there is now a bug when multiple sudo commands are run in parallel.

You can reproduce this behavior by running this Taskfile:

version: '3'

tasks:
  default:
    deps:
      - sudo
      - sudo

  sudo:
      cmds:
      - sudo true

It is important to note that the input password prompt is not necessary to brake the terminal. It works even if the password is already cached or sudo is set to nopasswd.

i could observe multiple ways it brakes the terminal, such as not rendering the terminal input, as in this asciinema recording:
asciicast

Since this behavior was not observable 1 year ago, I assumed it must be a regression in task. However, I can also reproduce this bug with older Task versions like v2.7, indicating that it could be a regression in sudo instead.

This issue was created mainly to track the progress of the investigation of this bug, and because I'm probably not the only one using sudo to do privilege stuff in task.

  • Task version: main (f0d2551)
  • Operating system: Archlinux
  • Experiments enabled: no
@task-bot task-bot added the state: needs triage Waiting to be triaged by a maintainer. label Oct 8, 2023
@sylv-io
Copy link
Contributor Author

sylv-io commented Oct 8, 2023

This simple go application confirms that this is indeed a bug in sudo:

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 going to point this issue to sudo-project and see if this regression can be pinpointed with git bisect.

Let's keep this issue open until it's properly addressed/fixed. 👍

@sylv-io sylv-io changed the title Running sudo asynchronously brakes terminal Asynchronous execution of sudo in parallel brake terminal Oct 8, 2023
@sylv-io sylv-io changed the title Asynchronous execution of sudo in parallel brake terminal Asynchronous execution of sudo in parallel brakes terminal Oct 8, 2023
@sylv-io sylv-io changed the title Asynchronous execution of sudo in parallel brakes terminal Asynchronous execution of sudo in parallel breaks terminal Oct 9, 2023
@sylv-io
Copy link
Contributor Author

sylv-io commented Oct 20, 2023

Bug in sudo fixed by commit fabb626.

@sylv-io sylv-io closed this as completed Oct 20, 2023
@task-bot task-bot removed the state: needs triage Waiting to be triaged by a maintainer. label Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants