summaryrefslogtreecommitdiff
path: root/cmd/podman/main.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-07-28 14:03:22 +0200
committerGitHub <noreply@github.com>2020-07-28 14:03:22 +0200
commit91c92d10fc64af7e7813ba46f8eae8a8e7db44de (patch)
tree8fa6bdb3d536f00f98a845cfa043335152cb48af /cmd/podman/main.go
parentd463715ce75254a7a52e902b36f91431197ab4a8 (diff)
parent8f7ed50cb20c04bbbb7c4907a183c07912d4bffb (diff)
downloadpodman-91c92d10fc64af7e7813ba46f8eae8a8e7db44de.tar.gz
podman-91c92d10fc64af7e7813ba46f8eae8a8e7db44de.tar.bz2
podman-91c92d10fc64af7e7813ba46f8eae8a8e7db44de.zip
Merge pull request #7085 from rhatdan/cmount
Cleanup handling of podman mount/unmount
Diffstat (limited to 'cmd/podman/main.go')
-rw-r--r--cmd/podman/main.go18
1 files changed, 13 insertions, 5 deletions
diff --git a/cmd/podman/main.go b/cmd/podman/main.go
index f46f74547..d0e89c2f5 100644
--- a/cmd/podman/main.go
+++ b/cmd/podman/main.go
@@ -40,13 +40,21 @@ func main() {
for _, m := range c.Mode {
if cfg.EngineMode == m {
// Command cannot be run rootless
- _, found := c.Command.Annotations[registry.ParentNSRequired]
- if rootless.IsRootless() && found {
- c.Command.RunE = func(cmd *cobra.Command, args []string) error {
- return fmt.Errorf("cannot run command %q in rootless mode", cmd.CommandPath())
+ _, found := c.Command.Annotations[registry.UnshareNSRequired]
+ if found {
+ if rootless.IsRootless() && found && os.Getuid() != 0 {
+ c.Command.RunE = func(cmd *cobra.Command, args []string) error {
+ return fmt.Errorf("cannot run command %q in rootless mode, must execute `podman unshare` first", cmd.CommandPath())
+ }
+ }
+ } else {
+ _, found = c.Command.Annotations[registry.ParentNSRequired]
+ if rootless.IsRootless() && found {
+ c.Command.RunE = func(cmd *cobra.Command, args []string) error {
+ return fmt.Errorf("cannot run command %q in rootless mode", cmd.CommandPath())
+ }
}
}
-
parent := rootCmd
if c.Parent != nil {
parent = c.Parent