...

Source file src/k8s.io/kubernetes/cmd/kubeadm/app/preflight/checks_windows.go

Documentation: k8s.io/kubernetes/cmd/kubeadm/app/preflight

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

View as plain text