Browse code

Use newer x/sys/windows SecurityAttributes struct

This struct now has a properly typed member, so use the properly typed
functions with it.

Also update the vendor directory and hope nothing explodes.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Jason A. Donenfeld authored on 2019/10/01 00:07:47
Showing 3 changed files
... ...
@@ -12,7 +12,6 @@ import (
12 12
 	"github.com/docker/docker/pkg/idtools"
13 13
 	"github.com/docker/docker/pkg/jsonmessage"
14 14
 	"github.com/docker/docker/pkg/system"
15
-	"github.com/pkg/errors"
16 15
 	"golang.org/x/sys/windows"
17 16
 )
18 17
 
... ...
@@ -31,13 +30,7 @@ func getAccountIdentity(builder *Builder, accountName string, ctrRootPath string
31 31
 		sid, err := windows.StringToSid(accountName)
32 32
 
33 33
 		if err == nil {
34
-			accountSid, err := sid.String()
35
-
36
-			if err != nil {
37
-				return idtools.Identity{SID: ""}, errors.Wrapf(err, "error converting SID to string")
38
-			}
39
-
40
-			return idtools.Identity{SID: accountSid}, nil
34
+			return idtools.Identity{SID: sid.String()}, nil
41 35
 		}
42 36
 	}
43 37
 
... ...
@@ -46,13 +39,7 @@ func getAccountIdentity(builder *Builder, accountName string, ctrRootPath string
46 46
 
47 47
 	// If this is a SID that is built-in and hence the same across all systems then use that.
48 48
 	if err == nil && (accType == windows.SidTypeAlias || accType == windows.SidTypeWellKnownGroup) {
49
-		accountSid, err := sid.String()
50
-
51
-		if err != nil {
52
-			return idtools.Identity{SID: ""}, errors.Wrapf(err, "error converting SID to string")
53
-		}
54
-
55
-		return idtools.Identity{SID: accountSid}, nil
49
+		return idtools.Identity{SID: sid.String()}, nil
56 50
 	}
57 51
 
58 52
 	// Check if the account name is one unique to containers.
... ...
@@ -5,7 +5,6 @@ import (
5 5
 	"os"
6 6
 	"unsafe"
7 7
 
8
-	winio "github.com/Microsoft/go-winio"
9 8
 	"github.com/docker/docker/pkg/signal"
10 9
 	"github.com/sirupsen/logrus"
11 10
 	"golang.org/x/sys/windows"
... ...
@@ -17,7 +16,7 @@ func (d *Daemon) setupDumpStackTrap(root string) {
17 17
 	// signaled. ACL'd to builtin administrators and local system
18 18
 	event := "Global\\stackdump-" + fmt.Sprint(os.Getpid())
19 19
 	ev, _ := windows.UTF16PtrFromString(event)
20
-	sd, err := winio.SddlToSecurityDescriptor("D:P(A;;GA;;;BA)(A;;GA;;;SY)")
20
+	sd, err := windows.SecurityDescriptorFromString("D:P(A;;GA;;;BA)(A;;GA;;;SY)")
21 21
 	if err != nil {
22 22
 		logrus.Errorf("failed to get security descriptor for debug stackdump event %s: %s", event, err.Error())
23 23
 		return
... ...
@@ -25,7 +24,7 @@ func (d *Daemon) setupDumpStackTrap(root string) {
25 25
 	var sa windows.SecurityAttributes
26 26
 	sa.Length = uint32(unsafe.Sizeof(sa))
27 27
 	sa.InheritHandle = 1
28
-	sa.SecurityDescriptor = uintptr(unsafe.Pointer(&sd[0]))
28
+	sa.SecurityDescriptor = sd
29 29
 	h, err := windows.CreateEvent(&sa, 0, 0, ev)
30 30
 	if h == 0 || err != nil {
31 31
 		logrus.Errorf("failed to create debug stackdump event %s: %s", event, err.Error())
... ...
@@ -11,7 +11,6 @@ import (
11 11
 	"time"
12 12
 	"unsafe"
13 13
 
14
-	winio "github.com/Microsoft/go-winio"
15 14
 	"golang.org/x/sys/windows"
16 15
 )
17 16
 
... ...
@@ -103,13 +102,13 @@ func mkdirall(path string, applyACL bool, sddl string) error {
103 103
 // and Local System.
104 104
 func mkdirWithACL(name string, sddl string) error {
105 105
 	sa := windows.SecurityAttributes{Length: 0}
106
-	sd, err := winio.SddlToSecurityDescriptor(sddl)
106
+	sd, err := windows.SecurityDescriptorFromString(sddl)
107 107
 	if err != nil {
108 108
 		return &os.PathError{Op: "mkdir", Path: name, Err: err}
109 109
 	}
110 110
 	sa.Length = uint32(unsafe.Sizeof(sa))
111 111
 	sa.InheritHandle = 1
112
-	sa.SecurityDescriptor = uintptr(unsafe.Pointer(&sd[0]))
112
+	sa.SecurityDescriptor = sd
113 113
 
114 114
 	namep, err := windows.UTF16PtrFromString(name)
115 115
 	if err != nil {