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,7 +22,11 @@ func Init(proto, addr, socketGroup string, tlsConfig *tls.Config) (ls []net.List
|
|||
case "unix":
|
||||
gid, err := lookupGID(socketGroup)
|
||||
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)
|
||||
if err != nil {
|
||||
|
|
|
@ -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,7 +35,11 @@ func Init(proto, addr, socketGroup string, tlsConfig *tls.Config) ([]net.Listene
|
|||
case "unix":
|
||||
gid, err := lookupGID(socketGroup)
|
||||
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)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue