1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #31833 from tonistiigi/docker-group

Fix default socket group regression
This commit is contained in:
Victor Vieux 2017-03-14 20:34:42 -07:00 committed by GitHub
commit 0b9b7906af
3 changed files with 16 additions and 2 deletions

View file

@ -10,6 +10,8 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
) )
const defaultSocketGroup = "docker"
func lookupGID(name string) (int, error) { func lookupGID(name string) (int, error) {
groupFile, err := user.GetGroupPath() groupFile, err := user.GetGroupPath()
if err != nil { if err != nil {

View file

@ -4,7 +4,9 @@ import (
"crypto/tls" "crypto/tls"
"fmt" "fmt"
"net" "net"
"os"
"github.com/Sirupsen/logrus"
"github.com/docker/go-connections/sockets" "github.com/docker/go-connections/sockets"
) )
@ -20,7 +22,11 @@ func Init(proto, addr, socketGroup string, tlsConfig *tls.Config) (ls []net.List
case "unix": case "unix":
gid, err := lookupGID(socketGroup) gid, err := lookupGID(socketGroup)
if err != nil { if err != nil {
return nil, err if socketGroup != defaultSocketGroup {
return nil, err
}
logrus.Warnf("could not change group %s to %s: %v", addr, defaultSocketGroup, err)
gid = os.Getgid()
} }
l, err := sockets.NewUnixSocket(addr, gid) l, err := sockets.NewUnixSocket(addr, gid)
if err != nil { if err != nil {

View file

@ -6,8 +6,10 @@ import (
"crypto/tls" "crypto/tls"
"fmt" "fmt"
"net" "net"
"os"
"strconv" "strconv"
"github.com/Sirupsen/logrus"
"github.com/coreos/go-systemd/activation" "github.com/coreos/go-systemd/activation"
"github.com/docker/go-connections/sockets" "github.com/docker/go-connections/sockets"
) )
@ -33,7 +35,11 @@ func Init(proto, addr, socketGroup string, tlsConfig *tls.Config) ([]net.Listene
case "unix": case "unix":
gid, err := lookupGID(socketGroup) gid, err := lookupGID(socketGroup)
if err != nil { if err != nil {
return nil, err if socketGroup != defaultSocketGroup {
return nil, err
}
logrus.Warnf("could not change group %s to %s: %v", addr, defaultSocketGroup, err)
gid = os.Getgid()
} }
l, err := sockets.NewUnixSocket(addr, gid) l, err := sockets.NewUnixSocket(addr, gid)
if err != nil { if err != nil {