checks_windows.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // +build windows
  2. /*
  3. Copyright 2017 The Kubernetes Authors.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. */
  14. package preflight
  15. import (
  16. "os/user"
  17. "github.com/pkg/errors"
  18. )
  19. // The "Well-known SID" of Administrator group
  20. // https://support.microsoft.com/en-us/help/243330/well-known-security-identifiers-in-windows-operating-systems
  21. const administratorSID = "S-1-5-32-544"
  22. // Check validates if a user has elevated (administrator) privileges.
  23. func (ipuc IsPrivilegedUserCheck) Check() (warnings, errorList []error) {
  24. currUser, err := user.Current()
  25. if err != nil {
  26. return nil, []error{errors.New("cannot get current user")}
  27. }
  28. groupIds, err := currUser.GroupIds()
  29. if err != nil {
  30. return nil, []error{errors.New("cannot get group IDs for current user")}
  31. }
  32. for _, sid := range groupIds {
  33. if sid == administratorSID {
  34. return nil, nil
  35. }
  36. }
  37. return nil, []error{errors.New("user is not running as administrator")}
  38. }
  39. // Check validates if Docker is setup to use systemd as the cgroup driver.
  40. // No-op for Windows.
  41. func (idsc IsDockerSystemdCheck) Check() (warnings, errorList []error) {
  42. return nil, nil
  43. }