|
|
e405ae |
From 6b47ff61936d2b602d29b229b079bda00dadad7e Mon Sep 17 00:00:00 2001
|
|
|
e405ae |
From: Debarshi Ray <rishi@fedoraproject.org>
|
|
|
e405ae |
Date: Thu, 2 Sep 2021 14:57:37 +0200
|
|
|
e405ae |
Subject: [PATCH] cmd/root: Suggest a way forward if coreos/toolbox was used
|
|
|
e405ae |
|
|
|
e405ae |
github.com/coreos/toolbox bind mounts the entire /run from the host
|
|
|
e405ae |
operating system into the toolbox container. Due to this, when run
|
|
|
e405ae |
rootful, the /run/.containerenv created by Podman inside the container
|
|
|
e405ae |
is also seen on the host. This confuses Toolbox into thinking that it's
|
|
|
e405ae |
running inside a container, even when it's running on the host.
|
|
|
e405ae |
|
|
|
e405ae |
This is an attempt to differentiate between a toolbox container and
|
|
|
e405ae |
the host by looking at the 'container' environment variable, so that
|
|
|
e405ae |
the user can be presented with a more helpful error message.
|
|
|
e405ae |
|
|
|
e405ae |
https://bugzilla.redhat.com/show_bug.cgi?id=1998191
|
|
|
e405ae |
---
|
|
|
e405ae |
src/cmd/root.go | 10 ++++++++++
|
|
|
e405ae |
1 file changed, 10 insertions(+)
|
|
|
e405ae |
|
|
|
e405ae |
diff --git a/src/cmd/root.go b/src/cmd/root.go
|
|
|
e405ae |
index 5e6f5874a469..139609592218 100644
|
|
|
e405ae |
--- a/src/cmd/root.go
|
|
|
e405ae |
+++ b/src/cmd/root.go
|
|
|
e405ae |
@@ -130,6 +130,16 @@ func preRun(cmd *cobra.Command, args []string) error {
|
|
|
e405ae |
|
|
|
e405ae |
if toolboxPath == "" {
|
|
|
e405ae |
if utils.IsInsideContainer() {
|
|
|
e405ae |
+ if containerType := os.Getenv("container"); containerType == "" {
|
|
|
e405ae |
+ var builder strings.Builder
|
|
|
e405ae |
+ fmt.Fprintf(&builder, "/run/.containerenv found on what looks like the host\n")
|
|
|
e405ae |
+ fmt.Fprintf(&builder, "If this is the host, then remove /run/.containerenv and try again.\n")
|
|
|
e405ae |
+ fmt.Fprintf(&builder, "Otherwise, contact your system administrator or file a bug.")
|
|
|
e405ae |
+
|
|
|
e405ae |
+ errMsg := builder.String()
|
|
|
e405ae |
+ return errors.New(errMsg)
|
|
|
e405ae |
+ }
|
|
|
e405ae |
+
|
|
|
e405ae |
return errors.New("TOOLBOX_PATH not set")
|
|
|
e405ae |
}
|
|
|
e405ae |
|
|
|
e405ae |
--
|
|
|
e405ae |
2.31.1
|
|
|
e405ae |
|