From 85c4d633db825a89e17d4df63736132bc1da48df Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 16 Mar 2022 00:39:57 +0100 Subject: [PATCH 1/2] pkg/system: remove deprecated (and unused) windows consts These consts were deprecated in 46c591b045a77b7f0f96f96a51d8304264685929, and although that has not been in a release yet (we usually deprecate for at least one release before removing), doing a search showed that there were no external consumers of these consts, so it should be fine to remove them. This patch removes the consts that were moded to pkg/idtools; - SeTakeOwnershipPrivilege - ContainerAdministratorSidString - ContainerUserSidString Signed-off-by: Sebastiaan van Stijn --- pkg/system/syscall_windows.go | 9 --------- 1 file changed, 9 deletions(-) diff --git a/pkg/system/syscall_windows.go b/pkg/system/syscall_windows.go index ef782d7ac8..e14d7fd75e 100644 --- a/pkg/system/syscall_windows.go +++ b/pkg/system/syscall_windows.go @@ -2,15 +2,6 @@ package system // import "github.com/docker/docker/pkg/system" import "golang.org/x/sys/windows" -const ( - // Deprecated: use github.com/docker/pkg/idtools.SeTakeOwnershipPrivilege - SeTakeOwnershipPrivilege = "SeTakeOwnershipPrivilege" - // Deprecated: use github.com/docker/pkg/idtools.ContainerAdministratorSidString - ContainerAdministratorSidString = "S-1-5-93-2-1" - // Deprecated: use github.com/docker/pkg/idtools.ContainerUserSidString - ContainerUserSidString = "S-1-5-93-2-2" -) - // VER_NT_WORKSTATION, see https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-osversioninfoexa const verNTWorkstation = 0x00000001 // VER_NT_WORKSTATION From 9bf40d7edd3605653c4f5e7f2dc7aa7bf5bf58ce Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 16 Mar 2022 00:41:30 +0100 Subject: [PATCH 2/2] pkg/system: move IsWindowsClient to pkg/parsers/operatingsystem This function was only used in a single place, and pkg/parsers/operatingsystem already copied the `verNTWorkstation` const, so we might as well move this function there as well to "unclutter" pkg/system. The function had no external users, so not adding an alias / stub. Signed-off-by: Sebastiaan van Stijn --- daemon/daemon_windows.go | 3 ++- .../operatingsystem/operatingsystem_windows.go | 6 ++++++ pkg/system/syscall_windows.go | 14 -------------- 3 files changed, 8 insertions(+), 15 deletions(-) delete mode 100644 pkg/system/syscall_windows.go diff --git a/daemon/daemon_windows.go b/daemon/daemon_windows.go index 6ea232da06..13907d0ea7 100644 --- a/daemon/daemon_windows.go +++ b/daemon/daemon_windows.go @@ -25,6 +25,7 @@ import ( "github.com/docker/docker/pkg/containerfs" "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/parsers" + "github.com/docker/docker/pkg/parsers/operatingsystem" "github.com/docker/docker/pkg/platform" "github.com/docker/docker/pkg/sysinfo" "github.com/docker/docker/pkg/system" @@ -553,7 +554,7 @@ func (daemon *Daemon) setDefaultIsolation() error { // On client SKUs, default to Hyper-V. @engine maintainers. This // should not be removed. Ping Microsoft folks is there are PRs to // to change this. - if system.IsWindowsClient() { + if operatingsystem.IsWindowsClient() { daemon.defaultIsolation = containertypes.IsolationHyperV } else { daemon.defaultIsolation = containertypes.IsolationProcess diff --git a/pkg/parsers/operatingsystem/operatingsystem_windows.go b/pkg/parsers/operatingsystem/operatingsystem_windows.go index 0b756141b6..c62db180f9 100644 --- a/pkg/parsers/operatingsystem/operatingsystem_windows.go +++ b/pkg/parsers/operatingsystem/operatingsystem_windows.go @@ -62,3 +62,9 @@ func GetOperatingSystemVersion() (string, error) { func IsContainerized() (bool, error) { return false, nil } + +// IsWindowsClient returns true if the SKU is client. It returns false on +// Windows server. +func IsWindowsClient() bool { + return windows.RtlGetVersion().ProductType == verNTWorkstation +} diff --git a/pkg/system/syscall_windows.go b/pkg/system/syscall_windows.go deleted file mode 100644 index e14d7fd75e..0000000000 --- a/pkg/system/syscall_windows.go +++ /dev/null @@ -1,14 +0,0 @@ -package system // import "github.com/docker/docker/pkg/system" - -import "golang.org/x/sys/windows" - -// VER_NT_WORKSTATION, see https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-osversioninfoexa -const verNTWorkstation = 0x00000001 // VER_NT_WORKSTATION - -// IsWindowsClient returns true if the SKU is client. It returns false on -// Windows server, or if an error occurred when making the GetVersionExW -// syscall. -func IsWindowsClient() bool { - ver := windows.RtlGetVersion() - return ver != nil && ver.ProductType == verNTWorkstation -}