Windows: Revendor github.com/Microsoft/go-winio
| ... | ... |
@@ -8,7 +8,7 @@ source 'hack/.vendor-helpers.sh' |
| 8 | 8 |
# the following lines are in sorted order, FYI |
| 9 | 9 |
clone git github.com/Azure/go-ansiterm 70b2c90b260171e829f1ebd7c17f600c11858dbe |
| 10 | 10 |
clone git github.com/Microsoft/hcsshim 116e0e9f5ced0cec94ae46d0aa1b3002a325f532 |
| 11 |
-clone git github.com/Microsoft/go-winio c40bf24f405ab3cc8e1383542d474e813332de6d |
|
| 11 |
+clone git github.com/Microsoft/go-winio f778f05015353be65d242f3fedc18695756153bb |
|
| 12 | 12 |
clone git github.com/Sirupsen/logrus v0.9.0 # logrus is a common dependency among multiple deps |
| 13 | 13 |
clone git github.com/docker/libtrust 9cbd2a1374f46905c68a4eb3694a130610adc62a |
| 14 | 14 |
clone git github.com/go-check/check 11d3bc7aa68e238947792f30573146a3231fc0f1 |
| ... | ... |
@@ -9,7 +9,7 @@ import ( |
| 9 | 9 |
"unicode/utf16" |
| 10 | 10 |
) |
| 11 | 11 |
|
| 12 |
-//sys adjustTokenPrivileges(token syscall.Handle, releaseAll bool, input *byte, outputSize uint32, output *byte, requiredSize *uint32) (err error) = advapi32.AdjustTokenPrivileges |
|
| 12 |
+//sys adjustTokenPrivileges(token syscall.Handle, releaseAll bool, input *byte, outputSize uint32, output *byte, requiredSize *uint32) (success bool, err error) [true] = advapi32.AdjustTokenPrivileges |
|
| 13 | 13 |
//sys impersonateSelf(level uint32) (err error) = advapi32.ImpersonateSelf |
| 14 | 14 |
//sys revertToSelf() (err error) = advapi32.RevertToSelf |
| 15 | 15 |
//sys openThreadToken(thread syscall.Handle, accessMask uint32, openAsSelf bool, token *syscall.Handle) (err error) = advapi32.OpenThreadToken |
| ... | ... |
@@ -21,6 +21,8 @@ import ( |
| 21 | 21 |
const ( |
| 22 | 22 |
SE_PRIVILEGE_ENABLED = 2 |
| 23 | 23 |
|
| 24 |
+ ERROR_NOT_ALL_ASSIGNED syscall.Errno = 1300 |
|
| 25 |
+ |
|
| 24 | 26 |
SeBackupPrivilege = "SeBackupPrivilege" |
| 25 | 27 |
SeRestorePrivilege = "SeRestorePrivilege" |
| 26 | 28 |
) |
| ... | ... |
@@ -91,10 +93,11 @@ func adjustPrivileges(token syscall.Handle, privileges []uint64) error {
|
| 91 | 91 |
} |
| 92 | 92 |
prevState := make([]byte, b.Len()) |
| 93 | 93 |
reqSize := uint32(0) |
| 94 |
- if err := adjustTokenPrivileges(token, false, &b.Bytes()[0], uint32(len(prevState)), &prevState[0], &reqSize); err != nil {
|
|
| 94 |
+ success, err := adjustTokenPrivileges(token, false, &b.Bytes()[0], uint32(len(prevState)), &prevState[0], &reqSize) |
|
| 95 |
+ if !success {
|
|
| 95 | 96 |
return err |
| 96 | 97 |
} |
| 97 |
- if int(binary.LittleEndian.Uint32(prevState[0:4])) < len(privileges) {
|
|
| 98 |
+ if err == ERROR_NOT_ALL_ASSIGNED {
|
|
| 98 | 99 |
return &PrivilegeError{privileges}
|
| 99 | 100 |
} |
| 100 | 101 |
return nil |
| ... | ... |
@@ -266,15 +266,16 @@ func setFileInformationByHandle(h syscall.Handle, class uint32, buffer *byte, si |
| 266 | 266 |
return |
| 267 | 267 |
} |
| 268 | 268 |
|
| 269 |
-func adjustTokenPrivileges(token syscall.Handle, releaseAll bool, input *byte, outputSize uint32, output *byte, requiredSize *uint32) (err error) {
|
|
| 269 |
+func adjustTokenPrivileges(token syscall.Handle, releaseAll bool, input *byte, outputSize uint32, output *byte, requiredSize *uint32) (success bool, err error) {
|
|
| 270 | 270 |
var _p0 uint32 |
| 271 | 271 |
if releaseAll {
|
| 272 | 272 |
_p0 = 1 |
| 273 | 273 |
} else {
|
| 274 | 274 |
_p0 = 0 |
| 275 | 275 |
} |
| 276 |
- r1, _, e1 := syscall.Syscall6(procAdjustTokenPrivileges.Addr(), 6, uintptr(token), uintptr(_p0), uintptr(unsafe.Pointer(input)), uintptr(outputSize), uintptr(unsafe.Pointer(output)), uintptr(unsafe.Pointer(requiredSize))) |
|
| 277 |
- if r1 == 0 {
|
|
| 276 |
+ r0, _, e1 := syscall.Syscall6(procAdjustTokenPrivileges.Addr(), 6, uintptr(token), uintptr(_p0), uintptr(unsafe.Pointer(input)), uintptr(outputSize), uintptr(unsafe.Pointer(output)), uintptr(unsafe.Pointer(requiredSize))) |
|
| 277 |
+ success = r0 != 0 |
|
| 278 |
+ if true {
|
|
| 278 | 279 |
if e1 != 0 {
|
| 279 | 280 |
err = error(e1) |
| 280 | 281 |
} else {
|