aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2022-03-01 16:50:38 -0500
committerGitHub <noreply@github.com>2022-03-01 16:50:38 -0500
commit965d28024cff51f7197b3b8bc060fdd167a2114f (patch)
tree323b987f60a2f2fba422a456eb00a3c1dc161567
parentcff448be2d10283e956fada480a063aa346f4a67 (diff)
parent791c8c347c1bbd69763b7358acfa415c18764d62 (diff)
downloadpodman-965d28024cff51f7197b3b8bc060fdd167a2114f.tar.gz
podman-965d28024cff51f7197b3b8bc060fdd167a2114f.tar.bz2
podman-965d28024cff51f7197b3b8bc060fdd167a2114f.zip
Merge pull request #13392 from baude/v4reverts
V4reverts
-rw-r--r--cmd/podman/registry/remote.go8
-rw-r--r--docs/source/markdown/podman.1.md2
-rw-r--r--pkg/util/utils.go2
-rw-r--r--pkg/util/utils_supported.go50
-rw-r--r--test/system/001-basic.bats11
5 files changed, 50 insertions, 23 deletions
diff --git a/cmd/podman/registry/remote.go b/cmd/podman/registry/remote.go
index 181ef6b4a..f05d8f7b4 100644
--- a/cmd/podman/registry/remote.go
+++ b/cmd/podman/registry/remote.go
@@ -30,12 +30,6 @@ func IsRemote() bool {
fs.Usage = func() {}
fs.SetInterspersed(false)
fs.BoolVarP(&remoteFromCLI.Value, "remote", "r", remote, "")
- connectionFlagName := "connection"
- ignoredConnection := ""
- fs.StringVarP(&ignoredConnection, connectionFlagName, "c", "", "")
- urlFlagName := "url"
- ignoredURL := ""
- fs.StringVar(&ignoredURL, urlFlagName, "", "")
// The shell completion logic will call a command called "__complete" or "__completeNoDesc"
// This command will always be the second argument
@@ -45,8 +39,6 @@ func IsRemote() bool {
start = 2
}
_ = fs.Parse(os.Args[start:])
- // --connection or --url implies --remote
- remoteFromCLI.Value = remoteFromCLI.Value || fs.Changed(connectionFlagName) || fs.Changed(urlFlagName)
})
return podmanOptions.EngineMode == entities.TunnelMode || remoteFromCLI.Value
}
diff --git a/docs/source/markdown/podman.1.md b/docs/source/markdown/podman.1.md
index 4d3e92dd2..b318001e4 100644
--- a/docs/source/markdown/podman.1.md
+++ b/docs/source/markdown/podman.1.md
@@ -42,7 +42,6 @@ and "$graphroot/networks" as rootless.
#### **--connection**, **-c**
Connection to use for remote podman, including Mac and Windows (excluding WSL2) machines, (Default connection is configured in `containers.conf`)
-Setting this option will switch the **--remote** option to true.
Remote connections use local containers.conf for default.
#### **--conmon**
@@ -109,7 +108,6 @@ environment variable is set, the **--remote** option defaults to true.
#### **--url**=*value*
URL to access Podman service (default from `containers.conf`, rootless `unix://run/user/$UID/podman/podman.sock` or as root `unix://run/podman/podman.sock`).
-Setting this option will switch the **--remote** option to true.
- `CONTAINER_HOST` is of the format `<schema>://[<user[:<password>]@]<host>[:<port>][<path>]`
diff --git a/pkg/util/utils.go b/pkg/util/utils.go
index bdd1e1383..925ff9830 100644
--- a/pkg/util/utils.go
+++ b/pkg/util/utils.go
@@ -463,6 +463,8 @@ func ParseIDMapping(mode namespaces.UsernsMode, uidMapSlice, gidMapSlice []strin
var (
rootlessConfigHomeDirOnce sync.Once
rootlessConfigHomeDir string
+ rootlessRuntimeDirOnce sync.Once
+ rootlessRuntimeDir string
)
type tomlOptionsConfig struct {
diff --git a/pkg/util/utils_supported.go b/pkg/util/utils_supported.go
index e9d6bfa31..848b35a45 100644
--- a/pkg/util/utils_supported.go
+++ b/pkg/util/utils_supported.go
@@ -6,21 +6,67 @@ package util
// should work to take darwin from this
import (
+ "fmt"
"os"
"path/filepath"
"syscall"
- cutil "github.com/containers/common/pkg/util"
"github.com/containers/podman/v4/pkg/rootless"
"github.com/pkg/errors"
+ "github.com/sirupsen/logrus"
)
// GetRuntimeDir returns the runtime directory
func GetRuntimeDir() (string, error) {
+ var rootlessRuntimeDirError error
+
if !rootless.IsRootless() {
return "", nil
}
- return cutil.GetRuntimeDir()
+
+ rootlessRuntimeDirOnce.Do(func() {
+ runtimeDir := os.Getenv("XDG_RUNTIME_DIR")
+ uid := fmt.Sprintf("%d", rootless.GetRootlessUID())
+ if runtimeDir == "" {
+ tmpDir := filepath.Join("/run", "user", uid)
+ if err := os.MkdirAll(tmpDir, 0700); err != nil {
+ logrus.Debug(err)
+ }
+ st, err := os.Stat(tmpDir)
+ if err == nil && int(st.Sys().(*syscall.Stat_t).Uid) == os.Geteuid() && (st.Mode().Perm()&0700 == 0700) {
+ runtimeDir = tmpDir
+ }
+ }
+ if runtimeDir == "" {
+ tmpDir := filepath.Join(os.TempDir(), fmt.Sprintf("podman-run-%s", uid))
+ if err := os.MkdirAll(tmpDir, 0700); err != nil {
+ logrus.Debug(err)
+ }
+ st, err := os.Stat(tmpDir)
+ if err == nil && int(st.Sys().(*syscall.Stat_t).Uid) == os.Geteuid() && (st.Mode().Perm()&0700 == 0700) {
+ runtimeDir = tmpDir
+ }
+ }
+ if runtimeDir == "" {
+ home := os.Getenv("HOME")
+ if home == "" {
+ rootlessRuntimeDirError = fmt.Errorf("neither XDG_RUNTIME_DIR nor HOME was set non-empty")
+ return
+ }
+ resolvedHome, err := filepath.EvalSymlinks(home)
+ if err != nil {
+ rootlessRuntimeDirError = errors.Wrapf(err, "cannot resolve %s", home)
+ return
+ }
+ runtimeDir = filepath.Join(resolvedHome, "rundir")
+ }
+ rootlessRuntimeDir = runtimeDir
+ })
+
+ if rootlessRuntimeDirError != nil {
+ return "", rootlessRuntimeDirError
+ }
+ return rootlessRuntimeDir, nil
}
// GetRootlessConfigHomeDir returns the config home directory when running as non root
diff --git a/test/system/001-basic.bats b/test/system/001-basic.bats
index 582efa058..748377e4b 100644
--- a/test/system/001-basic.bats
+++ b/test/system/001-basic.bats
@@ -126,17 +126,6 @@ See 'podman version --help'" "podman version --remote"
if grep -- " --remote " <<<"$output"; then
die "podman --help, with CONTAINER_CONNECTION set, is showing --remote"
fi
-
- # When it detects --url or --connection, --remote is not an option
- run_podman --url foobar --help
- if grep -- " --remote " <<<"$output"; then
- die "podman --help, with --url set, is showing --remote"
- fi
-
- run_podman --connection foobar --help
- if grep -- " --remote " <<<"$output"; then
- die "podman --help, with --connection set, is showing --remote"
- fi
}
# Check that just calling "podman-remote" prints the usage message even