github.com/containers/podman/v2@v2.2.2-0.20210501105131-c1e07d070c4c/pkg/rootless/rootless_unsupported.go (about)

     1  // +build !linux !cgo
     2  
     3  package rootless
     4  
     5  import (
     6  	"os"
     7  
     8  	"github.com/containers/storage/pkg/idtools"
     9  	"github.com/pkg/errors"
    10  )
    11  
    12  // IsRootless returns whether the user is rootless
    13  func IsRootless() bool {
    14  	uid := os.Geteuid()
    15  	// os.Geteuid() on Windows returns -1
    16  	if uid == -1 {
    17  		return false
    18  	}
    19  	return uid != 0
    20  }
    21  
    22  // BecomeRootInUserNS re-exec podman in a new userNS.  It returns whether podman was re-executed
    23  // into a new user namespace and the return code from the re-executed podman process.
    24  // If podman was re-executed the caller needs to propagate the error code returned by the child
    25  // process.  It is a convenience function for BecomeRootInUserNSWithOpts with a default configuration.
    26  func BecomeRootInUserNS(pausePid string) (bool, int, error) {
    27  	return false, -1, errors.New("this function is not supported on this os")
    28  }
    29  
    30  // GetRootlessUID returns the UID of the user in the parent userNS
    31  func GetRootlessUID() int {
    32  	return -1
    33  }
    34  
    35  // GetRootlessGID returns the GID of the user in the parent userNS
    36  func GetRootlessGID() int {
    37  	return -1
    38  }
    39  
    40  // TryJoinFromFilePaths attempts to join the namespaces of the pid files in paths.
    41  // This is useful when there are already running containers and we
    42  // don't have a pause process yet.  We can use the paths to the conmon
    43  // processes to attempt joining their namespaces.
    44  // If needNewNamespace is set, the file is read from a temporary user
    45  // namespace, this is useful for containers that are running with a
    46  // different uidmap and the unprivileged user has no way to read the
    47  // file owned by the root in the container.
    48  func TryJoinFromFilePaths(pausePidPath string, needNewNamespace bool, paths []string) (bool, int, error) {
    49  	return false, -1, errors.New("this function is not supported on this os")
    50  }
    51  
    52  // ConfigurationMatches checks whether the additional uids/gids configured for the user
    53  // match the current user namespace.
    54  func ConfigurationMatches() (bool, error) {
    55  	return true, nil
    56  }
    57  
    58  // GetConfiguredMappings returns the additional IDs configured for the current user.
    59  func GetConfiguredMappings() ([]idtools.IDMap, []idtools.IDMap, error) {
    60  	return nil, nil, errors.New("this function is not supported on this os")
    61  }
    62  
    63  // ReadMappingsProc returns the uid_map and gid_map
    64  func ReadMappingsProc(path string) ([]idtools.IDMap, error) {
    65  	return nil, nil
    66  }
    67  
    68  // IsFdInherited checks whether the fd is opened and valid to use
    69  func IsFdInherited(fd int) bool {
    70  	return false
    71  }