mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Vendor Update Go Libs (#13166)
* update github.com/alecthomas/chroma v0.8.0 -> v0.8.1 * github.com/blevesearch/bleve v1.0.10 -> v1.0.12 * editorconfig-core-go v2.1.1 -> v2.3.7 * github.com/gliderlabs/ssh v0.2.2 -> v0.3.1 * migrate editorconfig.ParseBytes to Parse * github.com/shurcooL/vfsgen to 0d455de96546 * github.com/go-git/go-git/v5 v5.1.0 -> v5.2.0 * github.com/google/uuid v1.1.1 -> v1.1.2 * github.com/huandu/xstrings v1.3.0 -> v1.3.2 * github.com/klauspost/compress v1.10.11 -> v1.11.1 * github.com/markbates/goth v1.61.2 -> v1.65.0 * github.com/mattn/go-sqlite3 v1.14.0 -> v1.14.4 * github.com/mholt/archiver v3.3.0 -> v3.3.2 * github.com/microcosm-cc/bluemonday 4f7140c49acb -> v1.0.4 * github.com/minio/minio-go v7.0.4 -> v7.0.5 * github.com/olivere/elastic v7.0.9 -> v7.0.20 * github.com/urfave/cli v1.20.0 -> v1.22.4 * github.com/prometheus/client_golang v1.1.0 -> v1.8.0 * github.com/xanzy/go-gitlab v0.37.0 -> v0.38.1 * mvdan.cc/xurls v2.1.0 -> v2.2.0 Co-authored-by: Lauris BH <lauris@nix.lv>
This commit is contained in:
98
vendor/golang.org/x/sys/windows/svc/security.go
generated
vendored
98
vendor/golang.org/x/sys/windows/svc/security.go
generated
vendored
@@ -7,6 +7,10 @@
|
||||
package svc
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
@@ -23,6 +27,8 @@ func allocSid(subAuth0 uint32) (*windows.SID, error) {
|
||||
// IsAnInteractiveSession determines if calling process is running interactively.
|
||||
// It queries the process token for membership in the Interactive group.
|
||||
// http://stackoverflow.com/questions/2668851/how-do-i-detect-that-my-application-is-running-as-service-or-in-an-interactive-s
|
||||
//
|
||||
// Deprecated: Use IsWindowsService instead.
|
||||
func IsAnInteractiveSession() (bool, error) {
|
||||
interSid, err := allocSid(windows.SECURITY_INTERACTIVE_RID)
|
||||
if err != nil {
|
||||
@@ -57,3 +63,95 @@ func IsAnInteractiveSession() (bool, error) {
|
||||
}
|
||||
return false, nil
|
||||
}
|
||||
|
||||
var (
|
||||
ntdll = windows.NewLazySystemDLL("ntdll.dll")
|
||||
_NtQueryInformationProcess = ntdll.NewProc("NtQueryInformationProcess")
|
||||
|
||||
kernel32 = windows.NewLazySystemDLL("kernel32.dll")
|
||||
_QueryFullProcessImageNameA = kernel32.NewProc("QueryFullProcessImageNameA")
|
||||
)
|
||||
|
||||
// IsWindowsService reports whether the process is currently executing
|
||||
// as a Windows service.
|
||||
func IsWindowsService() (bool, error) {
|
||||
// This code was copied from runtime.isWindowsService function.
|
||||
|
||||
// The below technique looks a bit hairy, but it's actually
|
||||
// exactly what the .NET framework does for the similarly named function:
|
||||
// https://github.com/dotnet/extensions/blob/f4066026ca06984b07e90e61a6390ac38152ba93/src/Hosting/WindowsServices/src/WindowsServiceHelpers.cs#L26-L31
|
||||
// Specifically, it looks up whether the parent process has session ID zero
|
||||
// and is called "services".
|
||||
const _CURRENT_PROCESS = ^uintptr(0)
|
||||
// pbi is a PROCESS_BASIC_INFORMATION struct, where we just care about
|
||||
// the 6th pointer inside of it, which contains the pid of the process
|
||||
// parent:
|
||||
// https://github.com/wine-mirror/wine/blob/42cb7d2ad1caba08de235e6319b9967296b5d554/include/winternl.h#L1294
|
||||
var pbi [6]uintptr
|
||||
var pbiLen uint32
|
||||
r0, _, _ := syscall.Syscall6(_NtQueryInformationProcess.Addr(), 5, _CURRENT_PROCESS, 0, uintptr(unsafe.Pointer(&pbi[0])), uintptr(unsafe.Sizeof(pbi)), uintptr(unsafe.Pointer(&pbiLen)), 0)
|
||||
if r0 != 0 {
|
||||
return false, errors.New("NtQueryInformationProcess failed: error=" + itoa(int(r0)))
|
||||
}
|
||||
var psid uint32
|
||||
err := windows.ProcessIdToSessionId(uint32(pbi[5]), &psid)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if psid != 0 {
|
||||
// parent session id should be 0 for service process
|
||||
return false, nil
|
||||
}
|
||||
|
||||
pproc, err := windows.OpenProcess(windows.PROCESS_QUERY_LIMITED_INFORMATION, false, uint32(pbi[5]))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
defer windows.CloseHandle(pproc)
|
||||
|
||||
// exeName gets the path to the executable image of the parent process
|
||||
var exeName [261]byte
|
||||
exeNameLen := uint32(len(exeName) - 1)
|
||||
r0, _, e0 := syscall.Syscall6(_QueryFullProcessImageNameA.Addr(), 4, uintptr(pproc), 0, uintptr(unsafe.Pointer(&exeName[0])), uintptr(unsafe.Pointer(&exeNameLen)), 0, 0)
|
||||
if r0 == 0 {
|
||||
if e0 != 0 {
|
||||
return false, e0
|
||||
} else {
|
||||
return false, syscall.EINVAL
|
||||
}
|
||||
}
|
||||
const (
|
||||
servicesLower = "services.exe"
|
||||
servicesUpper = "SERVICES.EXE"
|
||||
)
|
||||
i := int(exeNameLen) - 1
|
||||
j := len(servicesLower) - 1
|
||||
if i < j {
|
||||
return false, nil
|
||||
}
|
||||
for {
|
||||
if j == -1 {
|
||||
return i == -1 || exeName[i] == '\\', nil
|
||||
}
|
||||
if exeName[i] != servicesLower[j] && exeName[i] != servicesUpper[j] {
|
||||
return false, nil
|
||||
}
|
||||
i--
|
||||
j--
|
||||
}
|
||||
}
|
||||
|
||||
func itoa(val int) string { // do it here rather than with fmt to avoid dependency
|
||||
if val < 0 {
|
||||
return "-" + itoa(-val)
|
||||
}
|
||||
var buf [32]byte // big enough for int64
|
||||
i := len(buf) - 1
|
||||
for val >= 10 {
|
||||
buf[i] = byte(val%10 + '0')
|
||||
i--
|
||||
val /= 10
|
||||
}
|
||||
buf[i] = byte(val + '0')
|
||||
return string(buf[i:])
|
||||
}
|
||||
|
20
vendor/golang.org/x/sys/windows/syscall_windows.go
generated
vendored
20
vendor/golang.org/x/sys/windows/syscall_windows.go
generated
vendored
@@ -270,9 +270,11 @@ func NewCallbackCDecl(fn interface{}) uintptr {
|
||||
//sys RegEnumKeyEx(key Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, class *uint16, classLen *uint32, lastWriteTime *Filetime) (regerrno error) = advapi32.RegEnumKeyExW
|
||||
//sys RegQueryValueEx(key Handle, name *uint16, reserved *uint32, valtype *uint32, buf *byte, buflen *uint32) (regerrno error) = advapi32.RegQueryValueExW
|
||||
//sys GetCurrentProcessId() (pid uint32) = kernel32.GetCurrentProcessId
|
||||
//sys ProcessIdToSessionId(pid uint32, sessionid *uint32) (err error) = kernel32.ProcessIdToSessionId
|
||||
//sys GetConsoleMode(console Handle, mode *uint32) (err error) = kernel32.GetConsoleMode
|
||||
//sys SetConsoleMode(console Handle, mode uint32) (err error) = kernel32.SetConsoleMode
|
||||
//sys GetConsoleScreenBufferInfo(console Handle, info *ConsoleScreenBufferInfo) (err error) = kernel32.GetConsoleScreenBufferInfo
|
||||
//sys SetConsoleCursorPosition(console Handle, position Coord) (err error) = kernel32.SetConsoleCursorPosition
|
||||
//sys WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint32, reserved *byte) (err error) = kernel32.WriteConsoleW
|
||||
//sys ReadConsole(console Handle, buf *uint16, toread uint32, read *uint32, inputControl *byte) (err error) = kernel32.ReadConsoleW
|
||||
//sys CreateToolhelp32Snapshot(flags uint32, processId uint32) (handle Handle, err error) [failretval==InvalidHandle] = kernel32.CreateToolhelp32Snapshot
|
||||
@@ -388,11 +390,7 @@ func GetProcAddressByOrdinal(module Handle, ordinal uintptr) (proc uintptr, err
|
||||
r0, _, e1 := syscall.Syscall(procGetProcAddress.Addr(), 2, uintptr(module), ordinal, 0)
|
||||
proc = uintptr(r0)
|
||||
if proc == 0 {
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
} else {
|
||||
err = syscall.EINVAL
|
||||
}
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -1089,11 +1087,7 @@ func WSASendMsg(fd Handle, msg *WSAMsg, flags uint32, bytesSent *uint32, overlap
|
||||
}
|
||||
r1, _, e1 := syscall.Syscall6(sendRecvMsgFunc.sendAddr, 6, uintptr(fd), uintptr(unsafe.Pointer(msg)), uintptr(flags), uintptr(unsafe.Pointer(bytesSent)), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)))
|
||||
if r1 == socket_error {
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
} else {
|
||||
err = syscall.EINVAL
|
||||
}
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return err
|
||||
}
|
||||
@@ -1105,11 +1099,7 @@ func WSARecvMsg(fd Handle, msg *WSAMsg, bytesReceived *uint32, overlapped *Overl
|
||||
}
|
||||
r1, _, e1 := syscall.Syscall6(sendRecvMsgFunc.recvAddr, 5, uintptr(fd), uintptr(unsafe.Pointer(msg)), uintptr(unsafe.Pointer(bytesReceived)), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)), 0)
|
||||
if r1 == socket_error {
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
} else {
|
||||
err = syscall.EINVAL
|
||||
}
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
6222
vendor/golang.org/x/sys/windows/zsyscall_windows.go
generated
vendored
6222
vendor/golang.org/x/sys/windows/zsyscall_windows.go
generated
vendored
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user