Skip to content

Commit 965d280

Browse files
Merge pull request #13392 from baude/v4reverts
V4reverts
2 parents cff448b + 791c8c3 commit 965d280

File tree

5 files changed

+50
-23
lines changed

5 files changed

+50
-23
lines changed

cmd/podman/registry/remote.go

-8
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@ func IsRemote() bool {
3030
fs.Usage = func() {}
3131
fs.SetInterspersed(false)
3232
fs.BoolVarP(&remoteFromCLI.Value, "remote", "r", remote, "")
33-
connectionFlagName := "connection"
34-
ignoredConnection := ""
35-
fs.StringVarP(&ignoredConnection, connectionFlagName, "c", "", "")
36-
urlFlagName := "url"
37-
ignoredURL := ""
38-
fs.StringVar(&ignoredURL, urlFlagName, "", "")
3933

4034
// The shell completion logic will call a command called "__complete" or "__completeNoDesc"
4135
// This command will always be the second argument
@@ -45,8 +39,6 @@ func IsRemote() bool {
4539
start = 2
4640
}
4741
_ = fs.Parse(os.Args[start:])
48-
// --connection or --url implies --remote
49-
remoteFromCLI.Value = remoteFromCLI.Value || fs.Changed(connectionFlagName) || fs.Changed(urlFlagName)
5042
})
5143
return podmanOptions.EngineMode == entities.TunnelMode || remoteFromCLI.Value
5244
}

docs/source/markdown/podman.1.md

-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ and "$graphroot/networks" as rootless.
4242

4343
#### **--connection**, **-c**
4444
Connection to use for remote podman, including Mac and Windows (excluding WSL2) machines, (Default connection is configured in `containers.conf`)
45-
Setting this option will switch the **--remote** option to true.
4645
Remote connections use local containers.conf for default.
4746

4847
#### **--conmon**
@@ -109,7 +108,6 @@ environment variable is set, the **--remote** option defaults to true.
109108

110109
#### **--url**=*value*
111110
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`).
112-
Setting this option will switch the **--remote** option to true.
113111

114112
- `CONTAINER_HOST` is of the format `<schema>://[<user[:<password>]@]<host>[:<port>][<path>]`
115113

pkg/util/utils.go

+2
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,8 @@ func ParseIDMapping(mode namespaces.UsernsMode, uidMapSlice, gidMapSlice []strin
463463
var (
464464
rootlessConfigHomeDirOnce sync.Once
465465
rootlessConfigHomeDir string
466+
rootlessRuntimeDirOnce sync.Once
467+
rootlessRuntimeDir string
466468
)
467469

468470
type tomlOptionsConfig struct {

pkg/util/utils_supported.go

+48-2
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,67 @@ package util
66
// should work to take darwin from this
77

88
import (
9+
"fmt"
910
"os"
1011
"path/filepath"
1112
"syscall"
1213

13-
cutil "github.com/containers/common/pkg/util"
1414
"github.com/containers/podman/v4/pkg/rootless"
1515
"github.com/pkg/errors"
16+
"github.com/sirupsen/logrus"
1617
)
1718

1819
// GetRuntimeDir returns the runtime directory
1920
func GetRuntimeDir() (string, error) {
21+
var rootlessRuntimeDirError error
22+
2023
if !rootless.IsRootless() {
2124
return "", nil
2225
}
23-
return cutil.GetRuntimeDir()
26+
27+
rootlessRuntimeDirOnce.Do(func() {
28+
runtimeDir := os.Getenv("XDG_RUNTIME_DIR")
29+
uid := fmt.Sprintf("%d", rootless.GetRootlessUID())
30+
if runtimeDir == "" {
31+
tmpDir := filepath.Join("/run", "user", uid)
32+
if err := os.MkdirAll(tmpDir, 0700); err != nil {
33+
logrus.Debug(err)
34+
}
35+
st, err := os.Stat(tmpDir)
36+
if err == nil && int(st.Sys().(*syscall.Stat_t).Uid) == os.Geteuid() && (st.Mode().Perm()&0700 == 0700) {
37+
runtimeDir = tmpDir
38+
}
39+
}
40+
if runtimeDir == "" {
41+
tmpDir := filepath.Join(os.TempDir(), fmt.Sprintf("podman-run-%s", uid))
42+
if err := os.MkdirAll(tmpDir, 0700); err != nil {
43+
logrus.Debug(err)
44+
}
45+
st, err := os.Stat(tmpDir)
46+
if err == nil && int(st.Sys().(*syscall.Stat_t).Uid) == os.Geteuid() && (st.Mode().Perm()&0700 == 0700) {
47+
runtimeDir = tmpDir
48+
}
49+
}
50+
if runtimeDir == "" {
51+
home := os.Getenv("HOME")
52+
if home == "" {
53+
rootlessRuntimeDirError = fmt.Errorf("neither XDG_RUNTIME_DIR nor HOME was set non-empty")
54+
return
55+
}
56+
resolvedHome, err := filepath.EvalSymlinks(home)
57+
if err != nil {
58+
rootlessRuntimeDirError = errors.Wrapf(err, "cannot resolve %s", home)
59+
return
60+
}
61+
runtimeDir = filepath.Join(resolvedHome, "rundir")
62+
}
63+
rootlessRuntimeDir = runtimeDir
64+
})
65+
66+
if rootlessRuntimeDirError != nil {
67+
return "", rootlessRuntimeDirError
68+
}
69+
return rootlessRuntimeDir, nil
2470
}
2571

2672
// GetRootlessConfigHomeDir returns the config home directory when running as non root

test/system/001-basic.bats

-11
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,6 @@ See 'podman version --help'" "podman version --remote"
126126
if grep -- " --remote " <<<"$output"; then
127127
die "podman --help, with CONTAINER_CONNECTION set, is showing --remote"
128128
fi
129-
130-
# When it detects --url or --connection, --remote is not an option
131-
run_podman --url foobar --help
132-
if grep -- " --remote " <<<"$output"; then
133-
die "podman --help, with --url set, is showing --remote"
134-
fi
135-
136-
run_podman --connection foobar --help
137-
if grep -- " --remote " <<<"$output"; then
138-
die "podman --help, with --connection set, is showing --remote"
139-
fi
140129
}
141130

142131
# Check that just calling "podman-remote" prints the usage message even

0 commit comments

Comments
 (0)