Signed-off-by: John Howard <jhoward@microsoft.com>
| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
# the following lines are in sorted order, FYI |
| 2 | 2 |
github.com/Azure/go-ansiterm 388960b655244e76e24c75f48631564eaefade62 |
| 3 | 3 |
github.com/Microsoft/hcsshim v0.5.7 |
| 4 |
-github.com/Microsoft/go-winio v0.3.5 |
|
| 4 |
+github.com/Microsoft/go-winio v0.3.6 |
|
| 5 | 5 |
github.com/Sirupsen/logrus f76d643702a30fbffecdfe50831e11881c96ceb3 https://github.com/aaronlehmann/logrus |
| 6 | 6 |
github.com/davecgh/go-spew 6d212800a42e8ab5c146b8ace3490ee17e5225f9 |
| 7 | 7 |
github.com/docker/libtrust 9cbd2a1374f46905c68a4eb3694a130610adc62a |
| ... | ... |
@@ -83,7 +83,7 @@ func RunWithPrivileges(names []string, fn func() error) error {
|
| 83 | 83 |
return err |
| 84 | 84 |
} |
| 85 | 85 |
defer releaseThreadToken(token) |
| 86 |
- err = adjustPrivileges(token, privileges) |
|
| 86 |
+ err = adjustPrivileges(token, privileges, SE_PRIVILEGE_ENABLED) |
|
| 87 | 87 |
if err != nil {
|
| 88 | 88 |
return err |
| 89 | 89 |
} |
| ... | ... |
@@ -110,6 +110,15 @@ func mapPrivileges(names []string) ([]uint64, error) {
|
| 110 | 110 |
|
| 111 | 111 |
// EnableProcessPrivileges enables privileges globally for the process. |
| 112 | 112 |
func EnableProcessPrivileges(names []string) error {
|
| 113 |
+ return enableDisableProcessPrivilege(names, SE_PRIVILEGE_ENABLED) |
|
| 114 |
+} |
|
| 115 |
+ |
|
| 116 |
+// DisableProcessPrivileges disables privileges globally for the process. |
|
| 117 |
+func DisableProcessPrivileges(names []string) error {
|
|
| 118 |
+ return enableDisableProcessPrivilege(names, 0) |
|
| 119 |
+} |
|
| 120 |
+ |
|
| 121 |
+func enableDisableProcessPrivilege(names []string, action uint32) error {
|
|
| 113 | 122 |
privileges, err := mapPrivileges(names) |
| 114 | 123 |
if err != nil {
|
| 115 | 124 |
return err |
| ... | ... |
@@ -123,15 +132,15 @@ func EnableProcessPrivileges(names []string) error {
|
| 123 | 123 |
} |
| 124 | 124 |
|
| 125 | 125 |
defer token.Close() |
| 126 |
- return adjustPrivileges(token, privileges) |
|
| 126 |
+ return adjustPrivileges(token, privileges, action) |
|
| 127 | 127 |
} |
| 128 | 128 |
|
| 129 |
-func adjustPrivileges(token windows.Token, privileges []uint64) error {
|
|
| 129 |
+func adjustPrivileges(token windows.Token, privileges []uint64, action uint32) error {
|
|
| 130 | 130 |
var b bytes.Buffer |
| 131 | 131 |
binary.Write(&b, binary.LittleEndian, uint32(len(privileges))) |
| 132 | 132 |
for _, p := range privileges {
|
| 133 | 133 |
binary.Write(&b, binary.LittleEndian, p) |
| 134 |
- binary.Write(&b, binary.LittleEndian, uint32(SE_PRIVILEGE_ENABLED)) |
|
| 134 |
+ binary.Write(&b, binary.LittleEndian, action) |
|
| 135 | 135 |
} |
| 136 | 136 |
prevState := make([]byte, b.Len()) |
| 137 | 137 |
reqSize := uint32(0) |