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