Skip to content

Commit

Permalink
add groups check to ssh driver
Browse files Browse the repository at this point in the history
  • Loading branch information
kaylendog committed Dec 14, 2022
1 parent c88bc8b commit 0be72ee
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/drivers/ssh/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"os/exec"
"path"
"strconv"
"strings"
"time"

"golang.org/x/crypto/ssh"
Expand Down Expand Up @@ -141,8 +142,14 @@ func (d *Driver) Create() error {
}

if d.runtime.Name() == "Docker" {
if _, err := d.exec.RunCmd(exec.Command("sudo", "usermod", "-aG", "docker", d.GetSSHUsername())); err != nil {
return errors.Wrap(err, "usermod")
groups, err := d.exec.RunCmd(exec.Command("groups", d.GetSSHUsername()))
if err != nil {
return errors.Wrap(err, "groups")
}
if !strings.Contains(groups.Stderr.String(), "docker") {
if _, err := d.exec.RunCmd(exec.Command("sudo", "usermod", "-aG", "docker", d.GetSSHUsername())); err != nil {
return errors.Wrap(err, "usermod")
}
}
}

Expand Down

0 comments on commit 0be72ee

Please sign in to comment.