pkg/blobinfocache/default.go
func blobInfoCacheDir(sys *types.SystemContext, euid int) (string, error) {
	if sys != nil && sys.BlobInfoCacheDir != "" {
		return sys.BlobInfoCacheDir, nil
	}

	// FIXME? On Windows, os.Geteuid() returns -1.  What should we do?  Right now we treat it as unprivileged
	// and fail (fall back to memory-only) if neither HOME nor XDG_DATA_HOME is set, which is, at least, safe.
	if euid == 0 {
		if sys != nil && sys.RootForImplicitAbsolutePaths != "" {
			return filepath.Join(sys.RootForImplicitAbsolutePaths, systemBlobInfoCacheDir), nil
		}
		return systemBlobInfoCacheDir, nil
	}

	// This is intended to mirror the GraphRoot determination in github.com/containers/libpod/pkg/util.GetRootlessStorageOpts.
	dataDir := os.Getenv("XDG_DATA_HOME")
	if dataDir == "" {
		home := os.Getenv("HOME")
		if home == "" {
			return "", fmt.Errorf("neither XDG_DATA_HOME nor HOME was set non-empty")
		}
		dataDir = filepath.Join(home, ".local", "share")
	}
	return filepath.Join(dataDir, "containers", "cache"), nil
}
func blobInfoCacheDir(sys *types.SystemContext, euid int) (string, error) {
	if sys != nil && sys.BlobInfoCacheDir != "" {
		return sys.BlobInfoCacheDir, nil
	}

	// FIXME? On Windows, os.Geteuid() returns -1.  What should we do?  Right now we treat it as unprivileged
	// and fail (fall back to memory-only) if neither HOME nor XDG_DATA_HOME is set, which is, at least, safe.
	if euid == 0 {
		if sys != nil && sys.RootForImplicitAbsolutePaths != "" {
			return filepath.Join(sys.RootForImplicitAbsolutePaths, systemBlobInfoCacheDir), nil
		}
		return systemBlobInfoCacheDir, nil
	}

	// This is intended to mirror the GraphRoot determination in github.com/containers/libpod/pkg/util.GetRootlessStorageOpts.
	dataDir := os.Getenv("XDG_DATA_HOME")
	if dataDir == "" {
		home := os.Getenv("HOME")
		if home == "" {
			return "", fmt.Errorf("neither XDG_DATA_HOME nor HOME was set non-empty")
		}
		dataDir = filepath.Join(home, ".local", "share")
	}
	return filepath.Join(dataDir, "containers", "cache"), nil
}
// blobInfoCacheDir returns a path to a blob info cache appropripate for sys and euid.
// euid is used so that (sudo …) does not write root-owned files into the unprivileged users’ home directory.