소스 검색

Windows: Daemon broken on master

Signed-off-by: John Howard <jhoward@microsoft.com>
John Howard 9 년 전
부모
커밋
bfe252b781
3개의 변경된 파일35개의 추가작업 그리고 20개의 파일을 삭제
  1. 0 19
      pkg/idtools/idtools.go
  2. 20 0
      pkg/idtools/usergroupadd_linux.go
  3. 15 1
      pkg/idtools/usergroupadd_unsupported.go

+ 0 - 19
pkg/idtools/idtools.go

@@ -7,8 +7,6 @@ import (
 	"sort"
 	"sort"
 	"strconv"
 	"strconv"
 	"strings"
 	"strings"
-
-	"github.com/docker/docker/pkg/system"
 )
 )
 
 
 // IDMap contains a single entry for user namespace range remapping. An array
 // 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 {
 	return mkdirAs(path, mode, ownerUID, ownerGID, false)
 	return mkdirAs(path, mode, ownerUID, ownerGID, false)
 }
 }
 
 
-func mkdirAs(path string, mode os.FileMode, ownerUID, ownerGID int, mkAll bool) error {
-	if mkAll {
-		if err := system.MkdirAll(path, mode); err != nil && !os.IsExist(err) {
-			return err
-		}
-	} else {
-		if err := os.Mkdir(path, mode); err != nil && !os.IsExist(err) {
-			return err
-		}
-	}
-	// even if it existed, we will chown to change ownership as requested
-	if err := os.Chown(path, ownerUID, ownerGID); err != nil {
-		return err
-	}
-	return nil
-}
-
 // GetRootUIDGID retrieves the remapped root uid/gid pair from the set of maps.
 // GetRootUIDGID retrieves the remapped root uid/gid pair from the set of maps.
 // If the maps are empty, then the root uid/gid will default to "real" 0/0
 // If the maps are empty, then the root uid/gid will default to "real" 0/0
 func GetRootUIDGID(uidMap, gidMap []IDMap) (int, int, error) {
 func GetRootUIDGID(uidMap, gidMap []IDMap) (int, int, error) {

+ 20 - 0
pkg/idtools/usergroupadd_linux.go

@@ -2,10 +2,13 @@ package idtools
 
 
 import (
 import (
 	"fmt"
 	"fmt"
+	"os"
 	"os/exec"
 	"os/exec"
 	"path/filepath"
 	"path/filepath"
 	"strings"
 	"strings"
 	"syscall"
 	"syscall"
+
+	"github.com/docker/docker/pkg/system"
 )
 )
 
 
 // add a user and/or group to Linux /etc/passwd, /etc/group using standard
 // 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) {
 		}
 		}
 	}
 	}
 }
 }
+
+func mkdirAs(path string, mode os.FileMode, ownerUID, ownerGID int, mkAll bool) error {
+	if mkAll {
+		if err := system.MkdirAll(path, mode); err != nil && !os.IsExist(err) {
+			return err
+		}
+	} else {
+		if err := os.Mkdir(path, mode); err != nil && !os.IsExist(err) {
+			return err
+		}
+	}
+	// even if it existed, we will chown to change ownership as requested
+	if err := os.Chown(path, ownerUID, ownerGID); err != nil {
+		return err
+	}
+	return nil
+}

+ 15 - 1
pkg/idtools/usergroupadd_unsupported.go

@@ -2,7 +2,12 @@
 
 
 package idtools
 package idtools
 
 
-import "fmt"
+import (
+	"fmt"
+	"os"
+
+	"github.com/docker/docker/pkg/system"
+)
 
 
 // AddNamespaceRangesUser takes a name and finds an unused uid, gid pair
 // AddNamespaceRangesUser takes a name and finds an unused uid, gid pair
 // and calls the appropriate helper function to add the group and then
 // and calls the appropriate helper function to add the group and then
@@ -10,3 +15,12 @@ import "fmt"
 func AddNamespaceRangesUser(name string) (int, int, error) {
 func AddNamespaceRangesUser(name string) (int, int, error) {
 	return -1, -1, fmt.Errorf("No support for adding users or groups on this OS")
 	return -1, -1, fmt.Errorf("No support for adding users or groups on this OS")
 }
 }
+
+// Platforms such as Windows do not support the UID/GID concept. So make this
+// just a wrapper around system.MkdirAll.
+func mkdirAs(path string, mode os.FileMode, ownerUID, ownerGID int, mkAll bool) error {
+	if err := system.MkdirAll(path, mode); err != nil && !os.IsExist(err) {
+		return err
+	}
+	return nil
+}