checks_windows.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. errorList = []error{}
  25. currUser, err := user.Current()
  26. if err != nil {
  27. errorList = append(errorList, errors.New("cannot get current user"))
  28. return nil, errorList
  29. }
  30. groupIds, err := currUser.GroupIds()
  31. if err != nil {
  32. errorList = append(errorList, errors.New("cannot get group IDs for current user"))
  33. return nil, errorList
  34. }
  35. for _, sid := range groupIds {
  36. if sid == administratorSID {
  37. return nil, errorList
  38. }
  39. }
  40. errorList = append(errorList, errors.New("user is not running as administrator"))
  41. return nil, errorList
  42. }
  43. // Check validates if Docker is setup to use systemd as the cgroup driver.
  44. // No-op for Windows.
  45. func (idsc IsDockerSystemdCheck) Check() (warnings, errorList []error) {
  46. return nil, nil
  47. }
  48. // Check determines if IPVS proxier can be used or not
  49. // No-op for Windows.
  50. func (ipvspc IPVSProxierCheck) Check() (warnings, errors []error) {
  51. return nil, nil
  52. }