aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/golang.org/x/sys/windows
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/golang.org/x/sys/windows')
-rw-r--r--vendor/golang.org/x/sys/windows/asm_windows_386.s4
-rw-r--r--vendor/golang.org/x/sys/windows/asm_windows_amd64.s2
-rw-r--r--vendor/golang.org/x/sys/windows/env_unset.go15
-rw-r--r--vendor/golang.org/x/sys/windows/env_windows.go4
-rw-r--r--vendor/golang.org/x/sys/windows/registry/key.go10
-rw-r--r--vendor/golang.org/x/sys/windows/registry/registry_test.go2
-rw-r--r--vendor/golang.org/x/sys/windows/registry/zsyscall_windows.go2
-rw-r--r--vendor/golang.org/x/sys/windows/security_windows.go4
-rw-r--r--vendor/golang.org/x/sys/windows/service.go19
-rw-r--r--vendor/golang.org/x/sys/windows/svc/debug/service.go2
-rw-r--r--vendor/golang.org/x/sys/windows/svc/example/service.go2
-rw-r--r--vendor/golang.org/x/sys/windows/svc/mgr/config.go40
-rw-r--r--vendor/golang.org/x/sys/windows/svc/mgr/mgr_test.go81
-rw-r--r--vendor/golang.org/x/sys/windows/svc/mgr/recovery.go96
-rw-r--r--vendor/golang.org/x/sys/windows/svc/service.go4
-rw-r--r--vendor/golang.org/x/sys/windows/svc/svc_test.go19
-rw-r--r--vendor/golang.org/x/sys/windows/svc/sys_amd64.s2
-rw-r--r--vendor/golang.org/x/sys/windows/syscall.go3
-rw-r--r--vendor/golang.org/x/sys/windows/syscall_windows_test.go6
-rw-r--r--vendor/golang.org/x/sys/windows/types_windows.go65
-rw-r--r--vendor/golang.org/x/sys/windows/zsyscall_windows.go15
21 files changed, 331 insertions, 66 deletions
diff --git a/vendor/golang.org/x/sys/windows/asm_windows_386.s b/vendor/golang.org/x/sys/windows/asm_windows_386.s
index 1c20dd2..21d994d 100644
--- a/vendor/golang.org/x/sys/windows/asm_windows_386.s
+++ b/vendor/golang.org/x/sys/windows/asm_windows_386.s
@@ -6,8 +6,8 @@
// System calls for 386, Windows are implemented in runtime/syscall_windows.goc
//
-TEXT ·getprocaddress(SB), 7, $0-8
+TEXT ·getprocaddress(SB), 7, $0-16
JMP syscall·getprocaddress(SB)
-TEXT ·loadlibrary(SB), 7, $0-4
+TEXT ·loadlibrary(SB), 7, $0-12
JMP syscall·loadlibrary(SB)
diff --git a/vendor/golang.org/x/sys/windows/asm_windows_amd64.s b/vendor/golang.org/x/sys/windows/asm_windows_amd64.s
index 4d025ab..5bfdf79 100644
--- a/vendor/golang.org/x/sys/windows/asm_windows_amd64.s
+++ b/vendor/golang.org/x/sys/windows/asm_windows_amd64.s
@@ -9,5 +9,5 @@
TEXT ·getprocaddress(SB), 7, $0-32
JMP syscall·getprocaddress(SB)
-TEXT ·loadlibrary(SB), 7, $0-8
+TEXT ·loadlibrary(SB), 7, $0-24
JMP syscall·loadlibrary(SB)
diff --git a/vendor/golang.org/x/sys/windows/env_unset.go b/vendor/golang.org/x/sys/windows/env_unset.go
deleted file mode 100644
index b712c66..0000000
--- a/vendor/golang.org/x/sys/windows/env_unset.go
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2014 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build windows
-// +build go1.4
-
-package windows
-
-import "syscall"
-
-func Unsetenv(key string) error {
- // This was added in Go 1.4.
- return syscall.Unsetenv(key)
-}
diff --git a/vendor/golang.org/x/sys/windows/env_windows.go b/vendor/golang.org/x/sys/windows/env_windows.go
index e829238..bdc71e2 100644
--- a/vendor/golang.org/x/sys/windows/env_windows.go
+++ b/vendor/golang.org/x/sys/windows/env_windows.go
@@ -23,3 +23,7 @@ func Clearenv() {
func Environ() []string {
return syscall.Environ()
}
+
+func Unsetenv(key string) error {
+ return syscall.Unsetenv(key)
+}
diff --git a/vendor/golang.org/x/sys/windows/registry/key.go b/vendor/golang.org/x/sys/windows/registry/key.go
index d0beb19..c256483 100644
--- a/vendor/golang.org/x/sys/windows/registry/key.go
+++ b/vendor/golang.org/x/sys/windows/registry/key.go
@@ -113,12 +113,10 @@ func OpenRemoteKey(pcname string, k Key) (Key, error) {
// The parameter n controls the number of returned names,
// analogous to the way os.File.Readdirnames works.
func (k Key) ReadSubKeyNames(n int) ([]string, error) {
- ki, err := k.Stat()
- if err != nil {
- return nil, err
- }
- names := make([]string, 0, ki.SubKeyCount)
- buf := make([]uint16, ki.MaxSubKeyLen+1) // extra room for terminating zero byte
+ names := make([]string, 0)
+ // Registry key size limit is 255 bytes and described there:
+ // https://msdn.microsoft.com/library/windows/desktop/ms724872.aspx
+ buf := make([]uint16, 256) //plus extra room for terminating zero byte
loopItems:
for i := uint32(0); ; i++ {
if n > 0 {
diff --git a/vendor/golang.org/x/sys/windows/registry/registry_test.go b/vendor/golang.org/x/sys/windows/registry/registry_test.go
index 3cb9771..2f4dd69 100644
--- a/vendor/golang.org/x/sys/windows/registry/registry_test.go
+++ b/vendor/golang.org/x/sys/windows/registry/registry_test.go
@@ -29,7 +29,7 @@ func randKeyName(prefix string) string {
}
func TestReadSubKeyNames(t *testing.T) {
- k, err := registry.OpenKey(registry.CLASSES_ROOT, "TypeLib", registry.ENUMERATE_SUB_KEYS|registry.QUERY_VALUE)
+ k, err := registry.OpenKey(registry.CLASSES_ROOT, "TypeLib", registry.ENUMERATE_SUB_KEYS)
if err != nil {
t.Fatal(err)
}
diff --git a/vendor/golang.org/x/sys/windows/registry/zsyscall_windows.go b/vendor/golang.org/x/sys/windows/registry/zsyscall_windows.go
index ceebdd7..3778075 100644
--- a/vendor/golang.org/x/sys/windows/registry/zsyscall_windows.go
+++ b/vendor/golang.org/x/sys/windows/registry/zsyscall_windows.go
@@ -1,4 +1,4 @@
-// MACHINE GENERATED BY 'go generate' COMMAND; DO NOT EDIT
+// Code generated by 'go generate'; DO NOT EDIT.
package registry
diff --git a/vendor/golang.org/x/sys/windows/security_windows.go b/vendor/golang.org/x/sys/windows/security_windows.go
index f1ec5dc..4f17a33 100644
--- a/vendor/golang.org/x/sys/windows/security_windows.go
+++ b/vendor/golang.org/x/sys/windows/security_windows.go
@@ -296,6 +296,7 @@ const (
TOKEN_ADJUST_PRIVILEGES
TOKEN_ADJUST_GROUPS
TOKEN_ADJUST_DEFAULT
+ TOKEN_ADJUST_SESSIONID
TOKEN_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED |
TOKEN_ASSIGN_PRIMARY |
@@ -305,7 +306,8 @@ const (
TOKEN_QUERY_SOURCE |
TOKEN_ADJUST_PRIVILEGES |
TOKEN_ADJUST_GROUPS |
- TOKEN_ADJUST_DEFAULT
+ TOKEN_ADJUST_DEFAULT |
+ TOKEN_ADJUST_SESSIONID
TOKEN_READ = STANDARD_RIGHTS_READ | TOKEN_QUERY
TOKEN_WRITE = STANDARD_RIGHTS_WRITE |
TOKEN_ADJUST_PRIVILEGES |
diff --git a/vendor/golang.org/x/sys/windows/service.go b/vendor/golang.org/x/sys/windows/service.go
index a500dd7..62fc31b 100644
--- a/vendor/golang.org/x/sys/windows/service.go
+++ b/vendor/golang.org/x/sys/windows/service.go
@@ -43,6 +43,11 @@ const (
SC_STATUS_PROCESS_INFO = 0
+ SC_ACTION_NONE = 0
+ SC_ACTION_RESTART = 1
+ SC_ACTION_REBOOT = 2
+ SC_ACTION_RUN_COMMAND = 3
+
SERVICE_STOPPED = 1
SERVICE_START_PENDING = 2
SERVICE_STOP_PENDING = 3
@@ -148,6 +153,19 @@ type ENUM_SERVICE_STATUS_PROCESS struct {
ServiceStatusProcess SERVICE_STATUS_PROCESS
}
+type SERVICE_FAILURE_ACTIONS struct {
+ ResetPeriod uint32
+ RebootMsg *uint16
+ Command *uint16
+ ActionsCount uint32
+ Actions *SC_ACTION
+}
+
+type SC_ACTION struct {
+ Type uint32
+ Delay uint32
+}
+
//sys CloseServiceHandle(handle Handle) (err error) = advapi32.CloseServiceHandle
//sys CreateService(mgr Handle, serviceName *uint16, displayName *uint16, access uint32, srvType uint32, startType uint32, errCtl uint32, pathName *uint16, loadOrderGroup *uint16, tagId *uint32, dependencies *uint16, serviceStartName *uint16, password *uint16) (handle Handle, err error) [failretval==0] = advapi32.CreateServiceW
//sys OpenService(mgr Handle, serviceName *uint16, access uint32) (handle Handle, err error) [failretval==0] = advapi32.OpenServiceW
@@ -162,3 +180,4 @@ type ENUM_SERVICE_STATUS_PROCESS struct {
//sys ChangeServiceConfig2(service Handle, infoLevel uint32, info *byte) (err error) = advapi32.ChangeServiceConfig2W
//sys QueryServiceConfig2(service Handle, infoLevel uint32, buff *byte, buffSize uint32, bytesNeeded *uint32) (err error) = advapi32.QueryServiceConfig2W
//sys EnumServicesStatusEx(mgr Handle, infoLevel uint32, serviceType uint32, serviceState uint32, services *byte, bufSize uint32, bytesNeeded *uint32, servicesReturned *uint32, resumeHandle *uint32, groupName *uint16) (err error) = advapi32.EnumServicesStatusExW
+//sys QueryServiceStatusEx(service Handle, infoLevel uint32, buff *byte, buffSize uint32, bytesNeeded *uint32) (err error) = advapi32.QueryServiceStatusEx
diff --git a/vendor/golang.org/x/sys/windows/svc/debug/service.go b/vendor/golang.org/x/sys/windows/svc/debug/service.go
index 123df98..e621b87 100644
--- a/vendor/golang.org/x/sys/windows/svc/debug/service.go
+++ b/vendor/golang.org/x/sys/windows/svc/debug/service.go
@@ -31,7 +31,7 @@ func Run(name string, handler svc.Handler) error {
for {
select {
case <-sig:
- cmds <- svc.ChangeRequest{svc.Stop, 0, 0, status}
+ cmds <- svc.ChangeRequest{Cmd: svc.Stop, CurrentStatus: status}
case status = <-changes:
}
}
diff --git a/vendor/golang.org/x/sys/windows/svc/example/service.go b/vendor/golang.org/x/sys/windows/svc/example/service.go
index 237e809..74c9393 100644
--- a/vendor/golang.org/x/sys/windows/svc/example/service.go
+++ b/vendor/golang.org/x/sys/windows/svc/example/service.go
@@ -8,6 +8,7 @@ package main
import (
"fmt"
+ "strings"
"time"
"golang.org/x/sys/windows/svc"
@@ -26,6 +27,7 @@ func (m *myservice) Execute(args []string, r <-chan svc.ChangeRequest, changes c
slowtick := time.Tick(2 * time.Second)
tick := fasttick
changes <- svc.Status{State: svc.Running, Accepts: cmdsAccepted}
+ elog.Info(1, strings.Join(args, "-"))
loop:
for {
select {
diff --git a/vendor/golang.org/x/sys/windows/svc/mgr/config.go b/vendor/golang.org/x/sys/windows/svc/mgr/config.go
index 0a6edba..d804e31 100644
--- a/vendor/golang.org/x/sys/windows/svc/mgr/config.go
+++ b/vendor/golang.org/x/sys/windows/svc/mgr/config.go
@@ -88,23 +88,11 @@ func (s *Service) Config() (Config, error) {
}
}
- var p2 *windows.SERVICE_DESCRIPTION
- n = uint32(1024)
- for {
- b := make([]byte, n)
- p2 = (*windows.SERVICE_DESCRIPTION)(unsafe.Pointer(&b[0]))
- err := windows.QueryServiceConfig2(s.Handle,
- windows.SERVICE_CONFIG_DESCRIPTION, &b[0], n, &n)
- if err == nil {
- break
- }
- if err.(syscall.Errno) != syscall.ERROR_INSUFFICIENT_BUFFER {
- return Config{}, err
- }
- if n <= uint32(len(b)) {
- return Config{}, err
- }
+ b, err := s.queryServiceConfig2(windows.SERVICE_CONFIG_DESCRIPTION)
+ if err != nil {
+ return Config{}, err
}
+ p2 := (*windows.SERVICE_DESCRIPTION)(unsafe.Pointer(&b[0]))
return Config{
ServiceType: p.ServiceType,
@@ -121,7 +109,7 @@ func (s *Service) Config() (Config, error) {
}
func updateDescription(handle windows.Handle, desc string) error {
- d := windows.SERVICE_DESCRIPTION{toPtr(desc)}
+ d := windows.SERVICE_DESCRIPTION{Description: toPtr(desc)}
return windows.ChangeServiceConfig2(handle,
windows.SERVICE_CONFIG_DESCRIPTION, (*byte)(unsafe.Pointer(&d)))
}
@@ -137,3 +125,21 @@ func (s *Service) UpdateConfig(c Config) error {
}
return updateDescription(s.Handle, c.Description)
}
+
+// queryServiceConfig2 calls Windows QueryServiceConfig2 with infoLevel parameter and returns retrieved service configuration information.
+func (s *Service) queryServiceConfig2(infoLevel uint32) ([]byte, error) {
+ n := uint32(1024)
+ for {
+ b := make([]byte, n)
+ err := windows.QueryServiceConfig2(s.Handle, infoLevel, &b[0], n, &n)
+ if err == nil {
+ return b, nil
+ }
+ if err.(syscall.Errno) != syscall.ERROR_INSUFFICIENT_BUFFER {
+ return nil, err
+ }
+ if n <= uint32(len(b)) {
+ return nil, err
+ }
+ }
+}
diff --git a/vendor/golang.org/x/sys/windows/svc/mgr/mgr_test.go b/vendor/golang.org/x/sys/windows/svc/mgr/mgr_test.go
index 1569a22..13f1f38 100644
--- a/vendor/golang.org/x/sys/windows/svc/mgr/mgr_test.go
+++ b/vendor/golang.org/x/sys/windows/svc/mgr/mgr_test.go
@@ -95,6 +95,85 @@ func testConfig(t *testing.T, s *mgr.Service, should mgr.Config) mgr.Config {
return is
}
+func testRecoveryActions(t *testing.T, s *mgr.Service, should []mgr.RecoveryAction) {
+ is, err := s.RecoveryActions()
+ if err != nil {
+ t.Fatalf("RecoveryActions failed: %s", err)
+ }
+ if len(should) != len(is) {
+ t.Errorf("recovery action mismatch: contains %v actions, but should have %v", len(is), len(should))
+ }
+ for i, _ := range is {
+ if should[i].Type != is[i].Type {
+ t.Errorf("recovery action mismatch: Type is %v, but should have %v", is[i].Type, should[i].Type)
+ }
+ if should[i].Delay != is[i].Delay {
+ t.Errorf("recovery action mismatch: Delay is %v, but should have %v", is[i].Delay, should[i].Delay)
+ }
+ }
+}
+
+func testResetPeriod(t *testing.T, s *mgr.Service, should uint32) {
+ is, err := s.ResetPeriod()
+ if err != nil {
+ t.Fatalf("ResetPeriod failed: %s", err)
+ }
+ if should != is {
+ t.Errorf("reset period mismatch: reset period is %v, but should have %v", is, should)
+ }
+}
+
+func testSetRecoveryActions(t *testing.T, s *mgr.Service) {
+ r := []mgr.RecoveryAction{
+ mgr.RecoveryAction{
+ Type: mgr.NoAction,
+ Delay: 60000 * time.Millisecond,
+ },
+ mgr.RecoveryAction{
+ Type: mgr.ServiceRestart,
+ Delay: 4 * time.Minute,
+ },
+ mgr.RecoveryAction{
+ Type: mgr.ServiceRestart,
+ Delay: time.Minute,
+ },
+ mgr.RecoveryAction{
+ Type: mgr.RunCommand,
+ Delay: 4000 * time.Millisecond,
+ },
+ }
+
+ // 4 recovery actions with reset period
+ err := s.SetRecoveryActions(r, uint32(10000))
+ if err != nil {
+ t.Fatalf("SetRecoveryActions failed: %v", err)
+ }
+ testRecoveryActions(t, s, r)
+ testResetPeriod(t, s, uint32(10000))
+
+ // Infinite reset period
+ err = s.SetRecoveryActions(r, syscall.INFINITE)
+ if err != nil {
+ t.Fatalf("SetRecoveryActions failed: %v", err)
+ }
+ testRecoveryActions(t, s, r)
+ testResetPeriod(t, s, syscall.INFINITE)
+
+ // nil recovery actions
+ err = s.SetRecoveryActions(nil, 0)
+ if err.Error() != "recoveryActions cannot be nil" {
+ t.Fatalf("SetRecoveryActions failed with unexpected error message of %q", err)
+ }
+
+ // Delete all recovery actions and reset period
+ err = s.ResetRecoveryActions()
+ if err != nil {
+ t.Fatalf("ResetRecoveryActions failed: %v", err)
+ }
+ testRecoveryActions(t, s, nil)
+ testResetPeriod(t, s, 0)
+}
+
func remove(t *testing.T, s *mgr.Service) {
err := s.Delete()
if err != nil {
@@ -165,5 +244,7 @@ func TestMyService(t *testing.T) {
t.Errorf("ListServices failed to find %q service", name)
}
+ testSetRecoveryActions(t, s)
+
remove(t, s)
}
diff --git a/vendor/golang.org/x/sys/windows/svc/mgr/recovery.go b/vendor/golang.org/x/sys/windows/svc/mgr/recovery.go
new file mode 100644
index 0000000..9243dca
--- /dev/null
+++ b/vendor/golang.org/x/sys/windows/svc/mgr/recovery.go
@@ -0,0 +1,96 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build windows
+
+package mgr
+
+import (
+ "errors"
+ "time"
+ "unsafe"
+
+ "golang.org/x/sys/windows"
+)
+
+const (
+ // Possible recovery actions that the service control manager can perform.
+ NoAction = windows.SC_ACTION_NONE // no action
+ ComputerReboot = windows.SC_ACTION_REBOOT // reboot the computer
+ ServiceRestart = windows.SC_ACTION_RESTART // restart the service
+ RunCommand = windows.SC_ACTION_RUN_COMMAND // run a command
+)
+
+// RecoveryAction represents an action that the service control manager can perform when service fails.
+// A service is considered failed when it terminates without reporting a status of SERVICE_STOPPED to the service controller.
+type RecoveryAction struct {
+ Type int // one of NoAction, ComputerReboot, ServiceRestart or RunCommand
+ Delay time.Duration // the time to wait before performing the specified action
+}
+
+// SetRecoveryActions sets actions that service controller performs when service fails and
+// the time after which to reset the service failure count to zero if there are no failures, in seconds.
+// Specify INFINITE to indicate that service failure count should never be reset.
+func (s *Service) SetRecoveryActions(recoveryActions []RecoveryAction, resetPeriod uint32) error {
+ if recoveryActions == nil {
+ return errors.New("recoveryActions cannot be nil")
+ }
+ actions := []windows.SC_ACTION{}
+ for _, a := range recoveryActions {
+ action := windows.SC_ACTION{
+ Type: uint32(a.Type),
+ Delay: uint32(a.Delay.Nanoseconds() / 1000000),
+ }
+ actions = append(actions, action)
+ }
+ rActions := windows.SERVICE_FAILURE_ACTIONS{
+ ActionsCount: uint32(len(actions)),
+ Actions: &actions[0],
+ ResetPeriod: resetPeriod,
+ }
+ return windows.ChangeServiceConfig2(s.Handle, windows.SERVICE_CONFIG_FAILURE_ACTIONS, (*byte)(unsafe.Pointer(&rActions)))
+}
+
+// RecoveryActions returns actions that service controller performs when service fails.
+// The service control manager counts the number of times service s has failed since the system booted.
+// The count is reset to 0 if the service has not failed for ResetPeriod seconds.
+// When the service fails for the Nth time, the service controller performs the action specified in element [N-1] of returned slice.
+// If N is greater than slice length, the service controller repeats the last action in the slice.
+func (s *Service) RecoveryActions() ([]RecoveryAction, error) {
+ b, err := s.queryServiceConfig2(windows.SERVICE_CONFIG_FAILURE_ACTIONS)
+ if err != nil {
+ return nil, err
+ }
+ p := (*windows.SERVICE_FAILURE_ACTIONS)(unsafe.Pointer(&b[0]))
+ if p.Actions == nil {
+ return nil, err
+ }
+
+ var recoveryActions []RecoveryAction
+ actions := (*[1024]windows.SC_ACTION)(unsafe.Pointer(p.Actions))[:p.ActionsCount]
+ for _, action := range actions {
+ recoveryActions = append(recoveryActions, RecoveryAction{Type: int(action.Type), Delay: time.Duration(action.Delay) * time.Millisecond})
+ }
+ return recoveryActions, nil
+}
+
+// ResetRecoveryActions deletes both reset period and array of failure actions.
+func (s *Service) ResetRecoveryActions() error {
+ actions := make([]windows.SC_ACTION, 1)
+ rActions := windows.SERVICE_FAILURE_ACTIONS{
+ Actions: &actions[0],
+ }
+ return windows.ChangeServiceConfig2(s.Handle, windows.SERVICE_CONFIG_FAILURE_ACTIONS, (*byte)(unsafe.Pointer(&rActions)))
+}
+
+// ResetPeriod is the time after which to reset the service failure
+// count to zero if there are no failures, in seconds.
+func (s *Service) ResetPeriod() (uint32, error) {
+ b, err := s.queryServiceConfig2(windows.SERVICE_CONFIG_FAILURE_ACTIONS)
+ if err != nil {
+ return 0, err
+ }
+ p := (*windows.SERVICE_FAILURE_ACTIONS)(unsafe.Pointer(&b[0]))
+ return p.ResetPeriod, nil
+}
diff --git a/vendor/golang.org/x/sys/windows/svc/service.go b/vendor/golang.org/x/sys/windows/svc/service.go
index 903cba3..cda26b5 100644
--- a/vendor/golang.org/x/sys/windows/svc/service.go
+++ b/vendor/golang.org/x/sys/windows/svc/service.go
@@ -334,8 +334,8 @@ func Run(name string, handler Handler) error {
var svcmain uintptr
getServiceMain(&svcmain)
t := []windows.SERVICE_TABLE_ENTRY{
- {syscall.StringToUTF16Ptr(s.name), svcmain},
- {nil, 0},
+ {ServiceName: syscall.StringToUTF16Ptr(s.name), ServiceProc: svcmain},
+ {ServiceName: nil, ServiceProc: 0},
}
goWaitsH = uintptr(s.goWaits.h)
diff --git a/vendor/golang.org/x/sys/windows/svc/svc_test.go b/vendor/golang.org/x/sys/windows/svc/svc_test.go
index da7ec66..60eb447 100644
--- a/vendor/golang.org/x/sys/windows/svc/svc_test.go
+++ b/vendor/golang.org/x/sys/windows/svc/svc_test.go
@@ -7,10 +7,13 @@
package svc_test
import (
+ "fmt"
"io/ioutil"
+ "math/rand"
"os"
"os/exec"
"path/filepath"
+ "strings"
"testing"
"time"
@@ -86,8 +89,10 @@ func TestExample(t *testing.T) {
}
defer s.Close()
+ args := []string{"is", "manual-started", fmt.Sprintf("%d", rand.Int())}
+
testState(t, s, svc.Stopped)
- err = s.Start("is", "manual-started")
+ err = s.Start(args...)
if err != nil {
t.Fatalf("Start(%s) failed: %s", s.Name, err)
}
@@ -115,4 +120,16 @@ func TestExample(t *testing.T) {
if err != nil {
t.Fatalf("Delete failed: %s", err)
}
+
+ cmd := `Get-Eventlog -LogName Application -Newest 100` +
+ ` | Where Source -eq "myservice"` +
+ ` | Select -first 10` +
+ ` | Format-table -HideTableHeaders -property ReplacementStrings`
+ out, err := exec.Command("powershell", "-Command", cmd).CombinedOutput()
+ if err != nil {
+ t.Fatalf("powershell failed: %v\n%v", err, string(out))
+ }
+ if want := strings.Join(append([]string{name}, args...), "-"); !strings.Contains(string(out), want) {
+ t.Errorf("%q string does not contain %q", string(out), want)
+ }
}
diff --git a/vendor/golang.org/x/sys/windows/svc/sys_amd64.s b/vendor/golang.org/x/sys/windows/svc/sys_amd64.s
index 06b4259..bde25e9 100644
--- a/vendor/golang.org/x/sys/windows/svc/sys_amd64.s
+++ b/vendor/golang.org/x/sys/windows/svc/sys_amd64.s
@@ -7,7 +7,7 @@
// func servicemain(argc uint32, argv **uint16)
TEXT ·servicemain(SB),7,$0
MOVL CX, ·sArgc(SB)
- MOVL DX, ·sArgv(SB)
+ MOVQ DX, ·sArgv(SB)
SUBQ $32, SP // stack for the first 4 syscall params
diff --git a/vendor/golang.org/x/sys/windows/syscall.go b/vendor/golang.org/x/sys/windows/syscall.go
index b07bc23..af828a9 100644
--- a/vendor/golang.org/x/sys/windows/syscall.go
+++ b/vendor/golang.org/x/sys/windows/syscall.go
@@ -11,11 +11,14 @@
// system, set $GOOS and $GOARCH to the desired system. For example, if
// you want to view documentation for freebsd/arm on linux/amd64, set $GOOS
// to freebsd and $GOARCH to arm.
+//
// The primary use of this package is inside other packages that provide a more
// portable interface to the system, such as "os", "time" and "net". Use
// those packages rather than this one if you can.
+//
// For details of the functions and data types in this package consult
// the manuals for the appropriate operating system.
+//
// These calls return err == nil to indicate success; otherwise
// err represents an operating system error describing the failure and
// holds a value of type syscall.Errno.
diff --git a/vendor/golang.org/x/sys/windows/syscall_windows_test.go b/vendor/golang.org/x/sys/windows/syscall_windows_test.go
index 9c7133c..0e27464 100644
--- a/vendor/golang.org/x/sys/windows/syscall_windows_test.go
+++ b/vendor/golang.org/x/sys/windows/syscall_windows_test.go
@@ -105,3 +105,9 @@ func ExampleLoadLibrary() {
build := uint16(r >> 16)
print("windows version ", major, ".", minor, " (Build ", build, ")\n")
}
+
+func TestTOKEN_ALL_ACCESS(t *testing.T) {
+ if windows.TOKEN_ALL_ACCESS != 0xF01FF {
+ t.Errorf("TOKEN_ALL_ACCESS = %x, want 0xF01FF", windows.TOKEN_ALL_ACCESS)
+ }
+}
diff --git a/vendor/golang.org/x/sys/windows/types_windows.go b/vendor/golang.org/x/sys/windows/types_windows.go
index 52c2037..7d2a679 100644
--- a/vendor/golang.org/x/sys/windows/types_windows.go
+++ b/vendor/golang.org/x/sys/windows/types_windows.go
@@ -94,16 +94,29 @@ const (
FILE_APPEND_DATA = 0x00000004
FILE_WRITE_ATTRIBUTES = 0x00000100
- FILE_SHARE_READ = 0x00000001
- FILE_SHARE_WRITE = 0x00000002
- FILE_SHARE_DELETE = 0x00000004
- FILE_ATTRIBUTE_READONLY = 0x00000001
- FILE_ATTRIBUTE_HIDDEN = 0x00000002
- FILE_ATTRIBUTE_SYSTEM = 0x00000004
- FILE_ATTRIBUTE_DIRECTORY = 0x00000010
- FILE_ATTRIBUTE_ARCHIVE = 0x00000020
- FILE_ATTRIBUTE_NORMAL = 0x00000080
- FILE_ATTRIBUTE_REPARSE_POINT = 0x00000400
+ FILE_SHARE_READ = 0x00000001
+ FILE_SHARE_WRITE = 0x00000002
+ FILE_SHARE_DELETE = 0x00000004
+
+ FILE_ATTRIBUTE_READONLY = 0x00000001
+ FILE_ATTRIBUTE_HIDDEN = 0x00000002
+ FILE_ATTRIBUTE_SYSTEM = 0x00000004
+ FILE_ATTRIBUTE_DIRECTORY = 0x00000010
+ FILE_ATTRIBUTE_ARCHIVE = 0x00000020
+ FILE_ATTRIBUTE_DEVICE = 0x00000040
+ FILE_ATTRIBUTE_NORMAL = 0x00000080
+ FILE_ATTRIBUTE_TEMPORARY = 0x00000100
+ FILE_ATTRIBUTE_SPARSE_FILE = 0x00000200
+ FILE_ATTRIBUTE_REPARSE_POINT = 0x00000400
+ FILE_ATTRIBUTE_COMPRESSED = 0x00000800
+ FILE_ATTRIBUTE_OFFLINE = 0x00001000
+ FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 0x00002000
+ FILE_ATTRIBUTE_ENCRYPTED = 0x00004000
+ FILE_ATTRIBUTE_INTEGRITY_STREAM = 0x00008000
+ FILE_ATTRIBUTE_VIRTUAL = 0x00010000
+ FILE_ATTRIBUTE_NO_SCRUB_DATA = 0x00020000
+ FILE_ATTRIBUTE_RECALL_ON_OPEN = 0x00040000
+ FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS = 0x00400000
INVALID_FILE_ATTRIBUTES = 0xffffffff
@@ -312,6 +325,14 @@ var (
OID_SGC_NETSCAPE = []byte("2.16.840.1.113730.4.1\x00")
)
+// Pointer represents a pointer to an arbitrary Windows type.
+//
+// Pointer-typed fields may point to one of many different types. It's
+// up to the caller to provide a pointer to the appropriate type, cast
+// to Pointer. The caller must obey the unsafe.Pointer rules while
+// doing so.
+type Pointer *struct{}
+
// Invented values to support what package os expects.
type Timeval struct {
Sec int32
@@ -880,11 +901,15 @@ type MibIfRow struct {
Descr [MAXLEN_IFDESCR]byte
}
+type CertInfo struct {
+ // Not implemented
+}
+
type CertContext struct {
EncodingType uint32
EncodedCert *byte
Length uint32
- CertInfo uintptr
+ CertInfo *CertInfo
Store Handle
}
@@ -899,12 +924,16 @@ type CertChainContext struct {
RevocationFreshnessTime uint32
}
+type CertTrustListInfo struct {
+ // Not implemented
+}
+
type CertSimpleChain struct {
Size uint32
TrustStatus CertTrustStatus
NumElements uint32
Elements **CertChainElement
- TrustListInfo uintptr
+ TrustListInfo *CertTrustListInfo
HasRevocationFreshnessTime uint32
RevocationFreshnessTime uint32
}
@@ -919,14 +948,18 @@ type CertChainElement struct {
ExtendedErrorInfo *uint16
}
+type CertRevocationCrlInfo struct {
+ // Not implemented
+}
+
type CertRevocationInfo struct {
Size uint32
RevocationResult uint32
RevocationOid *byte
- OidSpecificInfo uintptr
+ OidSpecificInfo Pointer
HasFreshnessTime uint32
FreshnessTime uint32
- CrlInfo uintptr // *CertRevocationCrlInfo
+ CrlInfo *CertRevocationCrlInfo
}
type CertTrustStatus struct {
@@ -957,7 +990,7 @@ type CertChainPara struct {
type CertChainPolicyPara struct {
Size uint32
Flags uint32
- ExtraPolicyPara uintptr
+ ExtraPolicyPara Pointer
}
type SSLExtraCertChainPolicyPara struct {
@@ -972,7 +1005,7 @@ type CertChainPolicyStatus struct {
Error uint32
ChainIndex uint32
ElementIndex uint32
- ExtraPolicyStatus uintptr
+ ExtraPolicyStatus Pointer
}
const (
diff --git a/vendor/golang.org/x/sys/windows/zsyscall_windows.go b/vendor/golang.org/x/sys/windows/zsyscall_windows.go
index c7b3b15..fc56aec 100644
--- a/vendor/golang.org/x/sys/windows/zsyscall_windows.go
+++ b/vendor/golang.org/x/sys/windows/zsyscall_windows.go
@@ -1,4 +1,4 @@
-// MACHINE GENERATED BY 'go generate' COMMAND; DO NOT EDIT
+// Code generated by 'go generate'; DO NOT EDIT.
package windows
@@ -65,6 +65,7 @@ var (
procChangeServiceConfig2W = modadvapi32.NewProc("ChangeServiceConfig2W")
procQueryServiceConfig2W = modadvapi32.NewProc("QueryServiceConfig2W")
procEnumServicesStatusExW = modadvapi32.NewProc("EnumServicesStatusExW")
+ procQueryServiceStatusEx = modadvapi32.NewProc("QueryServiceStatusEx")
procGetLastError = modkernel32.NewProc("GetLastError")
procLoadLibraryW = modkernel32.NewProc("LoadLibraryW")
procLoadLibraryExW = modkernel32.NewProc("LoadLibraryExW")
@@ -472,6 +473,18 @@ func EnumServicesStatusEx(mgr Handle, infoLevel uint32, serviceType uint32, serv
return
}
+func QueryServiceStatusEx(service Handle, infoLevel uint32, buff *byte, buffSize uint32, bytesNeeded *uint32) (err error) {
+ r1, _, e1 := syscall.Syscall6(procQueryServiceStatusEx.Addr(), 5, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(buff)), uintptr(buffSize), uintptr(unsafe.Pointer(bytesNeeded)), 0)
+ if r1 == 0 {
+ if e1 != 0 {
+ err = errnoErr(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}
+
func GetLastError() (lasterr error) {
r0, _, _ := syscall.Syscall(procGetLastError.Addr(), 0, 0, 0, 0)
if r0 != 0 {