Browse code

Windows: Daemon broken on master

Signed-off-by: John Howard <jhoward@microsoft.com>

John Howard authored on 2015/10/13 00:42:07
Showing 3 changed files
... ...
@@ -7,8 +7,6 @@ import (
7 7
 	"sort"
8 8
 	"strconv"
9 9
 	"strings"
10
-
11
-	"github.com/docker/docker/pkg/system"
12 10
 )
13 11
 
14 12
 // 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 {
49 49
 	return mkdirAs(path, mode, ownerUID, ownerGID, false)
50 50
 }
51 51
 
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
-
69 52
 // GetRootUIDGID retrieves the remapped root uid/gid pair from the set of maps.
70 53
 // If the maps are empty, then the root uid/gid will default to "real" 0/0
71 54
 func GetRootUIDGID(uidMap, gidMap []IDMap) (int, int, error) {
... ...
@@ -2,10 +2,13 @@ package idtools
2 2
 
3 3
 import (
4 4
 	"fmt"
5
+	"os"
5 6
 	"os/exec"
6 7
 	"path/filepath"
7 8
 	"strings"
8 9
 	"syscall"
10
+
11
+	"github.com/docker/docker/pkg/system"
9 12
 )
10 13
 
11 14
 // 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) {
153 153
 		}
154 154
 	}
155 155
 }
156
+
157
+func mkdirAs(path string, mode os.FileMode, ownerUID, ownerGID int, mkAll bool) error {
158
+	if mkAll {
159
+		if err := system.MkdirAll(path, mode); err != nil && !os.IsExist(err) {
160
+			return err
161
+		}
162
+	} else {
163
+		if err := os.Mkdir(path, mode); err != nil && !os.IsExist(err) {
164
+			return err
165
+		}
166
+	}
167
+	// even if it existed, we will chown to change ownership as requested
168
+	if err := os.Chown(path, ownerUID, ownerGID); err != nil {
169
+		return err
170
+	}
171
+	return nil
172
+}
... ...
@@ -2,7 +2,12 @@
2 2
 
3 3
 package idtools
4 4
 
5
-import "fmt"
5
+import (
6
+	"fmt"
7
+	"os"
8
+
9
+	"github.com/docker/docker/pkg/system"
10
+)
6 11
 
7 12
 // AddNamespaceRangesUser takes a name and finds an unused uid, gid pair
8 13
 // and calls the appropriate helper function to add the group and then
... ...
@@ -10,3 +15,12 @@ import "fmt"
10 10
 func AddNamespaceRangesUser(name string) (int, int, error) {
11 11
 	return -1, -1, fmt.Errorf("No support for adding users or groups on this OS")
12 12
 }
13
+
14
+// Platforms such as Windows do not support the UID/GID concept. So make this
15
+// just a wrapper around system.MkdirAll.
16
+func mkdirAs(path string, mode os.FileMode, ownerUID, ownerGID int, mkAll bool) error {
17
+	if err := system.MkdirAll(path, mode); err != nil && !os.IsExist(err) {
18
+		return err
19
+	}
20
+	return nil
21
+}