Don't error with empty group

Don't error if no group is specified, as this was the prior API.  Also
don't return a docker specific error message as this is in `/pkg` and
used by other projects.  Just set the default group for the current
user/group consuming the package.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
Upstream-commit: 169c013911c9465f0e62a37f467d1afa54a0dbe7
Component: engine
This commit is contained in:
Michael Crosby
2017-04-27 09:26:21 -07:00
parent 7ee17f3128
commit e369d2c215
2 changed files with 10 additions and 6 deletions
@@ -22,10 +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
if socketGroup != "" {
if socketGroup != defaultSocketGroup {
return nil, err
}
logrus.Warnf("could not change group %s to %s: %v", addr, defaultSocketGroup, err)
}
logrus.Warnf("could not change group %s to %s: %v", addr, defaultSocketGroup, err)
gid = os.Getgid()
}
l, err := sockets.NewUnixSocket(addr, gid)
@@ -35,10 +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
if socketGroup != "" {
if socketGroup != defaultSocketGroup {
return nil, err
}
logrus.Warnf("could not change group %s to %s: %v", addr, defaultSocketGroup, err)
}
logrus.Warnf("could not change group %s to %s: %v", addr, defaultSocketGroup, err)
gid = os.Getgid()
}
l, err := sockets.NewUnixSocket(addr, gid)