Fix default socket group regression
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
parent
f7cfacbfe9
commit
c7c2cd4e8e
3 changed files with 16 additions and 2 deletions
|
@ -10,6 +10,8 @@ import (
|
|||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
const defaultSocketGroup = "docker"
|
||||
|
||||
func lookupGID(name string) (int, error) {
|
||||
groupFile, err := user.GetGroupPath()
|
||||
if err != nil {
|
||||
|
|
|
@ -4,7 +4,9 @@ import (
|
|||
"crypto/tls"
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/docker/go-connections/sockets"
|
||||
)
|
||||
|
||||
|
@ -20,8 +22,12 @@ func Init(proto, addr, socketGroup string, tlsConfig *tls.Config) (ls []net.List
|
|||
case "unix":
|
||||
gid, err := lookupGID(socketGroup)
|
||||
if err != nil {
|
||||
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)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("can't create unix socket %s: %v", addr, err)
|
||||
|
|
|
@ -6,8 +6,10 @@ import (
|
|||
"crypto/tls"
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/coreos/go-systemd/activation"
|
||||
"github.com/docker/go-connections/sockets"
|
||||
)
|
||||
|
@ -33,8 +35,12 @@ func Init(proto, addr, socketGroup string, tlsConfig *tls.Config) ([]net.Listene
|
|||
case "unix":
|
||||
gid, err := lookupGID(socketGroup)
|
||||
if err != nil {
|
||||
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)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("can't create unix socket %s: %v", addr, err)
|
||||
|
|
Loading…
Reference in a new issue