Skip to content

Commit bfe252b

Browse files
author
John Howard
committed
Windows: Daemon broken on master
Signed-off-by: John Howard <[email protected]>
1 parent 08c5f52 commit bfe252b

3 files changed

Lines changed: 35 additions & 20 deletions

File tree

‎pkg/idtools/idtools.go‎

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import (
77
"sort"
88
"strconv"
99
"strings"
10-
11-
"github.com/docker/docker/pkg/system"
1210
)
1311

1412
// IDMap contains a single entry for user namespace range remapping. An array
@@ -49,23 +47,6 @@ func MkdirAs(path string, mode os.FileMode, ownerUID, ownerGID int) error {
4947
return mkdirAs(path, mode, ownerUID, ownerGID, false)
5048
}
5149

52-
func mkdirAs(path string, mode os.FileMode, ownerUID, ownerGID int, mkAll bool) error {
53-
if mkAll {
54-
if err := system.MkdirAll(path, mode); err != nil && !os.IsExist(err) {
55-
return err
56-
}
57-
} else {
58-
if err := os.Mkdir(path, mode); err != nil && !os.IsExist(err) {
59-
return err
60-
}
61-
}
62-
// even if it existed, we will chown to change ownership as requested
63-
if err := os.Chown(path, ownerUID, ownerGID); err != nil {
64-
return err
65-
}
66-
return nil
67-
}
68-
6950
// GetRootUIDGID retrieves the remapped root uid/gid pair from the set of maps.
7051
// If the maps are empty, then the root uid/gid will default to "real" 0/0
7152
func GetRootUIDGID(uidMap, gidMap []IDMap) (int, int, error) {

‎pkg/idtools/usergroupadd_linux.go‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@ package idtools
22

33
import (
44
"fmt"
5+
"os"
56
"os/exec"
67
"path/filepath"
78
"strings"
89
"syscall"
10+
11+
"github.com/docker/docker/pkg/system"
912
)
1013

1114
// add a user and/or group to Linux /etc/passwd, /etc/group using standard
@@ -153,3 +156,20 @@ func findUnused(file string, id int) (int, error) {
153156
}
154157
}
155158
}
159+
160+
func mkdirAs(path string, mode os.FileMode, ownerUID, ownerGID int, mkAll bool) error {
161+
if mkAll {
162+
if err := system.MkdirAll(path, mode); err != nil && !os.IsExist(err) {
163+
return err
164+
}
165+
} else {
166+
if err := os.Mkdir(path, mode); err != nil && !os.IsExist(err) {
167+
return err
168+
}
169+
}
170+
// even if it existed, we will chown to change ownership as requested
171+
if err := os.Chown(path, ownerUID, ownerGID); err != nil {
172+
return err
173+
}
174+
return nil
175+
}

‎pkg/idtools/usergroupadd_unsupported.go‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,25 @@
22

33
package idtools
44

5-
import "fmt"
5+
import (
6+
"fmt"
7+
"os"
8+
9+
"github.com/docker/docker/pkg/system"
10+
)
611

712
// AddNamespaceRangesUser takes a name and finds an unused uid, gid pair
813
// and calls the appropriate helper function to add the group and then
914
// the user to the group in /etc/group and /etc/passwd respectively.
1015
func AddNamespaceRangesUser(name string) (int, int, error) {
1116
return -1, -1, fmt.Errorf("No support for adding users or groups on this OS")
1217
}
18+
19+
// Platforms such as Windows do not support the UID/GID concept. So make this
20+
// just a wrapper around system.MkdirAll.
21+
func mkdirAs(path string, mode os.FileMode, ownerUID, ownerGID int, mkAll bool) error {
22+
if err := system.MkdirAll(path, mode); err != nil && !os.IsExist(err) {
23+
return err
24+
}
25+
return nil
26+
}

0 commit comments

Comments
 (0)