-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unprivileged upgrade testing for Windows. (#4642)
* Add unprivileged upgrade testing for Windows. * Adjust to 8.14.0-SNAPSHOT as minimum. * Add SeCreateSymbolicLinkPrivilege * Simplify if unprivileged mode is supported. * Fix file access for upgrade. * Fix kill watcher process on Windows in unprivileged mode. * Fix imports. * Fix kill non child process in tests. * Fix lint.
- Loading branch information
1 parent
f09496e
commit 4d3a3f9
Showing
11 changed files
with
132 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
// or more contributor license agreements. Licensed under the Elastic License; | ||
// you may not use this file except in compliance with the Elastic License. | ||
|
||
//go:build !windows | ||
|
||
package upgradetest | ||
|
||
import "os" | ||
|
||
// killNoneChildProcess provides a way of killing a process that is not started as a child of this process. | ||
// | ||
// On Unix systems it just calls the native golang kill. | ||
func killNoneChildProcess(proc *os.Process) error { | ||
return proc.Kill() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
// or more contributor license agreements. Licensed under the Elastic License; | ||
// you may not use this file except in compliance with the Elastic License. | ||
|
||
//go:build windows | ||
|
||
package upgradetest | ||
|
||
import ( | ||
"os" | ||
"syscall" | ||
) | ||
|
||
// killNoneChildProcess provides a way of killing a process that is not started as a child of this process. | ||
// | ||
// On Windows when running in unprivileged mode the internal way that golang uses DuplicateHandle to perform the kill | ||
// only works when the process is a child of this process. | ||
func killNoneChildProcess(proc *os.Process) error { | ||
h, e := syscall.OpenProcess(syscall.PROCESS_TERMINATE, false, uint32(proc.Pid)) | ||
if e != nil { | ||
return os.NewSyscallError("OpenProcess", e) | ||
} | ||
defer func() { | ||
_ = syscall.CloseHandle(h) | ||
}() | ||
e = syscall.TerminateProcess(h, 1) | ||
return os.NewSyscallError("TerminateProcess", e) | ||
} |